This repository has been archived on 2026-02-22. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
can/Src/mmr_can_header.c
T
2022-02-19 12:59:05 +01:00

36 lines
914 B
C

#include "mmr_can_header.h"
#include "mmr_can_util.h"
#include "mmr_can_optimize.h"
uint32_t MMR_CAN_HeaderToBits(MmrCanHeader header) {
return 0
| ((uint32_t)header.priority << 26)
| ((uint32_t)header.messageId << 23)
| ((uint32_t)header.senderId << 13)
| ((uint32_t)header.seqNumber << 3)
| ((uint32_t)header.messageType);
}
MmrCanHeader MMR_CAN_HeaderFromBits(uint32_t bits) {
return (MmrCanHeader) {
.priority = bits >> 26,
.messageId = bits >> 23,
.senderId = bits >> 13,
.seqNumber = bits >> 3,
.messageType = bits,
};
}
bool MMR_CAN_IsHeaderScs(MmrCanHeader header) {
return header.messageType == MMR_CAN_MESSAGE_TYPE_SCS;
}
bool MMR_CAN_IsMultiFrame(MmrCanHeader *header) {
return header->messageType == MMR_CAN_MESSAGE_TYPE_MULTI_FRAME;
}
bool MMR_CAN_IsMultiFrameEnd(MmrCanHeader *header) {
return header->messageType == MMR_CAN_MESSAGE_TYPE_MULTI_FRAME_END;
}