fix: resolve 3 deferred issues (STM32-006, STM32-004, FPGA-001)

STM32-006: Remove blocking do-while loop that waited for legacy GUI start
flag — production V7 PyQt GUI never sends it, hanging the MCU at boot.

STM32-004: Check ad9523_init() return code and call Error_Handler() on
failure, matching the pattern used by all other hardware init calls.

FPGA-001: Simplify frame boundary detection to only trigger on
chirp_counter wrap-to-zero. Previous conditions checking == N and == 2N
were unreachable dead code (counter wraps at N-1). Now correct for any
chirps_per_elev value.
This commit is contained in:
Jason
2026-04-16 00:13:45 +05:45
parent b0e5b298fe
commit 8187771ab0
2 changed files with 22 additions and 35 deletions
@@ -175,7 +175,7 @@ float RADAR_Altitude;
double RADAR_Longitude = 0; double RADAR_Longitude = 0;
double RADAR_Latitude = 0; double RADAR_Latitude = 0;
extern uint8_t GUI_start_flag_received; extern uint8_t GUI_start_flag_received; // [STM32-006] Legacy, unused -- kept for linker compat
//RADAR //RADAR
@@ -1177,7 +1177,14 @@ static int configure_ad9523(void)
// init ad9523 defaults (fills any missing pdata defaults) // init ad9523 defaults (fills any missing pdata defaults)
DIAG("CLK", "Calling ad9523_init() -- fills pdata defaults"); DIAG("CLK", "Calling ad9523_init() -- fills pdata defaults");
ad9523_init(&init_param); {
int32_t init_ret = ad9523_init(&init_param);
DIAG("CLK", "ad9523_init() returned %ld", (long)init_ret);
if (init_ret != 0) {
DIAG_ERR("CLK", "ad9523_init() FAILED (ret=%ld) -- calling Error_Handler()", (long)init_ret);
Error_Handler();
}
}
/* [Bug #2 FIXED] Removed first ad9523_setup() call that was here. /* [Bug #2 FIXED] Removed first ad9523_setup() call that was here.
* It wrote to the chip while still in reset — writes were lost. * It wrote to the chip while still in reset — writes were lost.
@@ -1800,29 +1807,11 @@ int main(void)
HAL_UART_Transmit(&huart3, (uint8_t*)gps_send_error, sizeof(gps_send_error) - 1, 1000); HAL_UART_Transmit(&huart3, (uint8_t*)gps_send_error, sizeof(gps_send_error) - 1, 1000);
} }
// Check if start flag was received and settings are ready /* [STM32-006 FIXED] Removed blocking do-while loop that waited for
do{ * usbHandler.isStartFlagReceived(). The production V7 PyQt GUI does not
if (usbHandler.isStartFlagReceived() && * send the legacy 4-byte start flag [23,46,158,237], so this loop hung
usbHandler.getState() == USBHandler::USBState::READY_FOR_DATA) { * the MCU at boot indefinitely. The USB settings handshake (if ever
* re-enabled) should be handled non-blocking in the main loop. */
const RadarSettings& settings = usbHandler.getSettings();
// Use the settings to configure your radar system
/*
settings.getSystemFrequency();
settings.getChirpDuration1();
settings.getChirpDuration2();
settings.getChirpsPerPosition();
settings.getFreqMin();
settings.getFreqMax();
settings.getPRF1();
settings.getPRF2();
settings.getMaxDistance();
*/
}
}while(!usbHandler.isStartFlagReceived());
/***************************************************************/ /***************************************************************/
/************RF Power Amplifier Powering up sequence************/ /************RF Power Amplifier Powering up sequence************/
+8 -10
View File
@@ -404,16 +404,14 @@ always @(posedge clk or negedge reset_n) begin
// Default: no pulse // Default: no pulse
new_frame_pulse <= 1'b0; new_frame_pulse <= 1'b0;
// Dynamic frame detection using host_chirps_per_elev. // [FPGA-001 FIXED] Detect frame boundary when chirp_counter wraps to 0.
// Detect frame boundary when chirp_counter changes AND is a // The chirp_counter (driven by radar_mode_controller) counts 0..N-1
// multiple of host_chirps_per_elev (0, N, 2N, 3N, ...). // and wraps back to 0 at the start of each new frame. Previous code
// Uses a modulo counter that resets at host_chirps_per_elev. // also checked (== host_chirps_per_elev) and (== 2*host_chirps_per_elev)
if (chirp_counter != chirp_counter_prev) begin // which were unreachable dead conditions for any N, since the counter
if (chirp_counter == 6'd0 || // never reaches N. Now works correctly for any chirps_per_elev value.
chirp_counter == host_chirps_per_elev || if (chirp_counter != chirp_counter_prev && chirp_counter == 6'd0) begin
chirp_counter == {host_chirps_per_elev, 1'b0}) begin new_frame_pulse <= 1'b1;
new_frame_pulse <= 1'b1;
end
end end
// Store previous value // Store previous value