Skip to content

Commit

Permalink
Reinit CAN module if bus off detected + add camera (#68)
Browse files Browse the repository at this point in the history
* Reinit CAN module if bus off detected

* Add camera
  • Loading branch information
BluCodeGH authored Aug 5, 2024
1 parent 5c06f99 commit b3b2e1c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion message_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions stm32h7/stm32h7_can.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down

0 comments on commit b3b2e1c

Please sign in to comment.