Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP][DNM] KRKNWK-19361 v2.4 branch yoda fixes v2 #1442

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions nrf_802154/driver/include/nrf_802154.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ void nrf_802154_tx_power_set(int8_t power);
*/
int8_t nrf_802154_tx_power_get(void);

#if NRF_802154_ANTENNA_DIVERSITY
/**
* @brief Sets the antenna diversity rx mode.
*
Expand Down Expand Up @@ -325,6 +326,8 @@ bool nrf_802154_antenna_diversity_init(void);
*/
void nrf_802154_antenna_diversity_timer_irq_handler(void);

#endif /* NRF_802154_ANTENNA_DIVERSITY */

/**
* @brief Gets the current time.
*
Expand Down
13 changes: 13 additions & 0 deletions nrf_802154/driver/include/nrf_802154_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,19 @@ extern "C" {
#define NRF_802154_CARRIER_FUNCTIONS_ENABLED 1
#endif

/**
* @def NRF_802154_ANTENNA_DIVERSITY
*
* Enables experimental Antenna Diversity feature.
*/
#ifndef NRF_802154_ANTENNA_DIVERSITY
#if defined(NRF52_SERIES)
#define NRF_802154_ANTENNA_DIVERSITY 1
#else
#define NRF_802154_ANTENNA_DIVERSITY 0
#endif
#endif

/**
*@}
**/
Expand Down
2 changes: 2 additions & 0 deletions nrf_802154/driver/src/nrf_802154.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ void nrf_802154_deinit(void)
#endif
}

#if NRF_802154_ANTENNA_DIVERSITY
bool nrf_802154_antenna_diversity_rx_mode_set(nrf_802154_sl_ant_div_mode_t mode)
{
bool result = false;
Expand Down Expand Up @@ -392,6 +393,7 @@ void nrf_802154_antenna_diversity_timer_irq_handler(void)
nrf_802154_sl_ant_div_timer_irq_handle();
#endif
}
#endif /* NRF_802154_ANTENNA_DIVERSITY */

