![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
update for mbed-os-5.11 (and Nboard IHM-V2)
main.cpp@27:998da0f731ad, 2018-02-10 (annotated)
- Committer:
- jacquesolivierklein
- Date:
- Sat Feb 10 20:38:07 2018 +0000
- Revision:
- 27:998da0f731ad
- Parent:
- 22:af9dcf379926
- Child:
- 28:a0164609dcc0
initial
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jacquesolivierklein | 27:998da0f731ad | 1 | // Title : mbed-os-3-threads |
jacquesolivierklein | 27:998da0f731ad | 2 | // Author: Jacques-Olivier Klein - IUT de CACHAN |
jacquesolivierklein | 27:998da0f731ad | 3 | // Date: 2018-02-10 |
jacquesolivierklein | 27:998da0f731ad | 4 | |
Jonathan Austin |
0:2757d7abb7d9 | 5 | #include "mbed.h" |
jacquesolivierklein | 27:998da0f731ad | 6 | #include "IHM.h" |
Jonathan Austin |
0:2757d7abb7d9 | 7 | |
jacquesolivierklein | 27:998da0f731ad | 8 | IHM ihm; |
jacquesolivierklein | 27:998da0f731ad | 9 | |
jacquesolivierklein | 27:998da0f731ad | 10 | DigitalOut L0 (PB_3) ; // led L0 |
jacquesolivierklein | 27:998da0f731ad | 11 | DigitalOut L1 (PA_7) ; // led L1 |
jacquesolivierklein | 27:998da0f731ad | 12 | DigitalOut L2 (PA_6) ; // led L2 |
jacquesolivierklein | 27:998da0f731ad | 13 | |
jacquesolivierklein | 27:998da0f731ad | 14 | void led1_thread(); |
jacquesolivierklein | 27:998da0f731ad | 15 | void led2_thread(); |
Jonathan Austin |
0:2757d7abb7d9 | 16 | |
jacquesolivierklein | 27:998da0f731ad | 17 | Thread thread1; |
jacquesolivierklein | 27:998da0f731ad | 18 | Thread thread2; |
jacquesolivierklein | 27:998da0f731ad | 19 | |
jacquesolivierklein | 27:998da0f731ad | 20 | // main is the 1st thread |
jacquesolivierklein | 27:998da0f731ad | 21 | int main(void) |
jacquesolivierklein | 27:998da0f731ad | 22 | { ihm.LCD_clear(); |
jacquesolivierklein | 27:998da0f731ad | 23 | ihm.LCD_printf("3-threads-%s %s",__DATE__,__TIME__); |
jacquesolivierklein | 27:998da0f731ad | 24 | printf("mbed-os-3-threads-%s %s\n\r",__DATE__,__TIME__); |
jacquesolivierklein | 27:998da0f731ad | 25 | printf("DEFAULT_STACK_SIZE:%d\n\r", DEFAULT_STACK_SIZE); |
jacquesolivierklein | 27:998da0f731ad | 26 | |
jacquesolivierklein | 27:998da0f731ad | 27 | thread1.start(led1_thread); |
jacquesolivierklein | 27:998da0f731ad | 28 | thread2.start(led2_thread); |
jacquesolivierklein | 27:998da0f731ad | 29 | |
jacquesolivierklein | 27:998da0f731ad | 30 | while(1){ |
jacquesolivierklein | 27:998da0f731ad | 31 | L0=!L0; |
jacquesolivierklein | 27:998da0f731ad | 32 | printf("* [pid-%d]Main \n\r",Thread::gettid()); |
jacquesolivierklein | 27:998da0f731ad | 33 | Thread::wait(200); |
Jonathan Austin |
0:2757d7abb7d9 | 34 | } |
Jonathan Austin |
0:2757d7abb7d9 | 35 | } |
Jonathan Austin |
1:846c97078558 | 36 | |
jacquesolivierklein | 27:998da0f731ad | 37 | void led1_thread(){ |
jacquesolivierklein | 27:998da0f731ad | 38 | while (1) { |
jacquesolivierklein | 27:998da0f731ad | 39 | L1 = ! L1; |
jacquesolivierklein | 27:998da0f731ad | 40 | printf(" * [pid-%d]led1_thread \n\r",Thread::gettid()); |
jacquesolivierklein | 27:998da0f731ad | 41 | Thread::wait(500); |
jacquesolivierklein | 27:998da0f731ad | 42 | } |
jacquesolivierklein | 27:998da0f731ad | 43 | } |
jacquesolivierklein | 27:998da0f731ad | 44 | |
jacquesolivierklein | 27:998da0f731ad | 45 | void led2_thread(){ |
jacquesolivierklein | 27:998da0f731ad | 46 | while (1) { |
jacquesolivierklein | 27:998da0f731ad | 47 | L2 = ! L2; |
jacquesolivierklein | 27:998da0f731ad | 48 | printf(" *[pid-%d]led2_thread \n\r",Thread::gettid()); |
jacquesolivierklein | 27:998da0f731ad | 49 | Thread::wait(2500); |
jacquesolivierklein | 27:998da0f731ad | 50 | } |
jacquesolivierklein | 27:998da0f731ad | 51 | } |
jacquesolivierklein | 27:998da0f731ad | 52 |