The radio under esp_wifi: the board's ESP32-C6, reached over SDIO (Secure Digital input/output) through esp_wifi_remote and esp_hosted.
More...
|
| BaseType_t | __real_xTaskCreatePinnedToCore (TaskFunction_t fn, const char *name, const uint32_t stack, void *arg, UBaseType_t prio, TaskHandle_t *handle, const BaseType_t core) |
| | The linker's name for ESP-IDF's xTaskCreatePinnedToCore().
|
| BaseType_t | __wrap_xTaskCreatePinnedToCore (TaskFunction_t fn, const char *name, const uint32_t stack, void *arg, UBaseType_t prio, TaskHandle_t *handle, const BaseType_t core) |
| | Create a task on core 0 when no core is given.
|
| void | wifi_radio_mac (uint8_t mac[6]) |
| | 6 bytes that differ from board to board, for the network name.
|
| static void | link_failed (const char *why) |
| | Mark the link failed, once: log it and hold the C6 in reset.
|
| static void | on_hosted (void *arg, esp_event_base_t base, int32_t id, void *data) |
| | esp_hosted's events: the link up, and a link that failed for good.
|
| static bool | handlers_once (void) |
| | Register on_hosted() for the two events, before the first connect.
|
| static bool | wait_up (void) |
| | Wait for the TRANSPORT_UP event, at most WIFI_RADIO_UP_WAIT_MS.
|
| static void | version_once (void) |
| | Once, at the first start with the link up: the C6's version.
|
| esp_err_t | wifi_radio_link (void) |
| | Bring the link to the C6 up, before esp_wifi_init().
|
| bool | wifi_radio_failed (void) |
| | Whether the link has failed since the panel started.
|
The radio under esp_wifi: the board's ESP32-C6, reached over SDIO (Secure Digital input/output) through esp_wifi_remote and esp_hosted.
See wifi_radio.h.
The link: SDIO slot 1, 4 data lines at 40MHz, the pins of board_pins.h (BOARD_C6_*), which esp_hosted reads from sdkconfig.defaults; the checks below fail the build when the two differ. esp_hosted sets up its 6 tasks and the SDMMC (SD/MMC host) controller before app_main(); it resets and talks to the C6 from the radio's first start on (wifi_radio_link()). Between sessions the radio is off (esp_wifi_deinit() on the C6); the C6 stays powered and is not reset again until the panel restarts. A link that fails, at the first start or later, holds the C6 in reset until the panel restarts.
SPDX-License-Identifier: MIT
| BaseType_t __wrap_xTaskCreatePinnedToCore |
( |
TaskFunction_t | fn, |
|
|
const char * | name, |
|
|
const uint32_t | stack, |
|
|
void * | arg, |
|
|
UBaseType_t | prio, |
|
|
TaskHandle_t * | handle, |
|
|
const BaseType_t | core ) |
Create a task on core 0 when no core is given.
Core 1 runs the control task, which owns STOP and the heartbeat, and the run log task below it; nothing of the radio's runs there. esp_hosted creates its 6 tasks (SDIO receive buffer, read, process, write; RPC (remote procedure call) receive and send) at priority 23 with no core given, which on its own lets them take core 1 from the control task at priority 10. The link (CMakeLists.txt, –wrap) sends every xTaskCreatePinnedToCore() of the image through here, xTaskCreate() included: a task created with no core (tskNO_AFFINITY) runs on core 0, and a task created for a given core stays on it. xTaskCreateStatic() and the xTaskCreate*WithCaps() calls do not come through here; esp_hosted uses them only with CONFIG_ESP_HOSTED_DFLT_TASK_FROM_SPIRAM, which the #error above refuses.
Not covered by the wrap: the SD card and the C6 share ESP-IDF's SDMMC request mutex, which inherits priority. While the run log task on core 1 holds it for a card write and an esp_hosted task waits for it, the run log task runs at 23 on core 1, above the control task. The control task's longest period under that load is not measured.
- Parameters
-
| fn | The task's function. |
| name | Its name. |
| stack | Its stack in bytes. |
| arg | Its argument. |
| prio | Its priority. |
| handle | Receives its handle; may be NULL. |
| core | 0, 1 or tskNO_AFFINITY. |
- Returns
- pdPASS, or what ESP-IDF returns for a task it could not create.
| void link_failed |
( |
const char * | why | ) |
|
|
static |
Mark the link failed, once: log it and hold the C6 in reset.
esp_hosted's tasks keep running after a failure. A C6 that holds DAT1 (its interrupt line) low would keep esp_hosted's read task, priority 23 on core 0, failing and logging in a loop. EN low holds the C6 in reset; its SDIO pins let go, the 51kOhm pull-ups take DAT1 high, and the read task waits. The C6 stays in reset until the panel restarts.
- Parameters
-
| why | What failed, for the log. |
| void on_hosted |
( |
void * | arg, |
|
|
esp_event_base_t | base, |
|
|
int32_t | id, |
|
|
void * | data ) |
|
static |
esp_hosted's events: the link up, and a link that failed for good.
esp_hosted posts ESP_HOSTED_EVENT_TRANSPORT_UP once, when the C6 has sent its start event, and ESP_HOSTED_EVENT_TRANSPORT_FAILURE when the SDIO transfers to the C6 have failed for good. With CONFIG_ESP_HOSTED_TRANSPORT_RESTART_ON_FAILURE off it does not restart the panel; the worker sees the flag, takes the radio down and fails the session, and later starts fail at wifi_radio_link().
- Parameters
-
| arg | Unused. |
| base | ESP_HOSTED_EVENT. |
| id | The event. |
| data | Unused. |
| esp_err_t wifi_radio_link |
( |
void | | ) |
|
Bring the link to the C6 up, before esp_wifi_init().
Called from the task that brings the radio up. The first call resets the C6 (EN low for 10ms, then a fixed 1,500ms, CONFIG_ESP_HOSTED_SDIO_RESET_DELAY_MS), starts it as an SDIO card and waits for its start event, polling every 200ms. A C6 that starts as a card and sends no start event is reset again after 50 and after 100 polls; the call returns after about 25s. A C6 that does not start as a card ends the call after the card's start-up, at least 1,500ms. Then esp_hosted's TRANSPORT_UP event is awaited for at most 1,000ms. The C6's firmware version is logged once. Later calls with the link up return at once, with no reset.
- Returns
- ESP_OK with the link up; ESP_FAIL when the C6 did not answer, when the handlers of esp_hosted's events cannot be registered, and on every call once the link has failed, until the panel restarts. A C6 that did not answer is held in reset.