Add event handlers (#1)

* Add rx event handlers

* Fix compile errors and add constness

* Pass sender id

* Change api interface

* Revert changes

* Add filter fifo
This commit is contained in:
Stefano Calabretti
2021-11-30 19:34:18 +01:00
committed by GitHub
parent 503b333478
commit 90d1836dfa
6 changed files with 91 additions and 20 deletions
+6
View File
@@ -11,6 +11,12 @@
#define MMR_CAN_RX_FIFO CAN_RX_FIFO0
#endif
#if MMR_CAN_RX_FIFO == CAN_RX_FIFO0
#define MMR_CAN_FILTER_FIFO CAN_FILTER_FIFO0
#else
#define MMR_CAN_FILTER_FIFO CAN_FILTER_FIFO1
#endif
#if MMR_CAN_RX_FIFO == CAN_RX_FIFO0
#define MMR_CAN_RX_INTERRUPT CAN_IT_RX_FIFO0_MSG_PENDING
#else
+22
View File
@@ -0,0 +1,22 @@
#ifndef INC_MMR_CAN_EVENTS_H_
#define INC_MMR_CAN_EVENTS_H_
#include "mmr_can.h"
typedef struct {
CanId senderId;
uint8_t *message;
} MmrCanEvent;
typedef void (*MmrCanEventHandler)(MmrCanEvent *event);
typedef struct {
const MmrCanEventHandler *handlers;
const size_t count;
} MmrCanEventList;
void MMR_CAN_InitRxHandlers(const MmrCanEventList *rxEvents);
#endif /* INC_MMR_CAN_EVENTS_H_ */
+1 -1
View File
@@ -33,7 +33,7 @@ typedef uint8_t CanFilterBank;
typedef HAL_StatusTypeDef HalStatus;
typedef CAN_HandleTypeDef CanHandle;
typedef CAN_TxHeaderTypeDef CanTxHeader;
typedef CAN_RxHeaderTypeDef CanRxHeader;
typedef CAN_TxHeaderTypeDef CanTxHeader;
#endif /* INC_MMR_CAN_TYPES_H_ */
+3
View File
@@ -4,6 +4,9 @@
#include <stdint.h>
#include <string.h>
#define arrayLength(array) \
(sizeof(array) / sizeof(*(array)))
#define stringArrayLength(array) \
stringBufferLength((array), sizeof(array))