diff --git a/message_types.h b/message_types.h index 0bed009..ec0477f 100644 --- a/message_types.h +++ b/message_types.h @@ -181,6 +181,7 @@ enum BOARD_STATUS { E_LOGGING, // error_type x x x E_GPS, // x x x x E_SENSOR, // sensor_id x x x + E_VIDEO, // state x x x E_ILLEGAL_CAN_MSG, // x x x x E_SEGFAULT, // x x x x @@ -214,7 +215,8 @@ enum SENSOR_ID { SENSOR_PAYLOAD_TEMP, SENSOR_PAYLOAD_FLOW_RATE, SENSOR_9V_BATT_CURR_1, - SENSOR_9V_BATT_CURR_2 + SENSOR_9V_BATT_CURR_2, + SENSOR_FPS }; enum FILL_DIRECTION { diff --git a/stm32h7/stm32h7_can.c b/stm32h7/stm32h7_can.c index 71f9b7b..21f06d0 100644 --- a/stm32h7/stm32h7_can.c +++ b/stm32h7/stm32h7_can.c @@ -50,6 +50,13 @@ void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) } bool can_send(const can_msg_t* message) { + // Reinit the CAN module if a bus off state was detected + FDCAN_ProtocolStatusTypeDef protocolStatus = {}; + HAL_FDCAN_GetProtocolStatus(fdcan_handle, &protocolStatus); + if (protocolStatus.BusOff) { + CLEAR_BIT(fdcan_handle->Instance->CCCR, FDCAN_CCCR_INIT); + } + FDCAN_TxHeaderTypeDef TxHeader; uint8_t TxData[8] = {0};