Hallo zusammen,
ich habe eine kurze Frage zum Einführungsbeispiel blink unter ESP-IDF.
Wenn man sich diverse Tutorials zum Thema tasks bei freertos anschaut,
dann müssten tasks doch immer initialisiert werden:
xTaskCreate(&hello_task, "hello_task", 2048, NULL, 5, NULL);
oder so ähnlich.
Warum passiert das im blink example nicht (led-strip part habe ich
auskommentiert, da normale LED):
1 | #include <stdio.h>
|
2 | #include "freertos/FreeRTOS.h"
|
3 | #include "freertos/task.h"
|
4 | #include "driver/gpio.h"
|
5 | #include "esp_log.h"
|
6 | #include "led_strip.h"
|
7 | #include "sdkconfig.h"
|
8 |
|
9 | static const char *TAG = "example";
|
10 |
|
11 | /* Use project configuration menu (idf.py menuconfig) to choose the GPIO to blink,
|
12 | or you can edit the following line and set a number here.
|
13 | */
|
14 | #define BLINK_GPIO CONFIG_BLINK_GPIO
|
15 |
|
16 | static uint8_t s_led_state = 0;
|
17 | static void blink_led(void)
|
18 |
|
19 | {
|
20 | /* Set the GPIO level according to the state (LOW or HIGH)*/
|
21 | gpio_set_level(BLINK_GPIO, s_led_state);
|
22 | }
|
23 |
|
24 | static void configure_led(void)
|
25 | {
|
26 | ESP_LOGI(TAG, "Example configured to blink GPIO LED!");
|
27 | gpio_reset_pin(BLINK_GPIO);
|
28 | /* Set the GPIO as a push/pull output */
|
29 | gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
|
30 | }
|
31 |
|
32 | void app_main(void)
|
33 | {
|
34 |
|
35 | /* Configure the peripheral according to the LED type */
|
36 | configure_led();
|
37 |
|
38 | while (1) {
|
39 | ESP_LOGI(TAG, "Turning the LED %s!", s_led_state == true ? "ON" : "OFF");
|
40 | blink_led();
|
41 | /* Toggle the LED state */
|
42 | s_led_state = !s_led_state;
|
43 | vTaskDelay(200 / portTICK_PERIOD_MS);
|
44 | }
|
45 | }
|
Passiert die Initialisierung in einem header oder in der sdkconfig?
Danke für kurzfristige Erhellung!
Nicola