Master_Control/Core/Inc/AIR_State_Maschine.h
2022-07-18 16:54:42 +02:00

55 lines
1.2 KiB
C

/*
* AIR_State_Maschine.h
*
* Created on: Jun 15, 2022
* Author: max
*/
#ifndef INC_AIR_STATE_MASCHINE_H_
#define INC_AIR_STATE_MASCHINE_H_
#include "main.h"
#include "stm32g441xx.h"
#include "stm32g4xx_hal.h"
#define TS_INACTIVE 0
#define TS_PRECHARGE 2
#define TS_DISCHARGE 3
#define TS_ERROR 4
#define TS_ACTIVE 1
#define TS_CHARGING_CHECK 5
#define TS_CHARGING 6
#define ADC_READ_TIMEOUT 500 // in ms
#define SDC_LOWER_THRESHOLD 2500 // in ADC Values
#define PRECHARGE_95_DURATION 1000 // in ms
// FIXME
#define LOWER_VEHICLE_SIDE_VOLTAGE_LIMIT 150000 // in mV
typedef struct {
int32_t BatteryVoltageVehicleSide;
int32_t BatteryVoltageBatterySide;
uint8_t targetTSState;
uint8_t currentTSState;
uint32_t precharge95ReachedTimestamp;
uint32_t chargingCheckTimestamp;
} AIRStateHandler;
AIRStateHandler init_AIR_State_Maschine();
void Update_AIR_Info(AIRStateHandler* airstate);
uint8_t Update_AIR_State(AIRStateHandler* airstate);
void Activate_TS(AIRStateHandler* airstate);
void Deactivate_TS(AIRStateHandler* airstate);
void AIR_Precharge_Position();
void AIR_Inactive_Position();
void AIR_Discharge_Position();
void AIR_Active_Position();
void AIR_Error_Position();
#endif /* INC_AIR_STATE_MASCHINE_H_ */