Commit 36bec359 authored by Piotr Pryga's avatar Piotr Pryga Committed by Christopher Friedt
Browse files

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: default avatarPiotr Pryga <piotr.pryga@nordicsemi.no>
parent 587ad456
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "ll_sw/pdu.h"

#include "radio_internal.h"
#include "radio_df.h"

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

}

/* @brief Function configures CTE inline register to start sampling of CTE
 *        according to information parsed from CTEInfo field of received PDU.
 *
 * @param[in] cte_info_in_s1    Informs where to expect CTEInfo field in PDU:
 *                              in S1 for data pdu, not in S1 for adv. PDU
 */
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1)
{
#if defined(HAS_CTEINLINE_SUPPORT)
	const nrf_radio_cteinline_conf_t inline_conf = {
		.enable = true,
		/* Indicates whether CTEInfo is in S1 byte or not. */
		.info_in_s1 = cte_info_in_s1,
	/* Enable or disable switching and sampling when CRC is not OK. */
#if defined(CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC)
		.err_handling = true,
#else
		.err_handling = false,
#endif /* CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC */
		/* Maximum range of CTE time. 20 * 8us according to BT spec.*/
		.time_range = NRF_RADIO_CTEINLINE_TIME_RANGE_20,
		/* Spacing between samples for 1us AoD or AoA is set to 2us. */
		.rx1us = NRF_RADIO_CTEINLINE_RX_MODE_2US,
		/* Spacing between samples for 2us AoD or AoA is set to 4us. */
		.rx2us = NRF_RADIO_CTEINLINE_RX_MODE_4US,
		/**< S0 bit pattern to match all types of adv. PDUs */
		.s0_pattern = 0x0,
		/**< S0 bit mask set to don't match any bit in SO octet */
		.s0_mask = 0x0
	};

	nrf_radio_cteinline_configure(NRF_RADIO, &inline_conf);
#endif /* HAS_CTEINLINE_SUPPORT */
}
+5 −0
Original line number Diff line number Diff line
@@ -111,3 +111,8 @@ uint32_t radio_ar_match_get(void);
void radio_ar_status_reset(void);
uint32_t radio_ar_has_match(void);
void radio_ar_resolve(uint8_t *addr);

/* Enables CTE inline configuration to automatically setup sampling and
 * switching according to CTEInfo in received PDU.
 */
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1);
+2 −36
Original line number Diff line number Diff line
@@ -11,14 +11,13 @@
#include <sys/util_macro.h>
#include <hal/nrf_radio.h>
#include <hal/nrf_gpio.h>
#include <hal/ccm.h>

#include "radio_nrf5.h"
#include "radio.h"
#include "radio_df.h"
#include "radio_internal.h"

/* Devicetree node identifier for the radio node. */
#define RADIO_NODE DT_NODELABEL(radio)

/* Value to set for unconnected antenna GPIO pins. */
#define DFE_PSEL_NOT_SET 0xFF
/* Number of PSEL_DFEGPIO[n] registers in the radio peripheral. */
@@ -239,39 +238,6 @@ void radio_df_mode_set_aod(void)
	radio_df_mode_set(NRF_RADIO_DFE_OP_MODE_AOD);
}

/* @brief Function configures CTE inline register to start sampling of CTE
 *        according to information parsed from CTEInfo filed of received PDU.
 *
 * @param[in] cte_info_in_s1    Informs where to expect CTEInfo filed in PDU:
 *                              in S1 for data pdu, not in S1 for adv. PDU
 */
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1)
{
	const nrf_radio_cteinline_conf_t inline_conf = {
		.enable = true,
		/* Indicates whether CTEInfo is in S1 byte or not. */
		.info_in_s1 = cte_info_in_s1,
		/* Enable or disable switching and sampling when CRC is not OK. */
#if defined(CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC)
		.err_handling = true,
#else
		.err_handling = false,
#endif /* CONFIG_BT_CTLR_DF_SAMPLE_CTE_FOR_PDU_WITH_BAD_CRC */
		/* Maximum range of CTE time. 20 * 8us according to BT spec.*/
		.time_range = NRF_RADIO_CTEINLINE_TIME_RANGE_20,
		/* Spacing between samples for 1us AoD or AoA is set to 2us. */
		.rx1us = NRF_RADIO_CTEINLINE_RX_MODE_2US,
		/* Spacing between samples for 2us AoD or AoA is set to 4us. */
		.rx2us = NRF_RADIO_CTEINLINE_RX_MODE_4US,
		/**< S0 bit pattern to match all types of adv. PDUs */
		.s0_pattern = 0x0,
		/**< S0 bit mask set to don't match any bit in SO octet */
		.s0_mask = 0x0
	};

	nrf_radio_cteinline_configure(NRF_RADIO, &inline_conf);
}

static void radio_df_cte_inline_set_disabled(void)
{
	NRF_RADIO->CTEINLINECONF &= ~RADIO_CTEINLINECONF_CTEINLINECTRLEN_Msk;
+7 −4
Original line number Diff line number Diff line
@@ -4,6 +4,13 @@
 * SPDX-License-Identifier: Apache-2.0
 */

/* Devicetree node identifier for the radio node. */
#define RADIO_NODE DT_NODELABEL(radio)
/* Check if radio has hardware support to parse PDU for CTE info */
#if IS_ENABLED(DT_PROP_OR(RADIO_NODE, dfe_supported, 0))
#define HAS_CTEINLINE_SUPPORT
#endif

/* Function configures Radio with information about GPIO pins that may be
 * used to drive antenna switching during CTE Tx/RX.
 */
@@ -54,10 +61,6 @@ void radio_switch_complete_and_phy_end_disable(void);
void radio_switch_complete_and_phy_end_b2b_tx(uint8_t phy_curr, uint8_t flags_curr,
					      uint8_t phy_next, uint8_t flags_next);

/* Enables CTE inline configuration to automatically setup sampling and
 * switching according to CTEInfo in received PDU.
 */
void radio_df_cte_inline_set_enabled(bool cte_info_in_s1);
/* Set buffer to store IQ samples collected during CTE sampling */
void radio_df_iq_data_packet_set(uint8_t *buffer, size_t len);
/* Get number of stored IQ samples during CTE receive */
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ struct ll_sync_set {
		};
	} node_rx_lost;

	struct node_rx_hdr *node_rx_sync_estab;

#if defined(CONFIG_BT_CTLR_SYNC_ISO)
	struct {
		struct node_rx_hdr *node_rx_estab;