Purpose: Simple application example with 3 periodic functions triggered through a event-queue scheduler-object.
Dependencies: IHM_V2
Fork of mbed-os-example-mbed5-blinky by
Purpose: Simple application example with 3 periodic functions triggered through a event-queue scheduler-object. Target: L432KC / Nboard (from IUT-Cachan) Tested: YES (2019-01-09) Author: Jacques-Olivier Klein - IUT de CACHAN Date: 2018-02-10 rev. 2019-01-09 OS_STACK_SIZE=4096 Libraries: mbed-os rev5345:c966348(03jan2019) + IHMV2 (from IUT-Cachan) rev6:ad91067
Diff: main.cpp
- Revision:
- 27:a94bca3c9f30
- Parent:
- 22:af9dcf379926
- Child:
- 28:11ebe30bbd30
--- a/main.cpp Wed Feb 15 10:00:05 2017 +0000 +++ b/main.cpp Sat Feb 10 21:24:34 2018 +0000 @@ -1,13 +1,56 @@ +// Title : mbed-os-periodic-task +// Author: Jacques-Olivier Klein - IUT de CACHAN +// Date: 2018-02-10 + #include "mbed.h" +#include "IHM.h" + +IHM ihm; -DigitalOut led1(LED1); +DigitalOut L0 (PB_3) ; // led L0 +DigitalOut L1 (PA_7) ; // led L1 +DigitalOut L2 (PA_6) ; // led L2 +DigitalOut L6 (PA_0) ; // led L6 + +InterruptIn BP0Interrupt(PA_9); + +void led0_fun(); +void led1_fun(); +void led2_fun(); -// 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); +EventQueue the_event_queue; + +int main(void) +{ ihm.LCD_clear(); + ihm.LCD_printf("periodic-task-%s %s",__DATE__,__TIME__); + printf("mbed-os-periodic-task-%s %s\n\r",__DATE__,__TIME__); + printf("DEFAULT_STACK_SIZE:%d\n\r", DEFAULT_STACK_SIZE); + + the_event_queue.call_every(100, led0_fun); + the_event_queue.call_every(400, led1_fun); + the_event_queue.call_every(1600, led2_fun); + + printf("Starting event_queue...\n\r"); + the_event_queue.dispatch(); + + //while(1) hereafter will never be executed + while(1){ + Thread::wait(500); + L6=!L6; } } +void led0_fun() +{ + L0 = ! L0; +} + +void led1_fun() +{ + L1 = ! L1; +} + +void led2_fun() +{ + L2 = ! L2; +}