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:
committed by
GitHub
parent
e7bb09478e
commit
174f5e8d76
+10
-8
@@ -1,14 +1,11 @@
|
||||
#include <stdbool.h>
|
||||
#include "mmr_can.h"
|
||||
|
||||
static HalStatus receiveOne(ReceptionParams *rp);
|
||||
static HalStatus receiveAll(ReceptionParams *rp);
|
||||
static bool headerIsMultiFrame(MmrCanHeader *header, CanId targetId);
|
||||
|
||||
|
||||
typedef struct {
|
||||
CanHandle *handle;
|
||||
uint8_t *result;
|
||||
|
||||
struct {
|
||||
CanRxHeader rx;
|
||||
MmrCanHeader mmr;
|
||||
@@ -18,6 +15,11 @@ typedef struct {
|
||||
} ReceptionParams;
|
||||
|
||||
|
||||
static HalStatus receiveOne(ReceptionParams *rp);
|
||||
static HalStatus receiveAll(ReceptionParams *rp);
|
||||
static bool headerIsMultiFrame(MmrCanHeader *header, CanId targetId);
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Reads a CAN message and stores it inside the
|
||||
@@ -29,7 +31,7 @@ typedef struct {
|
||||
HalStatus MMR_CAN_Receive(CanHandle *hcan, MmrCanMessage *result) {
|
||||
ReceptionParams rp = {
|
||||
.handle = hcan,
|
||||
.result = interpretAs(uint8_t*, result->store),
|
||||
.result = (uint8_t*)result->store,
|
||||
.fifo = MMR_CAN_RX_FIFO,
|
||||
};
|
||||
|
||||
@@ -38,7 +40,7 @@ HalStatus MMR_CAN_Receive(CanHandle *hcan, MmrCanMessage *result) {
|
||||
return status;
|
||||
}
|
||||
|
||||
result->senderId = rp.headers.mmr.senderId;
|
||||
result->header = rp.headers.mmr;
|
||||
if (MMR_CAN_IsMultiFrame(&rp.headers.mmr)) {
|
||||
status |= receiveAll(&rp);
|
||||
}
|
||||
@@ -63,9 +65,9 @@ static HalStatus receiveAll(ReceptionParams *rp) {
|
||||
|
||||
static HalStatus receiveOne(ReceptionParams *rp) {
|
||||
HalStatus status =
|
||||
HAL_CAN_GetRxMessage(rp->hcan, rp->fifo, &(rp->headers.rx), rp->result);
|
||||
HAL_CAN_GetRxMessage(rp->handle, rp->fifo, &(rp->headers.rx), rp->result);
|
||||
|
||||
rp->headers.mmr = convertTo(MmrCanHeader, header->ExtId);
|
||||
rp->headers.mmr = convertTo(MmrCanHeader, rp->headers.rx.ExtId);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user