/* * Slave_Monitoring.h * * Created on: Jun 15, 2022 * Author: max */ #ifndef INC_SLAVE_MONITORING_H_ #define INC_SLAVE_MONITORING_H_ #include "AMS_Errorcodes.h" #include "Error_Check.h" #include "main.h" #include "stm32g431xx.h" #include #define N_SLAVES 9 #define N_CELLS_SERIES 10 #define N_CELLS_PARALLEL 9 #define N_TEMP_SENSORS 32 #define SLAVETIMEOUT 5000 #define SLAVE_HEARTBEAT_FRAMES 11 // 30% * 90 = 27, each sensor measures 2 cells #define SLAVE_MIN_TEMP_SENSORS 14 #define THRESH_UV 32768 /* 2.5V */ #define THRESH_OV 55050 /* 4.2V */ #define THRESH_UT 0 /* 0C */ #define THRESH_OT 880 /* 55C */ typedef struct { uint16_t slaveID; uint16_t cellVoltages[N_CELLS_SERIES]; uint16_t cellTemps[N_TEMP_SENSORS]; uint32_t timestamp; uint8_t error; uint8_t timeout; uint32_t frame_timestamps[SLAVE_HEARTBEAT_FRAMES]; uint8_t error_frame[8]; } SlaveHandler; extern SlaveHandler slaves[N_SLAVES]; extern uint16_t min_voltage, max_voltage; extern int16_t min_temp, max_temp; void initSlaves(); uint8_t checkSlaves(); #endif /* INC_SLAVE_MONITORING_H_ */