Rtos API example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut led1(LED1);
00004 DigitalOut led2(LED2);
00005 
00006 Serial computer(USBTX, USBRX);
00007 
00008 // This function is called when a character goes into the TX buffer.
00009 void txCallback() {
00010     led1 = !led1;
00011 }
00012 
00013 // This function is called when a character goes into the RX buffer.
00014 void rxCallback() {
00015     led2 = !led2;
00016     computer.putc(computer.getc());
00017 }
00018 
00019 int main() {
00020     printf("start test\n");
00021     computer.attach(&txCallback, Serial::TxIrq);
00022     computer.attach(&rxCallback, Serial::RxIrq);
00023     while (true) {
00024         wait(1);
00025     }
00026 }