KEIS
Dependencies: C12832_lcd mbed-rtos mbed
Fork of rtos_mutex by
Diff: main.cpp
- Revision:
- 5:cdc855b58daf
- Parent:
- 1:0f886ffbe0c1
--- a/main.cpp Tue Jun 04 16:03:01 2013 +0100 +++ b/main.cpp Wed Sep 25 05:05:24 2013 +0000 @@ -1,24 +1,31 @@ #include "mbed.h" #include "rtos.h" +#include "C12832_lcd.h" -Mutex stdio_mutex; +C12832_LCD lcd; +Mutex lcd_mutex; -void notify(const char* name, int state) { - stdio_mutex.lock(); - printf("%s: %d\n\r", name, state); - stdio_mutex.unlock(); +void mu_write(const char* name) { + Thread::wait(rand()/1000000); + lcd_mutex.lock(); + lcd.locate(0,3); + lcd.printf("%s writing\n\r", name); + Thread::wait(1000); + lcd.cls(); + lcd_mutex.unlock(); } void test_thread(void const *args) { while (true) { - notify((const char*)args, 0); Thread::wait(1000); - notify((const char*)args, 1); Thread::wait(1000); + mu_write((const char*)args); } } int main() { + lcd.cls(); Thread t2(test_thread, (void *)"Th 2"); Thread t3(test_thread, (void *)"Th 3"); + Thread t4(test_thread, (void *)"Th 4"); test_thread((void *)"Th 1"); }