From bd170f8d6a8d5c5df674d0cd381ee65ee81b35af Mon Sep 17 00:00:00 2001 From: Gregor Riepl Date: Wed, 20 Jan 2021 15:41:43 +0100 Subject: [PATCH] Use bit masks for message flags --- messages.h | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/messages.h b/messages.h index bcd7945..eaa99de 100644 --- a/messages.h +++ b/messages.h @@ -2,6 +2,7 @@ #define _MESSAGES_H #include +#include #define CAN_HOSTID_FEEDBACK 0x000 #define CAN_HOSTID_POWER 0x001 @@ -10,24 +11,34 @@ #define CAN_MSG_FEEDBACK_STATUS 0x010 typedef struct { - uint8_t empty_g:1; - uint8_t empty_h:1; - uint8_t reset_sw:1; - uint8_t pad:5; - uint8_t end_d:1; - uint8_t end_e:1; - uint8_t end_f:1; - uint8_t end_g:1; - uint8_t end_h:1; - uint8_t empty_d:1; - uint8_t empty_e:1; - uint8_t empty_f:1; + uint8_t bits[2]; } can_msg_feedback_status_t; +#define CAN_MSG_FEEDBACK_STATUS_FIELD_RESET_SW 1 +#define CAN_MSG_FEEDBACK_STATUS_BIT_RESET_SW 0x04 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_EMPTY_H 1 +#define CAN_MSG_FEEDBACK_STATUS_BIT_EMPTY_H 0x02 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_EMPTY_G 1 +#define CAN_MSG_FEEDBACK_STATUS_BIT_EMPTY_G 0x01 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_EMPTY_F 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_EMPTY_F 0x80 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_EMPTY_E 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_EMPTY_E 0x40 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_EMPTY_D 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_EMPTY_D 0x20 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_END_H 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_END_H 0x10 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_END_G 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_END_G 0x08 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_END_F 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_END_F 0x04 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_END_E 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_END_E 0x02 +#define CAN_MSG_FEEDBACK_STATUS_FIELD_END_D 0 +#define CAN_MSG_FEEDBACK_STATUS_BIT_END_D 0x01 #define CAN_MSG_POWER_STATUS 0x011 typedef struct { - uint8_t statush; - uint8_t statusl; + uint8_t bits[2]; } can_msg_power_status_t; #define CAN_MSG_POWER_DISPENSE 0x021