[nrf52840] update radio driver to 1fcfc44d566c02e555c866c907569b64959952a8 (#2363)

This commit is contained in:
Hubert Miś
2017-11-22 23:28:30 +00:00
committed by Jonathan Hui
parent ced3294fa1
commit e1ce2fb35d
11 changed files with 104 additions and 73 deletions
+4 -4
View File
@@ -71,7 +71,7 @@ enum
static bool sDisabled;
static otError sReceiveError = OT_ERROR_NONE;
static otRadioFrame sReceivedFrames[RADIO_RX_BUFFERS];
static otRadioFrame sReceivedFrames[NRF_DRV_RADIO802154_RX_BUFFERS];
static otRadioFrame sTransmitFrame;
static uint8_t sTransmitPsdu[OT_RADIO_FRAME_MAX_SIZE + 1];
@@ -105,7 +105,7 @@ static void dataInit(void)
sReceiveError = OT_ERROR_NONE;
for (uint32_t i = 0; i < RADIO_RX_BUFFERS; i++)
for (uint32_t i = 0; i < NRF_DRV_RADIO802154_RX_BUFFERS; i++)
{
sReceivedFrames[i].mPsdu = NULL;
}
@@ -512,7 +512,7 @@ void otPlatRadioSetDefaultTxPower(otInstance *aInstance, int8_t aPower)
void nrf5RadioProcess(otInstance *aInstance)
{
for (uint32_t i = 0; i < RADIO_RX_BUFFERS; i++)
for (uint32_t i = 0; i < NRF_DRV_RADIO802154_RX_BUFFERS; i++)
{
if (sReceivedFrames[i].mPsdu != NULL)
{
@@ -651,7 +651,7 @@ void nrf_drv_radio802154_received_raw(uint8_t *p_data, int8_t power, int8_t lqi)
{
otRadioFrame *receivedFrame = NULL;
for (uint32_t i = 0; i < RADIO_RX_BUFFERS; i++)
for (uint32_t i = 0; i < NRF_DRV_RADIO802154_RX_BUFFERS; i++)
{
if (sReceivedFrames[i].mPsdu == NULL)
{
@@ -131,12 +131,12 @@ void nrf_drv_radio802154_deinit(void)
nrf_drv_radio802154_fsm_deinit();
}
#if !RADIO_INTERNAL_IRQ_HANDLING
#if !NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
void nrf_drv_radio802154_irq_handler(void)
{
nrf_drv_radio802154_fsm_irq_handler();
}
#endif // !RADIO_INTERNAL_IRQ_HANDLING
#endif // !NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
#if ENABLE_FEM
void nrf_drv_radio802154_fem_control_cfg_set(const nrf_drv_radio802154_fem_control_cfg_t * p_cfg)
@@ -111,19 +111,19 @@ void nrf_drv_radio802154_init(void);
*/
void nrf_drv_radio802154_deinit(void);
#if !RADIO_INTERNAL_IRQ_HANDLING
#if !NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
/**
* @brief Handle interrupt request from the RADIO peripheral.
*
* @note When RADIO_INTERNAL_IRQ_HANDLING is enabled the driver internally handles the RADIO IRQ
* and this function shall not be called.
* @note When NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING is enabled the driver internally handles the
* RADIO IRQ and this function shall not be called.
*
* This function is intended to be used in Operating System environment when the OS handles IRQ
* and indirectly passes it to the driver or with RAAL implementation that indirectly passes radio
* IRQ handler to the driver (i.e. SoftDevice).
*/
void nrf_drv_radio802154_irq_handler(void);
#endif // !RADIO_INTERNAL_IRQ_HANDLING
#endif // !NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
/**
* @brief Set channel on which the radio shall operate right now.
@@ -46,9 +46,9 @@
#include "hal/nrf_radio.h"
/// Maximum number of Short Addresses of nodes for which there is pending data in buffer.
#define NUM_PENDING_SHORT_ADDRESSES RADIO_PENDING_SHORT_ADDRESSES
#define NUM_PENDING_SHORT_ADDRESSES NRF_DRV_RADIO802154_PENDING_SHORT_ADDRESSES
/// Maximum number of Extended Addresses of nodes for which there is pending data in buffer.
#define NUM_PENDING_EXTENDED_ADDRESSES RADIO_PENDING_EXTENDED_ADDRESSES
#define NUM_PENDING_EXTENDED_ADDRESSES NRF_DRV_RADIO802154_PENDING_EXTENDED_ADDRESSES
/// Value used to mark Short Address as unused.
#define UNUSED_PENDING_SHORT_ADDRESS ((uint8_t [SHORT_ADDRESS_SIZE]) {0xff, 0xff})
/// Value used to mark Extended Address as unused.
@@ -31,6 +31,10 @@
#ifndef NRF_DRIVER_RADIO802154_CONFIG_H__
#define NRF_DRIVER_RADIO802154_CONFIG_H__
#ifdef NRF_DRV_RADIO802154_PROJECT_CONFIG
#include NRF_DRV_RADIO802154_PROJECT_CONFIG
#endif
#include <nrf.h>
#ifdef __cplusplus
@@ -49,39 +53,47 @@ extern "C" {
******************************************************************************/
/**
* @def RADIO_CCA_MODE
* @def NRF_DRV_RADIO802154_CCA_MODE
*
* RADIO CCA Mode.
* CCA Mode used by the driver.
*
*/
#define RADIO_CCA_MODE_DEFAULT NRF_RADIO_CCA_MODE_ED
#ifndef NRF_DRV_RADIO802154_CCA_MODE_DEFAULT
#define NRF_DRV_RADIO802154_CCA_MODE_DEFAULT NRF_RADIO_CCA_MODE_ED
#endif
/**
* @def RADIO_CCA_ED_THRESHOLD
* @def NRF_DRV_RADIO802154_CCA_ED_THRESHOLD
*
* RADIO Energy Detection Threshold.
* Energy Detection Threshold used in CCA procedure.
*
*/
#define RADIO_CCA_ED_THRESHOLD_DEFAULT 0x2D
#ifndef NRF_DRV_RADIO802154_CCA_ED_THRESHOLD_DEFAULT
#define NRF_DRV_RADIO802154_CCA_ED_THRESHOLD_DEFAULT 0x2D
#endif
/**
* @def RADIO_CCA_CORR_THRESHOLD
* @def NRF_DRV_RADIO802154_CCA_CORR_THRESHOLD
*
* RADIO Correlator Threshold.
* Correlator Threshold used in CCA procedure.
*
*/
#define RADIO_CCA_CORR_THRESHOLD_DEFAULT 0x2D
#ifndef NRF_DRV_RADIO802154_CCA_CORR_THRESHOLD_DEFAULT
#define NRF_DRV_RADIO802154_CCA_CORR_THRESHOLD_DEFAULT 0x2D
#endif
/**
* @def RADIO_CCA_CORR_LIMIT
* @def NRF_DRV_RADIO802154_CCA_CORR_LIMIT
*
* RADIO Correlator limit.
* Correlator limit used in CCA procedure.
*
*/
#define RADIO_CCA_CORR_LIMIT_DEFAULT 0x02
#ifndef NRF_DRV_RADIO802154_CCA_CORR_LIMIT_DEFAULT
#define NRF_DRV_RADIO802154_CCA_CORR_LIMIT_DEFAULT 0x02
#endif
/**
* @def RADIO_INTERNAL_IRQ_HANDLING
* @def NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
*
* If the driver should internally handle the RADIO IRQ.
* In case the driver is used in an OS the RADIO IRQ may be handled by the OS and passed to
@@ -89,60 +101,79 @@ extern "C" {
* disabled.
*/
#ifndef NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
#if RAAL_SOFTDEVICE
#define RADIO_INTERNAL_IRQ_HANDLING 0
#define NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING 0
#else // RAAL_SOFTDEVICE
#define RADIO_INTERNAL_IRQ_HANDLING 1
#define NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING 1
#endif // RAAL_SOFTDEVICE
/**
* @def RADIO_IRQ_PRIORITY
*
* RADIO Interrupt priority.
*
*/
#define RADIO_IRQ_PRIORITY 0
#endif // NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
/**
* @def RADIO_PENDING_SHORT_ADDRESSES
* @def NRF_DRV_RADIO802154_IRQ_PRIORITY
*
* RADIO Number of slots containing short addresses of nodes for which pending data is stored.
* Interrupt priority for RADIO peripheral.
* It is recommended to keep IRQ priority high (low number) to prevent losing frames due to
* preemption.
*
*/
#define RADIO_PENDING_SHORT_ADDRESSES 10
#ifndef NRF_DRV_RADIO802154_IRQ_PRIORITY
#define NRF_DRV_RADIO802154_IRQ_PRIORITY 0
#endif
/**
* @def RADIO_PENDING_EXTENDED_ADDRESSES
* @def NRF_DRV_RADIO802154_PENDING_SHORT_ADDRESSES
*
* RADIO Number of slots containing extended addresses of nodes for which pending data is stored.
* Number of slots containing short addresses of nodes for which pending data is stored.
*
*/
#define RADIO_PENDING_EXTENDED_ADDRESSES 10
#ifndef NRF_DRV_RADIO802154_PENDING_SHORT_ADDRESSES
#define NRF_DRV_RADIO802154_PENDING_SHORT_ADDRESSES 10
#endif
/**
* @def RADIO_RX_BUFFERS
* @def NRF_DRV_RADIO802154_PENDING_EXTENDED_ADDRESSES
*
* RADIO Number of buffers in receive queue.
* Number of slots containing extended addresses of nodes for which pending data is stored.
*
*/
#define RADIO_RX_BUFFERS 16
#ifndef NRF_DRV_RADIO802154_PENDING_EXTENDED_ADDRESSES
#define NRF_DRV_RADIO802154_PENDING_EXTENDED_ADDRESSES 10
#endif
/**
* @def RADIO_SHORT_CCAIDLE_TXEN
* @def NRF_DRV_RADIO802154_RX_BUFFERS
*
* RADIO can start transmission using short CCAIDLE->TXEN or using software interrupt handler.
* Number of buffers in receive queue.
*
*/
#define RADIO_SHORT_CCAIDLE_TXEN 1
#ifndef NRF_DRV_RADIO802154_RX_BUFFERS
#define NRF_DRV_RADIO802154_RX_BUFFERS 16
#endif
// TODO: #ifdef to check direct / SWI notifications
/**
* @def RADIO_NOTIFICATION_SWI_PRIORITY
* @def NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN
*
* RADIO peripheral can start transmission using short CCAIDLE->TXEN or interrupt handler.
* If NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN is set to 0 interrupt handler is used, otherwise
* short is used.
*
*/
#ifndef NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN
#define NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN 1
#endif
/**
* @def NRF_DRV_RADIO802154_NOTIFICATION_SWI_PRIORITY
*
* Priority of software interrupt used to call notification from 802.15.4 driver.
*
*/
#define RADIO_NOTIFICATION_SWI_PRIORITY 5
#ifndef NRF_DRV_RADIO802154_NOTIFICATION_SWI_PRIORITY
#define NRF_DRV_RADIO802154_NOTIFICATION_SWI_PRIORITY 5
#endif
/**
*@}
@@ -65,7 +65,7 @@
NRF_RADIO_SHORT_FRAMESTART_BCSTART_MASK)
/// Value set to SHORTS register when received frame should be acknowledged.
#define SHORTS_TX_ACK (NRF_RADIO_SHORT_END_DISABLE_MASK)
#if RADIO_SHORT_CCAIDLE_TXEN
#if NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN
/// Value set to SHORTS register during transmission of a frame
#define SHORTS_TX_FRAME (NRF_RADIO_SHORT_END_DISABLE_MASK | NRF_RADIO_SHORT_READY_START_MASK | \
NRF_RADIO_SHORT_CCAIDLE_TXEN_MASK)
@@ -100,7 +100,7 @@
*/
#define RX_FRAME_LQI(psdu) ((psdu)[(psdu)[0] - 1])
#if RADIO_RX_BUFFERS > 1
#if NRF_DRV_RADIO802154_RX_BUFFERS > 1
/// Pointer to currently used receive buffer.
static rx_buffer_t * mp_current_rx_buffer;
#else
@@ -240,7 +240,7 @@ static inline void received_frame_notify(void)
*/
static inline void rx_buffer_in_use_set(rx_buffer_t * p_rx_buffer)
{
#if RADIO_RX_BUFFERS > 1
#if NRF_DRV_RADIO802154_RX_BUFFERS > 1
mp_current_rx_buffer = p_rx_buffer;
#else
(void) p_rx_buffer;
@@ -489,7 +489,7 @@ static void nrf_radio_reset(void)
/// Initialize interrupts for radio peripheral
static void irq_init(void)
{
NVIC_SetPriority(RADIO_IRQn, RADIO_IRQ_PRIORITY);
NVIC_SetPriority(RADIO_IRQn, NRF_DRV_RADIO802154_IRQ_PRIORITY);
NVIC_ClearPendingIRQ(RADIO_IRQn);
NVIC_EnableIRQ(RADIO_IRQn);
}
@@ -1306,7 +1306,7 @@ static inline void irq_ready_state_continuous_carrier(void)
assert(nrf_radio_state_get() == NRF_RADIO_STATE_TX_IDLE);
}
#if !RADIO_SHORT_CCAIDLE_TXEN
#if !NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN
/// This event is generated when CCA reports that channel is idle.
static inline void irq_ccaidle_state_tx_frame(void)
{
@@ -1314,7 +1314,7 @@ static inline void irq_ccaidle_state_tx_frame(void)
nrf_radio_task_trigger(NRF_RADIO_TASK_DISABLE);
}
#endif // RADIO_SHORT_CCAIDLE_TXEN
#endif // NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN
/// This event is generated when CCA reports idle channel during stand-alone procedure.
static inline void irq_ccaidle_state_cca(void)
@@ -1612,7 +1612,7 @@ static inline void irq_handler(void)
switch (m_state)
{
case RADIO_STATE_TX_FRAME:
#if !RADIO_SHORT_CCAIDLE_TXEN
#if !NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN
irq_ccaidle_state_tx_frame();
#else
// nrf_fem_control_time_latch was called at the beginning of the irq handler,
@@ -1625,7 +1625,7 @@ static inline void irq_handler(void)
irq_ccaidle_state_cca();
break;
#if RADIO_SHORT_CCAIDLE_TXEN
#if NRF_DRV_RADIO802154_SHORT_CCAIDLE_TXEN
case RADIO_STATE_WAITING_RX_FRAME:
case RADIO_STATE_RX_ACK:
// If CCAIDLE->TXEN short is enabled, this event may be handled after event END.
@@ -2172,11 +2172,11 @@ void nrf_drv_radio802154_fsm_cca_cfg_update(void)
}
}
#if RADIO_INTERNAL_IRQ_HANDLING
#if NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
void RADIO_IRQHandler(void)
#else // RADIO_INTERNAL_IRQ_HADLING
#else // NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
void nrf_drv_radio802154_fsm_irq_handler(void)
#endif // RADIO_INTERNAL_IRQ_HANDLING
#endif // NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
{
irq_handler();
}
@@ -214,12 +214,12 @@ void nrf_drv_radio802154_fsm_channel_update(void);
*/
void nrf_drv_radio802154_fsm_cca_cfg_update(void);
#if !RADIO_INTERNAL_IRQ_HANDLING
#if !NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
/**
* @brief Notify the FSM that there is a pending IRQ that should be handled.
*/
void nrf_drv_radio802154_fsm_irq_handler(void);
#endif // !RADIO_INTERNAL_IRQ_HANDLING
#endif // !NRF_DRV_RADIO802154_INTERNAL_IRQ_HANDLING
#ifdef __cplusplus
}
@@ -71,10 +71,10 @@ void nrf_drv_radio802154_pib_init(void)
m_data.short_addr[1] = 0xff;
memset(m_data.extended_addr, 0, sizeof(m_data.extended_addr));
m_data.cca.mode = RADIO_CCA_MODE_DEFAULT;
m_data.cca.ed_threshold = RADIO_CCA_ED_THRESHOLD_DEFAULT;
m_data.cca.corr_threshold = RADIO_CCA_CORR_THRESHOLD_DEFAULT;
m_data.cca.corr_limit = RADIO_CCA_CORR_LIMIT_DEFAULT;
m_data.cca.mode = NRF_DRV_RADIO802154_CCA_MODE_DEFAULT;
m_data.cca.ed_threshold = NRF_DRV_RADIO802154_CCA_ED_THRESHOLD_DEFAULT;
m_data.cca.corr_threshold = NRF_DRV_RADIO802154_CCA_CORR_THRESHOLD_DEFAULT;
m_data.cca.corr_limit = NRF_DRV_RADIO802154_CCA_CORR_LIMIT_DEFAULT;
}
bool nrf_drv_radio802154_pib_promiscuous_get(void)
@@ -76,7 +76,7 @@ static bool active_vector_priority_is_high(void)
irq_number = (IRQn_Type)(active_vector_id - CMSIS_IRQ_NUM_VECTACTIVE_DIFF);
active_priority = NVIC_GetPriority(irq_number);
return active_priority <= RADIO_NOTIFICATION_SWI_PRIORITY;
return active_priority <= NRF_DRV_RADIO802154_NOTIFICATION_SWI_PRIORITY;
}
void nrf_drv_radio802154_request_init(void)
@@ -40,15 +40,15 @@
#include "nrf_drv_radio802154_config.h"
#if RADIO_RX_BUFFERS < 1
#if NRF_DRV_RADIO802154_RX_BUFFERS < 1
#error Not enough rx buffers in the 802.15.4 radio driver.
#endif
rx_buffer_t nrf_drv_radio802154_rx_buffers[RADIO_RX_BUFFERS]; ///< Receive buffers.
rx_buffer_t nrf_drv_radio802154_rx_buffers[NRF_DRV_RADIO802154_RX_BUFFERS]; ///< Receive buffers.
void nrf_drv_radio802154_rx_buffer_init(void)
{
for (uint32_t i = 0; i < RADIO_RX_BUFFERS; i++)
for (uint32_t i = 0; i < NRF_DRV_RADIO802154_RX_BUFFERS; i++)
{
nrf_drv_radio802154_rx_buffers[i].free = true;
}
@@ -56,7 +56,7 @@ void nrf_drv_radio802154_rx_buffer_init(void)
rx_buffer_t * nrf_drv_radio802154_rx_buffer_free_find(void)
{
for (uint32_t i = 0; i < RADIO_RX_BUFFERS; i++)
for (uint32_t i = 0; i < NRF_DRV_RADIO802154_RX_BUFFERS; i++)
{
if (nrf_drv_radio802154_rx_buffers[i].free)
{
@@ -55,7 +55,7 @@
* One slot for each receive buffer, one for transmission, one for busy channel and one for energy
* detection.
*/
#define NTF_QUEUE_SIZE (RADIO_RX_BUFFERS + 3)
#define NTF_QUEUE_SIZE (NRF_DRV_RADIO802154_RX_BUFFERS + 3)
/** Size of requests queue.
*
* Two is minimal queue size. It is not expected in current implementation to queue a few requests.
@@ -362,7 +362,7 @@ void nrf_drv_radio802154_swi_init(void)
TIMESLOT_EXIT_INT |
REQ_INT);
NVIC_SetPriority(SWI_IRQn, RADIO_NOTIFICATION_SWI_PRIORITY);
NVIC_SetPriority(SWI_IRQn, NRF_DRV_RADIO802154_NOTIFICATION_SWI_PRIORITY);
NVIC_ClearPendingIRQ(SWI_IRQn);
NVIC_EnableIRQ(SWI_IRQn);
}