Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: IHM_V2
Fork of mbed-os-example-mbed5-blinky by
main.cpp
00001 // Title : mbed-os-q-32-bits-tx-rx 00002 // Author: Jacques-Olivier Klein - IUT de CACHAN 00003 // Date: 2018-02-10 rev. 2019-01-06 00004 00005 #include "mbed.h" 00006 #include "IHM.h" 00007 00008 #define THE_Q_SIZE 4 00009 00010 IHM ihm; 00011 00012 DigitalOut L0 (PB_3) ; // led L0 00013 DigitalOut L1 (PA_7) ; // led L1 00014 DigitalOut L2 (PA_6) ; // led L2 00015 00016 void tx_q(); 00017 void rx_q(); 00018 00019 Thread thread_tx_q; 00020 Thread thread_rx_q; 00021 00022 Queue<int, THE_Q_SIZE> the_queue; 00023 00024 int main(void) 00025 { ihm.LCD_clear(); 00026 ihm.LCD_printf("q-32b-tx-rx-%s %s",__DATE__,__TIME__); 00027 printf("mbed-os-q-32-bits-tx-rx-%s %s\n\r",__DATE__,__TIME__); 00028 printf("OS_STACK_SIZE:%d\n\r", OS_STACK_SIZE); 00029 00030 thread_tx_q.start(tx_q); 00031 thread_rx_q.start(rx_q); 00032 00033 while(1){ 00034 wait(3.000); 00035 L0=!L0; 00036 printf("* [pid-%d]Main \n\r",osThreadGetId()); 00037 } 00038 } 00039 00040 void tx_q (){ 00041 static int j=0; 00042 while (1){ 00043 L1 = ! L1; 00044 printf(" * Tx_q data:%d\n\r", j); 00045 the_queue.put((int*)j++); 00046 wait(1.000); 00047 } 00048 } 00049 00050 void rx_q (){ 00051 osEvent evt; 00052 while (true) { 00053 evt = the_queue.get(); 00054 L2 = ! L2; 00055 if (evt.status == osEventMessage) { 00056 printf(" *Rx_q data:%d\n\r", evt.value.v); 00057 } 00058 } 00059 }
Generated on Fri Jul 22 2022 00:40:28 by
1.7.2
