/* * 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" #include "charger_control.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; }*/ switch (id) { case CAN_ID_AMS_STATUS: { int sdc_closed = data[0] >> 7; if (sdc_closed == 0) { charger_control_disable_remote(); } break; } case CAN_ID_AMS_IN: { int active = data[0] & 0x01; if (active) { charger_control_enable_remote(); } } } }