Skip to content

Commit 2a6a1bd

Browse files
maje-embrlubos
authored andcommitted
esb: Update timer handling
The COMPARE2_CLEAR and COMPARE2_STOP timer shorts are now disabled after the first CC2 match. This prevents the stopping timer if CC2 is reached again. CC2 equals radio ramp-up time. Ref: NCSDK-35742 Signed-off-by: Marcin Jelinski <[email protected]>
1 parent 2692dc4 commit 2a6a1bd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

subsys/esb/esb.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ static void esb_fem_for_tx_set(bool ack)
484484
*/
485485
uint16_t ramp_up = esb_cfg.use_fast_ramp_up ? TX_FAST_RAMP_UP_TIME_US :
486486
TX_RAMP_UP_TIME_US;
487-
nrf_timer_cc_set(esb_timer.p_reg, NRF_TIMER_CC_CHANNEL2, ramp_up);
487+
nrfx_timer_compare(&esb_timer, NRF_TIMER_CC_CHANNEL2, ramp_up, true);
488488
}
489489

490490
if (IS_ENABLED(CONFIG_ESB_NEVER_DISABLE_TX)) {
@@ -1140,19 +1140,25 @@ static bool rx_fifo_push_rfbuf(uint8_t pipe, uint8_t pid)
11401140
static void esb_timer_handler(nrf_timer_event_t event_type, void *context)
11411141
{
11421142
if (nrf_timer_int_enable_check(esb_timer.p_reg, NRF_TIMER_INT_COMPARE1_MASK)) {
1143-
nrf_timer_event_clear(esb_timer.p_reg, NRF_TIMER_EVENT_COMPARE1);
11441143
if (on_timer_compare1 != NULL) {
11451144
on_timer_compare1();
11461145
}
11471146
}
11481147

1148+
if (event_type == NRF_TIMER_EVENT_COMPARE2) {
1149+
nrf_timer_shorts_disable(esb_timer.p_reg,
1150+
(NRF_TIMER_SHORT_COMPARE2_CLEAR_MASK | NRF_TIMER_SHORT_COMPARE2_STOP_MASK));
1151+
}
1152+
11491153
if (nrf54h_errata_216() && event_type == NRF_TIMER_EVENT_COMPARE3) {
11501154
nrf_timer_int_disable(esb_timer.p_reg, NRF_TIMER_INT_COMPARE3_MASK);
11511155

11521156
if (atomic_get(&errata_216_status) == ERRATA_216_ENABLED) {
11531157
/* This case is triggered after calling the radio_start() function */
11541158

11551159
/* Restore timer shorts */
1160+
nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_STOP);
1161+
nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_CLEAR);
11561162
nrf_timer_shorts_set(esb_timer.p_reg, errata_216_timer_shorts);
11571163

11581164
nrf_egu_task_trigger(ESB_EGU, ESB_EGU_TASK);
@@ -1374,7 +1380,6 @@ static void on_radio_disabled_tx(void)
13741380
* received by the time defined in wait_for_ack_timeout_us
13751381
*/
13761382

1377-
nrf_timer_task_trigger(esb_timer.p_reg, NRF_TIMER_TASK_CLEAR);
13781383
nrfx_timer_compare(&esb_timer, NRF_TIMER_CC_CHANNEL0,
13791384
(wait_for_ack_timeout_us + ADDR_EVENT_LATENCY_US), false);
13801385

0 commit comments

Comments
 (0)