Skip to content

Commit

Permalink
Fix Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dnakhooda committed Nov 1, 2024
1 parent fd84833 commit cf28eb6
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions platforms/stm32f405/src/can.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
* implement in `stm32xxxx_it.c`, which STM32CubeMX generates
*/

HAL_StatusTypeDef can_init(can_t *can) {
HAL_StatusTypeDef can_init(can_t *can)
{
/* set up interrupt & activate CAN */
HAL_CAN_IRQHandler(can->hcan);

int8_t err = HAL_CAN_ActivateNotification(can->hcan,
CAN_IT_RX_FIFO0_MSG_PENDING);
CAN_IT_RX_FIFO0_MSG_PENDING);
if (err != HAL_OK)
return err;
err = HAL_CAN_Start(can->hcan);
Expand All @@ -22,32 +23,34 @@ HAL_StatusTypeDef can_init(can_t *can) {
return err;
}

HAL_StatusTypeDef can_add_filter(can_t *can, uint32_t id_list[4]) {
HAL_StatusTypeDef can_add_filter(can_t *can, uint32_t id_list[4])
{
static int filterBank = 0;

if (filterBank > 7)
return HAL_ERROR;

CAN_FilterTypeDef filter;

filter.FilterActivation = ENABLE;
filter.FilterActivation = ENABLE;
filter.FilterFIFOAssignment = CAN_FILTER_FIFO0;
filter.FilterScale = CAN_FILTERSCALE_16BIT;
filter.FilterMode = CAN_FILTERMODE_IDLIST;

filter.FilterIdLow = id_list[0] << 5u;
filter.FilterMaskIdLow = id_list[1] << 5u;
filter.FilterIdHigh = id_list[2] << 5u;
filter.FilterMaskIdHigh = id_list[3] << 5u;
filter.FilterScale = CAN_FILTERSCALE_16BIT;
filter.FilterMode = CAN_FILTERMODE_IDLIST;

filter.FilterBank = filterBank;
filter.FilterIdLow = id_list[0] << 5u;
filter.FilterMaskIdLow = id_list[1] << 5u;
filter.FilterIdHigh = id_list[2] << 5u;
filter.FilterMaskIdHigh = id_list[3] << 5u;

filter.FilterBank = filterBank;

filterBank++;

return HAL_CAN_ConfigFilter(can->hcan, &filter);
}
}

HAL_StatusTypeDef can_send_msg(can_t *can, can_msg_t *msg) {
HAL_StatusTypeDef can_send_msg(can_t *can, can_msg_t *msg)
{
CAN_TxHeaderTypeDef tx_header;
tx_header.StdId = msg->id;
tx_header.ExtId = 0;
Expand All @@ -66,7 +69,8 @@ HAL_StatusTypeDef can_send_msg(can_t *can, can_msg_t *msg) {
return HAL_OK;
}

HAL_StatusTypeDef can_send_extended_msg(can_t *can, can_msg_t *msg) {
HAL_StatusTypeDef can_send_extended_msg(can_t *can, can_msg_t *msg)
{
CAN_TxHeaderTypeDef tx_header;
tx_header.StdId = 0;
tx_header.ExtId = msg->id;
Expand Down

0 comments on commit cf28eb6

Please sign in to comment.