Skip to content

Commit

Permalink
Merge branch 'support/esp32c6_csl_feature_merge' into 'master'
Browse files Browse the repository at this point in the history
openthread_port: support CSL on esp32c6

Closes TZ-41

See merge request espressif/esp-idf!22259
  • Loading branch information
jack0c committed Mar 20, 2023
2 parents e4cf722 + 29d5873 commit bb9200a
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 16 deletions.
71 changes: 70 additions & 1 deletion components/ieee802154/include/esp_ieee802154.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -474,6 +474,75 @@ extern void esp_ieee802154_timer0_done(void);
*/
extern void esp_ieee802154_timer1_done(void);

/**
* @brief Set the IEEE 802.15.4 Radio to receive state at a specific time.
*
*
* @param[in] time A specific timestamp for starting receiving.
* @return
* - ESP_OK on success
* - ESP_FAIL on failure due to invalid state.
*
* Note: Radio will start receiving after the timestamp, and continue receiving until it receives a valid frame.
* Ref to esp_ieee802154_receive_done().
*
*/
esp_err_t esp_ieee802154_receive_at(uint32_t time);

/**
* @brief Transmit the given frame at a specific time.
*
* @param[in] frame The pointer to the frame. Refer to `esp_ieee802154_transmit()`.
* @param[in] cca Perform CCA before transmission if it's true, otherwise transmit the frame directly.
* @param[in] time A specific timestamp for starting transmission.
*
* @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_at(const uint8_t *frame, bool cca, uint32_t time);

/**
* @brief Get the RSSI of the most recent received frame.
*
* @return The value of RSSI.
*
*/
int8_t esp_ieee802154_get_recent_rssi(void);

/**
* @brief Get the LQI of the most recent received frame.
*
* @return The value of LQI.
*
*/
uint8_t esp_ieee802154_get_recent_lqi(void);

/**
* @brief Set the key and addr for a frame needs to be encrypted by HW.
*
* @param[in] frame A frame needs to be encrypted. Refer to `esp_ieee802154_transmit()`.
* @param[in] key A 16-bytes key for encryption.
* @param[in] addr An 8-bytes addr for HW to generate nonce, in general, is the device extended address.
*
*/
void esp_ieee802154_set_transmit_security(uint8_t *frame, uint8_t *key, uint8_t *addr);

/**
* @brief This function will be called when a received frame needs to be acked with Enh-Ack, the upper
* layer should generate the Enh-Ack frame in this callback function.
*
* @param[in] frame The received frame.
* @param[in] frame_info The frame information. Refer to `esp_ieee802154_frame_info_t`.
* @param[out] enhack_frame The Enh-ack frame need to be generated via this function, HW will send it back after AIFS.
*
*/
void esp_ieee802154_enh_ack_generator(uint8_t *frame, esp_ieee802154_frame_info_t *frame_info, uint8_t* enhack_frame);

#ifdef __cplusplus
}
#endif
2 changes: 1 addition & 1 deletion components/ieee802154/lib
1 change: 1 addition & 0 deletions components/openthread/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ idf_component_register(SRC_DIRS "${src_dirs}"
INCLUDE_DIRS "${public_include_dirs}"
PRIV_INCLUDE_DIRS "${private_include_dirs}"
REQUIRES esp_netif lwip
LDFRAGMENTS linker.lf
PRIV_REQUIRES console driver esp_event esp_partition esp_timer
ieee802154 mbedtls spi_flash)

Expand Down
20 changes: 20 additions & 0 deletions components/openthread/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,24 @@ menu "OpenThread"
help
Set the OpenThread UART buffer size.

config OPENTHREAD_LINK_METRICS
bool "Enable link metrics feature"
depends on OPENTHREAD_ENABLED
default n
help
Select this option to enable link metrics feature

config OPENTHREAD_CSL_ENABLE
bool "Enable CSL feature"
depends on OPENTHREAD_ENABLED
default n
help
Select this option to enable CSL feature

config OPENTHREAD_CSL_DEBUG_ENABLE
bool "Enable CSL debug"
depends on OPENTHREAD_CSL_ENABLE
default n
help
Select this option to set rx on when sleep in CSL feature, only for debug
endmenu
10 changes: 10 additions & 0 deletions components/openthread/linker.lf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[mapping:openthread]
archive: libopenthread.a
entries:
if OPENTHREAD_CSL_ENABLE = y || OPENTHREAD_LINK_METRICS = y:
mesh_forwarder (noflash_text)
mac_frame (noflash_text)
csl_tx_scheduler (noflash_text)
link_metrics (noflash_text)
mac (noflash_text)
sub_mac (noflash_text)
Loading

0 comments on commit bb9200a

Please sign in to comment.