From 0f3069ee5ea0031a88b61cbf2a554bc063cc9f66 Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Fri, 24 Dec 2021 08:39:47 +0000 Subject: [PATCH] Move resetting of byte counts to the M0. Previously, these counts were zeroed by the M4 when leaving the OFF transceiver mode. Instead, do this on the M0 at the point where the M0 leaves IDLE mode. This avoids a potential race in which the M4 zeroes the M0 count after the M0 has already started incrementing it. --- firmware/hackrf_usb/sgpio_m0.s | 5 +++++ firmware/hackrf_usb/usb_api_transceiver.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/firmware/hackrf_usb/sgpio_m0.s b/firmware/hackrf_usb/sgpio_m0.s index 8df257c3..9965e9fb 100644 --- a/firmware/hackrf_usb/sgpio_m0.s +++ b/firmware/hackrf_usb/sgpio_m0.s @@ -175,6 +175,11 @@ idle: cmp mode, #MODE_IDLE // if mode == IDLE: // 1 beq idle // goto idle // 1 thru, 3 taken + // Reset counts. + mov zero, #0 // zero = 0 // 1 + str zero, [state, #M0_COUNT] // state.m0_count = zero // 2 + str zero, [state, #M4_COUNT] // state.m4_count = zero // 2 + loop: // The worst case timing is assumed to occur when reading the interrupt // status register *just* misses the flag being set - so we include the diff --git a/firmware/hackrf_usb/usb_api_transceiver.c b/firmware/hackrf_usb/usb_api_transceiver.c index 624fd4aa..c5e0a43f 100644 --- a/firmware/hackrf_usb/usb_api_transceiver.c +++ b/firmware/hackrf_usb/usb_api_transceiver.c @@ -301,8 +301,6 @@ void transceiver_startup(const transceiver_mode_t mode) { activate_best_clock_source(); hw_sync_enable(_hw_sync_mode); - m0_state.m0_count = 0; - m0_state.m4_count = 0; } usb_request_status_t usb_vendor_request_set_transceiver_mode(