diff options
Diffstat (limited to 'tmk_core/tool/mbed/mbed-sdk/libraries/tests/mbed/serial_interrupt/main.cpp')
-rw-r--r-- | tmk_core/tool/mbed/mbed-sdk/libraries/tests/mbed/serial_interrupt/main.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tmk_core/tool/mbed/mbed-sdk/libraries/tests/mbed/serial_interrupt/main.cpp b/tmk_core/tool/mbed/mbed-sdk/libraries/tests/mbed/serial_interrupt/main.cpp new file mode 100644 index 000000000..50b55e6e3 --- /dev/null +++ b/tmk_core/tool/mbed/mbed-sdk/libraries/tests/mbed/serial_interrupt/main.cpp @@ -0,0 +1,26 @@ +#include "mbed.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +Serial computer(USBTX, USBRX); + +// This function is called when a character goes into the TX buffer. +void txCallback() { + led1 = !led1; +} + +// This function is called when a character goes into the RX buffer. +void rxCallback() { + led2 = !led2; + computer.putc(computer.getc()); +} + +int main() { + printf("start test\n"); + computer.attach(&txCallback, Serial::TxIrq); + computer.attach(&rxCallback, Serial::RxIrq); + while (true) { + wait(1); + } +} |