Skip to content

Commit 2dad068

Browse files
ppryga-nordiccfriedt
authored andcommitted
Bluetooth: controller: radio: Add back2back TX switch after PHYEND event
Transmission of Constant Tone Extension is done after END event triggered by radio. To correctly switch from TX to TX (back 2 back TX) after transmission of CTE PHYEND event must be used instead of END event. The commit provides required function that allows LLL to correctly setup radio to do back to back switch of TX when CTE transmission is enabled. The radio_switch_complete_and_phy_end_b2b_tx cannot be implemented in radio.c source file. It will fail build of unit tests targeted for NRFBSIM simulator board. There is no RADIO_SHORTS_PHYEND_DISABLE_Msk macro defined in bsim_hw_models module. Signed-off-by: Piotr Pryga <[email protected]>
1 parent 1e2ad5a commit 2dad068

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
#include "ll_sw/pdu.h"
2323

24+
#include "radio_internal.h"
25+
2426
#if defined(CONFIG_BT_CTLR_GPIO_PA_PIN)
2527
#if ((CONFIG_BT_CTLR_GPIO_PA_PIN) > 31)
2628
#define NRF_GPIO_PA NRF_P1
@@ -490,19 +492,10 @@ void *radio_pkt_decrypt_get(void)
490492

491493
#if !defined(CONFIG_BT_CTLR_TIFS_HW)
492494

493-
#define SW_SWITCH_PREV_RX 0
494-
#define SW_SWITCH_NEXT_RX 0
495-
#define SW_SWITCH_PREV_TX 1
496-
#define SW_SWITCH_NEXT_TX 1
497-
#define SW_SWITCH_PREV_PHY_1M 0
498-
#define SW_SWITCH_PREV_FLAGS_DONTCARE 0
499-
#define SW_SWITCH_NEXT_FLAGS_DONTCARE 0
500-
501495
static uint8_t sw_tifs_toggle;
502496

503-
static inline void sw_switch(uint8_t dir_curr, uint8_t dir_next,
504-
uint8_t phy_curr, uint8_t flags_curr,
505-
uint8_t phy_next, uint8_t flags_next)
497+
void sw_switch(uint8_t dir_curr, uint8_t dir_next, uint8_t phy_curr, uint8_t flags_curr,
498+
uint8_t phy_next, uint8_t flags_next)
506499
{
507500
uint8_t ppi = HAL_SW_SWITCH_RADIO_ENABLE_PPI(sw_tifs_toggle);
508501
uint8_t cc = SW_SWITCH_TIMER_EVTS_COMP(sw_tifs_toggle);
@@ -511,8 +504,8 @@ static inline void sw_switch(uint8_t dir_curr, uint8_t dir_next,
511504
hal_radio_sw_switch_setup(cc, ppi, sw_tifs_toggle);
512505

513506
/* NOTE: As constants are passed to dir_curr and dir_next, the
514-
* compiler should optimize out the redundant code path as
515-
* this is an inline function.
507+
* compiler should optimize out the redundant code path
508+
* during the optimization.
516509
*/
517510
if (dir_next) {
518511
/* TX */
@@ -649,9 +642,8 @@ void radio_switch_complete_and_rx(uint8_t phy_rx)
649642
* across nRF5x radios, sw_switch assumes the 1M chain delay for
650643
* calculations.
651644
*/
652-
sw_switch(SW_SWITCH_PREV_TX, SW_SWITCH_NEXT_RX,
653-
SW_SWITCH_PREV_PHY_1M, SW_SWITCH_PREV_FLAGS_DONTCARE,
654-
phy_rx, SW_SWITCH_NEXT_FLAGS_DONTCARE);
645+
sw_switch(SW_SWITCH_TX, SW_SWITCH_RX, SW_SWITCH_PHY_1M, SW_SWITCH_FLAGS_DONTCARE, phy_rx,
646+
SW_SWITCH_FLAGS_DONTCARE);
655647
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
656648
}
657649

@@ -666,8 +658,7 @@ void radio_switch_complete_and_tx(uint8_t phy_rx, uint8_t flags_rx,
666658
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk |
667659
RADIO_SHORTS_END_DISABLE_Msk;
668660

669-
sw_switch(SW_SWITCH_PREV_RX, SW_SWITCH_NEXT_TX,
670-
phy_rx, flags_rx, phy_tx, flags_tx);
661+
sw_switch(SW_SWITCH_RX, SW_SWITCH_TX, phy_rx, flags_rx, phy_tx, flags_tx);
671662
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
672663
}
673664

@@ -682,8 +673,7 @@ void radio_switch_complete_and_b2b_tx(uint8_t phy_curr, uint8_t flags_curr,
682673
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk |
683674
RADIO_SHORTS_END_DISABLE_Msk;
684675

685-
sw_switch(SW_SWITCH_PREV_TX, SW_SWITCH_NEXT_TX,
686-
phy_curr, flags_curr, phy_next, flags_next);
676+
sw_switch(SW_SWITCH_TX, SW_SWITCH_TX, phy_curr, flags_curr, phy_next, flags_next);
687677
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
688678
}
689679

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_df.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "radio_nrf5.h"
1515
#include "radio_df.h"
16+
#include "radio_internal.h"
1617

1718
/* @brief Minimum antennas number required if antenna switching is enabled */
1819
#define DF_ANT_NUM_MIN 2
@@ -359,6 +360,18 @@ void radio_switch_complete_and_phy_end_disable(void)
359360
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
360361
}
361362

363+
void radio_switch_complete_and_phy_end_b2b_tx(uint8_t phy_curr, uint8_t flags_curr,
364+
uint8_t phy_next, uint8_t flags_next)
365+
{
366+
#if defined(CONFIG_BT_CTLR_TIFS_HW)
367+
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_PHYEND_DISABLE_Msk |
368+
RADIO_SHORTS_DISABLED_TXEN_Msk;
369+
#else /* !CONFIG_BT_CTLR_TIFS_HW */
370+
NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_PHYEND_DISABLE_Msk;
371+
sw_switch(SW_SWITCH_TX, SW_SWITCH_TX, phy_curr, flags_curr, phy_next, flags_next);
372+
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
373+
}
374+
362375
void radio_df_iq_data_packet_set(uint8_t *buffer, size_t len)
363376
{
364377
nrf_radio_dfe_buffer_set(NRF_RADIO, (uint32_t *)buffer, len);

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_df.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ void radio_df_reset(void);
5050
/* Completes switching and enables shortcut between PHYEND and DISABLE events */
5151
void radio_switch_complete_and_phy_end_disable(void);
5252

53+
/* Completes switching and enables shortcut between PHYEND and TXEN events */
54+
void radio_switch_complete_and_phy_end_b2b_tx(uint8_t phy_curr, uint8_t flags_curr,
55+
uint8_t phy_next, uint8_t flags_next);
56+
5357
/* Enables CTE inline configuration to automatically setup sampling and
5458
* switching according to CTEInfo in received PDU.
5559
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright (c) 2021 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#define SW_SWITCH_RX 0
8+
#define SW_SWITCH_TX 1
9+
#define SW_SWITCH_PHY_1M 0
10+
#define SW_SWITCH_FLAGS_DONTCARE 0
11+
12+
void sw_switch(uint8_t dir_curr, uint8_t dir_next, uint8_t phy_curr, uint8_t flags_curr,
13+
uint8_t phy_next, uint8_t flags_next);

0 commit comments

Comments
 (0)