added delay for CAN
This commit is contained in:
parent
ad21577cbb
commit
e48b87a11e
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#define CAN_ID_IN 0x501
|
#define CAN_ID_IN 0x501
|
||||||
#define CAN_ID_OUT 0x502
|
#define CAN_ID_OUT 0x502
|
||||||
|
#define CAN_STATUS_FREQ 1000
|
||||||
void can_init(CAN_HandleTypeDef* hcan);
|
void can_init(CAN_HandleTypeDef* hcan);
|
||||||
|
|
||||||
void can_handle_send_status();
|
void can_handle_send_status();
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
#include "can.h"
|
#include "can.h"
|
||||||
#include "ADBMS_Abstraction.h"
|
#include "ADBMS_Abstraction.h"
|
||||||
#include "state_machine.h"
|
#include "state_machine.h"
|
||||||
|
#include "stm32f3xx_hal.h"
|
||||||
|
|
||||||
//#define CAN_ID_IN 0x501
|
//#define CAN_ID_IN 0x501
|
||||||
//#define CAN_ID_OUT 0x502
|
//#define CAN_ID_OUT 0x502
|
||||||
|
int can_delay_manager = 0;
|
||||||
void can_init(CAN_HandleTypeDef* hcan) { ftcan_init(hcan); }
|
void can_init(CAN_HandleTypeDef* hcan) { ftcan_init(hcan); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -33,6 +35,11 @@ bit 51-62: temperature of the cell with highest temperature (12 bits moved 4 bit
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void can_handle_send_status() {
|
void can_handle_send_status() {
|
||||||
|
if (can_delay_manager > HAL_GetTick())
|
||||||
|
return;
|
||||||
|
else
|
||||||
|
can_delay_manager = HAL_GetTick() + CAN_STATUS_FREQ;
|
||||||
|
|
||||||
uint8_t data[8] = {};
|
uint8_t data[8] = {};
|
||||||
data[0] = (state.current_state << 5); // save 5 bit since codes are from 0-7 61 bits left
|
data[0] = (state.current_state << 5); // save 5 bit since codes are from 0-7 61 bits left
|
||||||
//data[1] = // in 8 bits from 0-100%
|
//data[1] = // in 8 bits from 0-100%
|
||||||
|
@ -134,6 +134,7 @@ int main(void)
|
|||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
|
/*
|
||||||
int ttt = HAL_GetTick() + 45000;
|
int ttt = HAL_GetTick() + 45000;
|
||||||
PWM_powerground_control(0);
|
PWM_powerground_control(0);
|
||||||
while (HAL_GetTick() < ttt){}
|
while (HAL_GetTick() < ttt){}
|
||||||
@ -143,11 +144,12 @@ int main(void)
|
|||||||
PWM_powerground_control(15);
|
PWM_powerground_control(15);
|
||||||
ttt = HAL_GetTick() + 5000;
|
ttt = HAL_GetTick() + 5000;
|
||||||
while (HAL_GetTick() < ttt){}
|
while (HAL_GetTick() < ttt){}
|
||||||
|
*/
|
||||||
|
|
||||||
//AMS_Loop();
|
AMS_Loop();
|
||||||
//sm_update();
|
sm_update();
|
||||||
//sm_test_cycle_states();
|
//sm_test_cycle_states();
|
||||||
//can_handle_send_status();
|
can_handle_send_status();
|
||||||
}
|
}
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,9 @@ void sm_init(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sm_update(){
|
void sm_update(){
|
||||||
RELAY_BAT_SIDE_VOLTAGE = mV_from_ADBMS6830(module.auxVoltages[0]);
|
RELAY_BAT_SIDE_VOLTAGE = module.auxVoltages[0] * 11.989;
|
||||||
RELAY_ESC_SIDE_VOLTAGE = mV_from_ADBMS6830(module.auxVoltages[1]);
|
RELAY_ESC_SIDE_VOLTAGE = module.auxVoltages[1] * 11.989;
|
||||||
CURRENT_MEASUREMENT = mV_from_ADBMS6830(module.auxVoltages[2]);
|
CURRENT_MEASUREMENT = module.auxVoltages[2] ;
|
||||||
|
|
||||||
switch (state.current_state) {
|
switch (state.current_state) {
|
||||||
case STATE_INACTIVE:
|
case STATE_INACTIVE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user