Demonstrate dependency between serial input and output

main.cpp

Committer:
infinnovation
Date:
2016-08-22
Revision:
0:2af96b59072d

File content as of revision 0:2af96b59072d:

#include "mbed.h"
Serial pc(USBTX, USBRX);

void
logchars(void) {
    while (true) {
        int c = pc.getc();
        pc.printf("[%02x]\r\n", c);
    }
}

int main(void) {
    Thread logger;
    pc.printf("putc/getc test\r\n");
    logger.start(logchars);
    while (true) {
        pc.printf("tick\r\n");
        wait(1.0);
    }
    return 0;
}