update for mbed-os-5.11 (and Nboard IHM-V2)

Dependencies:   IHM_V2

Committer:
jacquesolivierklein
Date:
Wed Jan 09 12:26:00 2019 +0000
Revision:
28:be81ea276c3a
Parent:
27:edb6c6685907
update for mbed-os-5.11 (and IHM-V2)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jacquesolivierklein 28:be81ea276c3a 1 // Title : mbed-os-isr-semaphore
jacquesolivierklein 27:edb6c6685907 2 // Author: Jacques-Olivier Klein - IUT de CACHAN
jacquesolivierklein 28:be81ea276c3a 3 // Date: 2018-02-10 - rev. 2019-01-06
jacquesolivierklein 27:edb6c6685907 4
Jonathan Austin 0:2757d7abb7d9 5 #include "mbed.h"
jacquesolivierklein 27:edb6c6685907 6 #include "IHM.h"
Jonathan Austin 0:2757d7abb7d9 7
jacquesolivierklein 27:edb6c6685907 8 IHM ihm;
jacquesolivierklein 27:edb6c6685907 9
jacquesolivierklein 27:edb6c6685907 10 DigitalOut L0 (PB_3) ; // led L0
jacquesolivierklein 27:edb6c6685907 11 DigitalOut L1 (PA_7) ; // led L1
jacquesolivierklein 27:edb6c6685907 12
jacquesolivierklein 27:edb6c6685907 13 InterruptIn BP0_Interrupt(PA_9);
jacquesolivierklein 27:edb6c6685907 14
jacquesolivierklein 27:edb6c6685907 15 void thread_Semaphore();
jacquesolivierklein 27:edb6c6685907 16 void isrBP0 ();
Jonathan Austin 0:2757d7abb7d9 17
jacquesolivierklein 28:be81ea276c3a 18 Thread thread_waiting_for_semaphore (osPriorityNormal,OS_STACK_SIZE );;
jacquesolivierklein 27:edb6c6685907 19 Semaphore mysemaphore(0);
jacquesolivierklein 27:edb6c6685907 20
jacquesolivierklein 27:edb6c6685907 21 int main(void)
jacquesolivierklein 27:edb6c6685907 22 { ihm.LCD_clear();
jacquesolivierklein 27:edb6c6685907 23 ihm.LCD_printf("irq-semaphore-%s %s",__DATE__,__TIME__);
jacquesolivierklein 27:edb6c6685907 24 printf("mbed-os-irq-semaphore-%s %s\n\r",__DATE__,__TIME__);
jacquesolivierklein 28:be81ea276c3a 25 printf("DEFAULT_STACK_SIZE:%d\n\r", OS_STACK_SIZE);
jacquesolivierklein 27:edb6c6685907 26
jacquesolivierklein 27:edb6c6685907 27 BP0_Interrupt.mode(PullUp);
jacquesolivierklein 27:edb6c6685907 28 thread_waiting_for_semaphore.start(thread_Semaphore);
jacquesolivierklein 27:edb6c6685907 29 BP0_Interrupt.fall(&isrBP0);
jacquesolivierklein 27:edb6c6685907 30 while(1){
jacquesolivierklein 27:edb6c6685907 31 L0=!L0;
jacquesolivierklein 28:be81ea276c3a 32 printf("* [pid-%d]Main \n\r",osThreadGetId());
jacquesolivierklein 28:be81ea276c3a 33 wait(0.200);
Jonathan Austin 0:2757d7abb7d9 34 }
Jonathan Austin 0:2757d7abb7d9 35 }
Jonathan Austin 1:846c97078558 36
jacquesolivierklein 27:edb6c6685907 37 void isrBP0 (){
jacquesolivierklein 27:edb6c6685907 38 mysemaphore.release();
jacquesolivierklein 27:edb6c6685907 39 }
jacquesolivierklein 27:edb6c6685907 40
jacquesolivierklein 27:edb6c6685907 41 void thread_Semaphore(){
jacquesolivierklein 27:edb6c6685907 42 while(1){
jacquesolivierklein 27:edb6c6685907 43 mysemaphore.wait();
jacquesolivierklein 27:edb6c6685907 44 L1=!L1;
jacquesolivierklein 28:be81ea276c3a 45 printf(" * [pid-%d]Semaphore \n\r",osThreadGetId());
jacquesolivierklein 27:edb6c6685907 46 }
jacquesolivierklein 27:edb6c6685907 47 }
jacquesolivierklein 27:edb6c6685907 48