Bluetooth: Controller: nRF54Lx: Use nrfx interface for bsim use (2/4)
Use nrfx interface for register access with sideeffects to facilitate bsim use. Remove CMSIS interface use, was replaced with nrf_grtc interface in previous commit. 4 part commits: 1. Add nrf_grtc interface. 2. Remove CMSIS interface use. 3. Add nrf_grtc interface, once missing bsim port available. 4. Remove CMSIS interface use, replaced by bsim port. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
24465ec160
commit
d5e75ce755
3 changed files with 0 additions and 36 deletions
|
@ -34,7 +34,6 @@ void cntr_init(void)
|
|||
GRTC_MODE_SYSCOUNTEREN_Pos) &
|
||||
GRTC_MODE_SYSCOUNTEREN_Msk;
|
||||
|
||||
NRF_GRTC->TASKS_CLEAR = 1U;
|
||||
nrf_grtc_task_trigger(NRF_GRTC, NRF_GRTC_TASK_CLEAR);
|
||||
|
||||
#if defined(CONFIG_BT_CTLR_NRF_GRTC_KEEPRUNNING)
|
||||
|
@ -55,7 +54,6 @@ void cntr_init(void)
|
|||
GRTC_CLKCFG_CLKFASTDIV_Msk);
|
||||
#endif /* CONFIG_BT_CTLR_NRF_GRTC_START */
|
||||
|
||||
NRF_GRTC->EVENTS_COMPARE[HAL_CNTR_GRTC_CC_IDX_TICKER] = 0U;
|
||||
nrf_grtc_event_clear(NRF_GRTC, HAL_CNTR_GRTC_EVENT_COMPARE_TICKER);
|
||||
|
||||
/* FIXME: Replace with nrf_grtc_int_enable when is available,
|
||||
|
@ -85,7 +83,6 @@ void cntr_init(void)
|
|||
#endif /* CONFIG_BT_CTLR_NRF_GRTC_AUTOEN_DEFAULT */
|
||||
0U;
|
||||
|
||||
NRF_GRTC->TASKS_START = 1U;
|
||||
nrf_grtc_task_trigger(NRF_GRTC, NRF_GRTC_TASK_START);
|
||||
#endif /* CONFIG_BT_CTLR_NRF_GRTC_START */
|
||||
|
||||
|
@ -139,11 +136,8 @@ uint32_t cntr_cnt_get(void)
|
|||
* ensure that L value does not change when H value is read.
|
||||
*/
|
||||
do {
|
||||
cntr_h = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
cntr_l = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERL;
|
||||
cntr_l = nrf_grtc_sys_counter_low_get(NRF_GRTC);
|
||||
cntr_h_overflow = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h_overflow = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
} while ((cntr_h & GRTC_SYSCOUNTER_SYSCOUNTERH_BUSY_Msk) ||
|
||||
(cntr_h_overflow & GRTC_SYSCOUNTER_SYSCOUNTERH_OVERFLOW_Msk));
|
||||
|
@ -166,17 +160,13 @@ void cntr_cmp_set(uint8_t cmp, uint32_t value)
|
|||
|
||||
/* Read current syscounter value */
|
||||
do {
|
||||
cntr_h = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
cntr_l = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERL;
|
||||
cntr_l = nrf_grtc_sys_counter_low_get(NRF_GRTC);
|
||||
cntr_h_overflow = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h_overflow = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
} while ((cntr_h & GRTC_SYSCOUNTER_SYSCOUNTERH_BUSY_Msk) ||
|
||||
(cntr_h_overflow & GRTC_SYSCOUNTER_SYSCOUNTERH_OVERFLOW_Msk));
|
||||
|
||||
/* Disable capture/compare */
|
||||
NRF_GRTC->CC[cmp].CCEN = 0U;
|
||||
nrf_grtc_sys_counter_compare_event_disable(NRF_GRTC, cmp);
|
||||
|
||||
/* Set a stale value in capture value */
|
||||
|
@ -184,7 +174,6 @@ void cntr_cmp_set(uint8_t cmp, uint32_t value)
|
|||
NRF_GRTC->CC[cmp].CCL = stale;
|
||||
|
||||
/* Trigger a capture */
|
||||
NRF_GRTC->TASKS_CAPTURE[cmp] = 1U;
|
||||
nrf_grtc_task_trigger(NRF_GRTC, (NRF_GRTC_TASK_CAPTURE_0 + (cmp * sizeof(uint32_t))));
|
||||
|
||||
/* Wait to get a new L value */
|
||||
|
@ -203,13 +192,10 @@ void cntr_cmp_set(uint8_t cmp, uint32_t value)
|
|||
}
|
||||
|
||||
/* Set compare register values */
|
||||
NRF_GRTC->CC[cmp].CCL = value;
|
||||
NRF_GRTC->CC[cmp].CCH = cntr_h & GRTC_CC_CCH_CCH_Msk;
|
||||
nrf_grtc_sys_counter_cc_set(NRF_GRTC, cmp,
|
||||
((((uint64_t)cntr_h & GRTC_CC_CCH_CCH_Msk) << 32) | value));
|
||||
|
||||
/* Enable compare */
|
||||
NRF_GRTC->CC[cmp].CCEN = 1U;
|
||||
nrf_grtc_sys_counter_compare_event_enable(NRF_GRTC, cmp);
|
||||
|
||||
#else /* !CONFIG_BT_CTLR_NRF_GRTC */
|
||||
|
|
|
@ -1182,7 +1182,6 @@ uint32_t radio_bc_has_match(void)
|
|||
void radio_tmr_status_reset(void)
|
||||
{
|
||||
#if defined(CONFIG_BT_CTLR_NRF_GRTC)
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCEN = 0U;
|
||||
nrf_grtc_sys_counter_compare_event_disable(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO);
|
||||
#else /* !CONFIG_BT_CTLR_NRF_GRTC */
|
||||
nrf_rtc_event_disable(NRF_RTC, RTC_EVTENCLR_COMPARE2_Msk);
|
||||
|
@ -1226,7 +1225,6 @@ void radio_tmr_status_reset(void)
|
|||
void radio_tmr_tx_status_reset(void)
|
||||
{
|
||||
#if defined(CONFIG_BT_CTLR_NRF_GRTC)
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCEN = 0U;
|
||||
nrf_grtc_sys_counter_compare_event_disable(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO);
|
||||
#else /* !CONFIG_BT_CTLR_NRF_GRTC */
|
||||
nrf_rtc_event_disable(NRF_RTC, RTC_EVTENCLR_COMPARE2_Msk);
|
||||
|
@ -1274,7 +1272,6 @@ void radio_tmr_tx_status_reset(void)
|
|||
void radio_tmr_rx_status_reset(void)
|
||||
{
|
||||
#if defined(CONFIG_BT_CTLR_NRF_GRTC)
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCEN = 0U;
|
||||
nrf_grtc_sys_counter_compare_event_disable(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO);
|
||||
#else /* !CONFIG_BT_CTLR_NRF_GRTC */
|
||||
nrf_rtc_event_disable(NRF_RTC, RTC_EVTENCLR_COMPARE2_Msk);
|
||||
|
@ -1395,7 +1392,6 @@ uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder)
|
|||
uint32_t cntr_l, cntr_h, cntr_h_overflow, stale;
|
||||
|
||||
/* Disable capture/compare */
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCEN = 0U;
|
||||
nrf_grtc_sys_counter_compare_event_disable(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO);
|
||||
|
||||
/* NOTE: We are going to use TASKS_CAPTURE to read current
|
||||
|
@ -1405,11 +1401,8 @@ uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder)
|
|||
|
||||
/* Read current syscounter value */
|
||||
do {
|
||||
cntr_h = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
cntr_l = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERL;
|
||||
cntr_l = nrf_grtc_sys_counter_low_get(NRF_GRTC);
|
||||
cntr_h_overflow = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h_overflow = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
} while ((cntr_h & GRTC_SYSCOUNTER_SYSCOUNTERH_BUSY_Msk) ||
|
||||
(cntr_h_overflow & GRTC_SYSCOUNTER_SYSCOUNTERH_OVERFLOW_Msk));
|
||||
|
@ -1419,7 +1412,6 @@ uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder)
|
|||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCL = stale;
|
||||
|
||||
/* Trigger a capture */
|
||||
NRF_GRTC->TASKS_CAPTURE[HAL_CNTR_GRTC_CC_IDX_RADIO] = 1U;
|
||||
nrf_grtc_task_trigger(NRF_GRTC, (NRF_GRTC_TASK_CAPTURE_0 +
|
||||
(HAL_CNTR_GRTC_CC_IDX_RADIO * sizeof(uint32_t))));
|
||||
|
||||
|
@ -1439,18 +1431,14 @@ uint32_t radio_tmr_start(uint8_t trx, uint32_t ticks_start, uint32_t remainder)
|
|||
}
|
||||
|
||||
/* Clear compare event, if any */
|
||||
NRF_GRTC->EVENTS_COMPARE[HAL_CNTR_GRTC_CC_IDX_RADIO] = 0U;
|
||||
nrf_grtc_event_clear(NRF_GRTC, HAL_CNTR_GRTC_EVENT_COMPARE_RADIO);
|
||||
|
||||
/* Set compare register values */
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCL = ticks_start;
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCH = cntr_h & GRTC_CC_CCH_CCH_Msk;
|
||||
nrf_grtc_sys_counter_cc_set(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO,
|
||||
((((uint64_t)cntr_h & GRTC_CC_CCH_CCH_Msk) << 32) |
|
||||
ticks_start));
|
||||
|
||||
/* Enable compare */
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCEN = 1U;
|
||||
nrf_grtc_sys_counter_compare_event_enable(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO);
|
||||
|
||||
#else /* !CONFIG_BT_CTLR_NRF_GRTC */
|
||||
|
@ -1526,7 +1514,6 @@ uint32_t radio_tmr_start_tick(uint8_t trx, uint32_t ticks_start)
|
|||
uint32_t cntr_l, cntr_h, cntr_h_overflow, stale;
|
||||
|
||||
/* Disable capture/compare */
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCEN = 0U;
|
||||
nrf_grtc_sys_counter_compare_event_disable(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO);
|
||||
|
||||
/* NOTE: We are going to use TASKS_CAPTURE to read current
|
||||
|
@ -1536,11 +1523,8 @@ uint32_t radio_tmr_start_tick(uint8_t trx, uint32_t ticks_start)
|
|||
|
||||
/* Read current syscounter value */
|
||||
do {
|
||||
cntr_h = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
cntr_l = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERL;
|
||||
cntr_l = nrf_grtc_sys_counter_low_get(NRF_GRTC);
|
||||
cntr_h_overflow = NRF_GRTC->SYSCOUNTER[1].SYSCOUNTERH;
|
||||
cntr_h_overflow = nrf_grtc_sys_counter_high_get(NRF_GRTC);
|
||||
} while ((cntr_h & GRTC_SYSCOUNTER_SYSCOUNTERH_BUSY_Msk) ||
|
||||
(cntr_h_overflow & GRTC_SYSCOUNTER_SYSCOUNTERH_OVERFLOW_Msk));
|
||||
|
@ -1550,7 +1534,6 @@ uint32_t radio_tmr_start_tick(uint8_t trx, uint32_t ticks_start)
|
|||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCL = stale;
|
||||
|
||||
/* Trigger a capture */
|
||||
NRF_GRTC->TASKS_CAPTURE[HAL_CNTR_GRTC_CC_IDX_RADIO] = 1U;
|
||||
nrf_grtc_task_trigger(NRF_GRTC, (NRF_GRTC_TASK_CAPTURE_0 +
|
||||
(HAL_CNTR_GRTC_CC_IDX_RADIO * sizeof(uint32_t))));
|
||||
|
||||
|
@ -1570,18 +1553,14 @@ uint32_t radio_tmr_start_tick(uint8_t trx, uint32_t ticks_start)
|
|||
}
|
||||
|
||||
/* Clear compare event, if any */
|
||||
NRF_GRTC->EVENTS_COMPARE[HAL_CNTR_GRTC_CC_IDX_RADIO] = 0U;
|
||||
nrf_grtc_event_clear(NRF_GRTC, HAL_CNTR_GRTC_EVENT_COMPARE_RADIO);
|
||||
|
||||
/* Set compare register values */
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCL = ticks_start;
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCH = cntr_h & GRTC_CC_CCH_CCH_Msk;
|
||||
nrf_grtc_sys_counter_cc_set(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO,
|
||||
((((uint64_t)cntr_h & GRTC_CC_CCH_CCH_Msk) << 32) |
|
||||
ticks_start));
|
||||
|
||||
/* Enable compare */
|
||||
NRF_GRTC->CC[HAL_CNTR_GRTC_CC_IDX_RADIO].CCEN = 1U;
|
||||
nrf_grtc_sys_counter_compare_event_enable(NRF_GRTC, HAL_CNTR_GRTC_CC_IDX_RADIO);
|
||||
|
||||
#else /* !CONFIG_BT_CTLR_NRF_GRTC */
|
||||
|
|
|
@ -121,7 +121,6 @@ static void rtc0_nrf5_isr(const void *arg)
|
|||
/* On compare0 run ticker worker instance0 */
|
||||
#if defined(CONFIG_BT_CTLR_NRF_GRTC)
|
||||
if (NRF_GRTC->EVENTS_COMPARE[HAL_CNTR_GRTC_CC_IDX_TICKER]) {
|
||||
NRF_GRTC->EVENTS_COMPARE[HAL_CNTR_GRTC_CC_IDX_TICKER] = 0U;
|
||||
nrf_grtc_event_clear(NRF_GRTC, HAL_CNTR_GRTC_EVENT_COMPARE_TICKER);
|
||||
#else /* !CONFIG_BT_CTLR_NRF_GRTC */
|
||||
if (NRF_RTC->EVENTS_COMPARE[0]) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue