From 1cb2abf74736bb7a54967f1374226f1455315928 Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Tue, 16 Mar 2021 16:18:59 +0000 Subject: [PATCH] Disable USB interrupts during sweep set_freq call Previously, a USB vendor request could interrupt in the middle of set_freq and make conflicting changes, leaving the HackRF in an undefined state. fixes #772 --- firmware/hackrf_usb/usb_api_sweep.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/firmware/hackrf_usb/usb_api_sweep.c b/firmware/hackrf_usb/usb_api_sweep.c index a664c3880..1a73e8ddd 100644 --- a/firmware/hackrf_usb/usb_api_sweep.c +++ b/firmware/hackrf_usb/usb_api_sweep.c @@ -29,6 +29,8 @@ #include "usb_endpoint.h" #include "streaming.h" +#include + #define MIN(x,y) ((x)<(y)?(x):(y)) #define MAX(x,y) ((x)>(y)?(x):(y)) #define FREQ_GRANULARITY 1000000 @@ -155,7 +157,10 @@ void sweep_mode(void) { sweep_freq += step_width; } } + + nvic_disable_irq(NVIC_USB0_IRQ); set_freq(sweep_freq + offset); + nvic_enable_irq(NVIC_USB0_IRQ); blocks_queued = 0; } }