~berfr/stm32f4discovery

ref: 502314b1cfe40f0cc95285b16afa9eac41119768 stm32f4discovery/src/main.c -rw-r--r-- 864 bytes
502314b1 — berfr Add source, cmake config as well as readme file 1 year, 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "stm32f4_discovery.h"

#include "FreeRTOS.h"
#include "task.h"

typedef struct {
    Led_TypeDef led;
    int delay_ms;
} LedTaskParam;

static const LedTaskParam param1 = { .led = LED4, .delay_ms = 200 };
static const LedTaskParam param2 = { .led = LED5, .delay_ms = 800 };

static void led_task(void *args) {
    LedTaskParam param = *(LedTaskParam*) args;
    while (1) {
        STM_EVAL_LEDToggle(param.led);
        vTaskDelay(pdMS_TO_TICKS(param.delay_ms));
    };
}

int main(void) {
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

    STM_EVAL_LEDInit(LED4);
    STM_EVAL_LEDInit(LED5);

    xTaskCreate(led_task, "LED_blink_1", 128, (void*)&param1, configMAX_PRIORITIES-1, NULL);
    xTaskCreate(led_task, "LED_blink_2", 128, (void*)&param2, configMAX_PRIORITIES-1, NULL);

    vTaskStartScheduler();
    while (1) {}
    return 0;
}