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 #include "test_env.h"
00003 
00004 #define TXPIN     USBTX
00005 #define RXPIN     USBRX
00006 
00007 
00008 namespace {
00009     const int BUFFER_SIZE = 48;
00010     char buffer[BUFFER_SIZE] = {0};
00011 }
00012 
00013 int main() {
00014     MBED_HOSTTEST_TIMEOUT(20);
00015     MBED_HOSTTEST_SELECT(echo);
00016     MBED_HOSTTEST_DESCRIPTION(Serial Echo at 115200);
00017     MBED_HOSTTEST_START("MBED_A9");
00018     wait(0.5);  // wait for characters to finish transmitting
00019 
00020     Serial pc(TXPIN, RXPIN);
00021     pc.baud(115200);
00022 
00023     while (1) {
00024         pc.gets(buffer, BUFFER_SIZE - 1);
00025         pc.printf("%s", buffer);
00026     }
00027 }