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 mbed-os-examples

/media/uploads/jacquesolivierklein/mbed-os-periodic-task.png

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

Committer:
jacquesolivierklein
Date:
Sat Feb 10 21:24:34 2018 +0000
Revision:
27:a94bca3c9f30
Parent:
22:af9dcf379926
Child:
28:11ebe30bbd30
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jacquesolivierklein 27:a94bca3c9f30 1 // Title : mbed-os-periodic-task
jacquesolivierklein 27:a94bca3c9f30 2 // Author: Jacques-Olivier Klein - IUT de CACHAN
jacquesolivierklein 27:a94bca3c9f30 3 // Date: 2018-02-10
jacquesolivierklein 27:a94bca3c9f30 4
Jonathan Austin 0:2757d7abb7d9 5 #include "mbed.h"
jacquesolivierklein 27:a94bca3c9f30 6 #include "IHM.h"
jacquesolivierklein 27:a94bca3c9f30 7
jacquesolivierklein 27:a94bca3c9f30 8 IHM ihm;
Jonathan Austin 0:2757d7abb7d9 9
jacquesolivierklein 27:a94bca3c9f30 10 DigitalOut L0 (PB_3) ; // led L0
jacquesolivierklein 27:a94bca3c9f30 11 DigitalOut L1 (PA_7) ; // led L1
jacquesolivierklein 27:a94bca3c9f30 12 DigitalOut L2 (PA_6) ; // led L2
jacquesolivierklein 27:a94bca3c9f30 13 DigitalOut L6 (PA_0) ; // led L6
jacquesolivierklein 27:a94bca3c9f30 14
jacquesolivierklein 27:a94bca3c9f30 15 InterruptIn BP0Interrupt(PA_9);
jacquesolivierklein 27:a94bca3c9f30 16
jacquesolivierklein 27:a94bca3c9f30 17 void led0_fun();
jacquesolivierklein 27:a94bca3c9f30 18 void led1_fun();
jacquesolivierklein 27:a94bca3c9f30 19 void led2_fun();
Jonathan Austin 0:2757d7abb7d9 20
jacquesolivierklein 27:a94bca3c9f30 21 EventQueue the_event_queue;
jacquesolivierklein 27:a94bca3c9f30 22
jacquesolivierklein 27:a94bca3c9f30 23 int main(void)
jacquesolivierklein 27:a94bca3c9f30 24 { ihm.LCD_clear();
jacquesolivierklein 27:a94bca3c9f30 25 ihm.LCD_printf("periodic-task-%s %s",__DATE__,__TIME__);
jacquesolivierklein 27:a94bca3c9f30 26 printf("mbed-os-periodic-task-%s %s\n\r",__DATE__,__TIME__);
jacquesolivierklein 27:a94bca3c9f30 27 printf("DEFAULT_STACK_SIZE:%d\n\r", DEFAULT_STACK_SIZE);
jacquesolivierklein 27:a94bca3c9f30 28
jacquesolivierklein 27:a94bca3c9f30 29 the_event_queue.call_every(100, led0_fun);
jacquesolivierklein 27:a94bca3c9f30 30 the_event_queue.call_every(400, led1_fun);
jacquesolivierklein 27:a94bca3c9f30 31 the_event_queue.call_every(1600, led2_fun);
jacquesolivierklein 27:a94bca3c9f30 32
jacquesolivierklein 27:a94bca3c9f30 33 printf("Starting event_queue...\n\r");
jacquesolivierklein 27:a94bca3c9f30 34 the_event_queue.dispatch();
jacquesolivierklein 27:a94bca3c9f30 35
jacquesolivierklein 27:a94bca3c9f30 36 //while(1) hereafter will never be executed
jacquesolivierklein 27:a94bca3c9f30 37 while(1){
jacquesolivierklein 27:a94bca3c9f30 38 Thread::wait(500);
jacquesolivierklein 27:a94bca3c9f30 39 L6=!L6;
Jonathan Austin 0:2757d7abb7d9 40 }
Jonathan Austin 0:2757d7abb7d9 41 }
Jonathan Austin 1:846c97078558 42
jacquesolivierklein 27:a94bca3c9f30 43 void led0_fun()
jacquesolivierklein 27:a94bca3c9f30 44 {
jacquesolivierklein 27:a94bca3c9f30 45 L0 = ! L0;
jacquesolivierklein 27:a94bca3c9f30 46 }
jacquesolivierklein 27:a94bca3c9f30 47
jacquesolivierklein 27:a94bca3c9f30 48 void led1_fun()
jacquesolivierklein 27:a94bca3c9f30 49 {
jacquesolivierklein 27:a94bca3c9f30 50 L1 = ! L1;
jacquesolivierklein 27:a94bca3c9f30 51 }
jacquesolivierklein 27:a94bca3c9f30 52
jacquesolivierklein 27:a94bca3c9f30 53 void led2_fun()
jacquesolivierklein 27:a94bca3c9f30 54 {
jacquesolivierklein 27:a94bca3c9f30 55 L2 = ! L2;
jacquesolivierklein 27:a94bca3c9f30 56 }