![](/media/cache/group/logo-cachanx.jpg.50x50_q85.jpg)
Purpose: Simple application example with 2 threads communicating 32-bit integers through a Queue event-object.
Dependencies: IHM_V2
Fork of mbed-os-example-mbed5-blinky by
Title : mbed-os-q-32-bits-tx-rx
Purpose: Simple application example with 2 threads communicating 32-bit integers through a Queue event-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
main.cpp
- Committer:
- jacquesolivierklein
- Date:
- 2019-01-09
- Revision:
- 28:5ac42b4bb038
- Parent:
- 27:1fa50737793f
File content as of revision 28:5ac42b4bb038:
// Title : mbed-os-q-32-bits-tx-rx // Author: Jacques-Olivier Klein - IUT de CACHAN // Date: 2018-02-10 rev. 2019-01-06 #include "mbed.h" #include "IHM.h" #define THE_Q_SIZE 4 IHM ihm; DigitalOut L0 (PB_3) ; // led L0 DigitalOut L1 (PA_7) ; // led L1 DigitalOut L2 (PA_6) ; // led L2 void tx_q(); void rx_q(); Thread thread_tx_q; Thread thread_rx_q; Queue<int, THE_Q_SIZE> the_queue; int main(void) { ihm.LCD_clear(); ihm.LCD_printf("q-32b-tx-rx-%s %s",__DATE__,__TIME__); printf("mbed-os-q-32-bits-tx-rx-%s %s\n\r",__DATE__,__TIME__); printf("OS_STACK_SIZE:%d\n\r", OS_STACK_SIZE); thread_tx_q.start(tx_q); thread_rx_q.start(rx_q); while(1){ wait(3.000); L0=!L0; printf("* [pid-%d]Main \n\r",osThreadGetId()); } } void tx_q (){ static int j=0; while (1){ L1 = ! L1; printf(" * Tx_q data:%d\n\r", j); the_queue.put((int*)j++); wait(1.000); } } void rx_q (){ osEvent evt; while (true) { evt = the_queue.get(); L2 = ! L2; if (evt.status == osEventMessage) { printf(" *Rx_q data:%d\n\r", evt.value.v); } } }