Dr. Pucher
/
Serial_interrupts
Test
main.cpp
- Committer:
- bulmecisco
- Date:
- 2018-11-15
- Revision:
- 2:f026b40fadb1
- Parent:
- 0:023c5cda6102
File content as of revision 2:f026b40fadb1:
#include "mbed.h" DigitalOut led1(LED1); DigitalOut led2(LED2); Serial pc(USBTX, USBRX); bool flag = false; char rec; void callback_ex() { // Note: you need to actually read from the serial to clear the RX interrupt //pc.putc(pc.getc()); while(pc.readable()) { rec = pc.getc(); } flag = true; led2 = !led2; } int main() { pc.attach(&callback_ex); while (1) { led1 = !led1; // wait(0.5); if(flag) { pc.putc(rec); flag = false; // led1 = !led1; } } }