-
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
0026f53
commit a685e98
Showing
2 changed files
with
155 additions
and
114 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
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 |
---|---|---|
@@ -1,52 +1,30 @@ | ||
#ifndef CAN_MANAGER_H | ||
#define CAN_MANAGER_H | ||
#ifndef CAN_MGR_H | ||
#define CAN_MGR_H | ||
|
||
#include "can_types.h" | ||
#include "generic_queue.h" | ||
#include "main.h" | ||
#include "stdbool.h" | ||
|
||
#define MAX_CAN_BUSES 2 | ||
#define CAN_MANAGER_MAX_QUEUE_ELEMENTS 50 | ||
#define CAN_MGR_MAX_CAN_BUSES 2 | ||
#define CAN_MGR_MAX_QUEUE_ELEMENTS 10 | ||
#define CAN_MGR_CAN_WAIT_ENABLED 1 | ||
#define CAN_MGR_FILTER_ERROR_CODE 2 | ||
#define CAN_MGR_CAN_INIT_IT_ERROR_CODE 3 | ||
#define CAN_MGR_CAN_START_ERROR_CODE 4 | ||
|
||
#define CM_CAN_ID_CHECK(can_id) \ | ||
if (can_id < 0 || can_id >= MAX_CAN_BUSES) \ | ||
#define CAN_MGR_ID_CHECK(can_id) \ | ||
if (can_id < 0 || can_id >= CAN_MGR_MAX_CAN_BUSES) \ | ||
return 0 | ||
|
||
#ifdef FDCAN_MANAGER | ||
#ifdef FDCAN_MGR | ||
int fdcan_init( | ||
FDCAN_HandleTypeDef *hcan, void(can_rx_msg_handler)(can_manager_message_t *), uint32_t activation_interrupt, | ||
uint32_t filter_config); | ||
FDCAN_FilterTypeDef *filter); | ||
#else | ||
int can_init( | ||
CAN_HandleTypeDef *hcan, void(can_rx_msg_handler)(can_manager_message_t *), uint32_t activation_interrupt, | ||
uint32_t filter_config); | ||
CAN_FilterTypeDef *filter); | ||
#endif | ||
|
||
#endif // CAN_MANAGER_H | ||
|
||
/*** | ||
* | ||
// CAN_interrupt | ||
can_manager_add_rx_queue(primary_can_id, &can_msg); | ||
int main() { | ||
// hcan, handler, priority | ||
int primary_can_id = can_init(&hcan1, handle_primary); | ||
int secondary_can_id = can_init(&hcan2, handle_secondary); | ||
while(1) { | ||
consume_rx_queue(primary_can_id); | ||
consume_rx_queue(secondary_can_id); | ||
flush_tx_queue(primary_can_id); | ||
flush_tx_queue(secondary_can_id); | ||
} | ||
} | ||
// libreria | ||
void consume_rx_queue() { | ||
// una volta per ogni coda, bastano circular_buffer | ||
} | ||
*/ | ||
#endif // CAN_MGR_H |