This commit is contained in:
hamza
2024-07-10 01:39:38 +03:00
parent 4375bfce48
commit a86985bfc9
11 changed files with 217 additions and 41 deletions

View File

@ -6,15 +6,18 @@
*/
#include "state_machine.h"
#include "ADBMS_Abstraction.h"
#include "AMS_HighLevel.h"
#include "PWM_control.h"
#include "TMP1075.h"
#include "errors.h"
#include "main.h"
#include "stm32f302xc.h"
#include "stm32f3xx_hal.h"
#include <stdint.h>
// Time to wait after reaching 95% of battery voltage before exiting precharge
// Set this to 1000 in scruti to demonstrate the voltage on the multimeter
#define PRECHARGE_DURATION 5000 // ms
// Time to wait for discharge
#define DISCHARGE_DURATION 5000 // ms
// Time to wait for charger voltage before going to TS_ERROR
#define MAX_CHARGING_CHECK_DURATION 2000 // ms
// Time to wait between closing relays
#define RELAY_CLOSE_WAIT 10 // ms
// Max time to wait for CAN messages. If we reach it then we emergency shutdown.
#define CAN_TIMEOUT 100000
StateHandle state;
int32_t RELAY_BAT_SIDE_VOLTAGE;
@ -155,7 +158,7 @@ void sm_precharge_discharge_manager(){
}
void sm_calibrate_powerground(){
if (powerground_calibration_stage != 4 && state.current_state == STATE_READY){
if (powerground_calibration_stage != 4 && state.current_state == STATE_PRECHARGE){
switch (powerground_calibration_stage) {
case 0:
powerground_calibration_timer = HAL_GetTick() + 0;