added delay for CAN

This commit is contained in:
2024-06-02 23:06:07 +03:00
parent ad21577cbb
commit e48b87a11e
4 changed files with 16 additions and 7 deletions

View File

@ -7,9 +7,11 @@
#include "can.h"
#include "ADBMS_Abstraction.h"
#include "state_machine.h"
#include "stm32f3xx_hal.h"
//#define CAN_ID_IN 0x501
//#define CAN_ID_OUT 0x502
int can_delay_manager = 0;
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() {
if (can_delay_manager > HAL_GetTick())
return;
else
can_delay_manager = HAL_GetTick() + CAN_STATUS_FREQ;
uint8_t data[8] = {};
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%