Skip to content

Commit

Permalink
Bluetooth: Controller: Fix single timer direction finding support
Browse files Browse the repository at this point in the history
Fix use of single timer software tIFS switching to support
direction finding.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
  • Loading branch information
cvinayak authored and kartben committed Feb 28, 2025
1 parent 7520742 commit ec69ccb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static inline void hal_trigger_crypt_by_bcmatch_ppi_config(void)
#if !defined(CONFIG_BT_CTLR_TIFS_HW)
/* DPPI setup used for SW-based auto-switching during TIFS. */

#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER)
#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER) && !defined(CONFIG_BT_CTLR_DF)
#define HAL_NRF_RADIO_TIMER_CLEAR_EVENT_END HAL_NRF_RADIO_EVENT_END
#define HAL_RADIO_GROUP_TASK_ENABLE_PUBLISH_END HAL_RADIO_PUBLISH_END
#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER || CONFIG_BT_CTLR_DF */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,50 +63,50 @@
*/
#define HAL_RADIO_ISR_LATENCY_MAX_US 80U

#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX)
/* Delay of CCM TASKS_CRYPT start in number of bits for Radio Bit counter */
#define CCM_TASKS_CRYPT_DELAY_BITS 3
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RX */
#define SW_SWITCH_TIMER_EVTS_COMP_BASE 4

#if defined(CONFIG_BT_CTLR_PHY_CODED)
#define SW_SWITCH_TIMER_EVTS_COMP_BASE 4
#define SW_SWITCH_TIMER_EVTS_COMP_S2_BASE 6
#endif /* !CONFIG_BT_CTLR_PHY_CODED */

#if defined(CONFIG_BT_CTLR_DF)
#if defined(CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE)
/* Allocate 2 adjacent channels for PHYEND delay compensation. Use the same channels as for
* PHY CODED S2. The CTEINLINE may not be enabled for PHY CODED so PHYEND event is generated
* at the same instant as END event. Hence the channels are used interchangeably.
* That saves from use of another timer.
*/
#define SW_SWITCH_TIMER_EVTS_COMP_PHYEND_DELAY_COMPENSATION_BASE 6
#endif /* CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE */

/* Wrapper for EVENTS_END event generated by Radio peripheral at the very end of the transmission
* or reception of a PDU on air. In case of regular PDU it is generated when last bit of CRC is
* received or transmitted.
*
* When direction finding is enabled a PDU may include Constant Tone Extension at its end. For PDU
* including CTE EVENTS_PHYEND event is generated at very end of a PDU. In case there is no CTE in
* a PDU the EVENTS_PHYEND event is generated in the same instant as EVENTS_END event.
*/
#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_END
#define HAL_NRF_RADIO_TRX_EVENT_END HAL_NRF_RADIO_EVENT_END
#define HAL_RADIO_TRX_EVENTS_END HAL_RADIO_EVENTS_PHYEND
#define HAL_NRF_RADIO_TRX_EVENT_END HAL_NRF_RADIO_EVENT_PHYEND

/* Wrapper for RADIO_SHORTS mask connecting EVENTS_END to EVENTS_DISABLE.
* This is a default shortcut used to automatically disable Radio after end of PDU.
/* Wrapper for RADIO_SHORTS mask connecting EVENTS_PHYEND to EVENTS_DISABLE.
* This is a mask for SOC that has Direction Finding Extension in a Radio peripheral.
* It enables shortcut for EVENTS_PHYEND event generated at very end to Radio EVENTS_DISABLE event.
* In case there is a CTE in a PDU then EVENTS_PHYEND event is generated after the CTE.
* If there is no CTE, it is generated in the same instant as EVENTS_END.
*/
#define NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk HAL_RADIO_SHORTS_TRX_END_DISABLE_Msk

#define HAL_EVENT_TIMER_TRX_CC_OFFSET 0
#define HAL_EVENT_TIMER_TRX_EVENT NRF_TIMER_EVENT_COMPARE0
#define HAL_EVENT_TIMER_READY_TASK NRF_TIMER_TASK_CAPTURE0

#define HAL_EVENT_TIMER_HCTO_CC_OFFSET 1
#define HAL_EVENT_TIMER_HCTO_EVENT NRF_TIMER_EVENT_COMPARE1
#define HAL_EVENT_TIMER_ADDRESS_TASK NRF_TIMER_TASK_CAPTURE1

#define HAL_EVENT_TIMER_TRX_END_CC_OFFSET 2
#define HAL_EVENT_TIMER_TRX_END_TASK NRF_TIMER_TASK_CAPTURE2

#define HAL_EVENT_TIMER_DEFERRED_TRX_CC_OFFSET 2
#define HAL_EVENT_TIMER_DEFERRED_TX_EVENT NRF_TIMER_EVENT_COMPARE2

#define HAL_EVENT_TIMER_SAMPLE_CC_OFFSET 3
#define HAL_EVENT_TIMER_SAMPLE_TASK NRF_TIMER_TASK_CAPTURE3
#define NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk HAL_RADIO_SHORTS_TRX_PHYEND_DISABLE_Msk

#define HAL_EVENT_TIMER_PA_LNA_CC_OFFSET 2
#define HAL_EVENT_TIMER_PA_LNA_PDN_CC_OFFSET 3
/* Delay of EVENTS_PHYEND event on receive PDU without CTE included when CTEINLINE is enabled */
#define RADIO_EVENTS_PHYEND_DELAY_US 16

#else /* !CONFIG_BT_CTLR_PHY_CODED */
#define SW_SWITCH_TIMER_EVTS_COMP_BASE 4
#if defined(CONFIG_BT_CTLR_DF_CONN_CTE_RX)
/* Delay of CCM TASKS_CRYPT start in number of bits for Radio Bit counter */
#define CCM_TASKS_CRYPT_DELAY_BITS 3
#endif /* CONFIG_BT_CTLR_DF_CONN_CTE_RX */

#else /* !CONFIG_BT_CTLR_DF */
/* Wrapper for EVENTS_END event generated by Radio peripheral at the very end of the transmission
* or reception of a PDU on air. In case of regular PDU it is generated when last bit of CRC is
* received or transmitted.
Expand All @@ -118,6 +118,7 @@
* This is a default shortcut used to automatically disable Radio after end of PDU.
*/
#define NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk HAL_RADIO_SHORTS_TRX_END_DISABLE_Msk
#endif /* !CONFIG_BT_CTLR_DF */

#define HAL_EVENT_TIMER_TRX_CC_OFFSET 0
#define HAL_EVENT_TIMER_TRX_EVENT NRF_TIMER_EVENT_COMPARE0
Expand All @@ -138,7 +139,6 @@

#define HAL_EVENT_TIMER_PA_LNA_CC_OFFSET 2
#define HAL_EVENT_TIMER_PA_LNA_PDN_CC_OFFSET 3
#endif /* !CONFIG_BT_CTLR_PHY_CODED */

#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */
#define EVENT_TIMER_ID 0
Expand All @@ -158,7 +158,6 @@
#endif /* !CONFIG_BT_CTLR_PHY_CODED */

#if defined(CONFIG_BT_CTLR_DF)

#if defined(CONFIG_BT_CTLR_DF_PHYEND_OFFSET_COMPENSATION_ENABLE)
/* Allocate 2 adjacent channels for PHYEND delay compensation. Use the same channels as for
* PHY CODED S2. The CTEINLINE may not be enabled for PHY CODED so PHYEND event is generated
Expand Down

0 comments on commit ec69ccb

Please sign in to comment.