Skip to content

Commit 515f953

Browse files
ppryga-nordicnashif
authored andcommitted
Bluetooth: controller: radio: Add DF configuration to enable CTE TX
Add set of functions that will make possible to configure radio Direction Finding Extension to transmit CTE for periodic advertising. Some of the new Radio API functions are provided as separate functions changing the same Radio peripheral registers, e.g. radio_df_mode_set_aoa, radio_df_mode_set_aod. This is done on purpose and is related with lack of DFE in nrf52_bsim. To avoid use of conditionally compiled constants to represent e.g. CTE mode; separate functions were introduced. Thanks to that DF unit tests are able to compile successfully without changes in nrf52_bsim platform. Also if DFE is added to nrf52_bsim there is no need to change the code until it is desired. Signed-off-by: Piotr Pryga <[email protected]>
1 parent b56a2d1 commit 515f953

File tree

3 files changed

+153
-1
lines changed

3 files changed

+153
-1
lines changed

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <sys/util_macro.h>
1111
#include <hal/nrf_radio.h>
1212

13+
#include "radio_nrf5.h"
1314
#include "radio_df.h"
1415

1516
/* @brief Minimum antennas number required if antenna switching is enabled */
@@ -134,3 +135,79 @@ uint8_t radio_df_ant_num_get(void)
134135
return 0;
135136
#endif
136137
}
138+
139+
static inline void radio_df_mode_set(uint8_t mode)
140+
{
141+
NRF_RADIO->DFEMODE &= ~RADIO_DFEMODE_DFEOPMODE_Msk;
142+
NRF_RADIO->DFEMODE |= ((mode << RADIO_DFEMODE_DFEOPMODE_Pos)
143+
& RADIO_DFEMODE_DFEOPMODE_Msk);
144+
}
145+
146+
void radio_df_mode_set_aoa(void)
147+
{
148+
radio_df_mode_set(NRF_RADIO_DFE_OP_MODE_AOA);
149+
}
150+
151+
void radio_df_mode_set_aod(void)
152+
{
153+
radio_df_mode_set(NRF_RADIO_DFE_OP_MODE_AOD);
154+
}
155+
156+
void radio_df_cte_inline_set(uint8_t enable)
157+
{
158+
NRF_RADIO->CTEINLINECONF &= ~RADIO_CTEINLINECONF_CTEINLINECTRLEN_Msk;
159+
NRF_RADIO->CTEINLINECONF |= ((enable <<
160+
RADIO_CTEINLINECONF_CTEINLINECTRLEN_Pos)
161+
& RADIO_CTEINLINECONF_CTEINLINECTRLEN_Msk);
162+
}
163+
164+
void radio_df_cte_length_set(uint8_t value)
165+
{
166+
NRF_RADIO->DFECTRL1 &= ~RADIO_DFECTRL1_NUMBEROF8US_Msk;
167+
NRF_RADIO->DFECTRL1 |= ((value << RADIO_DFECTRL1_NUMBEROF8US_Pos)
168+
& RADIO_DFECTRL1_NUMBEROF8US_Msk);
169+
}
170+
171+
void radio_df_ant_switch_pattern_clear(void)
172+
{
173+
NRF_RADIO->CLEARPATTERN = RADIO_CLEARPATTERN_CLEARPATTERN_Clear;
174+
}
175+
176+
static inline void radio_df_ant_switch_spacing_set(uint8_t spacing)
177+
{
178+
NRF_RADIO->DFECTRL1 &= ~RADIO_DFECTRL1_TSWITCHSPACING_Msk;
179+
NRF_RADIO->DFECTRL1 |= ((spacing << RADIO_DFECTRL1_TSWITCHSPACING_Pos)
180+
& RADIO_DFECTRL1_TSWITCHSPACING_Msk);
181+
}
182+
183+
void radio_df_ant_switch_spacing_set_2us(void)
184+
{
185+
radio_df_ant_switch_spacing_set(RADIO_DFECTRL1_TSWITCHSPACING_2us);
186+
}
187+
188+
void radio_df_ant_switch_spacing_set_4us(void)
189+
{
190+
radio_df_ant_switch_spacing_set(RADIO_DFECTRL1_TSWITCHSPACING_4us);
191+
}
192+
193+
void radio_df_ant_switch_pattern_set(uint8_t pattern)
194+
{
195+
NRF_RADIO->SWITCHPATTERN = pattern;
196+
}
197+
198+
void radio_df_reset(void)
199+
{
200+
radio_df_mode_set(RADIO_DFEMODE_DFEOPMODE_Disabled);
201+
radio_df_cte_inline_set(RADIO_CTEINLINECONF_CTEINLINECTRLEN_Disabled);
202+
radio_df_ant_switch_pattern_clear();
203+
}
204+
205+
void radio_switch_complete_and_phy_end_disable(void)
206+
{
207+
NRF_RADIO->SHORTS =
208+
(RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_PHYEND_DISABLE_Msk);
209+
210+
#if !defined(CONFIG_BT_CTLR_TIFS_HW)
211+
hal_radio_sw_switch_disable();
212+
#endif /* !CONFIG_BT_CTLR_TIFS_HW */
213+
}

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,30 @@
66

