From 677150f09b3631249f4984ca92e08f687591fd6b Mon Sep 17 00:00:00 2001 From: Gregor Riepl Date: Tue, 19 Jan 2021 19:30:35 +0100 Subject: [PATCH] Add symbolic CAN message constants --- feedback/firmware/Makefile | 5 ++-- feedback/firmware/main.c | 1 + messages.h | 47 ++++++++++++++++++++++++++++++++++++ poweriface/firmware/Makefile | 5 ++-- poweriface/firmware/main.c | 1 + 5 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 messages.h diff --git a/feedback/firmware/Makefile b/feedback/firmware/Makefile index 7225ebd..e7b223e 100644 --- a/feedback/firmware/Makefile +++ b/feedback/firmware/Makefile @@ -1,5 +1,6 @@ PRG = feedback -AVRCANLIB_PATH = ../../avr-can-lib +PROJ_ROOT = ../.. +AVRCANLIB_PATH = $(PROJ_ROOT)/avr-can-lib OBJ = main.o \ $(AVRCANLIB_PATH)/src/at90can_buffer.o \ $(AVRCANLIB_PATH)/src/at90can.o \ @@ -21,7 +22,7 @@ PROGRAMMER = usbtiny MCU_TARGET = atmega32m1 DEFS = -DF_CPU=16000000UL -DHAS_CAN_CONFIG_H -INCLUDES = -I. -I$(AVRCANLIB_PATH) +INCLUDES = -I. -I$(PROJ_ROOT) -I$(AVRCANLIB_PATH) LIBS = LFUSE = 0xdf diff --git a/feedback/firmware/main.c b/feedback/firmware/main.c index 881b366..b28fdfa 100644 --- a/feedback/firmware/main.c +++ b/feedback/firmware/main.c @@ -3,6 +3,7 @@ #include #include #include +#include static bool report_change = false; static uint16_t saved_status; diff --git a/messages.h b/messages.h new file mode 100644 index 0000000..bcd7945 --- /dev/null +++ b/messages.h @@ -0,0 +1,47 @@ +#ifndef _MESSAGES_H +#define _MESSAGES_H + +#include + +#define CAN_HOSTID_FEEDBACK 0x000 +#define CAN_HOSTID_POWER 0x001 +#define CAN_HOSTID_BROADCAST 0x00f +#define CAN_HOSTID_MASK 0x00f + +#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; +} can_msg_feedback_status_t; + +#define CAN_MSG_POWER_STATUS 0x011 +typedef struct { + uint8_t statush; + uint8_t statusl; +} can_msg_power_status_t; + +#define CAN_MSG_POWER_DISPENSE 0x021 +typedef uint8_t can_msg_power_dispense_t; +#define CAN_MSG_POWER_DISPENSE_OFF 0x00 +#define CAN_MSG_POWER_DISPENSE_SLOT1 0x01 +#define CAN_MSG_POWER_DISPENSE_SLOT2 0x02 +#define CAN_MSG_POWER_DISPENSE_SLOT3 0x03 +#define CAN_MSG_POWER_DISPENSE_SLOT4 0x04 +#define CAN_MSG_POWER_DISPENSE_SLOT5 0x05 + +#define CAN_MSG_AUTO_STATUS 0x04f +typedef uint8_t can_msg_auto_status_t; +#define CAN_MSG_AUTO_STATUS_DISABLE 0x00 +#define CAN_MSG_AUTO_STATUS_ENABLE 0x01 + +#endif diff --git a/poweriface/firmware/Makefile b/poweriface/firmware/Makefile index 38e056f..eac28f4 100644 --- a/poweriface/firmware/Makefile +++ b/poweriface/firmware/Makefile @@ -1,5 +1,6 @@ PRG = poweriface -AVRCANLIB_PATH = ../../avr-can-lib +PROJ_ROOT = ../.. +AVRCANLIB_PATH = $(PROJ_ROOT)/avr-can-lib OBJ = main.o \ $(AVRCANLIB_PATH)/src/at90can_buffer.o \ $(AVRCANLIB_PATH)/src/at90can.o \ @@ -21,7 +22,7 @@ PROGRAMMER = usbtiny MCU_TARGET = atmega32m1 DEFS = -DF_CPU=16000000UL -DHAS_CAN_CONFIG_H -INCLUDES = -I. -I$(AVRCANLIB_PATH) +INCLUDES = -I. -I$(PROJ_ROOT) -I$(AVRCANLIB_PATH) LIBS = LFUSE = 0xdf diff --git a/poweriface/firmware/main.c b/poweriface/firmware/main.c index 6cdd2c3..7f61573 100644 --- a/poweriface/firmware/main.c +++ b/poweriface/firmware/main.c @@ -4,6 +4,7 @@ #include #include #include +#include static bool report_change = false;