Skip to content

Commit 36bec35

Browse files
ppryga-nordiccfriedt
authored andcommitted
Bluetooth: radio: move radio_df_cte_inline_set_enabled to radio.c
To enable runtime parsing of PDU to find CTEInfo field CTEINLINE mode has to be enabled. Thanks to that it is possible to verify if the PDU has allowed CTE type e.g. for periodic advertising synchornization. To run CTEInfo parsing other parametrers of CTEINLINE are not relevant. If Radio is set to disable after PDU END event the CTE sampling will not be processed. The commit moves the radio_df_cte_inline_set_enable function to make it accessible even the direction finding features are disabled. Signed-off-by: Piotr Pryga <[email protected]>
1 parent 587ad45 commit 36bec35

File tree

5 files changed

+52
-40
lines changed

5 files changed

+52
-40
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ll_sw/pdu.h"
2323

2424
#include "radio_internal.h"
25+
#include "radio_df.h"
2526

2627
#if defined(CONFIG_BT_CTLR_GPIO_PA_PIN)
2728
#if ((CONFIG_BT_CTLR_GPIO_PA_PIN) > 31)
@@ -1508,3 +1509,38 @@ void radio_ar_resolve(uint8_t *addr)
15081509
AAR_ENABLE_ENABLE_Msk;
15091510

15101511
}
1512+
1513+
/* @brief Function configures CTE inline register to start sampling of CTE
1514+
* according to information parsed from CTEInfo field of received PDU.
1515+
*
1516+
* @param[in] cte_info_in_s1 Informs where to expect CTEInfo field in PDU:
1517+
* in S1 for data pdu, not in S1 for adv. PDU
1518+
*/
1519+
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1)
1520+
{
1521+
#if defined(HAS_CTEINLINE_SUPPORT)
1522+
const nrf_radio_cteinline_conf_t inline_conf = {
1523+
.enable = true,
1524+
/* Indicates whether CTEInfo is in S1 byte or not. */
1525+
.info_in_s1 = cte_info_in_s1,
1526+
/* Enable or disable switching and sampling when CRC is not OK. */
1527+
#if defined(CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC)
1528+
.err_handling = true,
1529+
#else
1530+
.err_handling = false,
1531+
#endif /* CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC */
1532+
/* Maximum range of CTE time. 20 * 8us according to BT spec.*/
1533+
.time_range = NRF_RADIO_CTEINLINE_TIME_RANGE_20,
1534+
/* Spacing between samples for 1us AoD or AoA is set to 2us. */
1535+
.rx1us = NRF_RADIO_CTEINLINE_RX_MODE_2US,
1536+
/* Spacing between samples for 2us AoD or AoA is set to 4us. */
1537+
.rx2us = NRF_RADIO_CTEINLINE_RX_MODE_4US,
1538+
/**< S0 bit pattern to match all types of adv. PDUs */
1539+
.s0_pattern = 0x0,
1540+
/**< S0 bit mask set to don't match any bit in SO octet */
1541+
.s0_mask = 0x0
1542+
};
1543+
1544+
nrf_radio_cteinline_configure(NRF_RADIO, &inline_conf);
1545+
#endif /* HAS_CTEINLINE_SUPPORT */
1546+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,8 @@ uint32_t radio_ar_match_get(void);
111111
void radio_ar_status_reset(void);
112112
uint32_t radio_ar_has_match(void);
113113
void radio_ar_resolve(uint8_t *addr);
114+
115+
/* Enables CTE inline configuration to automatically setup sampling and
116+
* switching according to CTEInfo in received PDU.
117+
*/
118+
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1);

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

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
#include <sys/util_macro.h>
1212
#include <hal/nrf_radio.h>
1313
#include <hal/nrf_gpio.h>
14+
#include <hal/ccm.h>
1415

1516
#include "radio_nrf5.h"
17+
#include "radio.h"
1618
#include "radio_df.h"
1719
#include "radio_internal.h"
1820

