upload
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

lufa_hid.mk 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #
  2. # LUFA Library
  3. # Copyright (C) Dean Camera, 2014.
  4. #
  5. # dean [at] fourwalledcubicle [dot] com
  6. # www.lufa-lib.org
  7. #
  8. LUFA_BUILD_MODULES += HID
  9. LUFA_BUILD_TARGETS += hid hid-ee teensy teensy-ee
  10. LUFA_BUILD_MANDATORY_VARS += MCU TARGET
  11. LUFA_BUILD_OPTIONAL_VARS +=
  12. LUFA_BUILD_PROVIDED_VARS +=
  13. LUFA_BUILD_PROVIDED_MACROS +=
  14. # -----------------------------------------------------------------------------
  15. # LUFA HID Bootloader Buildsystem Makefile Module.
  16. # -----------------------------------------------------------------------------
  17. # DESCRIPTION:
  18. # Provides a set of targets to re-program a device currently running a HID
  19. # class bootloader with a project's FLASH files.
  20. # -----------------------------------------------------------------------------
  21. # TARGETS:
  22. #
  23. # hid - Program FLASH into target via
  24. # hid_bootloader_cli
  25. # hid-ee - Program EEPROM into target via a temporary
  26. # AVR application and hid_bootloader_cli
  27. # teensy - Program FLASH into target via
  28. # teensy_loader_cli
  29. # teensy-ee - Program EEPROM into target via a temporary
  30. # AVR application and teensy_loader_cli
  31. #
  32. # MANDATORY PARAMETERS:
  33. #
  34. # MCU - Microcontroller device model name
  35. # TARGET - Application name
  36. #
  37. # OPTIONAL PARAMETERS:
  38. #
  39. # (None)
  40. #
  41. # PROVIDED VARIABLES:
  42. #
  43. # (None)
  44. #
  45. # PROVIDED MACROS:
  46. #
  47. # (None)
  48. #
  49. # -----------------------------------------------------------------------------
  50. SHELL = /bin/sh
  51. LUFA_MODULE_PATH := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))
  52. ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))
  53. ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))
  54. ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
  55. # Sanity-check values of mandatory user-supplied variables
  56. $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
  57. $(call ERROR_IF_EMPTY, MCU)
  58. $(call ERROR_IF_EMPTY, TARGET)
  59. # Output Messages
  60. MSG_HID_BOOTLOADER_CMD := ' [HID] :'
  61. MSG_OBJCPY_CMD := ' [OBJCPY] :'
  62. MSG_MAKE_CMD := ' [MAKE] :'
  63. # Programs in the target FLASH memory using the HID_BOOTLOADER_CLI tool
  64. hid: $(TARGET).hex $(MAKEFILE_LIST)
  65. @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"
  66. hid_bootloader_cli -mmcu=$(MCU) -v $<
  67. # Programs in the target EEPROM memory using the HID_BOOTLOADER_CLI tool (note: clears target FLASH memory)
  68. hid-ee: $(TARGET).eep $(MAKEFILE_LIST)
  69. @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
  70. avr-objcopy -I ihex -O binary $< $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
  71. @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
  72. $(MAKE) -C $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean hid
  73. # Programs in the target FLASH memory using the TEENSY_BOOTLOADER_CLI tool
  74. teensy: $(TARGET).hex $(MAKEFILE_LIST)
  75. @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"
  76. teensy_loader_cli -mmcu=$(MCU) -v $<
  77. # Programs in the target EEPROM memory using the TEENSY_BOOTLOADER_CLI tool (note: clears target FLASH memory)
  78. teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)
  79. @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"
  80. avr-objcopy -I ihex -O binary $< $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/InputEEData.bin
  81. @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"
  82. $(MAKE) -s -C $(LUFA_MODULE_PATH)/HID_EEPROM_Loader/ MCU=$(MCU) clean teensy
  83. # Phony build targets for this module
  84. .PHONY: hid hid-ee teensy teensy-ee