Skip to content
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
46 changes: 46 additions & 0 deletions nrf_802154/doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,157 +13,203 @@ Setting addresses and PAN ID of the device
******************************************

.. doxygengroup:: nrf_802154_addresses
:project: nrfxlib
:members:

.. _radiodriver_api_data:

Functions to calculate data given by the driver
***********************************************

.. doxygengroup:: nrf_802154_data
:project: nrfxlib
:members:

.. _radiodriver_api_transitions:

Functions to request FSM transitions and check the current state
****************************************************************

.. doxygengroup:: nrf_802154_transitions
:project: nrfxlib
:members:

.. _radiodriver_api_calls:

Calls to the higher layer
*************************

.. doxygengroup:: nrf_802154_calls
:project: nrfxlib
:members:

.. _radiodriver_api_memman:

Driver memory management
************************

.. doxygengroup:: nrf_802154_memman
:project: nrfxlib
:members:

.. _radiodriver_api_rssi:

RSSI measurement function
*************************

.. doxygengroup:: nrf_802154_rssi
:project: nrfxlib
:members:

.. _radiodriver_api_prom:

Promiscuous mode
****************

.. doxygengroup:: nrf_802154_prom
:project: nrfxlib
:members:

.. _radiodriver_api_autoack:

Auto ACK management
*******************

.. doxygengroup:: nrf_802154_autoack
:project: nrfxlib
:members:

.. _radiodriver_api_cca:

CCA configuration management
****************************

.. doxygengroup:: nrf_802154_cca
:project: nrfxlib
:members:

.. _radiodriver_api_csma:

CSMA-CA procedure
*****************

.. doxygengroup:: nrf_802154_csma
:project: nrfxlib
:members:

.. _radiodriver_api_timeout:

ACK timeout procedure
*********************

.. doxygengroup:: nrf_802154_timeout
:project: nrfxlib
:members:

.. _radiodriver_api_stats:

Statistics and measurements
***************************

.. doxygengroup:: nrf_802154_stats
:project: nrfxlib
:members:

.. _radiodriver_api_ifs:

Inter-frame spacing feature
***************************

.. doxygengroup:: nrf_802154_ifs
:project: nrfxlib
:members:

.. _radiodriver_api_capabilities:

Radio driver run-time capabilities feature
******************************************

.. doxygengroup:: nrf_802154_capabilities
:project: nrfxlib
:members:

.. _radiodriver_api_security:

Radio driver MAC security feature
*********************************

.. doxygengroup:: nrf_802154_security
:project: nrfxlib
:members:

.. _radiodriver_api_ie_writer:

Radio driver Information Element data injection feature
*******************************************************

.. doxygengroup:: nrf_802154_ie_writer
:project: nrfxlib
:members:

.. _radiodriver_api_config_radio:

Radio driver configuration
**************************

.. doxygengroup:: nrf_802154_config_radio
:project: nrfxlib
:members:

.. _radiodriver_api_config_csma:

CSMA/CA procedure configuration
*******************************

.. doxygengroup:: nrf_802154_config_csma
:project: nrfxlib
:members:

.. _radiodriver_api_config_timeout:

ACK timeout feature configuration
*********************************

.. doxygengroup:: nrf_802154_config_timeout
:project: nrfxlib
:members:

.. _radiodriver_api_config_transmission:

Transmission start notification feature configuration
*****************************************************

.. doxygengroup:: nrf_802154_config_transmission
:project: nrfxlib
:members:

.. _radiodriver_api_ie:

Information Elements configuration
**********************************

.. doxygengroup:: nrf_802154_ie
:project: nrfxlib
:members:

.. _radiodriver_api_other:

Interrupt Handlers
******************

.. doxygengroup:: nrf_802154_irq
:project: nrfxlib
:members:

.. _radiodriver_api_irq:

Other functions
***************

.. doxygengroup:: nrf_802154
:project: nrfxlib
:members:
102 changes: 64 additions & 38 deletions nrf_802154/driver/src/nrf_802154_trx.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,37 +333,81 @@ static void timer_frequency_set_1mhz(void)
nrf_timer_prescaler_set(NRF_802154_TIMER_INSTANCE, prescaler);
}

/** Disables the radio no matter its state. */
static void radio_force_disable(void)
{
/* Radio cannot be disabled if EVENT_DISABLED is set. Clear it first. */
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_DISABLE);
}

