/* * 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 ADC_READ_TIMEOUT 500 // in ms #define SDC_LOWER_THRESHOLD 2500 // in ADC Values // FIXME #define LOWER_VEHICLE_SIDE_VOLTAGE_LIMIT 150000 // in mV typedef struct { int32_t BatteryVoltageVehicleSide; int32_t BatteryVoltageBatterySide; uint8_t targetTSState; uint8_t currentTSState; uint16_t AIRPrechargeCurrent; // ADC Value uint16_t AIRPositiveCurrent; // ADC Value uint16_t AIRNegativeCurrent; // ADC Value uint16_t RelaisSupplyVoltage; uint16_t ShutdownCircuitVoltage; } AIRStateHandler; AIRStateHandler init_AIR_State_Maschine(ADC_HandleTypeDef* relay_adc, ADC_HandleTypeDef* sc_adc, DMA_HandleTypeDef* relay_dma, DMA_HandleTypeDef* sc_dma); 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(); void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc); #endif /* INC_AIR_STATE_MASCHINE_H_ */