nrf_802154_state_t nrf_802154_state_get(void)
{
Expand Down
24 changes: 24 additions & 0 deletions nrf_802154/driver/src/nrf_802154_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,12 @@ static bool timeslot_is_granted(void)

static bool antenna_diversity_is_enabled(void)
{
#if NRF_802154_ANTENNA_DIVERSITY
return (NRF_802154_SL_ANT_DIV_MODE_DISABLED !=
nrf_802154_sl_ant_div_cfg_mode_get(NRF_802154_SL_ANT_DIV_OP_RX));
#else
return false;
#endif
}

/***************************************************************************************************
Expand Down Expand Up @@ -793,8 +797,10 @@ static bool current_operation_terminate(nrf_802154_term_t term_lvl,
m_rx_prestarted_trig_count = 0;
(void)nrf_802154_sl_timer_remove(&m_rx_prestarted_timer);

#if NRF_802154_ANTENNA_DIVERSITY
/* Notify antenna diversity module that RX has been aborted. */
nrf_802154_sl_ant_div_rx_aborted_notify();
#endif

/* We might have boosted preconditions (to support coex) above level
* normally requested for current state by request_preconditions_for_state(m_state).
Expand All @@ -803,10 +809,12 @@ static bool current_operation_terminate(nrf_802154_term_t term_lvl,
request_preconditions_for_state(m_state);
}

#if NRF_802154_ANTENNA_DIVERSITY
if (m_state == RADIO_STATE_ED)
{
nrf_802154_sl_ant_div_energy_detection_aborted_notify();
}
#endif

if (notify)
{
Expand Down Expand Up @@ -1067,9 +1075,11 @@ static void ed_init(void)

uint32_t trx_ed_count = 0U;

#if NRF_802154_ANTENNA_DIVERSITY
// Notify antenna diversity about energy detection request. Antenna diversity state
// will be updated, and m_ed_time_left reduced accordingly.
nrf_802154_sl_ant_div_energy_detection_requested_notify(&m_ed_time_left);
#endif

if (!ed_iter_setup(&m_ed_time_left, &trx_ed_count))
{
Expand Down Expand Up @@ -1468,7 +1478,9 @@ static void on_rx_prestarted_timeout(nrf_802154_sl_timer_t * p_timer)

nrf_802154_critical_section_forcefully_enter();

#if NRF_802154_ANTENNA_DIVERSITY
nrf_802154_sl_ant_div_rx_preamble_timeout_notify();
#endif

do
{
Expand All @@ -1490,7 +1502,9 @@ static void on_rx_prestarted_timeout(nrf_802154_sl_timer_t * p_timer)
if (nrf_802154_sl_time64_is_in_future(now, m_rx_prestarted_timer.trigger_time))
{
m_rx_prestarted_trig_count = 1;
#if NRF_802154_ANTENNA_DIVERSITY
nrf_802154_sl_ant_div_rx_preamble_detected_notify();
#endif
break;
}
}
Expand All @@ -1514,6 +1528,7 @@ void nrf_802154_trx_receive_frame_prestarted(void)
{
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);

#if NRF_802154_ANTENNA_DIVERSITY
if (!antenna_diversity_is_enabled())
{
// Only assert if notifications mask would not allow for calling this function.
Expand All @@ -1524,14 +1539,17 @@ void nrf_802154_trx_receive_frame_prestarted(void)
{
// Antenna diversity uses this function for detecting possible preamble on air.
}
#endif

assert(m_state == RADIO_STATE_RX);

#if (NRF_802154_STATS_COUNT_ENERGY_DETECTED_EVENTS)
nrf_802154_stat_counter_increment(received_energy_events);
#endif

#if NRF_802154_ANTENNA_DIVERSITY
nrf_802154_sl_ant_div_rx_preamble_detected_notify();
#endif

// Antenna diversity module should be notified if framestart doesn't come.
bool rx_timeout_should_be_started = antenna_diversity_is_enabled();
Expand Down Expand Up @@ -1601,6 +1619,7 @@ void nrf_802154_trx_receive_frame_started(void)
break;
}

#if NRF_802154_ANTENNA_DIVERSITY
if (antenna_diversity_is_enabled())
{
// If antenna diversity is enabled, rx_prestarted_timer would be started even
Expand All @@ -1609,6 +1628,7 @@ void nrf_802154_trx_receive_frame_started(void)
(void)nrf_802154_sl_timer_remove(&m_rx_prestarted_timer);
nrf_802154_sl_ant_div_rx_frame_started_notify();
}
#endif

nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
}
Expand Down Expand Up @@ -1875,7 +1895,9 @@ void nrf_802154_trx_receive_frame_received(void)
nrf_802154_stat_timestamp_write(last_rx_end_timestamp, ts);
#endif

#if NRF_802154_ANTENNA_DIVERSITY
nrf_802154_sl_ant_div_rx_frame_received_notify();
#endif

bool send_ack = false;

Expand Down Expand Up @@ -2297,10 +2319,12 @@ void nrf_802154_trx_energy_detection_finished(uint8_t ed_sample)
* Operation will be resumed in next timeslot */
}
}
#if NRF_802154_ANTENNA_DIVERSITY
else if (nrf_802154_sl_ant_div_energy_detection_finished_notify())
{
ed_init();
}
#endif
else
{
nrf_802154_trx_channel_set(nrf_802154_pib_channel_get());
Expand Down
8 changes: 8 additions & 0 deletions nrf_802154/driver/src/nrf_802154_trx.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ void nrf_802154_trx_disable(void)
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
}

#if NRF_802154_ANTENNA_DIVERSITY
static void rx_automatic_antenna_handle(void)
{
switch (m_trx_state)
Expand All @@ -828,7 +829,9 @@ static void rx_automatic_antenna_handle(void)
break;
}
}
#endif

#if NRF_802154_ANTENNA_DIVERSITY
/**
* Updates the antenna for reception, according to antenna diversity configuration.
*/
Expand Down Expand Up @@ -860,7 +863,9 @@ static void rx_antenna_update(void)
assert(result);
(void)result;
}
#endif

#if NRF_802154_ANTENNA_DIVERSITY
/**
* Updates the antenna for transmission, according to antenna diversity configuration.
*
Expand Down Expand Up @@ -895,9 +900,11 @@ static void tx_antenna_update(void)
assert(false);
}
}
#endif

void nrf_802154_trx_antenna_update(void)
{
#if NRF_802154_ANTENNA_DIVERSITY
assert(m_trx_state != TRX_STATE_DISABLED);

switch (m_trx_state)
Expand All @@ -923,6 +930,7 @@ void nrf_802154_trx_antenna_update(void)
/* Intentionally empty */
break;
}
#endif
}

void nrf_802154_trx_channel_set(uint8_t channel)
Expand Down
13 changes: 13 additions & 0 deletions nrf_802154/serialization/include/host/nrf_802154_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,19 @@ extern "C" {
#define NRF_802154_TEST_MODES_ENABLED 0
#endif

/**
* @def NRF_802154_ANTENNA_DIVERSITY
*
* Enables experimental Antenna Diversity feature.
*/
#ifndef NRF_802154_ANTENNA_DIVERSITY
#if defined(NRF52_SERIES)
#define NRF_802154_ANTENNA_DIVERSITY 1
#else
#define NRF_802154_ANTENNA_DIVERSITY 0
#endif
#endif

#ifdef __cplusplus
}
#endif
Expand Down
Loading