Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C12832_lcd mbed-rtos mbed
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 lcd_thread1(void const *argument) { 00009 int count1; 00010 while (true) { 00011 Thread::signal_wait(0x1); 00012 lcd_mutex.lock(); 00013 lcd.locate(0,3); 00014 lcd.printf("%thread2 count: %d\n\r", count1); 00015 lcd_mutex.unlock(); 00016 count1++; 00017 } 00018 } 00019 00020 void count_thread1(void const *argument){ 00021 Thread thread2(lcd_thread1); 00022 while (true) { 00023 Thread::wait(1000); 00024 thread2.signal_set(0x1); 00025 } 00026 } 00027 00028 void lcd_thread2(void const *argument) { 00029 int count2=0; 00030 while (true) { 00031 Thread::signal_wait(0x1); 00032 // lcd_mutex.lock(); 00033 lcd.locate(0,15); 00034 lcd.printf("%thread4 count: %d\n\r", count2); 00035 // lcd_mutex.unlock(); 00036 count2++; 00037 } 00038 } 00039 00040 void count_thread2(void const *argument){ 00041 Thread thread4(lcd_thread2); 00042 while (true) { 00043 Thread::wait(2000); 00044 thread4.signal_set(0x1); 00045 } 00046 } 00047 00048 int main() { 00049 lcd.cls(); 00050 Thread thread1(count_thread1); 00051 // Thread thread2(lcd_thread1); 00052 Thread thread3(count_thread2); 00053 // Thread thread4(lcd_thread2); 00054 Thread::wait(osWaitForever); 00055 }
Generated on Sat Jul 30 2022 09:13:46 by
1.7.2