77
/* Performs steps related with DF antennae configuration. */
88
void radio_df_ant_configure(void);
9-
/* Provides number of available antennae for Direction Finding */
9+
/* Provides number of available antennas for Direction Finding. */
1010
uint8_t radio_df_ant_num_get(void);
11+
12+
/* Sets Direction Finding AOA mode. */
13+
void radio_df_mode_set_aoa(void);
14+
/* Sets Direction Finding AOD mode. */
15+
void radio_df_mode_set_aod(void);
16+
/* Sets inline configuration enabled or disabled for receive of CTE. */
17+
void radio_df_cte_inline_set(uint8_t eanble);
18+
/* Sets length of the CTE for transmission. */
19+
void radio_df_cte_length_set(uint8_t value);
20+
/* Clears antenna switch pattern. */
21+
void radio_df_ant_switch_pattern_clear(void);
22+
/* Set antenna switch spacing to 2[us] */
23+
void radio_df_ant_switch_spacing_set_2us(void);
24+
/* Set antenna switch spacing to 4[us] */
25+
void radio_df_ant_switch_spacing_set_4us(void);
26+
/* Set antenna switch pattern. Pay attention, paterns are added to
27+
* Radio internal list. Before start of new patterns clear the list
28+
* by call to @ref radio_df_ant_switch_pattern_clear.
29+
*/
30+
void radio_df_ant_switch_pattern_set(uint8_t pattern);
31+
/* Resets Direction Finding radio configuration */
32+
void radio_df_reset(void);
33+
34+
/* Completes switching and enables shortcut between PHYEND and DISABLE events */
35+
void radio_switch_complete_and_phy_end_disable(void);

tests/bluetooth/df/src/radio_df_stub.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,53 @@ uint8_t radio_df_ant_num_get(void)
1515
{
1616
return 0;
1717
}
18+
19+
void radio_df_cte_inline_set(uint8_t enable)
20+
{
21+
22+
}
23+
24+
void radio_df_cte_length_set(uint8_t value)
25+
{
26+
27+
}
28+
29+
void radio_df_ant_switch_pattern_clear(void)
30+
{
31+
32+
}
33+
34+
void radio_df_ant_switch_pattern_set(uint8_t pattern)
35+
{
36+
37+
}
38+
39+
void radio_df_reset(void)
40+
{
41+
42+
}
43+
44+
void radio_switch_complete_and_phy_end_disable(void)
45+
{
46+
47+
}
48+
49+
void radio_df_ant_switch_spacing_set_2us(void)
50+
{
51+
52+
}
53+
54+
void radio_df_ant_switch_spacing_set_4us(void)
55+
{
56+
57+
}
58+
59+
void radio_df_mode_set_aoa(void)
60+
{
61+
62+
}
63+
64+
void radio_df_mode_set_aod(void)
65+
{
66+
67+
}

0 commit comments

Comments
 (0)