Working version
This commit is contained in:
		@ -18,9 +18,12 @@
 | 
			
		||||
#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 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
 | 
			
		||||
 | 
			
		||||
@ -30,18 +33,12 @@ typedef struct {
 | 
			
		||||
  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;
 | 
			
		||||
  uint32_t precharge95ReachedTimestamp;
 | 
			
		||||
  uint32_t chargingCheckTimestamp;
 | 
			
		||||
 | 
			
		||||
} AIRStateHandler;
 | 
			
		||||
 | 
			
		||||
AIRStateHandler init_AIR_State_Maschine(ADC_HandleTypeDef* relay_adc,
 | 
			
		||||
                                        ADC_HandleTypeDef* sc_adc,
 | 
			
		||||
                                        DMA_HandleTypeDef* relay_dma,
 | 
			
		||||
                                        DMA_HandleTypeDef* sc_dma);
 | 
			
		||||
AIRStateHandler init_AIR_State_Maschine();
 | 
			
		||||
 | 
			
		||||
void Update_AIR_Info(AIRStateHandler* airstate);
 | 
			
		||||
uint8_t Update_AIR_State(AIRStateHandler* airstate);
 | 
			
		||||
@ -54,6 +51,4 @@ 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_ */
 | 
			
		||||
 | 
			
		||||
@ -15,7 +15,7 @@
 | 
			
		||||
#include "stm32g4xx_hal.h"
 | 
			
		||||
#include "stm32g4xx_hal_fdcan.h"
 | 
			
		||||
 | 
			
		||||
#define CANFRAMEBUFFERSIZE 256
 | 
			
		||||
#define CANFRAMEBUFFERSIZE 512
 | 
			
		||||
 | 
			
		||||
// Frame ID = Base Address + Slave ID + MessageNr.
 | 
			
		||||
#define SLAVE_STATUS_BASE_ADDRESS 0x600
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,6 @@
 | 
			
		||||
 | 
			
		||||
#include "stm32g4xx_hal_crc.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define SET_SHUNTDATA 0x01
 | 
			
		||||
#define SET_TSSTATE 0x02
 | 
			
		||||
#define GET_TSSTATE 0x03
 | 
			
		||||
 | 
			
		||||
@ -14,12 +14,11 @@
 | 
			
		||||
 | 
			
		||||
#include "stm32g441xx.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define NUMBEROFSLAVES 6
 | 
			
		||||
#define NUMBEROFCELLS 10
 | 
			
		||||
#define NUMBEROFTEMPS 32
 | 
			
		||||
 | 
			
		||||
#define SLAVETIMEOUT 2000
 | 
			
		||||
#define SLAVETIMEOUT 500
 | 
			
		||||
 | 
			
		||||
