drivers: nrf_802154: Update the IEEE 802.15.4 component
This commit updates the nRF 802.15.4 radio driver to feature the latest changes. sdk-nrf-802154 commit: 7e896fbeca9a0dc5240e583e321c62393af705ea Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
This commit is contained in:
parent
1f9145e8c8
commit
626e3dd960
|
@ -62,6 +62,7 @@ target_sources(nrf-802154-driver
|
|||
src/nrf_802154_trx_dppi.c
|
||||
src/nrf_802154_trx_ppi.c
|
||||
src/nrf_802154_tx_work_buffer.c
|
||||
src/nrf_802154_tx_power.c
|
||||
src/mac_features/nrf_802154_csma_ca.c
|
||||
src/mac_features/nrf_802154_delayed_trx.c
|
||||
src/mac_features/nrf_802154_filter.c
|
||||
|
@ -87,7 +88,6 @@ else ()
|
|||
target_sources(nrf-802154-driver
|
||||
PRIVATE
|
||||
src/nrf_802154_notification_swi.c
|
||||
src/nrf_802154_priority_drop_swi.c
|
||||
src/nrf_802154_request_swi.c
|
||||
)
|
||||
endif ()
|
||||
|
|
|
@ -405,6 +405,19 @@ typedef struct
|
|||
bool dynamic_data_is_set; // !< If dynamic data of the frame frame to be transmitted is set.
|
||||
} nrf_802154_transmitted_frame_props_t;
|
||||
|
||||
/**
|
||||
* @brief Structure passed in transmit metadata with information needed to set transmission power.
|
||||
*
|
||||
* If the @p use_metadata_value field is set to true the power in dBm used to transmit the frame is set to the value of the
|
||||
* field @p power.
|
||||
* Otherwise the value from PIB set by @ref nrf_802154_tx_power_set is used
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool use_metadata_value; // !< Set to true if the value in @p power should be used as the TX power in dBm
|
||||
int8_t power; // !< Transmission power in dBm
|
||||
} nrf_802154_tx_power_metadata_t;
|
||||
|
||||
/**
|
||||
* @brief Default initializer for nrf_802154_transmitted_frame_props_t.
|
||||
*/
|
||||
|
@ -421,6 +434,7 @@ typedef struct
|
|||
{
|
||||
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
|
||||
bool cca; // !< If the driver is to perform a CCA procedure before transmission.
|
||||
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used
|
||||
} nrf_802154_transmit_metadata_t;
|
||||
|
||||
/**
|
||||
|
@ -431,6 +445,7 @@ typedef struct
|
|||
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
|
||||
bool cca; // !< If the driver is to perform a CCA procedure before transmission.
|
||||
uint8_t channel; // !< Radio channel on which the frame is to be transmitted.
|
||||
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used
|
||||
} nrf_802154_transmit_at_metadata_t;
|
||||
|
||||
/**
|
||||
|
@ -439,6 +454,7 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
|
||||
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used
|
||||
} nrf_802154_transmit_csma_ca_metadata_t;
|
||||
|
||||
/**
|
||||
|
@ -471,6 +487,7 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
|
||||
int8_t tx_power; // !< Power to be used when transmitting the frame.
|
||||
bool cca; // !< If the driver is to perform CCA procedure before transmission.
|
||||
bool immediate; // !< If true, the driver schedules transmission immediately or never. If false, the transmission may be postponed
|
||||
// until its preconditions are met.
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
#include "nrf_802154_notification.h"
|
||||
#include "nrf_802154_pib.h"
|
||||
#include "nrf_802154_request.h"
|
||||
#include "nrf_802154_tx_power.h"
|
||||
#include "nrf_802154_stats.h"
|
||||
#include "platform/nrf_802154_random.h"
|
||||
#include "rsch/nrf_802154_rsch.h"
|
||||
|
@ -67,7 +68,8 @@ typedef enum
|
|||
{
|
||||
CSMA_CA_STATE_IDLE, ///< The CSMA-CA procedure is inactive.
|
||||
CSMA_CA_STATE_BACKOFF, ///< The CSMA-CA procedure is in backoff stage.
|
||||
CSMA_CA_STATE_ONGOING ///< The frame is being sent.
|
||||
CSMA_CA_STATE_ONGOING, ///< The frame is being sent.
|
||||
CSMA_CA_STATE_ABORTED ///< The CSMA-CA procedure is being aborted.
|
||||
} csma_ca_state_t;
|
||||
|
||||
static uint8_t m_nb; ///< The number of times the CSMA-CA algorithm was required to back off while attempting the current transmission.
|
||||
|
@ -75,6 +77,7 @@ static uint8_t m_be; ///< Backoff exponent,
|
|||
|
||||
static uint8_t * mp_data; ///< Pointer to a buffer containing PHR and PSDU of the frame being transmitted.
|
||||
static nrf_802154_transmitted_frame_props_t m_data_props; ///< Structure containing detailed properties of data in buffer.
|
||||
static int8_t m_tx_power; ///< Power in dBm to be used when transmitting the frame.
|
||||
static csma_ca_state_t m_state; ///< The current state of the CSMA-CA procedure.
|
||||
|
||||
/**
|
||||
|
@ -189,6 +192,7 @@ static void frame_transmit(rsch_dly_ts_id_t dly_ts_id)
|
|||
nrf_802154_transmit_params_t params =
|
||||
{
|
||||
.frame_props = m_data_props,
|
||||
.tx_power = m_tx_power,
|
||||
.cca = true,
|
||||
.immediate = NRF_802154_CSMA_CA_WAIT_FOR_TIMESLOT ? false : true,
|
||||
};
|
||||
|
@ -359,6 +363,9 @@ bool nrf_802154_csma_ca_start(uint8_t * p_d
|
|||
m_data_props = p_metadata->frame_props;
|
||||
m_nb = 0;
|
||||
m_be = nrf_802154_pib_csmaca_min_be_get();
|
||||
m_tx_power =
|
||||
nrf_802154_tx_power_convert_metadata_to_raw_value(nrf_802154_pib_channel_get(),
|
||||
p_metadata->tx_power);
|
||||
|
||||
random_backoff_start();
|
||||
|
||||
|
@ -371,19 +378,28 @@ bool nrf_802154_csma_ca_abort(nrf_802154_term_t term_lvl, req_originator_t req_o
|
|||
{
|
||||
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
|
||||
// Stop CSMA-CA only if request by the core or the higher layer.
|
||||
if ((req_orig != REQ_ORIG_CORE) && (req_orig != REQ_ORIG_HIGHER_LAYER))
|
||||
{
|
||||
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
|
||||
if (term_lvl < NRF_802154_TERM_802154)
|
||||
if (((req_orig != REQ_ORIG_CORE) && (req_orig != REQ_ORIG_HIGHER_LAYER)) ||
|
||||
(CSMA_CA_STATE_IDLE == nrf_802154_sl_atomic_load_u8(&m_state)))
|
||||
{
|
||||
// Return success in case procedure is already stopped.
|
||||
result = nrf_802154_sl_atomic_load_u8(&m_state) == CSMA_CA_STATE_IDLE;
|
||||
// The request does not originate from core or the higher layer or the procedure
|
||||
// is stopped already. Ignore the abort request and return success, no matter
|
||||
// the termination level.
|
||||
}
|
||||
else if (term_lvl >= NRF_802154_TERM_802154)
|
||||
{
|
||||
// The procedure is active and the termination level allows the abort
|
||||
// request to be executed. Force aborted state. Don't clear the frame
|
||||
// pointer - it might be needed to notify failure.
|
||||
nrf_802154_sl_atomic_store_u8(&m_state, CSMA_CA_STATE_ABORTED);
|
||||
nrf_802154_rsch_delayed_timeslot_cancel(NRF_802154_RESERVED_CSMACA_ID, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The procedure is active and the termination level does not allow
|
||||
// the abort request to be executed. Return failure
|
||||
result = false;
|
||||
}
|
||||
|
||||
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
|
@ -414,10 +430,27 @@ bool nrf_802154_csma_ca_tx_failed_hook(uint8_t * p_frame, nrf_802154_tx_error_t
|
|||
break;
|
||||
|
||||
default:
|
||||
if (p_frame == mp_data)
|
||||
if (csma_ca_state_set(CSMA_CA_STATE_ABORTED, CSMA_CA_STATE_IDLE))
|
||||
{
|
||||
// The procedure was successfully aborted.
|
||||
|
||||
if (p_frame != mp_data)
|
||||
{
|
||||
// The procedure was aborted while another operation was holding
|
||||
// frame pointer in the core - hence p_frame points to a different
|
||||
// frame than mp_data. CSMA-CA failure must be notified directly.
|
||||
notify_failed(error);
|
||||
}
|
||||
}
|
||||
else if (p_frame == mp_data)
|
||||
{
|
||||
// The procedure is active and transmission attempt failed. Try again
|
||||
result = channel_busy();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Intentionally empty.
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "nrf_802154_queue.h"
|
||||
#include "nrf_802154_request.h"
|
||||
#include "nrf_802154_utils.h"
|
||||
#include "nrf_802154_tx_power.h"
|
||||
#include "rsch/nrf_802154_rsch.h"
|
||||
#include "nrf_802154_sl_timer.h"
|
||||
#include "nrf_802154_sl_utils.h"
|
||||
|
@ -771,10 +772,13 @@ bool nrf_802154_delayed_trx_transmit(uint8_t * p
|
|||
|
||||
p_dly_tx_data->tx.p_data = p_data;
|
||||
p_dly_tx_data->tx.params.frame_props = p_metadata->frame_props;
|
||||
p_dly_tx_data->tx.params.cca = p_metadata->cca;
|
||||
p_dly_tx_data->tx.params.immediate = true;
|
||||
p_dly_tx_data->tx.channel = p_metadata->channel;
|
||||
p_dly_tx_data->id = NRF_802154_RESERVED_DTX_ID;
|
||||
p_dly_tx_data->tx.params.tx_power = nrf_802154_tx_power_convert_metadata_to_raw_value(
|
||||
p_metadata->channel,
|
||||
p_metadata->tx_power);
|
||||
p_dly_tx_data->tx.params.cca = p_metadata->cca;
|
||||
p_dly_tx_data->tx.params.immediate = true;
|
||||
p_dly_tx_data->tx.channel = p_metadata->channel;
|
||||
p_dly_tx_data->id = NRF_802154_RESERVED_DTX_ID;
|
||||
|
||||
rsch_dly_ts_param_t dly_ts_param =
|
||||
{
|
||||
|
@ -923,7 +927,7 @@ bool nrf_802154_delayed_trx_nearest_drx_time_to_midpoint_get(uint32_t * p_drx_ti
|
|||
{
|
||||
bool result = false;
|
||||
uint32_t min_time_to_start = 0xffffffff;
|
||||
uint64_t drx_time_to_start;
|
||||
uint64_t drx_time_to_start = UINT64_C(0xffffffff);
|
||||
uint32_t drx_time_to_midpoint;
|
||||
|
||||
for (int i = 0; i < sizeof(m_dly_rx_data) / sizeof(m_dly_rx_data[0]); i++)
|
||||
|
|
|
@ -278,6 +278,7 @@ bool nrf_802154_ifs_pretransmission(
|
|||
m_context.p_data = p_frame;
|
||||
m_context.params.frame_props = p_params->frame_props;
|
||||
m_context.params.cca = p_params->cca;
|
||||
m_context.params.tx_power = p_params->tx_power;
|
||||
m_context.params.immediate = true;
|
||||
m_timer.trigger_time = m_last_frame_timestamp + dt;
|
||||
m_timer.action_type = NRF_802154_SL_TIMER_ACTION_TYPE_CALLBACK;
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
#include "nrf_802154_pib.h"
|
||||
#include "nrf_802154_request.h"
|
||||
#include "nrf_802154_rx_buffer.h"
|
||||
#include "nrf_802154_tx_power.h"
|
||||
#include "nrf_802154_stats.h"
|
||||
#include "hal/nrf_radio.h"
|
||||
#include "platform/nrf_802154_clock.h"
|
||||
|
@ -65,7 +66,6 @@
|
|||
#include "platform/nrf_802154_temperature.h"
|
||||
#include "rsch/nrf_802154_rsch.h"
|
||||
#include "rsch/nrf_802154_rsch_crit_sect.h"
|
||||
#include "rsch/nrf_802154_rsch_prio_drop.h"
|
||||
#include "timer/nrf_802154_timer_coord.h"
|
||||
|
||||
#include "mac_features/nrf_802154_ack_timeout.h"
|
||||
|
@ -156,7 +156,7 @@ void nrf_802154_tx_power_set(int8_t power)
|
|||
|
||||
int8_t nrf_802154_tx_power_get(void)
|
||||
{
|
||||
return nrf_802154_pib_tx_power_get();
|
||||
return nrf_802154_tx_power_constrained_pib_power_get();
|
||||
}
|
||||
|
||||
bool nrf_802154_coex_rx_request_mode_set(nrf_802154_coex_rx_request_mode_t mode)
|
||||
|
@ -236,7 +236,6 @@ void nrf_802154_init(void)
|
|||
nrf_802154_pib_init();
|
||||
nrf_802154_security_pib_init();
|
||||
nrf_802154_sl_timer_module_init();
|
||||
nrf_802154_rsch_prio_drop_init();
|
||||
nrf_802154_random_init();
|
||||
nrf_802154_request_init();
|
||||
nrf_802154_rsch_crit_sect_init();
|
||||
|
@ -481,7 +480,8 @@ bool nrf_802154_transmit_raw(uint8_t * p_data,
|
|||
static const nrf_802154_transmit_metadata_t metadata_default =
|
||||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.cca = true
|
||||
.cca = true,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
p_metadata = &metadata_default;
|
||||
|
@ -490,8 +490,11 @@ bool nrf_802154_transmit_raw(uint8_t * p_data,
|
|||
nrf_802154_transmit_params_t params =
|
||||
{
|
||||
.frame_props = p_metadata->frame_props,
|
||||
.cca = p_metadata->cca,
|
||||
.immediate = false
|
||||
.tx_power = nrf_802154_tx_power_convert_metadata_to_raw_value(
|
||||
nrf_802154_pib_channel_get(),
|
||||
p_metadata->tx_power),
|
||||
.cca = p_metadata->cca,
|
||||
.immediate = false
|
||||
};
|
||||
|
||||
result = are_frame_properties_valid(¶ms.frame_props);
|
||||
|
@ -523,7 +526,8 @@ bool nrf_802154_transmit(const uint8_t * p_data,
|
|||
static const nrf_802154_transmit_metadata_t metadata_default =
|
||||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.cca = true
|
||||
.cca = true,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
p_metadata = &metadata_default;
|
||||
|
@ -532,8 +536,11 @@ bool nrf_802154_transmit(const uint8_t * p_data,
|
|||
nrf_802154_transmit_params_t params =
|
||||
{
|
||||
.frame_props = p_metadata->frame_props,
|
||||
.cca = p_metadata->cca,
|
||||
.immediate = false
|
||||
.tx_power = nrf_802154_tx_power_convert_metadata_to_raw_value(
|
||||
nrf_802154_pib_channel_get(),
|
||||
p_metadata->tx_power),
|
||||
.cca = p_metadata->cca,
|
||||
.immediate = false
|
||||
};
|
||||
|
||||
result = are_frame_properties_valid(¶ms.frame_props);
|
||||
|
@ -562,7 +569,8 @@ bool nrf_802154_transmit_raw_at(uint8_t * p_data
|
|||
nrf_802154_transmit_at_metadata_t metadata_default =
|
||||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.cca = true
|
||||
.cca = true,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
|
@ -869,6 +877,7 @@ bool nrf_802154_transmit_csma_ca_raw(uint8_t
|
|||
static const nrf_802154_transmit_csma_ca_metadata_t metadata_default =
|
||||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
p_metadata = &metadata_default;
|
||||
|
@ -899,6 +908,7 @@ bool nrf_802154_transmit_csma_ca(const uint8_t *
|
|||
static const nrf_802154_transmit_csma_ca_metadata_t metadata_default =
|
||||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
p_metadata = &metadata_default;
|
||||
|
|
|
@ -64,6 +64,7 @@
|
|||
#include "nrf_802154_utils.h"
|
||||
#include "nrf_802154_trx.h"
|
||||
#include "nrf_802154_tx_work_buffer.h"
|
||||
#include "nrf_802154_tx_power.h"
|
||||
#include "nrf_802154_types.h"
|
||||
#include "nrf_802154_utils.h"
|
||||
#include "drivers/nrfx_errors.h"
|
||||
|
@ -120,6 +121,7 @@ static uint32_t m_ed_time_left; ///< Remaining ti
|
|||
static uint8_t m_ed_result; ///< Result of the current energy detection procedure.
|
||||
static uint8_t m_last_lqi; ///< LQI of the last received non-ACK frame, corrected for the temperature.
|
||||
static int8_t m_last_rssi; ///< RSSI of the last received non-ACK frame, corrected for the temperature.
|
||||
static int8_t m_tx_power; ///< Power in dBm to be used to transmit the current frame.
|
||||
|
||||
static nrf_802154_frame_parser_data_t m_current_rx_frame_data; ///< RX frame parser data.
|
||||
|
||||
|
@ -1043,7 +1045,9 @@ static void rx_init(void)
|
|||
|
||||
nrf_802154_trx_receive_buffer_set(rx_buffer_get());
|
||||
|
||||
nrf_802154_trx_receive_frame(BCC_INIT / 8U, m_trx_receive_frame_notifications_mask);
|
||||
nrf_802154_trx_receive_frame(BCC_INIT / 8U,
|
||||
m_trx_receive_frame_notifications_mask,
|
||||
nrf_802154_tx_power_constrained_pib_power_get());
|
||||
|
||||
#if NRF_802154_TOTAL_TIMES_MEASUREMENT_ENABLED
|
||||
m_listening_start_hp_timestamp = nrf_802154_hp_timer_current_time_get();
|
||||
|
@ -1105,6 +1109,7 @@ static bool tx_init(const uint8_t * p_data, bool cca)
|
|||
m_flags.tx_with_cca = cca;
|
||||
nrf_802154_trx_transmit_frame(nrf_802154_tx_work_buffer_get(p_data),
|
||||
cca,
|
||||
m_tx_power,
|
||||
m_trx_transmit_frame_notifications_mask);
|
||||
|
||||
return true;
|
||||
|
@ -1169,7 +1174,7 @@ static void continuous_carrier_init(void)
|
|||
return;
|
||||
}
|
||||
|
||||
nrf_802154_trx_continuous_carrier();
|
||||
nrf_802154_trx_continuous_carrier(nrf_802154_tx_power_constrained_pib_power_get());
|
||||
}
|
||||
|
||||
/** Initialize Modulated Carrier operation. */
|
||||
|
@ -1185,7 +1190,7 @@ static void modulated_carrier_init(const uint8_t * p_data)
|
|||
return;
|
||||
}
|
||||
|
||||
nrf_802154_trx_modulated_carrier(p_data);
|
||||
nrf_802154_trx_modulated_carrier(p_data, nrf_802154_tx_power_constrained_pib_power_get());
|
||||
}
|
||||
|
||||
#endif // NRF_802154_CARRIER_FUNCTIONS_ENABLED
|
||||
|
@ -1912,7 +1917,9 @@ void nrf_802154_trx_receive_frame_crcerror(void)
|
|||
// We don't change receive buffer, receive will go to the same that was already used
|
||||
#if !NRF_802154_DISABLE_BCC_MATCHING
|
||||
request_preconditions_for_state(m_state);
|
||||
nrf_802154_trx_receive_frame(BCC_INIT / 8U, m_trx_receive_frame_notifications_mask);
|
||||
nrf_802154_trx_receive_frame(BCC_INIT / 8U,
|
||||
m_trx_receive_frame_notifications_mask,
|
||||
nrf_802154_tx_power_constrained_pib_power_get());
|
||||
|
||||
#if NRF_802154_TOTAL_TIMES_MEASUREMENT_ENABLED
|
||||
m_listening_start_hp_timestamp = nrf_802154_hp_timer_current_time_get();
|
||||
|
@ -2711,6 +2718,7 @@ bool nrf_802154_core_transmit(nrf_802154_term_t term_lvl,
|
|||
|
||||
state_set(p_params->cca ? RADIO_STATE_CCA_TX : RADIO_STATE_TX);
|
||||
mp_tx_data = p_data;
|
||||
m_tx_power = p_params->tx_power;
|
||||
|
||||
// coverity[check_return]
|
||||
result = tx_init(p_data, p_params->cca);
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
#include "nrf_802154_config.h"
|
||||
#include "nrf_802154_const.h"
|
||||
#include "nrf_802154_utils.h"
|
||||
#include "fal/nrf_802154_fal.h"
|
||||
|
||||
#define CSMACA_BE_MAXIMUM 8 ///< The maximum allowed CSMA-CA backoff exponent (BE) that results from the implementation
|
||||
|
||||
|
@ -119,66 +118,6 @@ typedef struct
|
|||
// Static variables.
|
||||
static nrf_802154_pib_data_t m_data; ///< Buffer containing PIB data.
|
||||
|
||||
/**
|
||||
* Converts TX power integer values to RADIO TX power allowed values.
|
||||
*
|
||||
* @param[in] integer_tx_power TX power integer value.
|
||||
*
|
||||
* @retval RADIO TX power allowed value.
|
||||
*/
|
||||
static nrf_radio_txpower_t to_radio_tx_power_convert(int8_t integer_tx_power)
|
||||
{
|
||||
const nrf_radio_txpower_t allowed_values[] =
|
||||
{
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Neg40dBm)
|
||||
NRF_RADIO_TXPOWER_NEG40DBM, /**< -40 dBm. */
|
||||
#endif
|
||||
NRF_RADIO_TXPOWER_NEG20DBM, /**< -20 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG16DBM, /**< -16 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG12DBM, /**< -12 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG8DBM, /**< -8 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG4DBM, /**< -4 dBm. */
|
||||
NRF_RADIO_TXPOWER_0DBM, /**< 0 dBm. */
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos2dBm)
|
||||
NRF_RADIO_TXPOWER_POS2DBM, /**< 2 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm)
|
||||
NRF_RADIO_TXPOWER_POS3DBM, /**< 3 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm)
|
||||
NRF_RADIO_TXPOWER_POS4DBM, /**< 4 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos5dBm)
|
||||
NRF_RADIO_TXPOWER_POS5DBM, /**< 5 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos6dBm)
|
||||
NRF_RADIO_TXPOWER_POS6DBM, /**< 6 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos7dBm)
|
||||
NRF_RADIO_TXPOWER_POS7DBM, /**< 7 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm)
|
||||
NRF_RADIO_TXPOWER_POS8DBM, /**< 8 dBm. */
|
||||
#endif
|
||||
};
|
||||
|
||||
nrf_radio_txpower_t radio_tx_power = allowed_values[NUMELTS(allowed_values) - 1];
|
||||
|
||||
if (integer_tx_power < (int8_t)radio_tx_power)
|
||||
{
|
||||
for (uint32_t i = 0; i < NUMELTS(allowed_values); i++)
|
||||
{
|
||||
if (integer_tx_power <= (int8_t)allowed_values[i])
|
||||
{
|
||||
radio_tx_power = allowed_values[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return radio_tx_power;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks if provided Coex transmit request mode is supported.
|
||||
*
|
||||
|
@ -320,11 +259,9 @@ void nrf_802154_pib_channel_set(uint8_t channel)
|
|||
m_data.channel = channel;
|
||||
}
|
||||
|
||||
nrf_radio_txpower_t nrf_802154_pib_tx_power_get(void)
|
||||
int8_t nrf_802154_pib_tx_power_get(void)
|
||||
{
|
||||
int8_t tx_power = nrf_802154_fal_tx_power_get(m_data.channel, m_data.tx_power);
|
||||
|
||||
return to_radio_tx_power_convert(tx_power);
|
||||
return m_data.tx_power;
|
||||
}
|
||||
|
||||
void nrf_802154_pib_tx_power_set(int8_t dbm)
|
||||
|
|
|
@ -118,7 +118,7 @@ void nrf_802154_pib_channel_set(uint8_t channel);
|
|||
*
|
||||
* @returns Transmit power in dBm.
|
||||
*/
|
||||
nrf_radio_txpower_t nrf_802154_pib_tx_power_get(void);
|
||||
int8_t nrf_802154_pib_tx_power_get(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the transmit power used for ACK frames.
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 - 2022, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file implements procedures that should be called with lower priority than caller in
|
||||
* the nrf 802.15.4 radio driver.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "nrf_802154_config.h"
|
||||
#include "nrf_802154_peripherals.h"
|
||||
#include "rsch/nrf_802154_rsch_prio_drop.h"
|
||||
|
||||
#include "nrf_802154_swi.h"
|
||||
#include "hal/nrf_egu.h"
|
||||
#include "platform/nrf_802154_clock.h"
|
||||
|
||||
#define HFCLK_STOP_INT NRF_EGU_INT_TRIGGERED1 ///< Label of HFClk stop interrupt.
|
||||
#define HFCLK_STOP_TASK NRF_EGU_TASK_TRIGGER1 ///< Label of HFClk stop task.
|
||||
#define HFCLK_STOP_EVENT NRF_EGU_EVENT_TRIGGERED1 ///< Label of HFClk stop event.
|
||||
|
||||
/**
|
||||
* @brief Requests a stop of the HF clock.
|
||||
*
|
||||
* The notification is triggered from the SWI priority level.
|
||||
*
|
||||
* @note This function is to be called through notification module to prevent calling it from
|
||||
* the arbiter context.
|
||||
*/
|
||||
static void swi_hfclk_stop(void)
|
||||
{
|
||||
assert(!nrf_egu_event_check(NRF_802154_EGU_INSTANCE, HFCLK_STOP_EVENT));
|
||||
|
||||
nrf_egu_task_trigger(NRF_802154_EGU_INSTANCE, HFCLK_STOP_TASK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Terminates the stopping of the HF clock.
|
||||
*
|
||||
* @note This function terminates the stopping of the HF clock only if it has not been performed
|
||||
* yet.
|
||||
*/
|
||||
static void swi_hfclk_stop_terminate(void)
|
||||
{
|
||||
nrf_egu_event_clear(NRF_802154_EGU_INSTANCE, HFCLK_STOP_EVENT);
|
||||
}
|
||||
|
||||
void nrf_802154_rsch_prio_drop_init(void)
|
||||
{
|
||||
nrf_egu_int_enable(NRF_802154_EGU_INSTANCE, HFCLK_STOP_INT);
|
||||
|
||||
nrf_802154_swi_init();
|
||||
}
|
||||
|
||||
void nrf_802154_rsch_prio_drop_hfclk_stop(void)
|
||||
{
|
||||
swi_hfclk_stop();
|
||||
}
|
||||
|
||||
void nrf_802154_rsch_prio_drop_hfclk_stop_terminate(void)
|
||||
{
|
||||
swi_hfclk_stop_terminate();
|
||||
}
|
||||
|
||||
void nrf_802154_rsch_prio_drop_swi_irq_handler(void)
|
||||
{
|
||||
if (nrf_egu_event_check(NRF_802154_EGU_INSTANCE, HFCLK_STOP_EVENT))
|
||||
{
|
||||
nrf_802154_clock_hfclk_stop();
|
||||
|
||||
nrf_egu_event_clear(NRF_802154_EGU_INSTANCE, HFCLK_STOP_EVENT);
|
||||
}
|
||||
}
|
|
@ -67,11 +67,6 @@ __WEAK void nrf_802154_notification_swi_irq_handler(void)
|
|||
/* Implementation provided by other module if necessary */
|
||||
}
|
||||
|
||||
__WEAK void nrf_802154_rsch_prio_drop_swi_irq_handler(void)
|
||||
{
|
||||
/* Implementation provided by other module if necessary */
|
||||
}
|
||||
|
||||
__WEAK void nrf_802154_request_swi_irq_handler(void)
|
||||
{
|
||||
/* Implementation provided by other module if necessary */
|
||||
|
@ -81,7 +76,6 @@ static void swi_irq_handler(void)
|
|||
{
|
||||
nrf_802154_trx_swi_irq_handler();
|
||||
nrf_802154_notification_swi_irq_handler();
|
||||
nrf_802154_rsch_prio_drop_swi_irq_handler();
|
||||
nrf_802154_request_swi_irq_handler();
|
||||
}
|
||||
|
||||
|
|
|
@ -908,7 +908,8 @@ bool nrf_802154_trx_receive_buffer_set(void * p_receive_buffer)
|
|||
}
|
||||
|
||||
void nrf_802154_trx_receive_frame(uint8_t bcc,
|
||||
nrf_802154_trx_receive_notifications_t notifications_mask)
|
||||
nrf_802154_trx_receive_notifications_t notifications_mask,
|
||||
int8_t ack_tx_power)
|
||||
{
|
||||
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
|
||||
|
@ -927,7 +928,7 @@ void nrf_802154_trx_receive_frame(uint8_t bcc,
|
|||
|
||||
m_flags.rssi_settled = false;
|
||||
|
||||
nrf_radio_txpower_set(NRF_RADIO, nrf_802154_pib_tx_power_get());
|
||||
nrf_radio_txpower_set(NRF_RADIO, (nrf_radio_txpower_t)ack_tx_power);
|
||||
|
||||
if (mp_receive_buffer != NULL)
|
||||
{
|
||||
|
@ -1139,6 +1140,7 @@ bool nrf_802154_trx_rssi_sample_is_available(void)
|
|||
|
||||
void nrf_802154_trx_transmit_frame(const void * p_transmit_buffer,
|
||||
bool cca,
|
||||
int8_t tx_power,
|
||||
nrf_802154_trx_transmit_notifications_t notifications_mask)
|
||||
{
|
||||
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
|
@ -1151,7 +1153,7 @@ void nrf_802154_trx_transmit_frame(const void * p_tra
|
|||
m_trx_state = TRX_STATE_TXFRAME;
|
||||
m_transmit_with_cca = cca;
|
||||
|
||||
nrf_radio_txpower_set(NRF_RADIO, nrf_802154_pib_tx_power_get());
|
||||
nrf_radio_txpower_set(NRF_RADIO, (nrf_radio_txpower_t)tx_power);
|
||||
nrf_radio_packetptr_set(NRF_RADIO, p_transmit_buffer);
|
||||
|
||||
// Set shorts
|
||||
|
@ -1767,7 +1769,7 @@ static void standalone_cca_abort(void)
|
|||
|
||||
#if NRF_802154_CARRIER_FUNCTIONS_ENABLED
|
||||
|
||||
void nrf_802154_trx_continuous_carrier(void)
|
||||
void nrf_802154_trx_continuous_carrier(int8_t tx_power)
|
||||
{
|
||||
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
|
||||
|
@ -1776,7 +1778,7 @@ void nrf_802154_trx_continuous_carrier(void)
|
|||
m_trx_state = TRX_STATE_CONTINUOUS_CARRIER;
|
||||
|
||||
// Set Tx Power
|
||||
nrf_radio_txpower_set(NRF_RADIO, nrf_802154_pib_tx_power_get());
|
||||
nrf_radio_txpower_set(NRF_RADIO, (nrf_radio_txpower_t)tx_power);
|
||||
|
||||
// Set FEM
|
||||
fem_for_pa_set();
|
||||
|
@ -1822,7 +1824,7 @@ static void continuous_carrier_abort(void)
|
|||
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_HIGH);
|
||||
}
|
||||
|
||||
void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer)
|
||||
void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer, int8_t tx_power)
|
||||
{
|
||||
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
|
||||
|
||||
|
@ -1832,7 +1834,7 @@ void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer)
|
|||
m_trx_state = TRX_STATE_MODULATED_CARRIER;
|
||||
|
||||
// Set Tx Power
|
||||
nrf_radio_txpower_set(NRF_RADIO, nrf_802154_pib_tx_power_get());
|
||||
nrf_radio_txpower_set(NRF_RADIO, (nrf_radio_txpower_t)tx_power);
|
||||
|
||||
// Set Tx buffer
|
||||
nrf_radio_packetptr_set(NRF_RADIO, p_transmit_buffer);
|
||||
|
|
|
@ -208,9 +208,11 @@ void nrf_802154_trx_cca_configuration_update(void);
|
|||
* @param[in] notifications_mask Selects additional notifications generated during a frame reception.
|
||||
* It is bitwise combination of @ref nrf_802154_trx_receive_notifications_t values.
|
||||
* When NRF_802154_DISABLE_BCC_MATCHING != 0, flag @ref TRX_RECEIVE_NOTIFICATION_PRESTARTED is forbidden.
|
||||
* @param[in] ack_tx_power Selects the power which should be used to transmitted an ACK if required.
|
||||
*/
|
||||
void nrf_802154_trx_receive_frame(uint8_t bcc,
|
||||
nrf_802154_trx_receive_notifications_t notifications_mask);
|
||||
nrf_802154_trx_receive_notifications_t notifications_mask,
|
||||
int8_t ack_tx_power);
|
||||
|
||||
/**@brief Puts the trx module into receive ACK mode.
|
||||
*
|
||||
|
@ -335,17 +337,17 @@ bool nrf_802154_trx_receive_buffer_set(void * p_receive_buffer);
|
|||
* bytes following p_transmit_buffer[0] to send.
|
||||
* The number of bytes pointed by p_transmit buffer must
|
||||
* be at least 1 and not less than p_transmit_buffer[0] + 1.
|
||||
*
|
||||
* @param cca Selects if CCA procedure should be performed prior to
|
||||
* real transmission. If false no cca will be performed.
|
||||
* If true, cca will be performed.
|
||||
*
|
||||
* @param tx_power Transmit power in dBm.
|
||||
* @param notifications_mask Selects additional notifications generated during a frame transmission.
|
||||
* It is bitwise combination of @ref nrf_802154_trx_transmit_notifications_t values.
|
||||
* @note To transmit ack after frame is received use @ref nrf_802154_trx_transmit_ack.
|
||||
*/
|
||||
void nrf_802154_trx_transmit_frame(const void * p_transmit_buffer,
|
||||
bool cca,
|
||||
int8_t tx_power,
|
||||
nrf_802154_trx_transmit_notifications_t notifications_mask);
|
||||
|
||||
/**@brief Puts the trx module into transmit ACK mode.
|
||||
|
@ -387,11 +389,13 @@ void nrf_802154_trx_standalone_cca(void);
|
|||
#if NRF_802154_CARRIER_FUNCTIONS_ENABLED
|
||||
|
||||
/**@brief Starts generating continuous carrier.
|
||||
*
|
||||
* @param[in] tx_power Transmit power in dBm.
|
||||
*
|
||||
* Generation of a continuous carrier generates no handlers. It may be terminated by a call to
|
||||
* @ref nrf_802154_trx_abort or @ref nrf_802154_trx_disable.
|
||||
*/
|
||||
void nrf_802154_trx_continuous_carrier(void);
|
||||
void nrf_802154_trx_continuous_carrier(int8_t tx_power);
|
||||
|
||||
/**@brief Restarts generating continuous carrier
|
||||
*
|
||||
|
@ -406,8 +410,9 @@ void nrf_802154_trx_continuous_carrier_restart(void);
|
|||
/**@brief Starts generating modulated carrier with given buffer.
|
||||
*
|
||||
* @param[in] p_transmit_buffer Pointer to a buffer used for modulating the carrier wave.
|
||||
* @param[in] tx_power Transmit power in dBm.
|
||||
*/
|
||||
void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer);
|
||||
void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer, int8_t tx_power);
|
||||
|
||||
/** @brief Restarts generating modulated carrier.*/
|
||||
void nrf_802154_trx_modulated_carrier_restart(void);
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Nordic Semiconductor ASA
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nrf_802154_tx_power.h"
|
||||
#include "nrf_802154_pib.h"
|
||||
#include "nrf_802154_utils.h"
|
||||
#include "fal/nrf_802154_fal.h"
|
||||
|
||||
/**
|
||||
* Converts TX power integer values to RADIO TX power allowed values.
|
||||
*
|
||||
* @param[in] integer_tx_power TX power integer value.
|
||||
*
|
||||
* @retval RADIO TX power allowed value.
|
||||
*/
|
||||
static nrf_radio_txpower_t to_radio_tx_power_convert(int8_t integer_tx_power)
|
||||
{
|
||||
static const nrf_radio_txpower_t allowed_values[] =
|
||||
{
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Neg40dBm)
|
||||
NRF_RADIO_TXPOWER_NEG40DBM, /**< -40 dBm. */
|
||||
#endif
|
||||
NRF_RADIO_TXPOWER_NEG20DBM, /**< -20 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG16DBM, /**< -16 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG12DBM, /**< -12 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG8DBM, /**< -8 dBm. */
|
||||
NRF_RADIO_TXPOWER_NEG4DBM, /**< -4 dBm. */
|
||||
NRF_RADIO_TXPOWER_0DBM, /**< 0 dBm. */
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos2dBm)
|
||||
NRF_RADIO_TXPOWER_POS2DBM, /**< 2 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos3dBm)
|
||||
NRF_RADIO_TXPOWER_POS3DBM, /**< 3 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos4dBm)
|
||||
NRF_RADIO_TXPOWER_POS4DBM, /**< 4 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos5dBm)
|
||||
NRF_RADIO_TXPOWER_POS5DBM, /**< 5 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos6dBm)
|
||||
NRF_RADIO_TXPOWER_POS6DBM, /**< 6 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos7dBm)
|
||||
NRF_RADIO_TXPOWER_POS7DBM, /**< 7 dBm. */
|
||||
#endif
|
||||
#if defined(RADIO_TXPOWER_TXPOWER_Pos8dBm)
|
||||
NRF_RADIO_TXPOWER_POS8DBM, /**< 8 dBm. */
|
||||
#endif
|
||||
};
|
||||
|
||||
nrf_radio_txpower_t radio_tx_power = allowed_values[NUMELTS(allowed_values) - 1];
|
||||
|
||||
if (integer_tx_power < (int8_t)radio_tx_power)
|
||||
{
|
||||
for (uint32_t i = 0; i < NUMELTS(allowed_values); i++)
|
||||
{
|
||||
if (integer_tx_power <= (int8_t)allowed_values[i])
|
||||
{
|
||||
radio_tx_power = allowed_values[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return radio_tx_power;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts TX power integer values to RADIO TX power allowed values, constrained by the allowed TX power allowed for
|
||||
* a specific channel.
|
||||
*
|
||||
* @param[in] channel The channel based on which the power should be constrained
|
||||
* @param[in] tx_power Unconstrained TX power integer value.
|
||||
*
|
||||
* @retval RADIO TX power allowed and constrained value.
|
||||
*/
|
||||
static nrf_radio_txpower_t constrain_and_convert_tx_power(uint8_t channel, int8_t tx_power)
|
||||
{
|
||||
int8_t constrained_power = nrf_802154_fal_tx_power_get(channel, tx_power);
|
||||
|
||||
return to_radio_tx_power_convert(constrained_power);
|
||||
}
|
||||
|
||||
nrf_radio_txpower_t nrf_802154_tx_power_convert_metadata_to_raw_value(
|
||||
uint8_t channel,
|
||||
nrf_802154_tx_power_metadata_t tx_power)
|
||||
{
|
||||
int8_t power_unconstrained =
|
||||
tx_power.use_metadata_value ? tx_power.power : nrf_802154_pib_tx_power_get();
|
||||
|
||||
return constrain_and_convert_tx_power(channel, power_unconstrained);
|
||||
}
|
||||
|
||||
nrf_radio_txpower_t nrf_802154_tx_power_constrained_pib_power_get(void)
|
||||
{
|
||||
return constrain_and_convert_tx_power(nrf_802154_pib_channel_get(),
|
||||
nrf_802154_pib_tx_power_get());
|
||||
}
|
||||
|
||||
nrf_radio_txpower_t nrf_802154_tx_power_constrained_pib_power_for_channel_get(uint8_t channel)
|
||||
{
|
||||
return constrain_and_convert_tx_power(channel, nrf_802154_pib_tx_power_get());
|
||||
}
|
|
@ -32,41 +32,47 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#ifndef NRF_802154_RSCH_PRIO_DROP_H__
|
||||
#define NRF_802154_RSCH_PRIO_DROP_H__
|
||||
#ifndef NRF_802154_TX_POWER_H__
|
||||
#define NRF_802154_TX_POWER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Initializes the notification module.
|
||||
*/
|
||||
void nrf_802154_rsch_prio_drop_init(void);
|
||||
#include "nrf_802154.h"
|
||||
|
||||
/**
|
||||
* @brief Requests the stop of the high frequency clock.
|
||||
/**@brief Convert tx_power value passed through metadata to a raw value in dBm used by the core module.
|
||||
|
||||
* This function also ensures that the value meets the constraints for the current channel.
|
||||
*
|
||||
* @note This function must be called through this module to prevent calling it from the arbiter
|
||||
* context.
|
||||
*/
|
||||
void nrf_802154_rsch_prio_drop_hfclk_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Terminates the requesting of the high frequency clock stop procedure.
|
||||
* @param[in] channel The channel to be used for transmission
|
||||
* @param[in] tx_power The value passed to the transmit metadata.
|
||||
*
|
||||
* @retval Returns the power in dBm which will be used to transmit the frame.
|
||||
*
|
||||
* Function used to to terminate the HFClk stop procedure requested by the previous call to
|
||||
* @rev nrf_802154_rsch_prio_drop_hfclk_stop. The HFClk stop procedure is terminated only if it has
|
||||
* not been started.
|
||||
*/
|
||||
void nrf_802154_rsch_prio_drop_hfclk_stop_terminate(void);
|
||||
nrf_radio_txpower_t nrf_802154_tx_power_convert_metadata_to_raw_value(
|
||||
uint8_t channel,
|
||||
nrf_802154_tx_power_metadata_t tx_power);
|
||||
|
||||
/**@brief Get the transmit power stored in PIB after applying the power constraints for the current channel.
|
||||
*
|
||||
* The current channel is acquired from PIB.
|
||||
*
|
||||
* @retval Returns the constrained power in dBm which will be used to transmit the frame.
|
||||
*
|
||||
*/
|
||||
nrf_radio_txpower_t nrf_802154_tx_power_constrained_pib_power_get(void);
|
||||
|
||||
/**@brief Get the transmit power stored in PIB after applying the power constraints for the given channel.
|
||||
*
|
||||
* @param[in] channel The channel based on which the power should be constrained
|
||||
*
|
||||
* @retval Returns the power in dBm which will be used to transmit the frame.
|
||||
*
|
||||
*/
|
||||
nrf_radio_txpower_t nrf_802154_tx_power_constrained_pib_power_for_channel_get(uint8_t channel);
|
||||
|
||||
/**
|
||||
*@}
|
||||
**/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // NRF_802154_RSCH_PRIO_DROP_H__
|
||||
#endif // NRF_802154_TX_POWER_H__
|
|
@ -235,6 +235,19 @@ typedef struct
|
|||
bool dynamic_data_is_set; // !< If dynamic data of the frame frame to be transmitted is set.
|
||||
} nrf_802154_transmitted_frame_props_t;
|
||||
|
||||
/**
|
||||
* @brief Structure passed in transmit metadata with information needed to set transmission power.
|
||||
*
|
||||
* If the @p use_metadata_value field is set to true the power in dBm used to transmit the frame is set to the value of the
|
||||
* field @p power.
|
||||
* Otherwise the value from PIB set by @ref nrf_802154_tx_power_set is used
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
bool use_metadata_value; // !< Set to true if the value in @p power should be used as the TX power in dBm
|
||||
int8_t power; // !< Transmission power in dBm
|
||||
} nrf_802154_tx_power_metadata_t;
|
||||
|
||||
/**
|
||||
* @brief Default initializer for nrf_802154_transmitted_frame_props_t.
|
||||
*/
|
||||
|
@ -251,6 +264,7 @@ typedef struct
|
|||
{
|
||||
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
|
||||
bool cca; // !< If the driver is to perform a CCA procedure before transmission.
|
||||
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used
|
||||
} nrf_802154_transmit_metadata_t;
|
||||
|
||||
/**
|
||||
|
@ -261,6 +275,7 @@ typedef struct
|
|||
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
|
||||
bool cca; // !< If the driver is to perform a CCA procedure before transmission.
|
||||
uint8_t channel; // !< Radio channel on which the frame is to be transmitted.
|
||||
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used
|
||||
} nrf_802154_transmit_at_metadata_t;
|
||||
|
||||
/**
|
||||
|
@ -269,6 +284,7 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
|
||||
nrf_802154_tx_power_metadata_t tx_power; // !< Information about the TX power to be used
|
||||
} nrf_802154_transmit_csma_ca_metadata_t;
|
||||
|
||||
/**
|
||||
|
|
|
@ -512,44 +512,69 @@ typedef enum
|
|||
#define NRF_802154_TRANSMITTED_FRAME_PROPS_DECODE(frame_props) \
|
||||
(&(frame_props).is_secured), (&(frame_props).dynamic_data_is_set)
|
||||
|
||||
/**
|
||||
* @brief Spinel data type description for nrf_802154_tx_power_metadata_t.
|
||||
*/
|
||||
#define SPINEL_DATATYPE_NRF_802154_TX_POWER_METADATA_S \
|
||||
SPINEL_DATATYPE_BOOL_S /* use_metadata_value */ \
|
||||
SPINEL_DATATYPE_INT8_S /* power */
|
||||
|
||||
/**
|
||||
* @brief Encodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TX_POWER_METADATA_S data type.
|
||||
*/
|
||||
#define NRF_802154_TX_POWER_METADATA_ENCODE(tx_power_metadata) \
|
||||
((tx_power_metadata).use_metadata_value), ((tx_power_metadata).power)
|
||||
|
||||
/**
|
||||
* @brief Decodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TX_POWER_METADATA_S data type.
|
||||
*/
|
||||
#define NRF_802154_TX_POWER_METADATA_DECODE(tx_power_metadata) \
|
||||
(&(tx_power_metadata).use_metadata_value), (&(tx_power_metadata).power)
|
||||
|
||||
/**
|
||||
* @brief Spinel data type description for nrf_802154_transmit_metadata_t.
|
||||
*/
|
||||
#define SPINEL_DATATYPE_NRF_802154_TRANSMIT_METADATA_S \
|
||||
SPINEL_DATATYPE_NRF_802154_TRANSMITTED_FRAME_PROPS_S /* frame_props */ \
|
||||
SPINEL_DATATYPE_BOOL_S /* cca */
|
||||
SPINEL_DATATYPE_BOOL_S /* cca */ \
|
||||
SPINEL_DATATYPE_NRF_802154_TX_POWER_METADATA_S /* tx_power */
|
||||
|
||||
/**
|
||||
* @brief Encodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TRANSMIT_METADATA_S data type.
|
||||
*/
|
||||
#define NRF_802154_TRANSMIT_METADATA_ENCODE(tx_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_ENCODE((tx_metadata).frame_props), \
|
||||
((tx_metadata).cca)
|
||||
((tx_metadata).cca), \
|
||||
NRF_802154_TX_POWER_METADATA_ENCODE((tx_metadata).tx_power)
|
||||
|
||||
/**
|
||||
* @brief Decodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TRANSMIT_METADATA_S data type.
|
||||
*/
|
||||
#define NRF_802154_TRANSMIT_METADATA_DECODE(tx_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_DECODE((tx_metadata).frame_props), \
|
||||
(&(tx_metadata).cca)
|
||||
(&(tx_metadata).cca), \
|
||||
NRF_802154_TX_POWER_METADATA_DECODE((tx_metadata).tx_power)
|
||||
|
||||
/**
|
||||
* @brief Spinel data type description for nrf_802154_transmit_csma_ca_metadata_t.
|
||||
*/
|
||||
#define SPINEL_DATATYPE_NRF_802154_TRANSMIT_CSMA_CA_METADATA_S \
|
||||
SPINEL_DATATYPE_NRF_802154_TRANSMITTED_FRAME_PROPS_S /* frame_props */
|
||||
#define SPINEL_DATATYPE_NRF_802154_TRANSMIT_CSMA_CA_METADATA_S \
|
||||
SPINEL_DATATYPE_NRF_802154_TRANSMITTED_FRAME_PROPS_S /* frame_props */ \
|
||||
SPINEL_DATATYPE_NRF_802154_TX_POWER_METADATA_S /* tx_power */
|
||||
|
||||
/**
|
||||
* @brief Encodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TRANSMIT_CSMA_CA_METADATA_S data type.
|
||||
*/
|
||||
#define NRF_802154_TRANSMIT_CSMA_CA_METADATA_ENCODE(tx_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_ENCODE((tx_metadata).frame_props)
|
||||
#define NRF_802154_TRANSMIT_CSMA_CA_METADATA_ENCODE(tx_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_ENCODE((tx_metadata).frame_props), \
|
||||
NRF_802154_TX_POWER_METADATA_ENCODE((tx_metadata).tx_power)
|
||||
|
||||
/**
|
||||
* @brief Decodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TRANSMIT_CSMA_CA_METADATA_S data type.
|
||||
*/
|
||||
#define NRF_802154_TRANSMIT_CSMA_CA_METADATA_DECODE(tx_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_DECODE((tx_metadata).frame_props)
|
||||
#define NRF_802154_TRANSMIT_CSMA_CA_METADATA_DECODE(tx_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_DECODE((tx_metadata).frame_props), \
|
||||
NRF_802154_TX_POWER_METADATA_DECODE((tx_metadata).tx_power)
|
||||
|
||||
/**
|
||||
* @brief Spinel data type description for nrf_802154_csma_ca_min_be_set.
|
||||
|
@ -627,7 +652,8 @@ typedef enum
|
|||
#define SPINEL_DATATYPE_NRF_802154_TRANSMIT_AT_METADATA_S \
|
||||
SPINEL_DATATYPE_NRF_802154_TRANSMITTED_FRAME_PROPS_S /* frame_props */ \
|
||||
SPINEL_DATATYPE_BOOL_S /* cca */ \
|
||||
SPINEL_DATATYPE_UINT8_S /* channel */
|
||||
SPINEL_DATATYPE_UINT8_S /* channel */ \
|
||||
SPINEL_DATATYPE_NRF_802154_TX_POWER_METADATA_S /* tx_power */
|
||||
|
||||
/**
|
||||
* @brief Encodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TRANSMIT_AT_METADATA_S data type.
|
||||
|
@ -635,7 +661,8 @@ typedef enum
|
|||
#define NRF_802154_TRANSMIT_AT_METADATA_ENCODE(tx_at_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_ENCODE((tx_at_metadata).frame_props), \
|
||||
((tx_at_metadata).cca), \
|
||||
((tx_at_metadata).channel)
|
||||
((tx_at_metadata).channel), \
|
||||
NRF_802154_TX_POWER_METADATA_ENCODE((tx_at_metadata).tx_power)
|
||||
|
||||
/**
|
||||
* @brief Decodes an instance of @ref SPINEL_DATATYPE_NRF_802154_TRANSMIT_AT_METADATA_S data type.
|
||||
|
@ -643,7 +670,8 @@ typedef enum
|
|||
#define NRF_802154_TRANSMIT_AT_METADATA_DECODE(tx_at_metadata) \
|
||||
NRF_802154_TRANSMITTED_FRAME_PROPS_DECODE((tx_at_metadata).frame_props), \
|
||||
(&(tx_at_metadata).cca), \
|
||||
(&(tx_at_metadata).channel)
|
||||
(&(tx_at_metadata).channel), \
|
||||
NRF_802154_TX_POWER_METADATA_DECODE((tx_at_metadata).tx_power)
|
||||
|
||||
/**
|
||||
* @brief Spinel data type description for nrf_802154_cca_cfg_t.
|
||||
|
|
|
@ -1129,6 +1129,7 @@ bool nrf_802154_transmit_csma_ca_raw(uint8_t
|
|||
static const nrf_802154_transmit_csma_ca_metadata_t metadata_default =
|
||||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
p_metadata = &metadata_default;
|
||||
|
@ -1424,7 +1425,8 @@ bool nrf_802154_transmit_raw(uint8_t * p_data,
|
|||
static const nrf_802154_transmit_metadata_t metadata_default =
|
||||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.cca = true
|
||||
.cca = true,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
p_metadata = &metadata_default;
|
||||
|
@ -1487,7 +1489,8 @@ bool nrf_802154_transmit_raw_at(uint8_t * p_data
|
|||
{
|
||||
.frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
|
||||
.cca = true,
|
||||
.channel = 11
|
||||
.channel = 11,
|
||||
.tx_power = {.use_metadata_value = false}
|
||||
};
|
||||
|
||||
p_metadata = &metadata_default;
|
||||
|
|
|
@ -266,11 +266,12 @@ bool nrf_802154_rsch_delayed_timeslot_request(const rsch_dly_ts_param_t * p_dly_
|
|||
* The delayed timeslot must be explicitly cancelled from the @p p_dly_ts_param->started_callback
|
||||
* handler function passed to @ref nrf_802154_rsch_delayed_timeslot_request. When timeslot is
|
||||
* released from the handler context, the @p handler flag must be set to @p true.
|
||||
* Otherwise, the timeslot can be cancelled before it requests desired preconditions.
|
||||
* The @p handler flag must be set to @p false in this case.
|
||||
* Otherwise, the timeslot can be cancelled before it starts, which may be earlier than entering the
|
||||
* @p p_dly_ts_param->started_callback handler function.
|
||||
*
|
||||
* Because @p RSCH_DLY_TS_TYPE_RELAXED request preconditions immedialy, the timeslots of this type
|
||||
* cannot be cancelled before the timeslot starts.
|
||||
* Care must be taken when canceling a timeslot from an interrupt context. Delayed timeslots with
|
||||
* type @p RSCH_DLY_TS_TYPE_PRECISE cannot be safely canceled from an interrupt context with higher
|
||||
* priority than delayed timeslot callback context.
|
||||
*
|
||||
* @param[in] dly_ts_id Identifier of the requested timeslot. If the provided value does not refer
|
||||
* to any scheduled delayed timeslot, the function returns false.
|
||||
|
|
|
@ -132,11 +132,6 @@ void nrf_802154_rsch_crit_sect_prio_request(rsch_prio_t prio)
|
|||
}
|
||||
}
|
||||
|
||||
void nrf_802154_rsch_prio_drop_init(void)
|
||||
{
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
void nrf_802154_rsch_crit_sect_init(void)
|
||||
{
|
||||
// Intentionally empty
|
||||
|
|
|
@ -86,6 +86,11 @@ void nrf_802154_sl_timer_init(nrf_802154_sl_timer_t * p_timer)
|
|||
// Intentionally empty
|
||||
}
|
||||
|
||||
void nrf_802154_sl_timer_deinit(nrf_802154_sl_timer_t * p_timer)
|
||||
{
|
||||
// Intentionally empty
|
||||
}
|
||||
|
||||
nrf_802154_sl_timer_ret_t nrf_802154_sl_timer_add(nrf_802154_sl_timer_t * p_timer)
|
||||
{
|
||||
uint64_t now = nrf_802154_sl_timer_current_time_get();
|
||||
|
|
Loading…
Reference in New Issue