From f0c934c7a8312fb8be0eb05c0abb004190f0db49 Mon Sep 17 00:00:00 2001 From: Xu Si Yu Date: Thu, 9 Mar 2023 14:48:29 +0800 Subject: [PATCH] openthread border router: support c6 single chip br --- components/esp_coex/include/esp_coexist.h | 8 ++++++++ components/esp_coex/src/coexist.c | 11 +++++++++++ examples/openthread/ot_br/README.md | 11 ++++++++++- examples/openthread/ot_br/main/esp_ot_br.c | 6 ++++++ examples/openthread/ot_br/main/idf_component.yml | 2 +- examples/openthread/ot_cli/main/idf_component.yml | 2 +- 6 files changed, 37 insertions(+), 3 deletions(-) diff --git a/components/esp_coex/include/esp_coexist.h b/components/esp_coex/include/esp_coexist.h index e3fb019d42..9ed897c28a 100644 --- a/components/esp_coex/include/esp_coexist.h +++ b/components/esp_coex/include/esp_coexist.h @@ -201,6 +201,14 @@ esp_err_t esp_external_coex_set_validate_high(bool is_high_valid); #endif #endif +#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_SOC_IEEE802154_SUPPORTED +/** + * @brief Enable Wi-Fi and 802.15.4 coexistence. + * @return : ESP_OK - success, other - failed + */ +esp_err_t esp_coex_wifi_i154_enable(void); +#endif + #ifdef __cplusplus } #endif diff --git a/components/esp_coex/src/coexist.c b/components/esp_coex/src/coexist.c index c603800575..f90aaf7108 100644 --- a/components/esp_coex/src/coexist.c +++ b/components/esp_coex/src/coexist.c @@ -395,3 +395,14 @@ esp_err_t esp_disable_extern_coex_gpio_pin() return ESP_OK; } #endif/*External Coex*/ + +#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_SOC_IEEE802154_SUPPORTED +esp_err_t esp_coex_wifi_i154_enable(void) +{ + // TODO: Add a scheme for wifi and 154 coex. + // Remove this function if FCC-50 closes. + coex_enable(); + coex_schm_status_bit_set(1, 1); + return ESP_OK; +} +#endif diff --git a/examples/openthread/ot_br/README.md b/examples/openthread/ot_br/README.md index 2286a01489..953c4c3bd7 100644 --- a/examples/openthread/ot_br/README.md +++ b/examples/openthread/ot_br/README.md @@ -7,11 +7,16 @@ This example demonstrates an [OpenThread border router](https://openthread.io/guides/border-router). +The ESP Thread Border Router SDK provides extra components and examples for putting the ESP Thread Border Router solution into production: + +* [ESP Thread Border Router Docs](https://docs.espressif.com/projects/esp-thread-br) +* [ESP Thread Border Router Repo](https://github.com/espressif/esp-thread-br) + ## How to use example ### Hardware Required #### **Wi-Fi based Thread Border Router** -The following SoCs are required to run this example: +By default, two SoCs are required to run this example: * An ESP32 series Wi-Fi SoC (ESP32, ESP32-C, ESP32-S, etc) loaded with this ot_br example. * An ESP32-H4 802.15.4 SoC loaded with [ot_rcp](../ot_rcp) example. * Another ESP32-H4 SoC loaded with [ot_cli](../ot_cli) example. @@ -25,6 +30,8 @@ ESP32 pin | ESP32-H4 pin GPIO4 | TX GPIO5 | RX +The example could also run on a single SoC which supports both Wi-Fi and Thread (e.g., ESP32-C6), but since there is only one RF path in ESP32-C6, which means Wi-Fi and Thread can't receive simultaneously, it has a significant impact on performance. Hence the two SoCs solution is recommended. + #### **Ethernet based Thread Border Router** Similar to the previous Wi-Fi based Thread Border Route setup, but a device with Ethernet interface is required, such as [ESP32-Ethernet-Kit](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/hw-reference/esp32/get-started-ethernet-kit.html) @@ -33,6 +40,8 @@ Similar to the previous Wi-Fi based Thread Border Route setup, but a device with ``` idf.py menuconfig ``` +In order to run the example on single SoC which supports both Wi-Fi and Thread, the option `CONFIG_ESP_COEX_SW_COEXIST_ENABLE` and option `CONFIG_OPENTHREAD_RADIO_NATIVE` should be enabled. The two options are enabled by default for ESP32-C6 target. + Two ways are provided to setup the Thread Border Router in this example: - Auto Start diff --git a/examples/openthread/ot_br/main/esp_ot_br.c b/examples/openthread/ot_br/main/esp_ot_br.c index 6d50eedbbf..38d8e43dd6 100644 --- a/examples/openthread/ot_br/main/esp_ot_br.c +++ b/examples/openthread/ot_br/main/esp_ot_br.c @@ -34,6 +34,7 @@ #include "esp_vfs_dev.h" #include "esp_vfs_eventfd.h" #include "esp_wifi.h" +#include "esp_coexist.h" #include "mdns.h" #include "nvs_flash.h" #include "protocol_examples_common.h" @@ -221,7 +222,12 @@ void app_main(void) #if CONFIG_EXAMPLE_CONNECT_WIFI #if CONFIG_OPENTHREAD_BR_AUTO_START ESP_ERROR_CHECK(example_connect()); +#if CONFIG_ESP_COEX_SW_COEXIST_ENABLE && CONFIG_OPENTHREAD_RADIO_NATIVE + ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_MIN_MODEM)); + ESP_ERROR_CHECK(esp_coex_wifi_i154_enable()); +#else ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); +#endif esp_openthread_set_backbone_netif(get_example_netif()); #else esp_ot_wifi_netif_init(); diff --git a/examples/openthread/ot_br/main/idf_component.yml b/examples/openthread/ot_br/main/idf_component.yml index 06ebf10ab6..6567df8d22 100644 --- a/examples/openthread/ot_br/main/idf_component.yml +++ b/examples/openthread/ot_br/main/idf_component.yml @@ -1,7 +1,7 @@ ## IDF Component Manager Manifest File dependencies: espressif/esp_ot_cli_extension: - version: "~0.3.0" + version: "~0.4.0" espressif/mdns: "^1.0.3" ## Required IDF version idf: diff --git a/examples/openthread/ot_cli/main/idf_component.yml b/examples/openthread/ot_cli/main/idf_component.yml index 33680db455..9d13c3b615 100644 --- a/examples/openthread/ot_cli/main/idf_component.yml +++ b/examples/openthread/ot_cli/main/idf_component.yml @@ -1,6 +1,6 @@ ## IDF Component Manager Manifest File dependencies: espressif/esp_ot_cli_extension: - version: "~0.3.0" + version: "~0.4.0" idf: version: ">=4.1.0"