![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
broken!
main.cpp@0:713e07f71d54, 2016-06-10 (annotated)
- Committer:
- chrissnow
- Date:
- Fri Jun 10 15:35:32 2016 +0000
- Revision:
- 0:713e07f71d54
RTOS and serial interrupts don't get along...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chrissnow | 0:713e07f71d54 | 1 | #include "mbed.h" |
chrissnow | 0:713e07f71d54 | 2 | |
chrissnow | 0:713e07f71d54 | 3 | DigitalOut led1(LED1); |
chrissnow | 0:713e07f71d54 | 4 | DigitalOut led2(LED2); |
chrissnow | 0:713e07f71d54 | 5 | |
chrissnow | 0:713e07f71d54 | 6 | Serial pc(USBTX, USBRX); |
chrissnow | 0:713e07f71d54 | 7 | |
chrissnow | 0:713e07f71d54 | 8 | void callback() { |
chrissnow | 0:713e07f71d54 | 9 | // Note: you need to actually read from the serial to clear the RX interrupt |
chrissnow | 0:713e07f71d54 | 10 | printf("%c\n", pc.getc()); |
chrissnow | 0:713e07f71d54 | 11 | led2 = !led2; |
chrissnow | 0:713e07f71d54 | 12 | } |
chrissnow | 0:713e07f71d54 | 13 | |
chrissnow | 0:713e07f71d54 | 14 | int main() { |
chrissnow | 0:713e07f71d54 | 15 | pc.attach(&callback); |
chrissnow | 0:713e07f71d54 | 16 | |
chrissnow | 0:713e07f71d54 | 17 | while (1) { |
chrissnow | 0:713e07f71d54 | 18 | led1 = !led1; |
chrissnow | 0:713e07f71d54 | 19 | wait(0.5); |
chrissnow | 0:713e07f71d54 | 20 | } |
chrissnow | 0:713e07f71d54 | 21 | } |