Multiple frames (#8)

* Add fields to mmr header

* Reorder priority constants

* Add message priority

* Add header to message

* Fix compile error

* Set correct bits in header

* Refactor

* Create queue
This commit is contained in:
Stefano Calabretti
2022-01-25 18:12:33 +01:00
committed by GitHub
parent e7bb09478e
commit 174f5e8d76
6 changed files with 117 additions and 69 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ typedef struct {
* Represents a CAN message
*/
typedef struct {
CanId senderId;
MmrCanHeader header;
void *store;
} MmrCanMessage;
+14 -2
View File
@@ -24,18 +24,30 @@ typedef enum {
} MmrCanMessageType;
typedef enum {
MMR_CAN_MESSAGE_PRIORITY_LOW = B_(0010),
MMR_CAN_MESSAGE_PRIORITY_NORMAL = B_(0001),
MMR_CAN_MESSAGE_PRIORITY_HIGH = B_(0000),
} MmrCanMessagePriority;
/**
* @brief
* This struct encodes the values stored inside the
* extended id field of a CAN packet.
*/
typedef struct {
uint32_t priority : 5;
uint32_t senderId : 23;
MmrCanMessagePriority priority : 3;
uint32_t dictionaryEntry : 10;
uint32_t senderId : 12;
MmrCanMessageType messageType : 4;
} MmrCanHeader;
uint32_t *MMR_CAN_HeaderToBits(MmrCanHeader *header);
MmrCanHeader *MMR_CAN_HeaderFromBits(uint32_t *bits);
bool MMR_CAN_IsMultiFrame(MmrCanHeader *header);
bool MMR_CAN_IsMultiFrameEnd(MmrCanHeader *header);
+14
View File
@@ -0,0 +1,14 @@
#ifndef INC_MMR_CAN_QUEUE_H_
#define INC_MMR_CAN_QUEUE_H_
#include <stdint.h>
#include "mmr_can.h"
#define MMR_CAN_QUEUE_SIZE 10
typedef struct {
MmrCanMessage messages[MMR_CAN_QUEUE_SIZE];
size_t count;
} MmrCanQueue;
#endif /* INC_MMR_CAN_QUEUE_H_ */