A very simple example of an RTOS executing on an LPC1768 Platform
Fork of app-board-RTOS-Threads by
Diff: main.cpp
- Revision:
- 8:261f8af23dae
- Parent:
- 7:ea9f0cd97179
--- a/main.cpp Mon Aug 08 13:01:08 2016 +0000 +++ b/main.cpp Mon Aug 08 14:55:12 2016 +0000 @@ -1,4 +1,5 @@ -// example to test the mbed Lab Board lcd lib with the mbed rtos +// Example using mbedRTOS on the LPC1768 +// Introduction to RTOS // Pot1 ADC limit for LED1 // Pot2 ADC limit for LED2 @@ -25,7 +26,8 @@ void thread1(void const *args) { int i; - while(true) { // thread loop + while(true) + { // thread loop pc_mutex.lock(); pc.printf("Thread1 count: %d\n\r",i); pc_mutex.unlock(); @@ -39,7 +41,8 @@ void thread2(void const *args) { int k; - while(true) { // thread loop + while(true) + { // thread loop pc_mutex.lock(); pc.printf("Thread 2 count : %d\n\r",k); pc_mutex.unlock(); @@ -49,10 +52,11 @@ } // Thread 4 -// the value of pot 1 changes the DC of LED1 +// Pot1's value is compared to a limit and LED1 is set or not void thread4(void const *args) { - while(true) { // thread loop + while(true) + { // thread loop pc_mutex.lock(); if( Pot1.read_u16() > 0xEFFF) { @@ -69,10 +73,11 @@ } // Thread 5 -// the value of pot 2 changes the DC of LED2 +// Pot2's value is compared to a limit and LED2 is set or not void thread5(void const *args) { - while(true) { // thread loop + while(true) + { // thread loop pc_mutex.lock(); if( Pot2.read_u16() > 0xEFFF) { @@ -95,8 +100,10 @@ Thread t4(thread4); //start thread4 Thread t5(thread5); //start thread5 - while(true) { // main is the next thread + while(true) + { // main is the next thread pc_mutex.lock(); + pc.printf("main\n\r"); pc_mutex.unlock(); Thread::wait(500); // wait 0.5s }