Skip to content

Commit

Permalink
Get messages (#72)
Browse files Browse the repository at this point in the history
* Added receive_msg function to get voltage and current CAN messgaes with arbitrary IDs

* fixed receive_msg

* finish receiving messages

* Removing receive message from fsdcan driver

---------

Co-authored-by: Scott A <[email protected]>
  • Loading branch information
caiodasilva2005 and Sabramz authored Feb 8, 2024
1 parent 18bfb4f commit 88be9f0
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions platforms/stm32g431/src/fdcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,4 @@ HAL_StatusTypeDef can_send_msg(can_t *can, can_msg_t *msg)
return HAL_ERROR;

return HAL_OK;
}

HAL_StatusTypeDef receive_msg(can_t *can)
{

FDCAN_RxHeaderTypeDef rx_header;
uint8_t rx_data[8]; //array of 8 bytes

if (HAL_FDCAN_GetRxFifoFillLevel(can->hcan, FDCAN_RX_FIFO0) > 0) { //Check if messages are available
if (HAL_FDCAN_GetRxMessage(can->hcan,FDCAN_RX_FIFO0,&rx_header,rx_data) == HAL_OK) {
uint32_t message_id = rx_header.Identifier;
if (message_id == VOLTAGE_CAN_ID) {
//process voltage ID
}
if (message_id == CURRENT_CAN_ID) {
//process current ID
}
return HAL_OK; //message was received
}
return HAL_ERROR; //Message was not received
}
return HAL_BUSY; //Rx FIFO did not contain messages
}

}

0 comments on commit 88be9f0

Please sign in to comment.