Skip to content
Permalink
Browse files

Bluetooth: controller: Fix regression in Coded PHY CI Change

Fix the regression in Coded PHY CI change implementation
introduced by reverting the commit 9d1ca9c ("Bluetooth:
controller: remove redundant PPI channel and TIMER CC").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
  • Loading branch information...
cvinayak authored and nashif committed Feb 26, 2019
1 parent d68666f commit f35dd8ece81af90443f943c781ff49e892774e23
@@ -388,9 +388,9 @@ static void sw_switch(u8_t dir, u8_t phy_curr, u8_t flags_curr, u8_t phy_next,
/* Switching to TX after RX on LE Coded PHY. */

u8_t ppi_en =
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI;
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI(sw_tifs_toggle);
u8_t cc_s2 =
SW_SWITCH_TIMER_EVTS_COMP_S2_BASE;
SW_SWITCH_TIMER_S2_EVTS_COMP(sw_tifs_toggle);
u8_t ppi_dis =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(
sw_tifs_toggle);
@@ -416,11 +416,6 @@ static void sw_switch(u8_t dir, u8_t phy_curr, u8_t flags_curr, u8_t phy_next,
HAL_SW_SWITCH_RADIO_ENABLE_PPI_REGISTER_TASK(ppi_en) =
HAL_SW_SWITCH_RADIO_ENABLE_PPI_TASK_TX;

/* Include PPI for S2 timing in the active group */
NRF_PPI->CHG[SW_SWITCH_TIMER_TASK_GROUP(
sw_tifs_toggle)] |=
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_INCLUDE;

/* Wire the Group task disable
* to the S2 EVENTS_COMPARE.
*/
@@ -446,14 +441,17 @@ static void sw_switch(u8_t dir, u8_t phy_curr, u8_t flags_curr, u8_t phy_next,
BIT(HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI));
} else {
/* Switching to TX after RX on LE 1M/2M PHY */
u8_t ppi_en =
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI(sw_tifs_toggle);
u8_t ppi_dis =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(
sw_tifs_toggle);

/* Exclude PPI for S2 timing from the active group */
NRF_PPI->CHG[SW_SWITCH_TIMER_TASK_GROUP(
sw_tifs_toggle)] &=
~(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_INCLUDE);
/* Invalidate PPI used when RXing on LE Coded PHY. */
HAL_SW_SWITCH_RADIO_ENABLE_PPI_REGISTER_EVT(ppi_en)
= 0;
HAL_SW_SWITCH_RADIO_ENABLE_PPI_REGISTER_TASK(ppi_en)
= 0;

/* Wire the Group task disable
* to the default EVENTS_COMPARE.
@@ -480,22 +478,25 @@ static void sw_switch(u8_t dir, u8_t phy_curr, u8_t flags_curr, u8_t phy_next,
#if defined(CONFIG_BT_CTLR_PHY_CODED)
#if defined(CONFIG_SOC_NRF52840)
if (1) {
u8_t ppi_en =
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI(
sw_tifs_toggle);
u8_t ppi_dis =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(
sw_tifs_toggle);

HAL_SW_SWITCH_RADIO_ENABLE_PPI_REGISTER_EVT(
ppi_en) = 0;
HAL_SW_SWITCH_RADIO_ENABLE_PPI_REGISTER_TASK(
ppi_en) = 0;

HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_EVT(
ppi_dis) =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_EVT(cc);
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_REGISTER_TASK(
ppi_dis) =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_TASK(
sw_tifs_toggle);

/* Exclude PPI for S2 timing from the active group */
NRF_PPI->CHG[SW_SWITCH_TIMER_TASK_GROUP(
sw_tifs_toggle)] &=
~(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_INCLUDE);
}
#endif /* CONFIG_SOC_NRF52840 */
#endif /* CONFIG_BT_CTLR_PHY_CODED */
@@ -708,10 +709,6 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
hal_sw_switch_timer_clear_ppi_config();

#if !defined(CONFIG_BT_CTLR_PHY_CODED) || !defined(CONFIG_SOC_NRF52840)
/* NOTE: PPI channel group disable is setup explicitly in sw_switch
* function when Coded PHY on nRF52840 is supported.
*/

nrf_ppi_channel_endpoint_setup(
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(0),
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_EVT(
@@ -724,14 +721,22 @@ u32_t radio_tmr_start(u8_t trx, u32_t ticks_start, u32_t remainder)
SW_SWITCH_TIMER_EVTS_COMP(1)),
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_TASK(1));

#endif /* !CONFIG_BT_CTLR_PHY_CODED || !CONFIG_SOC_NRF52840 */

NRF_PPI->CHG[SW_SWITCH_TIMER_TASK_GROUP(0)] =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_0_INCLUDE |
HAL_SW_SWITCH_RADIO_ENABLE_PPI_0_INCLUDE;
NRF_PPI->CHG[SW_SWITCH_TIMER_TASK_GROUP(1)] =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_1_INCLUDE |
HAL_SW_SWITCH_RADIO_ENABLE_PPI_1_INCLUDE;
#else /* CONFIG_BT_CTLR_PHY_CODED && CONFIG_SOC_NRF52840 */
NRF_PPI->CHG[SW_SWITCH_TIMER_TASK_GROUP(0)] =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_0_INCLUDE |
HAL_SW_SWITCH_RADIO_ENABLE_PPI_0_INCLUDE |
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_0_INCLUDE;
NRF_PPI->CHG[SW_SWITCH_TIMER_TASK_GROUP(1)] =
HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_1_INCLUDE |
HAL_SW_SWITCH_RADIO_ENABLE_PPI_1_INCLUDE |
HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_1_INCLUDE;
#endif /* CONFIG_BT_CTLR_PHY_CODED && CONFIG_SOC_NRF52840 */
#endif /* !CONFIG_BT_CTLR_TIFS_HW */

return remainder;
@@ -397,19 +397,32 @@ static inline void hal_radio_rxen_on_sw_switch(u8_t ppi)
}

#if defined(CONFIG_SOC_NRF52840)
/* The 2 adjacent TIMER EVENTS_COMPARE event offsets used for implementing
* SW_SWITCH_TIMER-based auto-switch for TIFS, when receiving in LE Coded PHY.
* 'index' must be 0 or 1.
*/
#define SW_SWITCH_TIMER_S2_EVTS_COMP(index) \
(SW_SWITCH_TIMER_EVTS_COMP_S2_BASE + index)

/* Wire the SW SWITCH TIMER EVENTS_COMPARE[<cc_offset>] event
* to RADIO TASKS_TXEN/RXEN task.
*/
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI 16
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_INCLUDE \
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE 16
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI(index) \
(HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_BASE + index)
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_0_INCLUDE \
((PPI_CHG_CH16_Included << PPI_CHG_CH16_Pos) & PPI_CHG_CH16_Msk)
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_EXCLUDE \
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_0_EXCLUDE \
((PPI_CHG_CH16_Excluded << PPI_CHG_CH16_Pos) & PPI_CHG_CH16_Msk)
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_1_INCLUDE \
((PPI_CHG_CH17_Included << PPI_CHG_CH17_Pos) & PPI_CHG_CH17_Msk)
#define HAL_SW_SWITCH_RADIO_ENABLE_S2_PPI_1_EXCLUDE \
((PPI_CHG_CH17_Excluded << PPI_CHG_CH17_Pos) & PPI_CHG_CH17_Msk)

/* Cancel the SW switch timer running considering S8 timing:
* wire the RADIO EVENTS_RATEBOOST event to SW_SWITCH_TIMER TASKS_CAPTURE task.
*/
#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI 17
#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI 18
#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI_REGISTER_EVT \
NRF_PPI->CH[HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI].EEP
#define HAL_SW_SWITCH_TIMER_S8_DISABLE_PPI_EVT \

0 comments on commit f35dd8e

Please sign in to comment.
You can’t perform that action at this time.