
Simple example of using getchar to read raw bytes from a Serial Terminal. You can use this example to look at the characters that PuTTY sends. That way, you might be able to build your own keyboard routines.
Diff: main.cpp
- Revision:
- 0:230a31b32cc1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Apr 29 07:49:43 2016 +0000 @@ -0,0 +1,41 @@ +#include "mbed.h" +#include "rtos.h" + +unsigned int delayms = 1000; + +void print_char(char c = '*') +{ + printf("%c", c); + fflush(stdout); +} + +DigitalOut led1(LED1); + +void print_thread(void const *argument) +{ + while (true) { + Thread::wait(delayms); + led1 = !led1; + } +} + +void read_keyboard(void const *argument) +{ + char c; + while (true) { + + c = getchar(); + printf("\t%X\n", c); + } +} + + +int main() +{ + printf("\n\n*** RTOS basic example ***\n"); + Thread t1(print_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE); + Thread t2(read_keyboard); + + //Sleep the main thread + Thread::wait(osWaitForever); +}