typedef struct {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -67,42 +67,14 @@ void AMS_Error_Handler(AMSErrorHandle);
 | 
			
		||||
#define BOOT0_FF_CLK_GPIO_Port GPIOC
 | 
			
		||||
#define BOOT0_FF_DATA_Pin GPIO_PIN_15
 | 
			
		||||
#define BOOT0_FF_DATA_GPIO_Port GPIOC
 | 
			
		||||
#define Relay_Supply_Voltage_Pin GPIO_PIN_0
 | 
			
		||||
#define Relay_Supply_Voltage_GPIO_Port GPIOA
 | 
			
		||||
#define Pos_AIR_Current_Pin GPIO_PIN_1
 | 
			
		||||
#define Pos_AIR_Current_GPIO_Port GPIOA
 | 
			
		||||
#define Neg_AIR_Current_Pin GPIO_PIN_2
 | 
			
		||||
#define Neg_AIR_Current_GPIO_Port GPIOA
 | 
			
		||||
#define PreCharge_AIR_Current_Pin GPIO_PIN_3
 | 
			
		||||
#define PreCharge_AIR_Current_GPIO_Port GPIOA
 | 
			
		||||
#define SC_Supply_Voltage_Pin GPIO_PIN_4
 | 
			
		||||
#define SC_Supply_Voltage_GPIO_Port GPIOA
 | 
			
		||||
#define AMS_ERROR_Pin GPIO_PIN_0
 | 
			
		||||
#define AMS_ERROR_GPIO_Port GPIOB
 | 
			
		||||
#define IMD_Error_Pin GPIO_PIN_1
 | 
			
		||||
#define IMD_Error_GPIO_Port GPIOB
 | 
			
		||||
#define AMS_Error_LED_Pin GPIO_PIN_2
 | 
			
		||||
#define AMS_Error_LED_GPIO_Port GPIOB
 | 
			
		||||
#define Volt_Error_CPU_Pin GPIO_PIN_10
 | 
			
		||||
#define Volt_Error_CPU_GPIO_Port GPIOB
 | 
			
		||||
#define Positive_Side_Error_CPU_Pin GPIO_PIN_11
 | 
			
		||||
#define Positive_Side_Error_CPU_GPIO_Port GPIOB
 | 
			
		||||
#define Neg_Side_Error_CPU_Pin GPIO_PIN_12
 | 
			
		||||
#define Neg_Side_Error_CPU_GPIO_Port GPIOB
 | 
			
		||||
#define HV_Inactive_CPU_Pin GPIO_PIN_13
 | 
			
		||||
#define HV_Inactive_CPU_GPIO_Port GPIOB
 | 
			
		||||
#define Neg_AIR_Open_CPU_Pin GPIO_PIN_14
 | 
			
		||||
#define Neg_AIR_Open_CPU_GPIO_Port GPIOB
 | 
			
		||||
#define High_Side_Open_CPU_Pin GPIO_PIN_15
 | 
			
		||||
#define High_Side_Open_CPU_GPIO_Port GPIOB
 | 
			
		||||
#define Inter_STM_CS_Pin GPIO_PIN_8
 | 
			
		||||
#define Inter_STM_CS_GPIO_Port GPIOA
 | 
			
		||||
#define Inter_STM_IRQ_Pin GPIO_PIN_9
 | 
			
		||||
#define Inter_STM_IRQ_GPIO_Port GPIOA
 | 
			
		||||
#define Status_LED_Pin GPIO_PIN_10
 | 
			
		||||
#define Status_LED_GPIO_Port GPIOA
 | 
			
		||||
#define IMD_Error_LED_Pin GPIO_PIN_3
 | 
			
		||||
#define IMD_Error_LED_GPIO_Port GPIOB
 | 
			
		||||
#define PreCharge_Control_Pin GPIO_PIN_5
 | 
			
		||||
#define PreCharge_Control_GPIO_Port GPIOB
 | 
			
		||||
#define AIR_Positive_Control_Pin GPIO_PIN_6
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,7 @@
 | 
			
		||||
 | 
			
		||||
#define HAL_MODULE_ENABLED
 | 
			
		||||
 | 
			
		||||
  #define HAL_ADC_MODULE_ENABLED
 | 
			
		||||
  /*#define HAL_ADC_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_COMP_MODULE_ENABLED   */
 | 
			
		||||
/*#define HAL_CORDIC_MODULE_ENABLED   */
 | 
			
		||||
#define HAL_CRC_MODULE_ENABLED
 | 
			
		||||
 | 
			
		||||
@ -56,12 +56,9 @@ void SVC_Handler(void);
 | 
			
		||||
void DebugMon_Handler(void);
 | 
			
		||||
void PendSV_Handler(void);
 | 
			
		||||
void SysTick_Handler(void);
 | 
			
		||||
void DMA1_Channel2_IRQHandler(void);
 | 
			
		||||
void ADC1_2_IRQHandler(void);
 | 
			
		||||
void FDCAN1_IT0_IRQHandler(void);
 | 
			
		||||
void FDCAN1_IT1_IRQHandler(void);
 | 
			
		||||
void SPI1_IRQHandler(void);
 | 
			
		||||
void DMA2_Channel1_IRQHandler(void);
 | 
			
		||||
/* USER CODE BEGIN EFP */
 | 
			
		||||
 | 
			
		||||
/* USER CODE END EFP */
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user