feat(802.15.4): introduce a series of APIs related power table

This commit is contained in:
zwx
2025-01-03 14:22:13 +08:00
parent 52f905b6c7
commit 5bf1cc9d44
7 changed files with 178 additions and 15 deletions
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -10,6 +10,7 @@
#include <stdint.h>
#include "hal/ieee802154_ll.h"
#include "esp_ieee802154_frame.h"
#include "esp_ieee802154_types.h"
#ifdef __cplusplus
extern "C" {
@@ -25,11 +26,11 @@ typedef struct {
bool promiscuous; /*!< A flag indicates promiscuous mode is enabled or not */
bool coordinator; /*!< A flag indicates the device is coordinator or not*/
bool rx_when_idle; /*!< A flag indicates the device is rx on when idle or not */
int8_t txpower; /*!< Tx power configuration */
esp_ieee802154_txpower_table_t power_table; /*!< The power table configuration */
uint8_t channel; /*!< Channel configuration */
ieee802154_ll_pending_mode_t pending_mode; /*!< Pending mode configuration */
ieee802154_ll_pending_mode_t pending_mode; /*!< Pending mode configuration */
int8_t cca_threshold; /*!< CCA threshold */
ieee802154_ll_cca_mode_t cca_mode; /*!< CCA mode */
ieee802154_ll_cca_mode_t cca_mode; /*!< CCA mode */
} ieee802154_pib_t;
/**
@@ -69,7 +70,7 @@ void ieee802154_pib_set_channel(uint8_t channel);
uint8_t ieee802154_pib_get_channel(void);
/**
* @brief Set a specific transmission power to the PIB.
* @brief Set a specific transmission power for current channel to the PIB.
*
* @param[in] power The power.
*
@@ -77,13 +78,58 @@ uint8_t ieee802154_pib_get_channel(void);
void ieee802154_pib_set_power(int8_t power);
/**
* @brief Get the transmission power from the PIB.
* @brief Get the transmission power of current channel from the PIB.
*
* @return
* - The transmission power has been set in the PIB.
*/
int8_t ieee802154_pib_get_power(void);
/**
* @brief Set a specific transmission power table to the PIB.
*
* @param[in] power_table The power table.
*
* @return
* - ESP_OK Set the transmission power table to the PIB successfully.
*/
esp_err_t ieee802154_pib_set_power_table(esp_ieee802154_txpower_table_t power_table);
/**
* @brief Get the transmission power table from the PIB.
*
* @param[out] out_power_table The power table.
*
* @return
* - ESP_OK Get the transmission power table from the PIB successfully.
*
*/
esp_err_t ieee802154_pib_get_power_table(esp_ieee802154_txpower_table_t *out_power_table);
/**
* @brief Set a specific transmission power for a specific channel to the PIB.
*
* @param[in] channel The channel.
* @param[in] power The power.
*
* @return
* - ESP_OK Set the transmission power of a specific channel from the PIB successfully.
* - ESP_ERR_INVALID_ARG Invalid channel.
*/
esp_err_t ieee802154_pib_set_power_with_channel(uint8_t channel, int8_t power);
/**
* @brief Get the transmission power of a specific channel from the PIB.
*
* @param[in] channel The channel.
* @param[out] out_power The power.
*
* @return
* - ESP_OK Get the transmission power of a specific channel from the PIB successfully.
* - ESP_ERR_INVALID_ARG Invalid channel.
*/
esp_err_t ieee802154_pib_get_power_with_channel(uint8_t channel, int8_t *out_power);
/**
* @brief Set the promiscuous mode to the PIB.
*
@@ -19,6 +19,14 @@ extern "C" {
#define IEEE802154_TAG "ieee802154"
#define IEEE802154_OQPSK_2P4G_CHANNEL_MIN 11
#define IEEE802154_OQPSK_2P4G_CHANNEL_MAX 26
static inline bool ieee802154_is_valid_channel(uint8_t channel)
{
return ((channel <= IEEE802154_OQPSK_2P4G_CHANNEL_MAX) && (channel >= IEEE802154_OQPSK_2P4G_CHANNEL_MIN));
}
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
#define IEEE802154_RF_ENABLE() ieee802154_rf_enable()
#define IEEE802154_RF_DISABLE() ieee802154_rf_disable()