diff --git a/nRF5_SDK_16.0.0_98a08e2/examples/common/time_sync.c b/nRF5_SDK_16.0.0_98a08e2/examples/common/time_sync.c index 4a21351..871498a 100644 --- a/nRF5_SDK_16.0.0_98a08e2/examples/common/time_sync.c +++ b/nRF5_SDK_16.0.0_98a08e2/examples/common/time_sync.c @@ -128,6 +128,7 @@ static nrf_atomic_u32_t m_sync_pkt_ringbuf_idx; static nrf_atomic_flag_t m_timeslot_session_open; static nrf_atomic_flag_t m_pending_close; +static nrf_atomic_flag_t m_pending_tx_stop; static nrf_atomic_u32_t m_blocked_cancelled_count; static uint32_t m_total_timeslot_length = 0; static uint32_t m_timeslot_distance = 0; @@ -469,6 +470,15 @@ void timeslot_begin_handler(void) m_total_timeslot_length = 0; + if (m_pending_tx_stop) + { + nrf_atomic_flag_clear(&m_send_sync_pkt); + nrf_atomic_flag_clear(&m_pending_tx_stop); + m_timeslot_distance = 0; + m_synchronized = false; + m_master_counter_diff = 0; + } + if (!m_send_sync_pkt) { if (m_radio_state != RADIO_STATE_RX || @@ -737,6 +747,7 @@ void SWI3_EGU3_IRQHandler(void) if (m_synchronized) { m_synchronized = false; + m_master_counter_diff = 0; if (m_callback) { @@ -1217,7 +1228,7 @@ uint32_t ts_tx_start(uint32_t sync_freq_hz) uint32_t ts_tx_stop() { - nrf_atomic_flag_clear(&m_send_sync_pkt); + nrf_atomic_flag_set(&m_pending_tx_stop); return NRF_SUCCESS; }