diff options
Diffstat (limited to 'examples/qa-slave-shield.cpp')
| -rw-r--r-- | examples/qa-slave-shield.cpp | 64 | 
1 files changed, 22 insertions, 42 deletions
| diff --git a/examples/qa-slave-shield.cpp b/examples/qa-slave-shield.cpp index fc33a4a..b395cca 100644 --- a/examples/qa-slave-shield.cpp +++ b/examples/qa-slave-shield.cpp @@ -1,70 +1,50 @@ -// Slave mode for QA shield +// slave mode for QA shield  #include "wirish.h" -#define LED_PIN BOARD_LED_PIN +#define LED_PIN 13 +#define NUM_GPIO 38 // not the number of the max... -#if defined(BOARD_maple) || defined(BOARD_maple_RET6) -const uint8 pins_to_skip[] = {LED_PIN}; +int i; -#elif defined(BOARD_maple_mini) -#define USB_DP 23 -#define USB_DM 24 -const uint8 pins_to_skip[] = {LED_PIN, USB_DP, USB_DM}; - -#elif defined(BOARD_maple_native) -const uint8 pins_to_skip[] = {LED_PIN}; - -#else -#error "Board type has not been selected correctly." -#endif - -bool skip_pin_p(uint8 pin); - -void setup() { +void setup() +{      /* Set up the LED to blink  */      pinMode(LED_PIN, OUTPUT); +    digitalWrite(LED_PIN, 1); -    for(int i = 0; i < NR_GPIO_PINS; i++) { -        if (skip_pin_p(i)) { -            continue; -        } +    for(i=0; i<NUM_GPIO; i++) { +        if(i==13) { continue; }          pinMode(i, OUTPUT); -        digitalWrite(i, LOW); +        digitalWrite(i,0);      } +    //delay(5000);      SerialUSB.println("OK, starting..."); +  }  void loop() { -    toggleLED(); +    digitalWrite(LED_PIN,1);      delay(100); +    digitalWrite(LED_PIN,0); -    for(int i = 0; i < NR_GPIO_PINS; i++) { -        if (skip_pin_p(i)) { -            continue; -        } -        togglePin(i); +    for(i=0; i<NUM_GPIO; i++) { +        if(i==13) { continue; } +        digitalWrite(i,1);          delay(5); -        togglePin(i); +        digitalWrite(i,0);          delay(5);      }  } -bool skip_pin_p(uint8 pin) { -    for (uint8 i = 0; i < sizeof(pins_to_skip); i++) { -        if (pin == pins_to_skip[i]) -            return true; -    } -    return false; -} -  // Force init to be called *first*, i.e. before static object allocation. -// Otherwise, statically allocated objects that need libmaple may fail. -__attribute__((constructor)) void premain() { +// Otherwise, statically allocated object that need libmaple may fail. + __attribute__(( constructor )) void premain() {      init();  } -int main(void) { +int main(void) +{      setup();      while (1) { | 
