From 49399ddd50d15787fd969c76b0b0ea249add216a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ant=C3=B4nio=20Cardoso?= Date: Fri, 28 Jun 2024 23:19:31 -0300 Subject: [PATCH] Fix wrong print function: Should be u16, not float --- firmware/src/machine.c | 45 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/firmware/src/machine.c b/firmware/src/machine.c index 680baac..7654280 100644 --- a/firmware/src/machine.c +++ b/firmware/src/machine.c @@ -8,13 +8,13 @@ volatile measurements_t measurements; volatile uint8_t machine_clk; volatile uint8_t machine_clk_divider; volatile uint8_t total_errors; // Contagem de ERROS - + // other variables volatile uint8_t led_clk_div; /** - * @brief + * @brief */ void machine_init(void) { @@ -52,7 +52,7 @@ void machine_init(void) set_machine_initial_state(); set_state_initializing(); -} +} /** * @brief set machine initial state @@ -74,7 +74,7 @@ inline void set_state_error(void) /** * @brief set initializing state -*/ +*/ inline void set_state_initializing(void) { VERBOSE_MSG_MACHINE(usart_send_string("\n>>>INITIALIZING STATE\n")); @@ -83,7 +83,7 @@ inline void set_state_initializing(void) /** * @brief set idle state -*/ +*/ inline void set_state_idle(void) { VERBOSE_MSG_MACHINE(usart_send_string("\n>>>IDLE STATE\n")); @@ -92,7 +92,7 @@ inline void set_state_idle(void) /** * @brief set running state -*/ +*/ inline void set_state_running(void) { VERBOSE_MSG_MACHINE(usart_send_string("\n>>>RUNNING STATE\n")); @@ -112,9 +112,9 @@ inline void set_state_reset(void) * @breif prints the configurations and definitions */ inline void print_configurations(void) -{ +{ VERBOSE_MSG_MACHINE(usart_send_string("CONFIGURATIONS:\n")); - + VERBOSE_MSG_MACHINE(usart_send_string("\nadc_f: ")); VERBOSE_MSG_MACHINE(usart_send_uint16( ADC_FREQUENCY )); VERBOSE_MSG_MACHINE(usart_send_string("\nmachine_f: ")); @@ -140,7 +140,7 @@ inline void print_error_flags(void) //VERBOSE_MSG_MACHINE(usart_send_string(" errFl: ")); //VERBOSE_MSG_MACHINE(usart_send_char(48+error_flags.no_canbus)); } - + /** * @brief Checks if the system is OK to run */ @@ -165,7 +165,7 @@ inline void task_idle(void) if(led_clk_div++ >= 30){ cpl_led(LED1); led_clk_div = 0; - } + } #endif set_state_running(); @@ -210,11 +210,11 @@ inline void task_error(void) VERBOSE_MSG_ERROR(usart_send_string("\t - No canbus communication with MIC19!\n")); if(!error_flags.all) VERBOSE_MSG_ERROR(usart_send_string("\t - Oh no, it was some unknown error.\n")); - + VERBOSE_MSG_ERROR(usart_send_string("The error level is: ")); VERBOSE_MSG_ERROR(usart_send_uint16(total_errors)); VERBOSE_MSG_ERROR(usart_send_char('\n')); - + if(total_errors < 2){ VERBOSE_MSG_ERROR(usart_send_string("I will reset the machine state.\n")); } @@ -222,18 +222,18 @@ inline void task_error(void) VERBOSE_MSG_ERROR(usart_send_string("The watchdog will reset the whole system.\n")); set_state_reset(); } - + #ifdef LED_ON cpl_led(LED2); #endif set_state_initializing(); } - + /** * @brief reset error task just freezes the processor and waits for watchdog */ inline void task_reset(void) -{ +{ #ifndef WATCHDOG_ON //wdt_init(); #endif @@ -253,21 +253,21 @@ void print_infos(void) case 0: //print_system_flags(); usart_send_string("\nvi: "); - usart_send_float(measurements.vi_avg); + usart_send_uint16(measurements.vi_avg); break; case 1: //print_error_flags(); usart_send_string(" , vo: "); - usart_send_float(measurements.vo_avg); + usart_send_uint16(measurements.vo_avg); break; case 2: - //print_control_others(); + //print_control_others(); usart_send_string(" , io: "); - usart_send_float(measurements.io_avg); + usart_send_uint16(measurements.io_avg); break; case 3: usart_send_string(" , dt: "); - usart_send_float(measurements.dt_avg); + usart_send_uint16(measurements.dt_avg); usart_send_char(','); usart_send_char(dt_min); break; @@ -355,8 +355,8 @@ inline void machine_run(void) task_running(); #ifdef CAN_ON can_app_task(); - #endif /* CAN_ON */ - + #endif /* CAN_ON */ + break; case STATE_ERROR: task_error(); @@ -376,4 +376,3 @@ ISR(TIMER2_COMPA_vect) { machine_clk = 1; } -