This commit is contained in:
2024-07-06 13:23:12 +03:00
parent f50643cc84
commit 16824744e7
5 changed files with 110 additions and 58 deletions

17
Core/Inc/eeprom.h Executable file
View File

@ -0,0 +1,17 @@
#ifndef INC_EEPROM_H_
#define INC_EEPROM_H_
#include "stm32f3xx_hal.h"
#include <stdint.h>
__attribute__((packed)) typedef struct {
uint8_t id;
} EEPROMConfig;
extern EEPROMConfig eeprom_config;
void eeprom_init(I2C_HandleTypeDef* hi2c);
void eeprom_config_save();
#endif // INC_EEPROM_H_

View File

@ -24,7 +24,6 @@
// 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
@ -59,8 +58,6 @@ typedef struct {
} StateHandle;
extern StateHandle state;
static bool relay_closed = 0; //NOTE: unused?
static bool precharge_closed = 0; //NOTE: unused?
extern int16_t RELAY_BAT_SIDE_VOLTAGE;
extern int16_t RELAY_ESC_SIDE_VOLTAGE;
extern int16_t CURRENT_MEASUREMENT;
@ -82,15 +79,13 @@ State sm_update_error();
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_battery_temperature(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_calibrate_powerground();
void sm_precharge_discharge_manager();
void sm_powerground_manager(int8_t percent, bool source);
void sm_handle_ams_in(const uint8 *data);
void sm_check_errors();