From c6a5ffd2c0011e30f1ff44d1d407d13def55b753 Mon Sep 17 00:00:00 2001 From: jazzpi Date: Thu, 4 Aug 2022 14:08:07 +0200 Subject: [PATCH] Only use BQ and TMP144 once clock is synchronized --- Core/Src/main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index ce4504c..4f48e00 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -209,15 +209,16 @@ int main(void) { /* USER CODE BEGIN 3 */ update_status_leds(); - afe_measure(); - tmp144_read_temps(); - if (HAL_GetTick() - main_loop_start > ERROR_CHECK_START) { - check_error_conditions(); - } fan_ctrl_update(); clock_sync_update(); - // Only start sending CAN frames once the clock is synchronized + // Only use communication interfaces (BQ UART, TMP144 UARTs, CAN) once the + // clock is synchronized if (clock_sync_state == CLOCK_SYNC_NORMAL_OPERATION) { + afe_measure(); + tmp144_read_temps(); + if (HAL_GetTick() - main_loop_start > ERROR_CHECK_START) { + check_error_conditions(); + } ams_can_send_heartbeat(); } delay_period();