feat(openthread): support hardware reset RCP while processing RCP failure

This commit is contained in:
zwx 2025-01-09 16:48:54 +08:00
parent 72d91b5117
commit 07425e242c
5 changed files with 43 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -266,8 +266,8 @@ otError SpiSpinelInterface::WaitForFrame(uint64_t timeout_us)
otError SpiSpinelInterface::HardwareReset(void)
{
if (mRcpFailureHandler) {
ConductSPITransaction(true, 0, 0); // clear
mRcpFailureHandler();
ConductSPITransaction(true, 0, 0); // clear
}
return OT_ERROR_NONE;
}

View File

@ -8,6 +8,18 @@ menu "OpenThread Border Router Example"
SSID and PSK, and then form a Thread network automatically. Otherwise, user need
to configure Wi-Fi and Thread manually.
config OPENTHREAD_SUPPORT_HW_RESET_RCP
bool 'Enable hardware RCP resetting'
default False
help
If enabled, the Thread Border Router will support hardware resetting the RCP
when processing RCP failure.
config OPENTHREAD_HW_RESET_RCP_PIN
int 'Pin to RCP reset'
depends on OPENTHREAD_SUPPORT_HW_RESET_RCP
default 7
menu "External coexist wire type and pin config"
config EXTERNAL_COEX_WIRE_TYPE
int "The wire_type of external coexist"

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*
@ -38,6 +38,7 @@
#include "mdns.h"
#include "nvs_flash.h"
#include "protocol_examples_common.h"
#include "driver/gpio.h"
#include "driver/uart.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
@ -62,6 +63,26 @@
#define TAG "esp_ot_br"
#if CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP
#define PIN_TO_RCP_RESET CONFIG_OPENTHREAD_HW_RESET_RCP_PIN
static void rcp_failure_hardware_reset_handler(void)
{
gpio_config_t reset_pin_config;
memset(&reset_pin_config, 0, sizeof(reset_pin_config));
reset_pin_config.intr_type = GPIO_INTR_DISABLE;
reset_pin_config.pin_bit_mask = BIT(PIN_TO_RCP_RESET);
reset_pin_config.mode = GPIO_MODE_OUTPUT;
reset_pin_config.pull_down_en = GPIO_PULLDOWN_DISABLE;
reset_pin_config.pull_up_en = GPIO_PULLUP_DISABLE;
gpio_config(&reset_pin_config);
gpio_set_level(PIN_TO_RCP_RESET, 0);
vTaskDelay(pdMS_TO_TICKS(10));
gpio_set_level(PIN_TO_RCP_RESET, 1);
vTaskDelay(pdMS_TO_TICKS(30));
gpio_reset_pin(PIN_TO_RCP_RESET);
}
#endif
#if CONFIG_EXTERNAL_COEX_ENABLE
static void ot_br_external_coexist_init(void)
{
@ -192,6 +213,9 @@ void app_main(void)
ESP_ERROR_CHECK(nvs_flash_init());
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
#if CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP
esp_openthread_register_rcp_failure_handler(rcp_failure_hardware_reset_handler);
#endif
xTaskCreate(ot_task_worker, "ot_br_main", 8192, xTaskGetCurrentTaskHandle(), 5, NULL);
xTaskCreate(ot_br_init, "ot_br_init", 6144, NULL, 4, NULL);
}

View File

@ -0,0 +1,2 @@
CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP=y
CONFIG_OPENTHREAD_HW_RESET_RCP_PIN=6

View File

@ -1 +1,3 @@
CONFIG_OPENTHREAD_RADIO_SPINEL_SPI=y
CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP=y
CONFIG_OPENTHREAD_HW_RESET_RCP_PIN=7