3 # Released into the public domain.
5 # dean [at] fourwalledcubicle [dot] com
6 # www.fourwalledcubicle.com
9 DMBS_BUILD_MODULES += HID
10 DMBS_BUILD_TARGETS += hid hid-ee teensy teensy-ee
11 DMBS_BUILD_MANDATORY_VARS += MCU TARGET
12 DMBS_BUILD_OPTIONAL_VARS +=
13 DMBS_BUILD_PROVIDED_VARS +=
14 DMBS_BUILD_PROVIDED_MACROS +=
16 # Conditionally import the CORE module of DMBS if it is not already imported
17 DMBS_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
18 ifeq ($(findstring CORE, $(DMBS_BUILD_MODULES)),)
19 include $(DMBS_MODULE_PATH)/core.mk
22 # Sanity-check values of mandatory user-supplied variables
23 $(foreach MANDATORY_VAR, $(DMBS_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
24 $(call ERROR_IF_EMPTY, MCU)
25 $(call ERROR_IF_EMPTY, TARGET)
28 MSG_HID_BOOTLOADER_CMD := ' [HID] :'
29 MSG_OBJCPY_CMD := ' [OBJCPY] :'
30 MSG_MAKE_CMD := ' [MAKE] :'
32 # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
33 hid: $(TARGET).hex $(MAKEFILE_LIST)
34 @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
35 hid_bootloader_cli -mmcu=$(MCU) -v $<
37 # Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
38 hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
39 @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
40 avr-objcopy -I ihex -O binary $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
41 @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
42 $(MAKE) -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
44 # Programs in the target FLASH memory using the TEENSY_BOOTLOADER_CLI tool
45 teensy: $(TARGET).hex $(MAKEFILE_LIST)
46 @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
47 teensy_loader_cli -mmcu=$(MCU) -v $<
49 # Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
50 teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
51 @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
52 avr-objcopy -I ihex -O binary $< $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
53 @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
54 $(MAKE) -s -C $(DMBS_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean teensy
56 # Phony build targets for this module
57 .PHONY: $(DMBS_BUILD_TARGETS)