Stage-1 Students SoCEM / Mbed 2 deprecated PrimativeKeyboardInput

Dependencies:   mbed-rtos mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "rtos.h"
00003 
00004 unsigned int delayms = 1000;
00005 
00006 void print_char(char c = '*')
00007 {
00008     printf("%c", c);
00009     fflush(stdout);
00010 }
00011 
00012 DigitalOut led1(LED1);
00013 
00014 void print_thread(void const *argument)
00015 {
00016     while (true) {
00017         Thread::wait(delayms);
00018         led1 = !led1;
00019     }
00020 }
00021 
00022 void read_keyboard(void const *argument)
00023 {
00024     char c;
00025     while (true) {
00026         
00027         c = getchar();
00028         printf("\t%X\n", c);
00029     }
00030 }
00031 
00032 
00033 int main()
00034 {
00035     printf("\n\n*** RTOS basic example ***\n");
00036     Thread t1(print_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE);
00037     Thread t2(read_keyboard);
00038     
00039     //Sleep the main thread
00040     Thread::wait(osWaitForever);
00041 }