2024-05-27 13:29:53 +02:00

29 lines
727 B
C

/*
* can.c
* Created on: Mai 23, 2024
* Author: Hamza
*/
#include "can.h"
//#define CAN_ID_IN 0x501
//#define CAN_ID_OUT 0x502
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));
}
void can_handle_recieve_command(const uint8_t *data){
ftcan_msg_received_cb(0x501, 16, data);
}