Fix further sweep timeout issues

This commit is contained in:
Jan Käberich 2022-06-26 18:47:34 +02:00
parent 4541dcb71b
commit 947a6b9d83
9 changed files with 53 additions and 14 deletions

View file

@ -21,7 +21,7 @@ HW::Mode activeMode;
static bool unlevel = false;
static Protocol::ReferenceSettings ref;
static uint64_t lastISR;
static volatile uint64_t lastISR;
static uint32_t IF1 = HW::DefaultIF1;
static uint32_t IF2 = HW::DefaultIF2;
@ -293,7 +293,16 @@ HW::AmplitudeSettings HW::GetAmplitudeSettings(int16_t cdbm, uint64_t freq, bool
bool HW::TimedOut() {
constexpr uint64_t timeout = 1000000;
if(activeMode != Mode::Idle && activeMode != Mode::Generator && Delay::get_us() - lastISR > timeout) {
auto bufISR = lastISR;
uint64_t now = Delay::get_us();
uint64_t timeSinceLast = now - bufISR;
if(activeMode != Mode::Idle && activeMode != Mode::Generator && timeSinceLast > timeout) {
LOG_WARN("Timed out, last ISR was at %lu%06lu, now %lu%06lu"
, (uint32_t) (bufISR / 1000000), (uint32_t)(bufISR%1000000)
, (uint32_t) (now / 1000000), (uint32_t)(now%1000000));
if(activeMode == Mode::VNA) {
VNA::PrintStatus();
}
return true;
} else {
return false;