/** Robustly disable the radio peripheral based on the radio state. */
static void radio_robust_disable(void)
{
nrf_radio_state_t radio_state = nrf_radio_state_get(NRF_RADIO);

if ((radio_state == NRF_RADIO_STATE_RXDISABLE) || (radio_state == NRF_RADIO_STATE_TXDISABLE))
{
/* RADIO is in an unstable state that should resolve to DISABLED. Do nothing. */
}
else
{
/* RADIO is in a stable state and needs to be transitioned to DISABLED manually. */
radio_force_disable();
}
}

static inline void wait_until_radio_is_disabled(void)
{
nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_HIGH);

bool radio_is_disabled = false;
bool repeat = false;

do
{
/* RADIO should enter DISABLED state after no longer than RX ramp-down time or TX ramp-down
* time, depending on its initial state before TASK_DISABLE was triggered. The loop below busy
* waits for the state transition to complete. To prevent the CPU from spinning in an endless
* loop, the maximum allowed number of loop cycles is limited. The limit's intention is not to
* approximate the expected maximum time the transition might actually take, which is generally
* very short, but to act as a safeguard against obviously incorrect and unexpected behaviors.
* In practice, in most cases the radio will have already changed state to DISABLED before this
* function starts. In the remaining cases several cycles of the loop should be sufficient for
* the transition to complete.
*/
for (uint32_t i = 0; i < MAX_RAMPDOWN_CYCLES; i++)
{
if (nrf_radio_state_get(NRF_RADIO) == NRF_RADIO_STATE_DISABLED)
{
radio_is_disabled = true;
break;
}
#if defined(CONFIG_SOC_SERIES_BSIM_NRFXX)
nrf_802154_delay_us(1);
/* In this simulated board, and in general in the POSIX ARCH,
* code takes 0 simulated time to execute.
* Let's hold for 1 microsecond to allow the RADIO HW to clear the state
*/
#endif
}

/* RADIO should enter DISABLED state after no longer than RX ramp-down time or TX ramp-down
* time, depending on its initial state before TASK_DISABLE was triggered. The loop below busy
* waits for the state transition to complete. To prevent the CPU from spinning in an endless
* loop, the maximum allowed number of loop cycles is limited. The limit's intention is not to
* approximate the expected maximum time the transition might actually take, which is generally
* very short, but to act as a safeguard against obviously incorrect and unexpected behaviors.
* In practice, in most cases the radio will have already changed state to DISABLED before this
* function starts. In the remaining cases several cycles of the loop should be sufficient for
* the transition to complete.
*/
for (uint32_t i = 0; i < MAX_RAMPDOWN_CYCLES; i++)
{
if (nrf_radio_state_get(NRF_RADIO) == NRF_RADIO_STATE_DISABLED)
#ifdef NRF54L_SERIES
if (!radio_is_disabled && !repeat)
{
/* Radio still not in disabled state.
* Manually disable the radio and repeat the loop once as a last resort.
*/
radio_force_disable();
repeat = true;
}
else
{
radio_is_disabled = true;
break;
}
#if defined(CONFIG_SOC_SERIES_BSIM_NRFXX)
nrf_802154_delay_us(1);
/* In this simulated board, and in general in the POSIX ARCH,
* code takes 0 simulated time to execute.
* Let's hold for 1 microsecond to allow the RADIO HW to clear the state
*/
#endif
}
while (repeat);

NRF_802154_ASSERT(radio_is_disabled);
(void)radio_is_disabled;
Expand Down Expand Up @@ -525,24 +569,6 @@ static void nrf_radio_reset(void)
nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
}

/** Robustly disable the radio peripheral. */
static void radio_robust_disable(void)
{
nrf_radio_state_t radio_state = nrf_radio_state_get(NRF_RADIO);

if ((radio_state == NRF_RADIO_STATE_RXDISABLE) || (radio_state == NRF_RADIO_STATE_TXDISABLE))
{
/* RADIO is in an unstable state that should resolve to DISABLED. Do nothing. */
}
else
{
/* RADIO is in a stable state and needs to be transitioned to DISABLED manually.
* It cannot be disabled if EVENT_DISABLED is set. Clear it first. */
nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_DISABLE);
}
}

static void channel_set(uint8_t channel)
{
NRF_802154_ASSERT(channel >= 11U && channel <= 26U);
Expand Down
Loading