mv-bms/Core/Src/can.c
2024-05-24 19:06:34 +02:00

28 lines
673 B
C

/*
* can.c
* Created on: Mai 23, 2024
* Author: Hamza
*/
#include "can.h"
#include "AMS_HighLevel.h"
//#include "TMP1075.h"
#include "can-halal.h"
#include "state_machine.h"
void can_init(CAN_HandleTypeDef* hcan) { ftcan_init(hcan); }
/*
This function sends the status of the mvbms, the battery and of powerground.
once every 1s in states: INACTIVE, PRECHARGE, DISCHARGE, CHARGING, ERROR.
once every 0.5s in states: READY, ACTIVE.
with format of:
*/
void can_handle_send_status() {
static uint8_t data[8] = {};
data[0] = (state.current_state << 5); //save 5 bit since codes are from 0-6
ftcan_transmit(CAN_ID_OUT, data, sizeof(data));
}