added sm_check_errors
This commit is contained in:
		@ -5,6 +5,7 @@
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include "ADBMS_LL_Driver.h"
 | 
			
		||||
#include "AMS_HighLevel.h"
 | 
			
		||||
#include "errors.h"
 | 
			
		||||
#include "PWM_control.h"
 | 
			
		||||
#include "TMP1075.h"
 | 
			
		||||
#include <math.h>
 | 
			
		||||
@ -23,6 +24,7 @@
 | 
			
		||||
// Time to wait between closing relays
 | 
			
		||||
#define RELAY_CLOSE_WAIT 10 // ms
 | 
			
		||||
 | 
			
		||||
#warning 
 | 
			
		||||
typedef enum {              //  states -> 3 bit. valid transitions: (all could transition to error)
 | 
			
		||||
  STATE_INACTIVE,           // INACTIVE   ->  PRECHARGE, CHARGING, ERROR  
 | 
			
		||||
  STATE_PRECHARGE,          // PRECHARGE  ->  INACTIVE, READY, DISCHARGE, ERROR
 | 
			
		||||
@ -35,21 +37,16 @@ typedef enum {              //  states -> 3 bit. valid transitions: (all could t
 | 
			
		||||
} State;
 | 
			
		||||
  
 | 
			
		||||
typedef struct {  
 | 
			
		||||
  uint16_t bms_timeout : 1;
 | 
			
		||||
  uint16_t bms_overtemp : 1;
 | 
			
		||||
  uint16_t bms_fault : 1;
 | 
			
		||||
 | 
			
		||||
  uint16_t bms_timeout : 1;
 | 
			
		||||
  uint16_t bms_fault : 1;
 | 
			
		||||
  uint16_t temperature_error : 1;
 | 
			
		||||
  uint16_t current_error : 1;
 | 
			
		||||
  uint16_t voltage_error : 1;
 | 
			
		||||
 | 
			
		||||
  uint16_t temperature_sensor_missing : 1;
 | 
			
		||||
  uint16_t current_sensor_missing : 1;
 | 
			
		||||
  uint16_t voltage_error : 1;
 | 
			
		||||
  uint16_t voltage_missing : 1;
 | 
			
		||||
  uint16_t battery_missing : 1;
 | 
			
		||||
  uint16_t relay_missing : 1;
 | 
			
		||||
 | 
			
		||||
  uint16_t state_transition_fail : 1;
 | 
			
		||||
 | 
			
		||||
} ErrorKind;
 | 
			
		||||
 | 
			
		||||
//typedef enum {} WarningKind;
 | 
			
		||||
@ -67,6 +64,8 @@ static bool precharge_closed = 0;
 | 
			
		||||
extern int16_t RELAY_BAT_SIDE_VOLTAGE;
 | 
			
		||||
extern int16_t RELAY_ESC_SIDE_VOLTAGE;
 | 
			
		||||
extern int16_t CURRENT_MEASUREMENT;
 | 
			
		||||
extern uint8_t powerground_status;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void sm_init();
 | 
			
		||||
void sm_update();
 | 
			
		||||
@ -84,12 +83,14 @@ typedef enum { RELAY_MAIN, RELAY_PRECHARGE } Relay;
 | 
			
		||||
void sm_set_relay_positions(State state);
 | 
			
		||||
void sm_set_relay(Relay relay, bool closed);
 | 
			
		||||
void sm_check_charging();
 | 
			
		||||
void sm_check_cell_temps(int8_t* id, int16_t* temp);
 | 
			
		||||
void sm_check_battery_temperature(int8_t* id, int16_t* temp);
 | 
			
		||||
 | 
			
		||||
int16_t sm_return_cell_temperature(int id);
 | 
			
		||||
int16_t sm_return_cell_voltage(int id);
 | 
			
		||||
 | 
			
		||||
void sm_handle_ams_in(const uint8 *data);
 | 
			
		||||
void sm_check_errors();
 | 
			
		||||
void sm_set_error(ErrorKind error_kind, bool is_errored);
 | 
			
		||||
 | 
			
		||||
void sm_test_cycle_states();
 | 
			
		||||
 | 
			
		||||
#endif /* "INC_STATE_MACHINE_H" */
 | 
			
		||||
		Reference in New Issue
	
	Block a user