This should be the state of the code from the end of the FT23 season
41 lines
674 B
C
41 lines
674 B
C
/*
|
|
* can.c
|
|
*
|
|
* Created on: 21.06.2023
|
|
* Author: max
|
|
*/
|
|
|
|
|
|
#include "can.h"
|
|
#include "can-halal.h"
|
|
#include "slave_handler.h"
|
|
#include "b_cccv_algo.h"
|
|
|
|
void initCan(FDCAN_HandleTypeDef *hcan)
|
|
{
|
|
ftcan_init(hcan);
|
|
ftcan_add_filter(0, 0);
|
|
}
|
|
|
|
void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data)
|
|
{
|
|
if ((id & 0xFF0) == CAN_ID_SLAVE_STATUS_BASE) {
|
|
slaves_handle_status(data);
|
|
return;
|
|
}
|
|
|
|
if (id == CAN_ID_CHARGER_ACTIVE)
|
|
{
|
|
if(data[0] == 1)
|
|
{
|
|
uint8_t* ptr = &data[1];
|
|
startcharging(((float) ftcan_unmarshal_unsigned(&ptr, 2))/10000);
|
|
}
|
|
else
|
|
{
|
|
stopcharging();
|
|
}
|
|
return;
|
|
}
|
|
}
|