Skip to content

Commit b544acb

Browse files
committed
Merge branch 'feature/support_hw_reset_when_handling_rcp_failure_v5.3' into 'release/v5.3'
feat(openthread): support hardware reset RCP while processing RCP failure (v5.3) See merge request espressif/esp-idf!36554
2 parents 36cf635 + 6c6c6cb commit b544acb

File tree

5 files changed

+43
-3
lines changed

5 files changed

+43
-3
lines changed

components/openthread/src/port/esp_spi_spinel_interface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -266,8 +266,8 @@ otError SpiSpinelInterface::WaitForFrame(uint64_t timeout_us)
266266
otError SpiSpinelInterface::HardwareReset(void)
267267
{
268268
if (mRcpFailureHandler) {
269-
ConductSPITransaction(true, 0, 0); // clear
270269
mRcpFailureHandler();
270+
ConductSPITransaction(true, 0, 0); // clear
271271
}
272272
return OT_ERROR_NONE;
273273
}

examples/openthread/ot_br/main/Kconfig.projbuild

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ menu "OpenThread Border Router Example"
88
SSID and PSK, and then form a Thread network automatically. Otherwise, user need
99
to configure Wi-Fi and Thread manually.
1010

11+
config OPENTHREAD_SUPPORT_HW_RESET_RCP
12+
bool 'Enable hardware RCP resetting'
13+
default False
14+
help
15+
If enabled, the Thread Border Router will support hardware resetting the RCP
16+
when processing RCP failure.
17+
18+
config OPENTHREAD_HW_RESET_RCP_PIN
19+
int 'Pin to RCP reset'
20+
depends on OPENTHREAD_SUPPORT_HW_RESET_RCP
21+
default 7
22+
1123
menu "External coexist wire type and pin config"
1224
config EXTERNAL_COEX_WIRE_TYPE
1325
int "The wire_type of external coexist"

examples/openthread/ot_br/main/esp_ot_br.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: CC0-1.0
55
*
@@ -38,6 +38,7 @@
3838
#include "mdns.h"
3939
#include "nvs_flash.h"
4040
#include "protocol_examples_common.h"
41+
#include "driver/gpio.h"
4142
#include "driver/uart.h"
4243
#include "freertos/FreeRTOS.h"
4344
#include "freertos/task.h"
@@ -62,6 +63,26 @@
6263

6364
#define TAG "esp_ot_br"
6465

66+
#if CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP
67+
#define PIN_TO_RCP_RESET CONFIG_OPENTHREAD_HW_RESET_RCP_PIN
68+
static void rcp_failure_hardware_reset_handler(void)
69+
{
70+
gpio_config_t reset_pin_config;
71+
memset(&reset_pin_config, 0, sizeof(reset_pin_config));
72+
reset_pin_config.intr_type = GPIO_INTR_DISABLE;
73+
reset_pin_config.pin_bit_mask = BIT(PIN_TO_RCP_RESET);
74+
reset_pin_config.mode = GPIO_MODE_OUTPUT;
75+
reset_pin_config.pull_down_en = GPIO_PULLDOWN_DISABLE;
76+
reset_pin_config.pull_up_en = GPIO_PULLUP_DISABLE;
77+
gpio_config(&reset_pin_config);
78+
gpio_set_level(PIN_TO_RCP_RESET, 0);
79+
vTaskDelay(pdMS_TO_TICKS(10));
80+
gpio_set_level(PIN_TO_RCP_RESET, 1);
81+
vTaskDelay(pdMS_TO_TICKS(30));
82+
gpio_reset_pin(PIN_TO_RCP_RESET);
83+
}
84+
#endif
85+
6586
#if CONFIG_EXTERNAL_COEX_ENABLE
6687
static void ot_br_external_coexist_init(void)
6788
{
@@ -192,6 +213,9 @@ void app_main(void)
192213
ESP_ERROR_CHECK(nvs_flash_init());
193214
ESP_ERROR_CHECK(esp_netif_init());
194215
ESP_ERROR_CHECK(esp_event_loop_create_default());
216+
#if CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP
217+
esp_openthread_register_rcp_failure_handler(rcp_failure_hardware_reset_handler);
218+
#endif
195219
xTaskCreate(ot_task_worker, "ot_br_main", 8192, xTaskGetCurrentTaskHandle(), 5, NULL);
196220
xTaskCreate(ot_br_init, "ot_br_init", 6144, NULL, 4, NULL);
197221
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP=y
2+
CONFIG_OPENTHREAD_HW_RESET_RCP_PIN=6
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
CONFIG_OPENTHREAD_RADIO_SPINEL_SPI=y
2+
CONFIG_OPENTHREAD_SUPPORT_HW_RESET_RCP=y
3+
CONFIG_OPENTHREAD_HW_RESET_RCP_PIN=7

0 commit comments

Comments
 (0)