aboutsummaryrefslogtreecommitdiffstats
path: root/examples/debug-dtrrts.cpp
blob: 61c061a1c7bafd8d75c8a23540cd07eb7435febc (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
// Test sketch for figuring out DTR/RTS behavior on different platforms.

#include "wirish.h"
#include "usb.h"

#define LED_PIN BOARD_LED_PIN
#define PWM_PIN 2

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

    /* Send a message out USART2  */
    Serial2.begin(9600);
    Serial2.println("Debugging DTR/RTS...");

}

void loop() {
    toggleLED();
    delay(100);

    Serial2.print("DTR: ");
    Serial2.print(usbGetDTR(), DEC);
    Serial2.print("\tRTS: ");
    Serial2.println(usbGetRTS(), DEC);
}

// 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() {
    init();
}

int main(void) {
    setup();

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