Skip to content

Commit

Permalink
nrf_802154: rev 3cc749721224cd1e0dd43e778bbba7bf7cca6e75
Browse files Browse the repository at this point in the history
This commit updates revision of the nrf_802154 component to commit
3cc749721224cd1e0dd43e778bbba7bf7cca6e75 of the sdk-nrf-802154
repository.

Signed-off-by: Andrzej Kuros <[email protected]>
  • Loading branch information
ankuns authored and rlubos committed May 6, 2022
1 parent c3201e1 commit 83225e4
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 136 deletions.
11 changes: 10 additions & 1 deletion nrf_802154/driver/include/nrf_802154_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,22 @@ typedef struct
} data; // !< Result values that are valid only for successful operations.
} nrf_802154_transmit_done_metadata_t;

/**
* @brief Represents components of tx_power to be applied for stages on transmit path.
*/
typedef struct
{
nrf_radio_txpower_t radio_tx_power; // !< TX power to be applied to the RADIO peripheral.
int8_t fem_gain; // !< Gain of the Front-End Module in dB.
} nrf_802154_tx_power_split_t;

/**
* @brief Structure that holds transmission parameters.
*/
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.
nrf_802154_tx_power_split_t tx_power; // !< Power to be used when transmitting the frame, split into components to be applied on each stage on transmit path.
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.
Expand Down
50 changes: 0 additions & 50 deletions nrf_802154/driver/src/fal/nrf_802154_fal.c

This file was deleted.

8 changes: 4 additions & 4 deletions nrf_802154/driver/src/mac_features/nrf_802154_csma_ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +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 nrf_802154_tx_power_split_t m_tx_power; ///< Power to be used when transmitting the frame split into components.
static csma_ca_state_t m_state; ///< The current state of the CSMA-CA procedure.

/**
Expand Down Expand Up @@ -363,9 +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);
(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(nrf_802154_pib_channel_get(),
p_metadata->tx_power,
&m_tx_power);

random_backoff_start();

Expand Down
6 changes: 3 additions & 3 deletions nrf_802154/driver/src/mac_features/nrf_802154_delayed_trx.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ 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.tx_power = nrf_802154_tx_power_convert_metadata_to_raw_value(
p_metadata->channel,
p_metadata->tx_power);
(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(p_metadata->channel,
p_metadata->tx_power,
&p_dly_tx_data->tx.params.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;
Expand Down
30 changes: 19 additions & 11 deletions nrf_802154/driver/src/nrf_802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ void nrf_802154_tx_power_set(int8_t power)

int8_t nrf_802154_tx_power_get(void)
{
return nrf_802154_tx_power_constrained_pib_power_get();
nrf_802154_tx_power_split_t split_power = {0};

(void)nrf_802154_tx_power_split_pib_power_get(&split_power);

return split_power.fem_gain + split_power.radio_tx_power;
}

bool nrf_802154_coex_rx_request_mode_set(nrf_802154_coex_rx_request_mode_t mode)
Expand Down Expand Up @@ -491,13 +495,15 @@ bool nrf_802154_transmit_raw(uint8_t * p_data,
nrf_802154_transmit_params_t params =
{
.frame_props = p_metadata->frame_props,
.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
.tx_power = {0},
.cca = p_metadata->cca,
.immediate = false
};

(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(nrf_802154_pib_channel_get(),
p_metadata->tx_power,
&params.tx_power);

result = are_frame_properties_valid(&params.frame_props);
if (result)
{
Expand Down Expand Up @@ -537,13 +543,15 @@ bool nrf_802154_transmit(const uint8_t * p_data,
nrf_802154_transmit_params_t params =
{
.frame_props = p_metadata->frame_props,
.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
.tx_power = {0},
.cca = p_metadata->cca,
.immediate = false
};

(void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(nrf_802154_pib_channel_get(),
p_metadata->tx_power,
&params.tx_power);

result = are_frame_properties_valid(&params.frame_props);
if (result)
{
Expand Down
40 changes: 28 additions & 12 deletions nrf_802154/driver/src/nrf_802154_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ static rx_buffer_t * const mp_current_rx_buffer = &nrf_802154_rx_buffers[0];

#endif

static uint8_t * mp_ack; ///< Pointer to Ack frame buffer.
static uint8_t * mp_tx_data; ///< Pointer to the data to transmit.
static uint32_t m_ed_time_left; ///< Remaining time of the current energy detection procedure [us].
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 uint8_t * mp_ack; ///< Pointer to Ack frame buffer.
static uint8_t * mp_tx_data; ///< Pointer to the data to transmit.
static uint32_t m_ed_time_left; ///< Remaining time of the current energy detection procedure [us].
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 nrf_802154_tx_power_split_t m_tx_power; ///< Power to be used to transmit the current frame split into components.
static int8_t m_last_rssi; ///< RSSI of the last received non-ACK frame, corrected for the temperature.

static nrf_802154_frame_parser_data_t m_current_rx_frame_data; ///< RX frame parser data.

Expand Down Expand Up @@ -1025,9 +1025,13 @@ static void rx_init(void)

nrf_802154_trx_receive_buffer_set(rx_buffer_get());

nrf_802154_tx_power_split_t split_power = {0};

(void)nrf_802154_tx_power_split_pib_power_get(&split_power);

nrf_802154_trx_receive_frame(BCC_INIT / 8U,
m_trx_receive_frame_notifications_mask,
nrf_802154_tx_power_constrained_pib_power_get());
&split_power);

#if NRF_802154_TOTAL_TIMES_MEASUREMENT_ENABLED
m_listening_start_hp_timestamp = nrf_802154_hp_timer_current_time_get();
Expand Down Expand Up @@ -1089,7 +1093,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_tx_power,
m_trx_transmit_frame_notifications_mask);

return true;
Expand Down Expand Up @@ -1153,8 +1157,11 @@ static void continuous_carrier_init(void)
{
return;
}
nrf_802154_tx_power_split_t split_power = {0};

nrf_802154_trx_continuous_carrier(nrf_802154_tx_power_constrained_pib_power_get());
(void)nrf_802154_tx_power_split_pib_power_get(&split_power);

nrf_802154_trx_continuous_carrier(&split_power);
}

/** Initialize Modulated Carrier operation. */
Expand All @@ -1170,7 +1177,11 @@ static void modulated_carrier_init(const uint8_t * p_data)
return;
}

