added sm_test_cycle_states();
This commit is contained in:
parent
a0e55c0f44
commit
cb4b5cb53e
@ -5,6 +5,9 @@
|
||||
#include <stdbool.h>
|
||||
#include "ADBMS_LL_Driver.h"
|
||||
#include "AMS_HighLevel.h"
|
||||
#include "PWM_control.h"
|
||||
#include "TMP1075.h"
|
||||
#include <math.h>
|
||||
|
||||
// Minimum vehicle side voltage to exit precharge
|
||||
#define MIN_VEHICLE_SIDE_VOLTAGE 150000 // mV
|
||||
@ -87,4 +90,6 @@ void sm_handle_ams_in(const uint8 *data);
|
||||
void sm_check_errors();
|
||||
void sm_set_error(ErrorKind error_kind, bool is_errored);
|
||||
|
||||
void sm_test_cycle_states();
|
||||
|
||||
#endif /* "INC_STATE_MACHINE_H" */
|
@ -1,11 +1,8 @@
|
||||
#include "state_machine.h"
|
||||
#include "ADBMS_LL_Driver.h"
|
||||
#include "TMP1075.h"
|
||||
#include "common_defs.h"
|
||||
#include <math.h>
|
||||
#include "stm32f3xx_hal.h"
|
||||
|
||||
StateHandle state;
|
||||
static int16_t timestamp;
|
||||
static uint32_t timestamp;
|
||||
|
||||
void sm_init(){
|
||||
state.current_state = STATE_INACTIVE;
|
||||
@ -16,7 +13,7 @@ void sm_init(){
|
||||
void sm_update(){
|
||||
RELAY_BAT_SIDE_VOLTAGE = module.auxVoltages[0];
|
||||
RELAY_ESC_SIDE_VOLTAGE = module.auxVoltages[1];
|
||||
CURRENT_MEASUREMENT_VOLTAGE = module.auxVoltages[2];
|
||||
CURRENT_MEASUREMENT = module.auxVoltages[2];
|
||||
|
||||
switch (state.current_state) {
|
||||
case STATE_INACTIVE:
|
||||
@ -232,3 +229,30 @@ void sm_check_errors(){
|
||||
state.error_source = (1 << 10);
|
||||
}
|
||||
}
|
||||
|
||||
void sm_test_cycle_states(){
|
||||
if (timestamp > HAL_GetTick())
|
||||
return;
|
||||
switch (state.current_state) {
|
||||
case STATE_INACTIVE:
|
||||
state.current_state = STATE_PRECHARGE;
|
||||
timestamp = HAL_GetTick() + 10000;
|
||||
return;
|
||||
case STATE_PRECHARGE:
|
||||
state.current_state = STATE_READY;
|
||||
timestamp = HAL_GetTick() + 10000;
|
||||
return;
|
||||
case STATE_READY:
|
||||
state.current_state = STATE_ACTIVE;
|
||||
timestamp = HAL_GetTick() + 10000;
|
||||
return;
|
||||
case STATE_ACTIVE:
|
||||
state.current_state = STATE_DISCHARGE;
|
||||
timestamp = HAL_GetTick() + 10000;
|
||||
return;
|
||||
case STATE_DISCHARGE:
|
||||
state.current_state = STATE_INACTIVE;
|
||||
timestamp = HAL_GetTick() + 10000;
|
||||
return;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user