From a08a9ceee3eb3b58de249528ed1cd397fb9e8cdc Mon Sep 17 00:00:00 2001 From: "Duda, Lukasz" Date: Mon, 9 Dec 2019 22:17:18 +0100 Subject: [PATCH] [nrf528xx] update nRF IEEE 802.15.4 Radio Driver to version 1.6.1 (#4390) --- .../radio/fem/simple_gpio/nrf_fem_config.h | 2 +- .../three_pin_gpio/nrf_fem_three_pin_gpio.c | 15 +++++---- .../drivers/radio/nrf_802154_core.c | 32 +++++++++++++++---- .../drivers/radio/nrf_802154_peripherals.h | 2 +- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/third_party/NordicSemiconductor/drivers/radio/fem/simple_gpio/nrf_fem_config.h b/third_party/NordicSemiconductor/drivers/radio/fem/simple_gpio/nrf_fem_config.h index 0dd3e1ef3..aa16f067a 100644 --- a/third_party/NordicSemiconductor/drivers/radio/fem/simple_gpio/nrf_fem_config.h +++ b/third_party/NordicSemiconductor/drivers/radio/fem/simple_gpio/nrf_fem_config.h @@ -117,7 +117,7 @@ typedef struct /** Mask of GPIOTE channels used for FEM control. */ #define NRF_802154_FEM_GPIOTE_CHANNELS_USED_MASK ( \ - (1 << NRF_FEM_CONTROL_DEAFULT_LNA_GPIOTE_CHANNEL) | \ + (1 << NRF_FEM_CONTROL_DEFAULT_LNA_GPIOTE_CHANNEL) | \ (1 << NRF_FEM_CONTROL_DEFAULT_PA_GPIOTE_CHANNEL)) #ifdef __cplusplus diff --git a/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio/nrf_fem_three_pin_gpio.c b/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio/nrf_fem_three_pin_gpio.c index b71311dbd..68bad9d7f 100644 --- a/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio/nrf_fem_three_pin_gpio.c +++ b/third_party/NordicSemiconductor/drivers/radio/fem/three_pin_gpio/nrf_fem_three_pin_gpio.c @@ -261,12 +261,13 @@ static int32_t event_configuration_set(const nrf_802154_fal_event_t * const p_ev p_event->event.timer.compare_channel_mask, 1); - nrf_ppi_channel_endpoint_setup(m_nrf_fem_interface_config.ppi_ch_id_pdn, - (uint32_t)(&(p_event->event.timer.p_timer_instance-> - EVENTS_COMPARE[compare_channel])), - pdn_task_addr); + nrf_ppi_channel_endpoint_setup( + (nrf_ppi_channel_t)m_nrf_fem_interface_config.ppi_ch_id_pdn, + (uint32_t)(&(p_event->event.timer.p_timer_instance-> + EVENTS_COMPARE[compare_channel])), + pdn_task_addr); - nrf_ppi_channel_enable(m_nrf_fem_interface_config.ppi_ch_id_pdn); + nrf_ppi_channel_enable((nrf_ppi_channel_t)m_nrf_fem_interface_config.ppi_ch_id_pdn); nrf_timer_cc_write(p_event->event.timer.p_timer_instance, (nrf_timer_cc_channel_t)compare_channel, @@ -552,9 +553,9 @@ bool nrf_fem_prepare_powerdown(NRF_TIMER_Type * p_instance, } nrf_timer_cc_write(p_instance, - compare_channel, + (nrf_timer_cc_channel_t)compare_channel, m_nrf_fem_interface_config.fem_config.trx_hold_us + 1); - nrf_ppi_channel_endpoint_setup(m_nrf_fem_interface_config.ppi_ch_id_pdn, + nrf_ppi_channel_endpoint_setup((nrf_ppi_channel_t)m_nrf_fem_interface_config.ppi_ch_id_pdn, (uint32_t)(&(p_instance->EVENTS_COMPARE[compare_channel])), pdn_task_addr); diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c index 38721121e..ea15796f7 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_core.c @@ -638,7 +638,7 @@ static void irq_deinit(void) static void nrf_timer_init(void) { nrf_timer_mode_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_MODE_TIMER); - nrf_timer_bit_width_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_BIT_WIDTH_16); + nrf_timer_bit_width_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_BIT_WIDTH_32); nrf_timer_frequency_set(NRF_802154_TIMER_INSTANCE, NRF_TIMER_FREQ_1MHz); #if NRF_802154_DISABLE_BCC_MATCHING @@ -1042,6 +1042,8 @@ static void rx_terminate(void) nrf_ppi_channel_disable(PPI_CRCOK_DIS_PPI); nrf_ppi_channel_disable(PPI_ADDRESS_COUNTER_COUNT); nrf_ppi_channel_disable(PPI_CRCERROR_COUNTER_CLEAR); + nrf_ppi_channel_endpoint_setup(PPI_CRCERROR_CLEAR, 0, 0); + nrf_ppi_fork_endpoint_setup(PPI_CRCERROR_CLEAR, 0); #endif // NRF_802154_DISABLE_BCC_MATCHING // Disable LNA @@ -1106,6 +1108,8 @@ static void tx_ack_terminate(void) #if NRF_802154_DISABLE_BCC_MATCHING nrf_ppi_channel_disable(PPI_CRCERROR_CLEAR); nrf_ppi_channel_disable(PPI_CRCOK_DIS_PPI); + nrf_ppi_channel_endpoint_setup(PPI_CRCERROR_CLEAR, 0, 0); + nrf_ppi_fork_endpoint_setup(PPI_CRCERROR_CLEAR, 0); #endif // NRF_802154_DISABLE_BCC_MATCHING // Disable PA @@ -2178,19 +2182,29 @@ static void irq_crcok_state_rx(void) #endif // !NRF_802154_DISABLE_BCC_MATCHING // Set FEM PPIs - uint32_t time_to_pa = nrf_timer_cc_read(NRF_802154_TIMER_INSTANCE, - NRF_TIMER_CC_CHANNEL1); + uint32_t time_to_rampup = nrf_timer_cc_read(NRF_802154_TIMER_INSTANCE, + NRF_TIMER_CC_CHANNEL1); nrf_802154_fal_event_t timer = m_activate_tx_cc0; - timer.event.timer.counter_value += time_to_pa; + timer.event.timer.counter_value += time_to_rampup; nrf_802154_fal_pa_configuration_set(&timer, NULL); // Detect if PPI worked (timer is counting or TIMER event is marked) nrf_timer_task_trigger(NRF_802154_TIMER_INSTANCE, NRF_TIMER_TASK_CAPTURE3); - if (nrf_timer_cc_read(NRF_802154_TIMER_INSTANCE, NRF_TIMER_CC_CHANNEL3) < - nrf_timer_cc_read(NRF_802154_TIMER_INSTANCE, NRF_TIMER_CC_CHANNEL1)) + uint32_t current_timer_value = nrf_timer_cc_read(NRF_802154_TIMER_INSTANCE, + NRF_TIMER_CC_CHANNEL3); + uint32_t time_to_fem = nrf_timer_cc_read(NRF_802154_TIMER_INSTANCE, + NRF_TIMER_CC_CHANNEL0); + + // When external PA uses timer, it should be configured to a time later than ramp up + // time. In such case, the timer stops with shorts on PA timer. + // But if external PA does not use timer, FEM time is set to a value in the pased + // used by LNA. After timer overflow, the timer stops with short on the past value + // used by LNA. We have to detect if the timer is after the overflow. + if ((current_timer_value < time_to_rampup) && + ((time_to_fem >= time_to_rampup) || (current_timer_value > time_to_fem))) { wait_for_phyend = true; } @@ -2242,6 +2256,8 @@ static void irq_crcok_state_rx(void) #if !NRF_802154_DISABLE_BCC_MATCHING nrf_ppi_channel_disable(PPI_TIMER_TX_ACK); + nrf_ppi_channel_endpoint_setup(PPI_TIMER_TX_ACK, 0, 0); + nrf_ppi_fork_endpoint_setup(PPI_TIMER_TX_ACK, 0); #endif // !NRF_802154_DISABLE_BCC_MATCHING // RX uses the same peripherals as TX_ACK until RADIO ints are updated. @@ -2372,7 +2388,9 @@ static void irq_phyend_state_tx_ack(void) NRF_TIMER_TASK_START)); #else // NRF_802154_DISABLE_BCC_MATCHING nrf_ppi_channel_disable(PPI_TIMER_TX_ACK); -#endif // NRF_802154_DISABLE_BCC_MATCHING + nrf_ppi_channel_endpoint_setup(PPI_TIMER_TX_ACK, 0, 0); + nrf_ppi_fork_endpoint_setup(PPI_TIMER_TX_ACK, 0); +#endif // NRF_802154_DISABLE_BCC_MATCHING // Enable PPI disabled by CRCOK nrf_ppi_channel_enable(PPI_EGU_RAMP_UP); diff --git a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_peripherals.h b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_peripherals.h index 0a72db511..6ba51520e 100644 --- a/third_party/NordicSemiconductor/drivers/radio/nrf_802154_peripherals.h +++ b/third_party/NordicSemiconductor/drivers/radio/nrf_802154_peripherals.h @@ -492,7 +492,7 @@ extern "C" { #ifdef NRF_802154_FRAME_TIMESTAMP_ENABLED #define NRF_802154_PPI_GROUPS_USED_MASK ((1 << NRF_802154_PPI_CORE_GROUP) | \ - (1 << NRF_802154_PPI_TIMESTAMP_GROUP) + (1 << NRF_802154_PPI_TIMESTAMP_GROUP)) #else // NRF_802154_FRAME_TIMESTAMP_ENABLED #define NRF_802154_PPI_GROUPS_USED_MASK (1 << NRF_802154_PPI_CORE_GROUP) #endif // NRF_802154_FRAME_TIMESTAMP_ENABLED