e979363730
Bug 1 (main.cpp:630): system_emergency_state lacked volatile. Under -O1+ the compiler is permitted to hoist the read outside the blink loop, making while (system_emergency_state) unconditionally infinite. Once entered, the only escape was the 4 s IWDG timeout — which resets the MCU and re-energizes the PA rails that Emergency_Stop() explicitly cut. Marking the variable volatile forces a memory read on every iteration so an external clear (ISR, USB command, manual reset) can break the loop correctly. Bug 2 (ADAR1000_AGC.cpp:59): holdoff_frames is a public uint8_t; if a caller sets it to 0, the condition holdoff_counter >= holdoff_frames is always true (any uint8_t >= 0), causing the AGC outer loop to increase gain on every non-saturated frame with no holdoff delay. With alternating sat/no-sat frames this produces a ±step oscillation that prevents the receiver from settling. Fix: clamp holdoff_frames to a minimum of 1 in the constructor, preserving all existing test assertions (none use 0; default remains 4). Reported-by: shaun0927 (Junghwan) <https://github.com/shaun0927>