Skip to content

Commit

Permalink
can manager: exposed can send api
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazzucchi committed Jan 24, 2024
1 parent 43ea4b6 commit 2fd08b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions can-manager/can_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* ++++++++++++++++++++++++
*
* int primary_can_id = -1;
* int secondary_can_id = -2;
* int secondary_can_id = -1;
*
* void f() {
* can_manager_message_t msg = {
Expand Down Expand Up @@ -159,7 +159,7 @@ void _fdcan_wait(FDCAN_HandleTypeDef *hcan) {
}
#endif

int _fdcan_send(int can_id, can_manager_message_t *msg) {
int fdcan_send(int can_id, can_manager_message_t *msg) {
CAN_MGR_ID_CHECK(can_id);
FDCAN_HandleTypeDef *hcan = fdcan_buses[can_id];

Expand Down Expand Up @@ -271,7 +271,7 @@ void _can_wait(CAN_HandleTypeDef *hcan) {
}
#endif

int _can_send(int can_id, can_manager_message_t *msg) {
int can_send(int can_id, can_manager_message_t *msg) {
CAN_MGR_ID_CHECK(can_id);
CAN_HandleTypeDef *hcan = can_buses[can_id];
#ifndef TEST
Expand Down Expand Up @@ -320,11 +320,11 @@ int flush_tx_queue(int can_id) {
int sent_messages = 0;
while (GENQ_pop(&_tx_queues[can_id], (uint8_t *)&msg)) {
#ifdef FDCAN_MGR
if (!_fdcan_send(can_id, &msg)) {
if (!fdcan_send(can_id, &msg)) {
return -1;
}
#else
if (!_can_send(can_id, &msg)) {
if (!can_send(can_id, &msg)) {
return -1;
}
#endif
Expand Down
5 changes: 5 additions & 0 deletions can-manager/can_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ typedef struct {
uint8_t data[8];
} can_manager_message_t;

#ifdef FDCAN_MGR
int fdcan_send(int can_id, can_manager_message_t *msg);
#else
int can_send(int can_id, can_manager_message_t *msg);
#endif
int consume_rx_queue(int can_id);
int flush_tx_queue(int can_id);
int add_to_rx_queue(int can_id, can_manager_message_t *msg);
Expand Down

0 comments on commit 2fd08b8

Please sign in to comment.