Several examples run on only mbed-os5.13.0 (not 5.14.0)
Dependencies: BD_SD_DISCO_F769NI BSP_DISCO_F769NI LCD_DISCO_F769NI TS_DISCO_F769NI USBHost_F769NI
Diff: z_example/0_led_blinky.cpp
- Revision:
- 3:35ac9ee7d2d6
- Child:
- 4:0f4affc00183
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/z_example/0_led_blinky.cpp Wed Aug 07 05:39:01 2019 +0000 @@ -0,0 +1,108 @@ +/* + * Mbed Application program / Blinky + * + * Copyright (c) 2018,'19 Kenji Arai / JH1PJL + * http://www.page.sannet.ne.jp/kenjia/index.html + * https://os.mbed.com/users/kenjiArai/ + * Created: April 10th, 2018 + * Revised: July 18th, 2019 + */ + +#include "select_program.h" +//#define EXAMPLE_0_BLINKY_LED +#ifdef EXAMPLE_0_BLINKY_LED + +// Include -------------------------------------------------------------------- +#include "mbed.h" + +// Definition ----------------------------------------------------------------- +#define LEDON 1 +#define LEDOFF 0 + +#define FOREVER 0x7fffffff + +// Constructor ---------------------------------------------------------------- +DigitalOut my_led1(LED1); +DigitalOut my_led2(LED2); +DigitalOut my_led3(LED3); +Serial pc(USBTX, USBRX, 115200); + +// RAM ------------------------------------------------------------------------ + +// ROM / Constant data -------------------------------------------------------- + +// Function prototypes -------------------------------------------------------- +static void tsk_0(void const *args); +static void tsk_1(void const *args); +static void tsk_2(void const *args); +static void tsk_3(void const *args); + +//------------------------------------------------------------------------------ +// Control Program +//------------------------------------------------------------------------------ +osThreadDef(tsk_0, osPriorityNormal,2048); +osThreadDef(tsk_1, osPriorityNormal,2048); +osThreadDef(tsk_2, osPriorityNormal,2048); +osThreadDef(tsk_3, osPriorityNormal,2048); + +int main() +{ + pc.printf("\x1b[2J\x1b[H %s\r\n %s %s (UTC)\r\n", + __FILE__, __DATE__, __TIME__); + osThreadId id0, id1, id2, id3; + id0 = osThreadCreate(osThread(tsk_0), NULL); + id1 = osThreadCreate(osThread(tsk_1), NULL); + id2 = osThreadCreate(osThread(tsk_2), NULL); + id3 = osThreadCreate(osThread(tsk_3), NULL); + pc.printf("id0=0x%x, id1=0x%x, id2=0x%x, id3=0x%x\r\n", + (uint32_t)id0, (uint32_t)id1, (uint32_t)id2, (uint32_t)id3); + while(true) { + ThisThread::sleep_for(FOREVER); + } +} + +void tsk_0(void const *args) +{ + Timer t; + uint32_t count = 0; + + while(true) { + t.reset(); + t.start(); + pc.printf("%5d\r\n", count++); + uint32_t wait = 1000 - t.read_ms(); + ThisThread::sleep_for(wait); + } +} + +void tsk_1(void const *args) +{ + while(true) { + my_led1 = LEDON; + ThisThread::sleep_for(5); + my_led1 = LEDOFF; + ThisThread::sleep_for(1995); + } +} + +void tsk_2(void const *args) +{ + while(true) { + my_led2 = LEDON; + ThisThread::sleep_for(5); + my_led2 = LEDOFF; + ThisThread::sleep_for(2995); + } +} + +void tsk_3(void const *args) +{ + while(true) { + my_led3 = LEDON; + ThisThread::sleep_for(5); + my_led3 = LEDOFF; + ThisThread::sleep_for(3995); + } +} + +#endif