19-
/* Devicetree node identifier for the radio node. */
20-
#define RADIO_NODE DT_NODELABEL(radio)
21-
2221
/* Value to set for unconnected antenna GPIO pins. */
2322
#define DFE_PSEL_NOT_SET 0xFF
2423
/* Number of PSEL_DFEGPIO[n] registers in the radio peripheral. */
@@ -239,39 +238,6 @@ void radio_df_mode_set_aod(void)
239238
radio_df_mode_set(NRF_RADIO_DFE_OP_MODE_AOD);
240239
}
241240

242-
/* @brief Function configures CTE inline register to start sampling of CTE
243-
* according to information parsed from CTEInfo filed of received PDU.
244-
*
245-
* @param[in] cte_info_in_s1 Informs where to expect CTEInfo filed in PDU:
246-
* in S1 for data pdu, not in S1 for adv. PDU
247-
*/
248-
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1)
249-
{
250-
const nrf_radio_cteinline_conf_t inline_conf = {
251-
.enable = true,
252-
/* Indicates whether CTEInfo is in S1 byte or not. */
253-
.info_in_s1 = cte_info_in_s1,
254-
/* Enable or disable switching and sampling when CRC is not OK. */
255-
#if defined(CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC)
256-
.err_handling = true,
257-
#else
258-
.err_handling = false,
259-
#endif /* CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC */
260-
/* Maximum range of CTE time. 20 * 8us according to BT spec.*/
261-
.time_range = NRF_RADIO_CTEINLINE_TIME_RANGE_20,
262-
/* Spacing between samples for 1us AoD or AoA is set to 2us. */
263-
.rx1us = NRF_RADIO_CTEINLINE_RX_MODE_2US,
264-
/* Spacing between samples for 2us AoD or AoA is set to 4us. */
265-
.rx2us = NRF_RADIO_CTEINLINE_RX_MODE_4US,
266-
/**< S0 bit pattern to match all types of adv. PDUs */
267-
.s0_pattern = 0x0,
268-
/**< S0 bit mask set to don't match any bit in SO octet */
269-
.s0_mask = 0x0
270-
};
271-
272-
nrf_radio_cteinline_configure(NRF_RADIO, &inline_conf);
273-
}
274-
275241
static void radio_df_cte_inline_set_disabled(void)
276242
{
277243
NRF_RADIO->CTEINLINECONF &= ~RADIO_CTEINLINECONF_CTEINLINECTRLEN_Msk;

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
/* Devicetree node identifier for the radio node. */
8+
#define RADIO_NODE DT_NODELABEL(radio)
9+
/* Check if radio has hardware support to parse PDU for CTE info */
10+
#if IS_ENABLED(DT_PROP_OR(RADIO_NODE, dfe_supported, 0))
11+
#define HAS_CTEINLINE_SUPPORT
12+
#endif
13+
714
/* Function configures Radio with information about GPIO pins that may be
815
* used to drive antenna switching during CTE Tx/RX.
916
*/
@@ -54,10 +61,6 @@ void radio_switch_complete_and_phy_end_disable(void);
5461
void radio_switch_complete_and_phy_end_b2b_tx(uint8_t phy_curr, uint8_t flags_curr,
5562
uint8_t phy_next, uint8_t flags_next);
5663

57-
/* Enables CTE inline configuration to automatically setup sampling and
58-
* switching according to CTEInfo in received PDU.
59-
*/
60-
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1);
6164
/* Set buffer to store IQ samples collected during CTE sampling */
6265
void radio_df_iq_data_packet_set(uint8_t *buffer, size_t len);
6366
/* Get number of stored IQ samples during CTE receive */

subsys/bluetooth/controller/ll_sw/ull_sync_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ struct ll_sync_set {
3333
};
3434
} node_rx_lost;
3535

36+
struct node_rx_hdr *node_rx_sync_estab;
37+
3638
#if defined(CONFIG_BT_CTLR_SYNC_ISO)
3739
struct {
3840
struct node_rx_hdr *node_rx_estab;

0 commit comments

Comments
 (0)