From 09b1d6aa72dbdcbf81963cfdb45ef5a25c701eb5 Mon Sep 17 00:00:00 2001 From: cpq Date: Thu, 13 May 2021 15:05:09 +0100 Subject: [PATCH] Running two blinkers --- examples/stm32-freertos-tcp/main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/stm32-freertos-tcp/main.c b/examples/stm32-freertos-tcp/main.c index ad750698..f3399255 100644 --- a/examples/stm32-freertos-tcp/main.c +++ b/examples/stm32-freertos-tcp/main.c @@ -26,16 +26,19 @@ static void server(void *args) { } static void blinker(void *args) { - while (args == NULL) { - led_toggle(); - vTaskDelay(pdMS_TO_TICKS(1000)); + uint16_t pin = ((char *) args)[0] == '1' ? LED2 : LED3; + int ms = pin == LED2 ? 750 : 1500; + for (;;) { + gpio_toggle(pin); + vTaskDelay(pdMS_TO_TICKS(ms)); } } int main(void) { init_hardware(); xTaskCreate(server, "server", 4096, NULL, configMAX_PRIORITIES - 1, NULL); - xTaskCreate(blinker, "blinker", 128, NULL, configMAX_PRIORITIES - 1, NULL); + xTaskCreate(blinker, "blinker", 128, "1", configMAX_PRIORITIES - 1, NULL); + xTaskCreate(blinker, "blinker", 128, "2", configMAX_PRIORITIES - 1, NULL); vTaskStartScheduler(); // This blocks return 0; // Unreachable }