Improve behaviour on full USB buffer

This commit is contained in:
Jan Käberich 2021-09-24 22:21:38 +02:00
parent 4a374e022d
commit 0452d2472c
4 changed files with 18 additions and 2 deletions

View file

@ -408,7 +408,17 @@ void VNA::SweepHalted() {
// This function is called from a low level interrupt, need to dispatch to lower priority to allow USB
// handling to continue
STM::DispatchToInterrupt([](){
while(usb_available_buffer() < reservedUSBbuffer);
uint32_t start = HAL_GetTick();
while(usb_available_buffer() < reservedUSBbuffer) {
if(HAL_GetTick() - start > 100) {
// still no buffer space after some time, something more serious must have gone wrong
// -> abort sweep and return to idle
usb_clear_buffer();
FPGA::AbortSweep();
HW::SetIdle();
return;
}
}
FPGA::ResumeHaltedSweep();
});
}