Skip to content

Commit

Permalink
can handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Donahue committed Dec 16, 2023
1 parent 1576590 commit 324464e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Core/Inc/can_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ can_t can2;
/* Shepherd hanbdles both can busses the same way */
void can_receive_callback(CAN_HandleTypeDef *hcan);

void get_can_msg();
uint8_t get_can_msg(can_msg_t* msg);

#endif // CAN_HANDLER_H
9 changes: 8 additions & 1 deletion Core/Src/can_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ void can_receive_callback(CAN_HandleTypeDef *hcan)
new_msg.len = rx_header.DLC;
new_msg.id = rx_header.StdId;

enqueue(can_receive_queue, new_msg.data);
ringbuffer_enqueue(can_receive_queue, new_msg);
}

uint8_t get_can_msg(can_msg_t* msg)
{
/* no messages to read */
if (ringbuffer_is_empty(&can_receive_queue)) return -1;

ringbuffer_dequeue(&can_receive_queue, msg);
}

0 comments on commit 324464e

Please sign in to comment.