mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 05:34:32 +02:00
Merge branch 'feature/support_154_thread_on_esp32h2' into 'master'
esp32h2: enable IEEE 802.15.4 and Thread See merge request espressif/esp-idf!14315
This commit is contained in:
@@ -106,6 +106,7 @@
|
||||
/components/hal/ @esp-idf-codeowners/peripherals
|
||||
/components/heap/ @esp-idf-codeowners/system
|
||||
/components/idf_test/ @esp-idf-codeowners/ci
|
||||
/components/ieee802154/ @esp-idf-codeowners/ieee802154
|
||||
/components/jsmn/ @esp-idf-codeowners/app-utilities
|
||||
/components/json/ @esp-idf-codeowners/app-utilities
|
||||
/components/libsodium/ @esp-idf-codeowners/security
|
||||
|
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -106,3 +106,7 @@
|
||||
[submodule "components/openthread/lib"]
|
||||
path = components/openthread/lib
|
||||
url = ../../espressif/esp-thread-lib.git
|
||||
|
||||
[submodule "components/ieee802154/lib"]
|
||||
path = components/ieee802154/lib
|
||||
url = ../../espressif/esp-ieee802154-lib.git
|
||||
|
@@ -28,3 +28,4 @@ PROVIDE ( GPSPI4 = 0x60037000 );
|
||||
PROVIDE ( APB_SARADC = 0x60040000 );
|
||||
PROVIDE ( USB_SERIAL_JTAG = 0x60043000 );
|
||||
PROVIDE ( GDMA = 0x6003F000 );
|
||||
PROVIDE ( IEEE802154 = 0x60047000 );
|
||||
|
Submodule components/esp_phy/lib updated: 6def308291...8b1137c35c
18
components/ieee802154/CMakeLists.txt
Normal file
18
components/ieee802154/CMakeLists.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
idf_component_register(
|
||||
INCLUDE_DIRS include
|
||||
)
|
||||
|
||||
if(CONFIG_IEEE802154_ENABLED)
|
||||
if(CONFIG_IEEE802154_LIB_FROM_INTERNAL_SRC)
|
||||
idf_component_get_property(ieee802154_lib ieee802154_driver COMPONENT_LIB)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${ieee802154_lib}>)
|
||||
else()
|
||||
add_prebuilt_library(ieee802154_lib "${CMAKE_CURRENT_SOURCE_DIR}/lib/${idf_target}/lib802154.a")
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE ieee802154_lib)
|
||||
endif()
|
||||
|
||||
# force the phy libraries to be linked behind ieee802154
|
||||
idf_component_get_property(esp_phy_lib esp_phy COMPONENT_LIB)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE $<TARGET_FILE:${esp_phy_lib}> libphy.a libbtbb.a
|
||||
$<TARGET_FILE:${esp_phy_lib}>)
|
||||
endif()
|
15
components/ieee802154/Kconfig
Normal file
15
components/ieee802154/Kconfig
Normal file
@@ -0,0 +1,15 @@
|
||||
menu "IEEE 802.15.4"
|
||||
visible if IDF_TARGET_ESP32H2
|
||||
|
||||
config IEEE802154_ENABLED
|
||||
bool
|
||||
default "y" if IDF_TARGET_ESP32H2
|
||||
|
||||
config IEEE802154_LIB_FROM_INTERNAL_SRC
|
||||
bool "Build IEEE 802.15.4 libraries from source"
|
||||
depends on IEEE802154_ENABLED
|
||||
default n
|
||||
help
|
||||
Override the shipped lib802154.a for internal builds.
|
||||
|
||||
endmenu # IEEE 802.15.4
|
367
components/ieee802154/include/esp_ieee802154.h
Normal file
367
components/ieee802154/include/esp_ieee802154.h
Normal file
@@ -0,0 +1,367 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_ieee802154_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the IEEE 802.15.4 subsystem.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the IEEE 802.15.4 subsystem.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Get the operational channel.
|
||||
*
|
||||
* @return The channel number (11~26).
|
||||
*
|
||||
*/
|
||||
uint8_t esp_ieee802154_get_channel(void);
|
||||
|
||||
/**
|
||||
* @brief Set the operational channel.
|
||||
*
|
||||
* @param[in] channel The channel number (11-26).
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_channnel(uint8_t channel);
|
||||
|
||||
/**
|
||||
* @brief Get the transmit power.
|
||||
*
|
||||
* @return The transmit power in dBm.
|
||||
*
|
||||
*/
|
||||
int8_t esp_ieee802154_get_txpower(void);
|
||||
|
||||
/**
|
||||
* @brief Set the transmit power.
|
||||
*
|
||||
* @param[in] power The transmit power in dBm.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_txpower(int8_t power);
|
||||
|
||||
/**
|
||||
* @brief Get the promiscuous mode.
|
||||
*
|
||||
* @return
|
||||
* - True The promiscuous mode is enabled.
|
||||
* - False The promiscuous mode is disabled.
|
||||
*
|
||||
*/
|
||||
bool esp_ieee802154_get_promiscuous(void);
|
||||
|
||||
/**
|
||||
* @brief Set the promiscuous mode.
|
||||
*
|
||||
* @param[in] enable The promiscuous mode to be set.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_promiscuous(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Get the IEEE 802.15.4 Radio state.
|
||||
*
|
||||
* @return The IEEE 802.15.4 Radio state, refer to esp_ieee802154_state_t.
|
||||
*
|
||||
*/
|
||||
esp_ieee802154_state_t esp_ieee802154_get_state(void);
|
||||
|
||||
/**
|
||||
* @brief Set the IEEE 802.15.4 Radio to sleep state.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success.
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_sleep(void);
|
||||
|
||||
/**
|
||||
* @brief Set the IEEE 802.15.4 Radio to receive state.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
* Note: Radio will continue receiving until it receives a valid frame.
|
||||
* Ref to esp_ieee802154_receive_done().
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_receive(void);
|
||||
|
||||
/**
|
||||
* @brief Transmit the given frame.
|
||||
*
|
||||
* @param[in] frame The pointer to the frame, the frame format:
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | Len | MHR | MAC Payload | FCS |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* @param[in] cca Perform CCA before transmission if it's true, otherwise transmit the frame directly.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success.
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
* Note: The transmit result will be reported via esp_ieee802154_transmit_done()
|
||||
* or esp_ieee802154_transmit_failed().
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_transmit(const uint8_t *frame, bool cca);
|
||||
|
||||
/**
|
||||
* @brief Set the time to wait for the ack frame.
|
||||
*
|
||||
* @param[in] timeout The time to wait for the ack frame, in symbol unit (16 us).
|
||||
* Default: 0x006C, Range: 0x0000 - 0xFFFF.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_ack_timeout(uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Get the device PAN ID.
|
||||
*
|
||||
* @return The device PAN ID.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ieee802154_get_panid(void);
|
||||
|
||||
/**
|
||||
* @brief Set the device PAN ID.
|
||||
*
|
||||
* @param[in] panid The device PAN ID.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_panid(uint16_t panid);
|
||||
|
||||
/**
|
||||
* @brief Get the device short address.
|
||||
*
|
||||
* @return The device short address.
|
||||
*
|
||||
*/
|
||||
uint16_t esp_ieee802154_get_short_address(void);
|
||||
|
||||
/**
|
||||
* @brief Set the device short address.
|
||||
*
|
||||
* @param[in] short_address The device short address.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_short_address(uint16_t short_address);
|
||||
|
||||
/**
|
||||
* @brief Get the device extended address.
|
||||
*
|
||||
* @param[out] ext_addr The pointer to the device extended address.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_get_extended_address(uint8_t *ext_addr);
|
||||
|
||||
/**
|
||||
* @brief Set the device extended address.
|
||||
*
|
||||
* @param[in] ext_addr The pointer to the device extended address.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_extended_address(const uint8_t *ext_addr);
|
||||
|
||||
/**
|
||||
* @brief Get the auto frame pending mode.
|
||||
*
|
||||
* @return The auto frame pending mode, refer to esp_ieee802154_pending_mode_t.
|
||||
*
|
||||
*/
|
||||
esp_ieee802154_pending_mode_t esp_ieee802154_get_pending_mode(void);
|
||||
|
||||
/**
|
||||
* @brief Set the auto frame pending mode.
|
||||
*
|
||||
* @param[in] pending_mode The auto frame pending mode, refer to esp_ieee802154_pending_mode_t.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_pending_mode(esp_ieee802154_pending_mode_t pending_mode);
|
||||
|
||||
/**
|
||||
* @brief Add address to the source matching table.
|
||||
*
|
||||
* @param[in] addr The pointer to the address.
|
||||
* @param[in] is_short Short address or Extended address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success.
|
||||
* - ESP_ERR_NO_MEM if the pending table is full.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_add_pending_addr(const uint8_t *addr, bool is_short);
|
||||
|
||||
/**
|
||||
* @brief Remove address from the source matching table.
|
||||
*
|
||||
* @param[in] addr The pointer to the address.
|
||||
* @param[in] is_short Short address or Extended address.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success.
|
||||
* - ESP_ERR_NOT_FOUND if the address was not found from the source matching table.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_clear_pending_addr(const uint8_t *addr, bool is_short);
|
||||
|
||||
/**
|
||||
* @brief Clear the source matching table to empty.
|
||||
*
|
||||
* @param[in] is_short Clear Short address table or Extended address table.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_reset_pending_table(bool is_short);
|
||||
|
||||
/**
|
||||
* @brief Get the CCA threshold.
|
||||
*
|
||||
* @return The CCA threshold in dBm.
|
||||
*
|
||||
*/
|
||||
int8_t esp_ieee802154_get_cca_threshold(void);
|
||||
|
||||
/**
|
||||
* @brief Set the CCA threshold.
|
||||
*
|
||||
* @param[in] cca_threshold The CCA threshold in dBm.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_cca_threshold(int8_t cca_threshold);
|
||||
|
||||
/**
|
||||
* @brief Get the CCA mode.
|
||||
*
|
||||
* @return The CCA mode, refer to esp_ieee802154_cca_mode_t.
|
||||
*
|
||||
*/
|
||||
esp_ieee802154_cca_mode_t esp_ieee802154_get_cca_mode(void);
|
||||
|
||||
/**
|
||||
* @brief Set the CCA mode.
|
||||
*
|
||||
* @param[in] cca_mode The CCA mode, refer to esp_ieee802154_cca_mode_t.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_cca_mode(esp_ieee802154_cca_mode_t cca_mode);
|
||||
|
||||
/**
|
||||
* @brief Enable rx_on_when_idle mode, radio will receive during idle.
|
||||
*
|
||||
* @param[in] enable Enable/Disable rx_on_when_idle mode.
|
||||
*
|
||||
*/
|
||||
void esp_ieee802154_set_rx_when_idle(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Get the rx_on_when_idle mode.
|
||||
*
|
||||
* @return rx_on_when_idle mode.
|
||||
*
|
||||
*/
|
||||
bool esp_ieee802154_get_rx_when_idle(void);
|
||||
|
||||
/**
|
||||
* @brief Perform energy detection.
|
||||
*
|
||||
* @param[in] duration The duration of energy detection, in symbol unit (16 us).
|
||||
* The result will be reported via esp_ieee802154_energy_detect_done().
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success.
|
||||
* - ESP_FAIL on failure due to invalid state.
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ieee802154_energy_detect(uint32_t duration);
|
||||
|
||||
|
||||
/** Below are the events generated by IEEE 802.15.4 subsystem, which are in ISR context **/
|
||||
/**
|
||||
* @brief A Frame was received.
|
||||
*
|
||||
* @param[in] frame The point to the received frame, frame format:
|
||||
* |-----------------------------------------------------------------------|
|
||||
* | Len | MHR | MAC Payload (no FCS) |
|
||||
* |-----------------------------------------------------------------------|
|
||||
* @param[in] frame_info More information of the received frame, refer to esp_ieee802154_frame_info_t.
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_receive_done(uint8_t *frame, esp_ieee802154_frame_info_t *frame_info);
|
||||
|
||||
/**
|
||||
* @brief The SFD field of the frame was received.
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_receive_sfd_done(void);
|
||||
|
||||
/**
|
||||
* @brief The Frame Transmission succeeded.
|
||||
*
|
||||
* @param[in] frame The pointer to the transmitted frame.
|
||||
* @param[in] ack The received ACK frame, it could be NULL if the transmitted frame's AR bit is not set.
|
||||
* @param[in] ack_frame_info More information of the ACK frame, refer to esp_ieee802154_frame_info_t.
|
||||
*
|
||||
* Note: refer to esp_ieee802154_transmit().
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_transmit_done(const uint8_t *frame, const uint8_t *ack, esp_ieee802154_frame_info_t *ack_frame_info);
|
||||
|
||||
/**
|
||||
* @brief The Frame Transmission failed.
|
||||
*
|
||||
* @param[in] frame The pointer to the frame.
|
||||
* @param[in] error The transmission failure reason, refer to esp_ieee802154_tx_error_t.
|
||||
*
|
||||
* Note: refer to esp_ieee802154_transmit().
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_transmit_failed(const uint8_t *frame, esp_ieee802154_tx_error_t error);
|
||||
|
||||
/**
|
||||
* @brief The SFD field of the frame was transmitted.
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_transmit_sfd_done(uint8_t *frame);
|
||||
|
||||
/**
|
||||
* @brief The energy detection done.
|
||||
*
|
||||
* @param[in] power The detected power level, in dBm.
|
||||
*
|
||||
* Note: refer to esp_ieee802154_energy_detect().
|
||||
*
|
||||
*/
|
||||
extern void esp_ieee802154_energy_detect_done(int8_t power);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
79
components/ieee802154/include/esp_ieee802154_types.h
Normal file
79
components/ieee802154/include/esp_ieee802154_types.h
Normal file
@@ -0,0 +1,79 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The radio state types.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_IEEE802154_RADIO_DISABLE, /*!< Radio not up */
|
||||
ESP_IEEE802154_RADIO_SLEEP, /*!< Radio in the sleep state */
|
||||
ESP_IEEE802154_RADIO_RECEIVE, /*!< Radio in the receive state */
|
||||
ESP_IEEE802154_RADIO_TRANSMIT, /*!< Radio in the transmit state */
|
||||
} esp_ieee802154_state_t;
|
||||
|
||||
/**
|
||||
* @brief The transmit error types.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_IEEE802154_TX_ERR_NONE, /*!< No transmit error */
|
||||
ESP_IEEE802154_TX_ERR_CCA_BUSY, /*!< Channel is busy */
|
||||
ESP_IEEE802154_TX_ERR_ABORT, /*!< Transmit abort */
|
||||
ESP_IEEE802154_TX_ERR_NO_ACK, /*!< No Ack frame received until timeout */
|
||||
ESP_IEEE802154_TX_ERR_INVALID_ACK, /*!< Invalid Ack frame */
|
||||
ESP_IEEE802154_TX_ERR_COEXIST, /*!< Rejected by coexist system */
|
||||
} esp_ieee802154_tx_error_t;
|
||||
|
||||
/**
|
||||
* @brief The CCA mode types.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_IEEE802154_CCA_MODE_CARRIER, /*!< Carrier only */
|
||||
ESP_IEEE802154_CCA_MODE_ED, /*!< Energy Detect only */
|
||||
ESP_IEEE802154_CCA_MODE_CARRIER_OR_ED, /*!< Carrier or Energy Detect */
|
||||
ESP_IEEE802154_CCA_MODE_CARRIER_AND_ED, /*!< Carrier and Energy Detect */
|
||||
} esp_ieee802154_cca_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The frame pending mode types.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_IEEE802154_AUTO_PENDING_DISABLE, /*!< Frame pending bit always set to 1 in the ack to Data Request */
|
||||
ESP_IEEE802154_AUTO_PENDING_ENABLE, /*!< Frame pending bit set to 1 if src address matches, in the ack to Data Request */
|
||||
ESP_IEEE802154_AUTO_PENDING_ENHANCED, /*!< Frame pending bit set to 1 if src address matches, in all ack frames */
|
||||
} esp_ieee802154_pending_mode_t;
|
||||
|
||||
/**
|
||||
* @brief The information of received 15.4 frame.
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
bool pending; /*!< The frame was acked with frame pending set */
|
||||
uint8_t channel; /*!< Channel */
|
||||
int8_t rssi; /*!< RSSI */
|
||||
uint8_t lqi; /*!< LQI */
|
||||
uint64_t timestamp; /*!< The timestamp when the frame's SFD field was received */
|
||||
} esp_ieee802154_frame_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
1
components/ieee802154/lib
Submodule
1
components/ieee802154/lib
Submodule
Submodule components/ieee802154/lib added at 46396c46bd
@@ -69,7 +69,7 @@ idf_component_register(SRC_DIRS "${src_dirs}"
|
||||
EXCLUDE_SRCS "${exclude_srcs}"
|
||||
INCLUDE_DIRS "${public_include_dirs}"
|
||||
PRIV_INCLUDE_DIRS "${private_include_dirs}"
|
||||
REQUIRES mbedtls)
|
||||
REQUIRES mbedtls ieee802154)
|
||||
|
||||
if(CONFIG_OPENTHREAD_ENABLED)
|
||||
target_compile_definitions(
|
||||
|
@@ -6,6 +6,25 @@ menu "OpenThread"
|
||||
help
|
||||
Select this option to enable OpenThread and show the submenu with OpenThread configuration choices.
|
||||
|
||||
choice OPENTHREAD_RADIO_TYPE
|
||||
prompt "Config the Thread radio type"
|
||||
depends on OPENTHREAD_ENABLED
|
||||
default OPENTHREAD_RADIO_NATIVE if IDF_TARGET_ESP32H2
|
||||
default OPENTHREAD_RADIO_SPINEL_UART
|
||||
help
|
||||
Configure how OpenThread connects to the 15.4 radio
|
||||
|
||||
config OPENTHREAD_RADIO_NATIVE
|
||||
bool "Native 15.4 radio"
|
||||
help
|
||||
Select this to use the native 15.4 radio.
|
||||
|
||||
config OPENTHREAD_RADIO_SPINEL_UART
|
||||
bool "Connect via UART"
|
||||
help
|
||||
Select this to connect to a Radio Co-Processor via UART.
|
||||
endchoice
|
||||
|
||||
choice OPENTHREAD_DEVICE_TYPE
|
||||
prompt "Config the Thread device type"
|
||||
depends on OPENTHREAD_ENABLED
|
||||
|
@@ -72,7 +72,9 @@ typedef struct {
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
RADIO_MODE_UART_RCP = 0x0, /*!< UART connection to a 15.4 capable radio co-processor(RCP)*/
|
||||
RADIO_MODE_NATIVE = 0x0, /*!< Use the native 15.4 radio*/
|
||||
RADIO_MODE_UART_RCP = 0x1, /*!< UART connection to a 15.4 capable radio co-processor (RCP)*/
|
||||
RADIO_MODE_SPI_RCP = 0x2, /*!< SPI connection to a 15.4 capable radio co-processor (RCP)*/
|
||||
} esp_openthread_radio_mode_t;
|
||||
|
||||
/**
|
||||
|
Submodule components/openthread/lib updated: 3a3009e7a1...d84f8967f8
@@ -215,8 +215,9 @@ INPUT = \
|
||||
$(IDF_PATH)/components/freemodbus/common/include/esp_modbus_master.h \
|
||||
$(IDF_PATH)/components/perfmon/include/xtensa_perfmon_access.h \
|
||||
$(IDF_PATH)/components/perfmon/include/xtensa_perfmon_apis.h \
|
||||
$(IDF_PATH)/components/perfmon/include/xtensa_perfmon_masks.h
|
||||
|
||||
$(IDF_PATH)/components/perfmon/include/xtensa_perfmon_masks.h \
|
||||
$(IDF_PATH)/components/ieee802154/include/esp_ieee802154.h \
|
||||
$(IDF_PATH)/components/ieee802154/include/esp_ieee802154_types.h
|
||||
|
||||
## Target specific headers are in seperate Doxyfile files
|
||||
@INCLUDE = $(IDF_PATH)/docs/doxygen/Doxyfile_$(IDF_TARGET)
|
||||
|
@@ -24,10 +24,10 @@
|
||||
#include "esp_netif_net_stack.h"
|
||||
#include "esp_openthread.h"
|
||||
#include "esp_openthread_border_router.h"
|
||||
#include "esp_openthread_defaults.h"
|
||||
#include "esp_openthread_lock.h"
|
||||
#include "esp_openthread_netif_glue.h"
|
||||
#include "esp_openthread_types.h"
|
||||
#include "esp_ot_config.h"
|
||||
#include "esp_vfs_eventfd.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "nvs_flash.h"
|
||||
@@ -143,8 +143,8 @@ static void create_config_network(otInstance *instance)
|
||||
static void ot_task_worker(void *aContext)
|
||||
{
|
||||
esp_openthread_platform_config_t config = {
|
||||
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_UART_RCP_CONFIG(4, 5),
|
||||
.host_config = ESP_OPENTHREAD_DEFAULT_UART_HOST_CONFIG(),
|
||||
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
|
||||
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
|
||||
};
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "esp_openthread_types.h"
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_RADIO_UART_RCP_CONFIG(pin_rx, pin_tx) \
|
||||
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
|
||||
{ \
|
||||
.radio_mode = RADIO_MODE_UART_RCP, \
|
||||
.radio_uart_config = { \
|
||||
@@ -31,12 +31,12 @@
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = pin_rx, \
|
||||
.tx_pin = pin_tx, \
|
||||
.rx_pin = 4, \
|
||||
.tx_pin = 5, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_UART_HOST_CONFIG() \
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_UART, \
|
||||
.host_uart_config = { \
|
@@ -21,10 +21,10 @@
|
||||
#include "esp_netif.h"
|
||||
#include "esp_netif_types.h"
|
||||
#include "esp_openthread.h"
|
||||
#include "esp_openthread_defaults.h"
|
||||
#include "esp_openthread_lock.h"
|
||||
#include "esp_openthread_netif_glue.h"
|
||||
#include "esp_openthread_types.h"
|
||||
#include "esp_ot_config.h"
|
||||
#include "esp_vfs_eventfd.h"
|
||||
#include "driver/uart.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
@@ -56,8 +56,8 @@ static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t
|
||||
static void ot_task_worker(void *aContext)
|
||||
{
|
||||
esp_openthread_platform_config_t config = {
|
||||
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_UART_RCP_CONFIG(4, 5),
|
||||
.host_config = ESP_OPENTHREAD_DEFAULT_UART_HOST_CONFIG(),
|
||||
.radio_config = ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG(),
|
||||
.host_config = ESP_OPENTHREAD_DEFAULT_HOST_CONFIG(),
|
||||
.port_config = ESP_OPENTHREAD_DEFAULT_PORT_CONFIG(),
|
||||
};
|
||||
esp_netif_t *openthread_netif;
|
||||
@@ -89,9 +89,10 @@ void app_main(void)
|
||||
{
|
||||
// Used eventfds:
|
||||
// * netif
|
||||
// * ot task queue
|
||||
// * radio driver
|
||||
esp_vfs_eventfd_config_t eventfd_config = {
|
||||
.max_fds = 2,
|
||||
.max_fds = 3,
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
72
examples/openthread/ot_cli/main/esp_ot_config.h
Normal file
72
examples/openthread/ot_cli/main/esp_ot_config.h
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright 2021 Espressif Systems (Shanghai) CO LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "esp_openthread_types.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32H2
|
||||
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
|
||||
{ \
|
||||
.radio_mode = RADIO_MODE_NATIVE, \
|
||||
}
|
||||
|
||||
#else
|
||||
#define ESP_OPENTHREAD_DEFAULT_RADIO_CONFIG() \
|
||||
{ \
|
||||
.radio_mode = RADIO_MODE_UART_RCP, \
|
||||
.radio_uart_config = { \
|
||||
.port = 1, \
|
||||
.uart_config = \
|
||||
{ \
|
||||
.baud_rate = 115200, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = 4, \
|
||||
.tx_pin = 5, \
|
||||
}, \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_HOST_CONFIG() \
|
||||
{ \
|
||||
.host_connection_mode = HOST_CONNECTION_MODE_UART, \
|
||||
.host_uart_config = { \
|
||||
.port = 0, \
|
||||
.uart_config = \
|
||||
{ \
|
||||
.baud_rate = 115200, \
|
||||
.data_bits = UART_DATA_8_BITS, \
|
||||
.parity = UART_PARITY_DISABLE, \
|
||||
.stop_bits = UART_STOP_BITS_1, \
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE, \
|
||||
.rx_flow_ctrl_thresh = 0, \
|
||||
.source_clk = UART_SCLK_APB, \
|
||||
}, \
|
||||
.rx_pin = UART_PIN_NO_CHANGE, \
|
||||
.tx_pin = UART_PIN_NO_CHANGE, \
|
||||
}, \
|
||||
}
|
||||
|
||||
#define ESP_OPENTHREAD_DEFAULT_PORT_CONFIG() \
|
||||
{ \
|
||||
.storage_partition_name = "ot_storage", \
|
||||
.netif_queue_size = 10, \
|
||||
.task_queue_size = 10, \
|
||||
}
|
21
examples/openthread/ot_cli/sdkconfig.defaults.esp32h2
Normal file
21
examples/openthread/ot_cli/sdkconfig.defaults.esp32h2
Normal file
@@ -0,0 +1,21 @@
|
||||
#
|
||||
# mbedTLS
|
||||
#
|
||||
|
||||
# ESP32H2-TODO: enable HW acceleration
|
||||
CONFIG_MBEDTLS_HARDWARE_AES=n
|
||||
CONFIG_MBEDTLS_HARDWARE_MPI=n
|
||||
CONFIG_MBEDTLS_HARDWARE_SHA=n
|
||||
# end of mbedTLS
|
||||
|
||||
#
|
||||
# OpenThread
|
||||
#
|
||||
CONFIG_OPENTHREAD_BORDER_ROUTER=n
|
||||
# end of OpenThread
|
||||
|
||||
#
|
||||
# IEEE 802.15.4
|
||||
#
|
||||
CONFIG_IEEE802154_ENABLED=y
|
||||
# end of IEEE 802.15.4
|
Reference in New Issue
Block a user