aboutsummaryrefslogtreecommitdiffstats
path: root/examples/qa-slave-shield.cpp
blob: b395cca6cdebe13481e5e98136d27de99ce37734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// slave mode for QA shield

#include "wirish.h"

#define LED_PIN 13
#define NUM_GPIO 38 // not the number of the max...

int i;

void setup()
{
    /* Set up the LED to blink  */
    pinMode(LED_PIN, OUTPUT);
    digitalWrite(LED_PIN, 1);

    for(i=0; i<NUM_GPIO; i++) {
        if(i==13) { continue; }
        pinMode(i, OUTPUT);
        digitalWrite(i,0);
    }
    //delay(5000);
    SerialUSB.println("OK, starting...");

}

void loop() {
    digitalWrite(LED_PIN,1);
    delay(100);
    digitalWrite(LED_PIN,0);

    for(i=0; i<NUM_GPIO; i++) {
        if(i==13) { continue; }
        digitalWrite(i,1);
        delay(5);
        digitalWrite(i,0);
        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() {
    init();
}

int main(void)
{
    setup();

    while (1) {
        loop();
    }
    return 0;
}