Skip to content

Commit

Permalink
Fix wrong print function: Should be u16, not float
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Jun 29, 2024
1 parent e52ebd6 commit 49399dd
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions firmware/src/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -52,7 +52,7 @@ void machine_init(void)
set_machine_initial_state();
set_state_initializing();

}
}

/**
* @brief set machine initial state
Expand All @@ -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"));
Expand All @@ -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"));
Expand All @@ -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"));
Expand All @@ -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: "));
Expand All @@ -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
*/
Expand All @@ -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();
Expand Down Expand Up @@ -210,30 +210,30 @@ 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"));
}
if(total_errors >= 20){
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
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -376,4 +376,3 @@ ISR(TIMER2_COMPA_vect)
{
machine_clk = 1;
}

0 comments on commit 49399dd

Please sign in to comment.