![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
update for mbed-os-5.11 (and Nboard IHM-V2)
Diff: main.cpp
- Revision:
- 27:998da0f731ad
- Parent:
- 22:af9dcf379926
- Child:
- 28:a0164609dcc0
--- a/main.cpp Wed Feb 15 10:00:05 2017 +0000 +++ b/main.cpp Sat Feb 10 20:38:07 2018 +0000 @@ -1,13 +1,52 @@ +// Title : mbed-os-3-threads +// Author: Jacques-Olivier Klein - IUT de CACHAN +// Date: 2018-02-10 + #include "mbed.h" +#include "IHM.h" -DigitalOut led1(LED1); +IHM ihm; + +DigitalOut L0 (PB_3) ; // led L0 +DigitalOut L1 (PA_7) ; // led L1 +DigitalOut L2 (PA_6) ; // led L2 + +void led1_thread(); +void led2_thread(); -// main() runs in its own thread in the OS -// (note the calls to wait below for delays) -int main() { - while (true) { - led1 = !led1; - wait(0.5); +Thread thread1; +Thread thread2; + +// main is the 1st thread +int main(void) +{ ihm.LCD_clear(); + ihm.LCD_printf("3-threads-%s %s",__DATE__,__TIME__); + printf("mbed-os-3-threads-%s %s\n\r",__DATE__,__TIME__); + printf("DEFAULT_STACK_SIZE:%d\n\r", DEFAULT_STACK_SIZE); + + thread1.start(led1_thread); + thread2.start(led2_thread); + + while(1){ + L0=!L0; + printf("* [pid-%d]Main \n\r",Thread::gettid()); + Thread::wait(200); } } +void led1_thread(){ + while (1) { + L1 = ! L1; + printf(" * [pid-%d]led1_thread \n\r",Thread::gettid()); + Thread::wait(500); + } +} + +void led2_thread(){ + while (1) { + L2 = ! L2; + printf(" *[pid-%d]led2_thread \n\r",Thread::gettid()); + Thread::wait(2500); + } +} +