Update header (#9)
* Add ack message type * Rename dictionaryEntry to messageId * Refactor * Map message ids
This commit is contained in:
committed by
GitHub
parent
174f5e8d76
commit
906dfcd3db
@@ -4,6 +4,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "mmr_can_util.h"
|
#include "mmr_can_util.h"
|
||||||
#include "mmr_can_binary_literals.h"
|
#include "mmr_can_binary_literals.h"
|
||||||
|
#include "mmr_can_message_id.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
@@ -18,13 +19,13 @@
|
|||||||
* messages have a higher priority over normal ones
|
* messages have a higher priority over normal ones
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
MMR_CAN_MESSAGE_ACK = B_(0001),
|
||||||
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME = B_(0010),
|
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME = B_(0010),
|
||||||
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME_END = B_(0011),
|
MMR_CAN_MESSAGE_TYPE_MULTI_FRAME_END = B_(0011),
|
||||||
MMR_CAN_MESSAGE_TYPE_NORMAL = B_(1000),
|
MMR_CAN_MESSAGE_TYPE_NORMAL = B_(1000),
|
||||||
} MmrCanMessageType;
|
} MmrCanMessageType;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MMR_CAN_MESSAGE_PRIORITY_LOW = B_(0010),
|
MMR_CAN_MESSAGE_PRIORITY_LOW = B_(0010),
|
||||||
MMR_CAN_MESSAGE_PRIORITY_NORMAL = B_(0001),
|
MMR_CAN_MESSAGE_PRIORITY_NORMAL = B_(0001),
|
||||||
@@ -39,7 +40,7 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MmrCanMessagePriority priority : 3;
|
MmrCanMessagePriority priority : 3;
|
||||||
uint32_t dictionaryEntry : 10;
|
MmrCanMessageId messageId : 10;
|
||||||
uint32_t senderId : 12;
|
uint32_t senderId : 12;
|
||||||
MmrCanMessageType messageType : 4;
|
MmrCanMessageType messageType : 4;
|
||||||
} MmrCanHeader;
|
} MmrCanHeader;
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#ifndef INC_MMR_CAN_MESSAGE_ID_H_
|
||||||
|
#define INC_MMR_CAN_MESSAGE_ID_H_
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "mmr_can_binary_literals.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
* Message ids are 10 bits wide
|
||||||
|
* The first 3 bits determine the message id type, while
|
||||||
|
* the other 7 determine the subtype.
|
||||||
|
*
|
||||||
|
* Ids scheme:
|
||||||
|
*
|
||||||
|
* id | type | subtype
|
||||||
|
* -----|------|---------
|
||||||
|
* SCS | 000 | xxxxxxx
|
||||||
|
*/
|
||||||
|
typedef enum MmrCanMessageId MmrCanMessageId;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
MMR_CAN_MESSAGE_ID_TYPE_SCS = 0,
|
||||||
|
} MmrCanMessageIdType;
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t MMR_CAN_GetMessageIdType(MmrCanMessageId msgId);
|
||||||
|
uint8_t MMR_CAN_GetMessageIdSubtype(MmrCanMessageId msgId);
|
||||||
|
|
||||||
|
bool MMR_CAN_IsMessageIdOfType(MmrCanMessageId msgId, MmrCanMessageIdType type);
|
||||||
|
bool MMR_CAN_IsMessageIdSCS(MmrCanMessageId msgId);
|
||||||
|
|
||||||
|
|
||||||
|
enum MmrCanMessageId {
|
||||||
|
// SCS
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_PPA = 0x1,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_PLF,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_LV12,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_LV24,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_PF,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_FRBPS,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_EBS,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_APPS,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_TPS,
|
||||||
|
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AS_R2D,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AS_TS,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AS_FINISHED,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AS_EMERGENCY,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AS_READY,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AS_DRIVING,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AS_OFF,
|
||||||
|
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AM_MANUAL_DRIVING,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AM_ACCELERATION,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AM_SKIDPAD,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AM_AUTOCROSS,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AM_TRACKDRIVE,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AM_EBS_TEST,
|
||||||
|
MMR_CAN_MESSAGE_ID_SCS_AM_INSPECTION = 0x17,
|
||||||
|
// !SCS
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // !INC_MMR_CAN_MESSAGE_ID_H_
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
#include "mmr_can_message_id.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool MMR_CAN_IsMessageIdSCS(MmrCanMessageId msgId) {
|
||||||
|
return MMR_CAN_IsMessageIdOfType(msgId, MMR_CAN_MESSAGE_ID_TYPE_SCS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MMR_CAN_IsMessageIdOfType(
|
||||||
|
MmrCanMessageId msgId,
|
||||||
|
MmrCanMessageIdType type
|
||||||
|
) {
|
||||||
|
return MMR_CAN_GetMessageIdType(msgId) == type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t MMR_CAN_GetMessageIdType(MmrCanMessageId msgId) {
|
||||||
|
return msgId >> 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t MMR_CAN_GetMessageIdSubtype(MmrCanMessageId msgId) {
|
||||||
|
return msgId & B8_(0111, 1111);
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ static uint8_t computeNextMessageLength(MmrCanPacket *packet);
|
|||||||
static void setMessageType(TransmissionParams *header, MmrCanMessageType type);
|
static void setMessageType(TransmissionParams *header, MmrCanMessageType type);
|
||||||
static void syncHeaders(TransmissionParams *tp);
|
static void syncHeaders(TransmissionParams *tp);
|
||||||
|
|
||||||
|
|
||||||
HalStatus MMR_CAN_Send(CanHandle *hcan, MmrCanPacket packet) {
|
HalStatus MMR_CAN_Send(CanHandle *hcan, MmrCanPacket packet) {
|
||||||
TransmissionParams tp = {
|
TransmissionParams tp = {
|
||||||
.handle = hcan,
|
.handle = hcan,
|
||||||
|
|||||||
Reference in New Issue
Block a user