#include #include "main.h" #include "can.h" #include "scs_sdc.h" #include "can-halal.h" extern int can_ams_last_tick; extern TSState request_state; HAL_StatusTypeDef can_init(FDCAN_HandleTypeDef* handle) { TRY(ftcan_init(handle)); TRY(ftcan_add_filter(CAN_ID_AMS_STATUS, 0xFFF)); TRY(ftcan_add_filter(CAN_ID_AMS_ERROR, 0xFFF)); return HAL_OK; } HAL_StatusTypeDef can_update_state(){ uint8_t data; if (request_state == TS_ACTIVE){ data = 0x01; } else if (request_state == TS_INACTIVE) { data = 0x00; } else { return HAL_ERROR; } return ftcan_transmit(CAN_ID_AMS_IN, &data, sizeof(data)); } void ftcan_msg_received_cb(uint16_t id, size_t len, const uint8_t* data) { switch (id) { case CAN_ID_AMS_STATUS: can_ams_last_tick = HAL_GetTick(); ts_handle_ams_status(data); break; case CAN_ID_AMS_SIGNALS: break; case CAN_ID_AMS_ERROR: break; default: break; } }