nrf_802154_trx_modulated_carrier(p_data, nrf_802154_tx_power_constrained_pib_power_get());
nrf_802154_tx_power_split_t split_power = {0};

(void)nrf_802154_tx_power_split_pib_power_get(&split_power);

nrf_802154_trx_modulated_carrier(p_data, &split_power);
}

#endif // NRF_802154_CARRIER_FUNCTIONS_ENABLED
Expand Down Expand Up @@ -1897,9 +1908,14 @@ 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_tx_power_split_t split_power = {0};

(void)nrf_802154_tx_power_split_pib_power_get(&split_power);

nrf_802154_trx_receive_frame(BCC_INIT / 8U,
m_trx_receive_frame_notifications_mask,
nrf_802154_tx_power_constrained_pib_power_get());
&split_power);

#if NRF_802154_TOTAL_TIMES_MEASUREMENT_ENABLED
m_listening_start_hp_timestamp = nrf_802154_hp_timer_current_time_get();
Expand Down
35 changes: 21 additions & 14 deletions nrf_802154/driver/src/nrf_802154_trx.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

#include "nrf_802154_config.h"
#include "nrf_802154_const.h"
#include "nrf_802154_types.h"
#include "nrf_802154_peripherals.h"
#include "nrf_802154_pib.h"
#include "nrf_802154_rssi.h"
Expand Down Expand Up @@ -321,8 +320,9 @@ static void fem_for_lna_reset(void)
*
* @note This function must be called before ramp up PPIs are configured.
*/
static void fem_for_pa_set(void)
static void fem_for_pa_set(int8_t gain)
{
(void)mpsl_fem_pa_gain_set(gain);
if (mpsl_fem_pa_configuration_set(&m_activate_tx_cc0, NULL) == 0)
{
nrf_timer_shorts_enable(m_activate_tx_cc0.event.timer.p_timer_instance,
Expand All @@ -347,10 +347,12 @@ static void fem_for_pa_reset(void)
*
* @note This function must be called before ramp up PPIs are configured.
*/
static void fem_for_tx_set(bool cca)
static void fem_for_tx_set(bool cca, int8_t gain)
{
bool success;

(void)mpsl_fem_pa_gain_set(gain);

if (cca)
{
bool pa_set = false;
Expand Down Expand Up @@ -909,7 +911,7 @@ 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,
int8_t ack_tx_power)
const nrf_802154_tx_power_split_t * p_ack_tx_power)
{
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);

Expand All @@ -928,7 +930,7 @@ void nrf_802154_trx_receive_frame(uint8_t bcc,

m_flags.rssi_settled = false;

nrf_radio_txpower_set(NRF_RADIO, (nrf_radio_txpower_t)ack_tx_power);
nrf_radio_txpower_set(NRF_RADIO, p_ack_tx_power->radio_tx_power);

if (mp_receive_buffer != NULL)
{
Expand Down Expand Up @@ -1014,6 +1016,9 @@ void nrf_802154_trx_receive_frame(uint8_t bcc,
nrf_timer_cc_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_CC_CHANNEL0, delta_time);
}

// Set FEM PA gain for ACK transmission
mpsl_fem_pa_gain_set(p_ack_tx_power->fem_gain);

m_timer_value_on_radio_end_event = delta_time;

// Select antenna
Expand Down Expand Up @@ -1140,7 +1145,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,
const nrf_802154_tx_power_split_t * p_tx_power,
nrf_802154_trx_transmit_notifications_t notifications_mask)
{
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
Expand All @@ -1153,7 +1158,8 @@ 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_radio_txpower_t)tx_power);
nrf_radio_txpower_set(NRF_RADIO, p_tx_power->radio_tx_power);

nrf_radio_packetptr_set(NRF_RADIO, p_transmit_buffer);

// Set shorts
Expand Down Expand Up @@ -1197,7 +1203,7 @@ void nrf_802154_trx_transmit_frame(const void * p_tra

nrf_radio_int_enable(NRF_RADIO, ints_to_enable);

fem_for_tx_set(cca);
fem_for_tx_set(cca, p_tx_power->fem_gain);
nrf_802154_trx_antenna_update();
nrf_802154_trx_ppi_for_ramp_up_set(cca ? NRF_RADIO_TASK_RXEN : NRF_RADIO_TASK_TXEN, false);

Expand Down Expand Up @@ -1769,7 +1775,7 @@ static void standalone_cca_abort(void)

#if NRF_802154_CARRIER_FUNCTIONS_ENABLED

void nrf_802154_trx_continuous_carrier(int8_t tx_power)
void nrf_802154_trx_continuous_carrier(const nrf_802154_tx_power_split_t * p_tx_power)
{
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);

Expand All @@ -1778,10 +1784,10 @@ void nrf_802154_trx_continuous_carrier(int8_t tx_power)
m_trx_state = TRX_STATE_CONTINUOUS_CARRIER;

// Set Tx Power
nrf_radio_txpower_set(NRF_RADIO, (nrf_radio_txpower_t)tx_power);
nrf_radio_txpower_set(NRF_RADIO, p_tx_power->radio_tx_power);

// Set FEM
fem_for_pa_set();
fem_for_pa_set(p_tx_power->fem_gain);

// Select antenna
nrf_802154_trx_antenna_update();
Expand Down Expand Up @@ -1824,7 +1830,8 @@ 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, int8_t tx_power)
void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer,
const nrf_802154_tx_power_split_t * p_tx_power)
{
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);

Expand All @@ -1834,7 +1841,7 @@ void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer, int8_t tx_
m_trx_state = TRX_STATE_MODULATED_CARRIER;

// Set Tx Power
nrf_radio_txpower_set(NRF_RADIO, (nrf_radio_txpower_t)tx_power);
nrf_radio_txpower_set(NRF_RADIO, p_tx_power->radio_tx_power);

// Set Tx buffer
nrf_radio_packetptr_set(NRF_RADIO, p_transmit_buffer);
Expand All @@ -1843,7 +1850,7 @@ void nrf_802154_trx_modulated_carrier(const void * p_transmit_buffer, int8_t tx_
nrf_radio_shorts_set(NRF_RADIO, SHORTS_MOD_CARRIER);

// Set FEM
fem_for_pa_set();
fem_for_pa_set(p_tx_power->fem_gain);

// Select antenna
nrf_802154_trx_antenna_update();
Expand Down
Loading

0 comments on commit 83225e4

Please sign in to comment.