diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2011-03-04 20:25:26 -0500 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2011-03-04 23:16:32 -0500 |
commit | 02e76ec27b5737bce836a5460427b538076f01ef (patch) | |
tree | 30fb1f21caba0504ff414edc853474f0d365f790 /examples/qa-slave-shield.cpp | |
parent | 7973deea3908f4f865f59c5e2df1eef6810cc70e (diff) | |
download | librambutan-02e76ec27b5737bce836a5460427b538076f01ef.tar.gz librambutan-02e76ec27b5737bce836a5460427b538076f01ef.zip |
Brought examples/ up to date; PIN_MAP bugfix for D24.
Diffstat (limited to 'examples/qa-slave-shield.cpp')
-rw-r--r-- | examples/qa-slave-shield.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/examples/qa-slave-shield.cpp b/examples/qa-slave-shield.cpp index b395cca..178b780 100644 --- a/examples/qa-slave-shield.cpp +++ b/examples/qa-slave-shield.cpp @@ -1,50 +1,51 @@ -// slave mode for QA shield +// Slave mode for QA shield #include "wirish.h" -#define LED_PIN 13 -#define NUM_GPIO 38 // not the number of the max... +// FIXME generalize for Maple Native, Maple Mini (NUM_GPIO, Mini USB +// breakout pins, etc.) -int i; +#define LED_PIN BOARD_LED_PIN +#define NUM_GPIO 38 // Ignore JTAG pins. -void setup() -{ +void setup() { /* Set up the LED to blink */ pinMode(LED_PIN, OUTPUT); - digitalWrite(LED_PIN, 1); + digitalWrite(LED_PIN, HIGH); - for(i=0; i<NUM_GPIO; i++) { - if(i==13) { continue; } + for(int i = 0; i < NUM_GPIO; i++) { + if (i == BOARD_LED_PIN) { + continue; + } pinMode(i, OUTPUT); - digitalWrite(i,0); + digitalWrite(i, LOW); } - //delay(5000); SerialUSB.println("OK, starting..."); - } void loop() { - digitalWrite(LED_PIN,1); + toggleLED(); delay(100); - digitalWrite(LED_PIN,0); + toggleLED(); - for(i=0; i<NUM_GPIO; i++) { - if(i==13) { continue; } - digitalWrite(i,1); + for(int i = 0; i < NUM_GPIO; i++) { + if (i == BOARD_LED_PIN) { + continue; + } + togglePin(i); delay(5); - digitalWrite(i,0); + togglePin(i); delay(5); } } // Force init to be called *first*, i.e. before static object allocation. -// Otherwise, statically allocated object that need libmaple may fail. - __attribute__(( constructor )) void premain() { +// Otherwise, statically allocated objects that need libmaple may fail. +__attribute__((constructor)) void premain() { init(); } -int main(void) -{ +int main(void) { setup(); while (1) { |