-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d87a3e0
commit 2a627ba
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include "can_handler.h" | ||
#include "FreeRTOS.h" | ||
|
||
typedef struct { | ||
can_msg_t can_msg; | ||
osThreadId_t msg_timer; | ||
uint8_t msg_rate; /* in messages per second */ | ||
} rl_can_msg_t; | ||
|
||
HAL_StatusTypeDef send_rl_can_msg(can_t *can, rl_can_msg_t *rl_can_msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
#include "can_utility.h" | ||
|
||
/** | ||
* Sends a rate limited can message | ||
*/ | ||
HAL_StatusTypeDef send_rl_can_msg(can_t *can, rl_can_msg_t *rl_can_msg) | ||
{ | ||
if (osTimerIsRunning(rl_can_msg->msg_timer)) { | ||
return HAL_BUSY; | ||
} | ||
|
||
can_send_msg(can, &rl_can_msg->can_msg); | ||
osTimerStart(rl_can_msg->msg_timer, | ||
pdMS_TO_TICKS(rl_can_msg->msg_rate * 1000)); | ||
|
||
return HAL_OK; | ||
} |