/* * slave_handler.h * * Created on: Jun 21, 2023 * Author: max */ #ifndef INC_SLAVE_HANDLER_H_ #define INC_SLAVE_HANDLER_H_ #include "stm32h7xx_hal.h" #define N_SLAVES 6 typedef enum { SLAVE_ERR_NONE, SLAVE_ERR_TIMEOUT, SLAVE_ERR_OT, SLAVE_ERR_UT, SLAVE_ERR_OV, SLAVE_ERR_UV, SLAVE_ERR_UNKNOWN, } SlaveErrorKind; typedef struct { SlaveErrorKind kind; uint32_t data; // Cell/temperature ID etc } SlaveError; typedef struct { uint8_t id; SlaveError error; uint8_t soc; uint16_t min_voltage; uint16_t max_voltage; int16_t max_temp; uint32_t last_message; } SlaveHandle; extern SlaveHandle slaves[N_SLAVES]; float slaves_get_maximum_voltage(); void slaves_handle_status(const uint8_t *data); void slave_handler_init(); #endif /* INC_SLAVE_HANDLER_H_ */