Kiyoshi Hayakawa / Mbed 2 deprecated rtos_mutex

Dependencies:   C12832_lcd mbed-rtos mbed

Fork of rtos_mutex by mbed official

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 #include "C12832_lcd.h"
00004 
00005 C12832_LCD lcd;
00006 Mutex lcd_mutex; 
00007 
00008 void mu_write(const char* name) {
00009     Thread::wait(rand()/1000000);
00010     lcd_mutex.lock();
00011     lcd.locate(0,3);
00012     lcd.printf("%s writing\n\r", name);
00013     Thread::wait(1000);
00014     lcd.cls();
00015     lcd_mutex.unlock();
00016 }
00017 
00018 void test_thread(void const *args) {
00019     while (true) {
00020         mu_write((const char*)args); 
00021     }
00022 }
00023 
00024 int main() {
00025     lcd.cls();
00026     Thread t2(test_thread, (void *)"Th 2");
00027     Thread t3(test_thread, (void *)"Th 3");
00028     Thread t4(test_thread, (void *)"Th 4");
00029     
00030     test_thread((void *)"Th 1");
00031 }