aboutsummaryrefslogtreecommitdiffstats
path: root/testhal
diff options
context:
space:
mode:
Diffstat (limited to 'testhal')
-rw-r--r--testhal/AVR/MEGA/ADC/Makefile114
-rw-r--r--testhal/AVR/MEGA/EXT/Makefile114
-rw-r--r--testhal/AVR/MEGA/GPT/Makefile114
-rw-r--r--testhal/AVR/MEGA/I2C/Makefile114
-rw-r--r--testhal/AVR/MEGA/ICU/Makefile114
-rw-r--r--testhal/AVR/MEGA/PWM/Makefile114
-rw-r--r--testhal/AVR/MEGA/SPI/Makefile114
7 files changed, 700 insertions, 98 deletions
diff --git a/testhal/AVR/MEGA/ADC/Makefile b/testhal/AVR/MEGA/ADC/Makefile
index aafd4002f..97a49e120 100644
--- a/testhal/AVR/MEGA/ADC/Makefile
+++ b/testhal/AVR/MEGA/ADC/Makefile
@@ -56,6 +56,21 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),)
USE_VERBOSE_PROGRAMMATION = no
endif
+# Enable this if you want to use AVRDUDE programmer.
+ifeq ($(USE_AVRDUDE_PROGRAMMER),)
+ USE_AVRDUDE_PROGRAMMER = yes
+endif
+
+# Enable this if you want to use DFU programmer.
+ifeq ($(USE_DFU_PROGRAMMER),)
+ USE_DFU_PROGRAMMER = no
+endif
+
+# Enable this if you want to use MICRONUCLEUS programmer.
+ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),)
+ USE_MICRONUCLEUS_PROGRAMMER = no
+endif
+
#
# Building and programming global options.
##############################################################################
@@ -67,7 +82,7 @@ endif
# Define project name here.
PROJECT = ch
-# Imported source files.
+# Imported source files and paths
CHIBIOS = ../../../..
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
@@ -95,8 +110,8 @@ CSRC = $(KERNSRC) \
CPPSRC =
INCDIR = $(CHIBIOS)/os/license $(PORTINC) $(KERNINC) \
- $(HALINC) $(OSALINC) $(PLATFORMINC) \
- $(BOARDINC) $(CHIBIOS)/os/various $(STREAMSINC)
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(TESTINC) \
+ $(BOARDINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths.
@@ -132,9 +147,6 @@ SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
-# AVR programming tool.
-AVRDUDE = avrdude
-
# Size of the elf binary file.
ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
@@ -175,18 +187,30 @@ ULIBS =
##############################################################################
##############################################################################
-# Start of programming Options (avrdude).
+# Start of programming Options.
#
-# TODO: Add the programmer for ATtiny, and for ATXmega.
-# AVR programmer.
-AVRDUDE_PROGRAMMER = wiring
+# List of available AVR programmer.
+AVRDUDE_PROGRAMMER = avrdude
+AVRDUDE_PROGRAMMER_ID = wiring
+DFU_PROGRAMMER = dfu-programmer
+MICRONUCLEUS = micronucleus
+
+# Set the AVR programmer according to the selection..
+ifeq ($(USE_AVRDUDE_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER)
+else ifeq ($(USE_DFU_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(DFU_PROGRAMMER)
+else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER)
+else
+ $(error ERROR: Please you need to configure the AVR programmer!)
+endif
# AVR serial port.
AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
# Check if the counter cycle erase must be performed after device programming.
ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
@@ -203,17 +227,37 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
AVRDUDE_VERBOSE = -v -v
endif
-# AVR programmer flags.
+# AVR programmer flags for AVRDUDE programmer.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -b 115200
-AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+endif
+
+# AVR programmer flags for DFU programmer.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+DFU_WRITE_FLASH = flash --force
+DFU_ERASE_FLASH = erase
+DFU_RESET=reset
+endif
+
+# AVR programmer flags for MICRONUCLEUS programmer.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+MICRONUCLEUS_TIMEOUT_ARG = --timeout 60
+MICRONUCLEUS_RUN_ARG = --run
+MICRONUCLEUS_TYPE_ARG = --type raw
+MICRONUCLEUS_DUMP_PROGRESS = --dump-progress
+MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG)
+endif
#
-# End of Programming Options (avrdude).
+# End of Programming Options.
##############################################################################
##############################################################################
@@ -227,4 +271,46 @@ include $(RULESPATH)/rules.mk
# End of include file.
##############################################################################
+##############################################################################
+# Programming rules
+#
+
+# AVRDUDE programming rules.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $<
+ @echo Done.
+endif
+
+# DFU programming rules.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $<
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET)
+ @echo Done.
+
+erase:
+ @echo
+ @echo Erasing $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH)
+ @echo Done.
+endif
+
+# MICRONUCLEUS programming rules.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).bin
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $<
+ @echo Done.
+endif
+
+#
+# End of programming rules.
+##############################################################################
+
# EOF
diff --git a/testhal/AVR/MEGA/EXT/Makefile b/testhal/AVR/MEGA/EXT/Makefile
index aafd4002f..97a49e120 100644
--- a/testhal/AVR/MEGA/EXT/Makefile
+++ b/testhal/AVR/MEGA/EXT/Makefile
@@ -56,6 +56,21 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),)
USE_VERBOSE_PROGRAMMATION = no
endif
+# Enable this if you want to use AVRDUDE programmer.
+ifeq ($(USE_AVRDUDE_PROGRAMMER),)
+ USE_AVRDUDE_PROGRAMMER = yes
+endif
+
+# Enable this if you want to use DFU programmer.
+ifeq ($(USE_DFU_PROGRAMMER),)
+ USE_DFU_PROGRAMMER = no
+endif
+
+# Enable this if you want to use MICRONUCLEUS programmer.
+ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),)
+ USE_MICRONUCLEUS_PROGRAMMER = no
+endif
+
#
# Building and programming global options.
##############################################################################
@@ -67,7 +82,7 @@ endif
# Define project name here.
PROJECT = ch
-# Imported source files.
+# Imported source files and paths
CHIBIOS = ../../../..
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
@@ -95,8 +110,8 @@ CSRC = $(KERNSRC) \
CPPSRC =
INCDIR = $(CHIBIOS)/os/license $(PORTINC) $(KERNINC) \
- $(HALINC) $(OSALINC) $(PLATFORMINC) \
- $(BOARDINC) $(CHIBIOS)/os/various $(STREAMSINC)
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(TESTINC) \
+ $(BOARDINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths.
@@ -132,9 +147,6 @@ SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
-# AVR programming tool.
-AVRDUDE = avrdude
-
# Size of the elf binary file.
ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
@@ -175,18 +187,30 @@ ULIBS =
##############################################################################
##############################################################################
-# Start of programming Options (avrdude).
+# Start of programming Options.
#
-# TODO: Add the programmer for ATtiny, and for ATXmega.
-# AVR programmer.
-AVRDUDE_PROGRAMMER = wiring
+# List of available AVR programmer.
+AVRDUDE_PROGRAMMER = avrdude
+AVRDUDE_PROGRAMMER_ID = wiring
+DFU_PROGRAMMER = dfu-programmer
+MICRONUCLEUS = micronucleus
+
+# Set the AVR programmer according to the selection..
+ifeq ($(USE_AVRDUDE_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER)
+else ifeq ($(USE_DFU_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(DFU_PROGRAMMER)
+else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER)
+else
+ $(error ERROR: Please you need to configure the AVR programmer!)
+endif
# AVR serial port.
AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
# Check if the counter cycle erase must be performed after device programming.
ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
@@ -203,17 +227,37 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
AVRDUDE_VERBOSE = -v -v
endif
-# AVR programmer flags.
+# AVR programmer flags for AVRDUDE programmer.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -b 115200
-AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+endif
+
+# AVR programmer flags for DFU programmer.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+DFU_WRITE_FLASH = flash --force
+DFU_ERASE_FLASH = erase
+DFU_RESET=reset
+endif
+
+# AVR programmer flags for MICRONUCLEUS programmer.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+MICRONUCLEUS_TIMEOUT_ARG = --timeout 60
+MICRONUCLEUS_RUN_ARG = --run
+MICRONUCLEUS_TYPE_ARG = --type raw
+MICRONUCLEUS_DUMP_PROGRESS = --dump-progress
+MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG)
+endif
#
-# End of Programming Options (avrdude).
+# End of Programming Options.
##############################################################################
##############################################################################
@@ -227,4 +271,46 @@ include $(RULESPATH)/rules.mk
# End of include file.
##############################################################################
+##############################################################################
+# Programming rules
+#
+
+# AVRDUDE programming rules.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $<
+ @echo Done.
+endif
+
+# DFU programming rules.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $<
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET)
+ @echo Done.
+
+erase:
+ @echo
+ @echo Erasing $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH)
+ @echo Done.
+endif
+
+# MICRONUCLEUS programming rules.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).bin
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $<
+ @echo Done.
+endif
+
+#
+# End of programming rules.
+##############################################################################
+
# EOF
diff --git a/testhal/AVR/MEGA/GPT/Makefile b/testhal/AVR/MEGA/GPT/Makefile
index aafd4002f..97a49e120 100644
--- a/testhal/AVR/MEGA/GPT/Makefile
+++ b/testhal/AVR/MEGA/GPT/Makefile
@@ -56,6 +56,21 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),)
USE_VERBOSE_PROGRAMMATION = no
endif
+# Enable this if you want to use AVRDUDE programmer.
+ifeq ($(USE_AVRDUDE_PROGRAMMER),)
+ USE_AVRDUDE_PROGRAMMER = yes
+endif
+
+# Enable this if you want to use DFU programmer.
+ifeq ($(USE_DFU_PROGRAMMER),)
+ USE_DFU_PROGRAMMER = no
+endif
+
+# Enable this if you want to use MICRONUCLEUS programmer.
+ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),)
+ USE_MICRONUCLEUS_PROGRAMMER = no
+endif
+
#
# Building and programming global options.
##############################################################################
@@ -67,7 +82,7 @@ endif
# Define project name here.
PROJECT = ch
-# Imported source files.
+# Imported source files and paths
CHIBIOS = ../../../..
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
@@ -95,8 +110,8 @@ CSRC = $(KERNSRC) \
CPPSRC =
INCDIR = $(CHIBIOS)/os/license $(PORTINC) $(KERNINC) \
- $(HALINC) $(OSALINC) $(PLATFORMINC) \
- $(BOARDINC) $(CHIBIOS)/os/various $(STREAMSINC)
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(TESTINC) \
+ $(BOARDINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths.
@@ -132,9 +147,6 @@ SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
-# AVR programming tool.
-AVRDUDE = avrdude
-
# Size of the elf binary file.
ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
@@ -175,18 +187,30 @@ ULIBS =
##############################################################################
##############################################################################
-# Start of programming Options (avrdude).
+# Start of programming Options.
#
-# TODO: Add the programmer for ATtiny, and for ATXmega.
-# AVR programmer.
-AVRDUDE_PROGRAMMER = wiring
+# List of available AVR programmer.
+AVRDUDE_PROGRAMMER = avrdude
+AVRDUDE_PROGRAMMER_ID = wiring
+DFU_PROGRAMMER = dfu-programmer
+MICRONUCLEUS = micronucleus
+
+# Set the AVR programmer according to the selection..
+ifeq ($(USE_AVRDUDE_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER)
+else ifeq ($(USE_DFU_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(DFU_PROGRAMMER)
+else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER)
+else
+ $(error ERROR: Please you need to configure the AVR programmer!)
+endif
# AVR serial port.
AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
# Check if the counter cycle erase must be performed after device programming.
ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
@@ -203,17 +227,37 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
AVRDUDE_VERBOSE = -v -v
endif
-# AVR programmer flags.
+# AVR programmer flags for AVRDUDE programmer.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -b 115200
-AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+endif
+
+# AVR programmer flags for DFU programmer.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+DFU_WRITE_FLASH = flash --force
+DFU_ERASE_FLASH = erase
+DFU_RESET=reset
+endif
+
+# AVR programmer flags for MICRONUCLEUS programmer.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+MICRONUCLEUS_TIMEOUT_ARG = --timeout 60
+MICRONUCLEUS_RUN_ARG = --run
+MICRONUCLEUS_TYPE_ARG = --type raw
+MICRONUCLEUS_DUMP_PROGRESS = --dump-progress
+MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG)
+endif
#
-# End of Programming Options (avrdude).
+# End of Programming Options.
##############################################################################
##############################################################################
@@ -227,4 +271,46 @@ include $(RULESPATH)/rules.mk
# End of include file.
##############################################################################
+##############################################################################
+# Programming rules
+#
+
+# AVRDUDE programming rules.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $<
+ @echo Done.
+endif
+
+# DFU programming rules.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $<
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET)
+ @echo Done.
+
+erase:
+ @echo
+ @echo Erasing $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH)
+ @echo Done.
+endif
+
+# MICRONUCLEUS programming rules.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).bin
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $<
+ @echo Done.
+endif
+
+#
+# End of programming rules.
+##############################################################################
+
# EOF
diff --git a/testhal/AVR/MEGA/I2C/Makefile b/testhal/AVR/MEGA/I2C/Makefile
index aafd4002f..97a49e120 100644
--- a/testhal/AVR/MEGA/I2C/Makefile
+++ b/testhal/AVR/MEGA/I2C/Makefile
@@ -56,6 +56,21 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),)
USE_VERBOSE_PROGRAMMATION = no
endif
+# Enable this if you want to use AVRDUDE programmer.
+ifeq ($(USE_AVRDUDE_PROGRAMMER),)
+ USE_AVRDUDE_PROGRAMMER = yes
+endif
+
+# Enable this if you want to use DFU programmer.
+ifeq ($(USE_DFU_PROGRAMMER),)
+ USE_DFU_PROGRAMMER = no
+endif
+
+# Enable this if you want to use MICRONUCLEUS programmer.
+ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),)
+ USE_MICRONUCLEUS_PROGRAMMER = no
+endif
+
#
# Building and programming global options.
##############################################################################
@@ -67,7 +82,7 @@ endif
# Define project name here.
PROJECT = ch
-# Imported source files.
+# Imported source files and paths
CHIBIOS = ../../../..
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
@@ -95,8 +110,8 @@ CSRC = $(KERNSRC) \
CPPSRC =
INCDIR = $(CHIBIOS)/os/license $(PORTINC) $(KERNINC) \
- $(HALINC) $(OSALINC) $(PLATFORMINC) \
- $(BOARDINC) $(CHIBIOS)/os/various $(STREAMSINC)
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(TESTINC) \
+ $(BOARDINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths.
@@ -132,9 +147,6 @@ SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
-# AVR programming tool.
-AVRDUDE = avrdude
-
# Size of the elf binary file.
ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
@@ -175,18 +187,30 @@ ULIBS =
##############################################################################
##############################################################################
-# Start of programming Options (avrdude).
+# Start of programming Options.
#
-# TODO: Add the programmer for ATtiny, and for ATXmega.
-# AVR programmer.
-AVRDUDE_PROGRAMMER = wiring
+# List of available AVR programmer.
+AVRDUDE_PROGRAMMER = avrdude
+AVRDUDE_PROGRAMMER_ID = wiring
+DFU_PROGRAMMER = dfu-programmer
+MICRONUCLEUS = micronucleus
+
+# Set the AVR programmer according to the selection..
+ifeq ($(USE_AVRDUDE_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER)
+else ifeq ($(USE_DFU_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(DFU_PROGRAMMER)
+else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER)
+else
+ $(error ERROR: Please you need to configure the AVR programmer!)
+endif
# AVR serial port.
AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
# Check if the counter cycle erase must be performed after device programming.
ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
@@ -203,17 +227,37 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
AVRDUDE_VERBOSE = -v -v
endif
-# AVR programmer flags.
+# AVR programmer flags for AVRDUDE programmer.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -b 115200
-AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+endif
+
+# AVR programmer flags for DFU programmer.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+DFU_WRITE_FLASH = flash --force
+DFU_ERASE_FLASH = erase
+DFU_RESET=reset
+endif
+
+# AVR programmer flags for MICRONUCLEUS programmer.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+MICRONUCLEUS_TIMEOUT_ARG = --timeout 60
+MICRONUCLEUS_RUN_ARG = --run
+MICRONUCLEUS_TYPE_ARG = --type raw
+MICRONUCLEUS_DUMP_PROGRESS = --dump-progress
+MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG)
+endif
#
-# End of Programming Options (avrdude).
+# End of Programming Options.
##############################################################################
##############################################################################
@@ -227,4 +271,46 @@ include $(RULESPATH)/rules.mk
# End of include file.
##############################################################################
+##############################################################################
+# Programming rules
+#
+
+# AVRDUDE programming rules.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $<
+ @echo Done.
+endif
+
+# DFU programming rules.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $<
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET)
+ @echo Done.
+
+erase:
+ @echo
+ @echo Erasing $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH)
+ @echo Done.
+endif
+
+# MICRONUCLEUS programming rules.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).bin
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $<
+ @echo Done.
+endif
+
+#
+# End of programming rules.
+##############################################################################
+
# EOF
diff --git a/testhal/AVR/MEGA/ICU/Makefile b/testhal/AVR/MEGA/ICU/Makefile
index aafd4002f..97a49e120 100644
--- a/testhal/AVR/MEGA/ICU/Makefile
+++ b/testhal/AVR/MEGA/ICU/Makefile
@@ -56,6 +56,21 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),)
USE_VERBOSE_PROGRAMMATION = no
endif
+# Enable this if you want to use AVRDUDE programmer.
+ifeq ($(USE_AVRDUDE_PROGRAMMER),)
+ USE_AVRDUDE_PROGRAMMER = yes
+endif
+
+# Enable this if you want to use DFU programmer.
+ifeq ($(USE_DFU_PROGRAMMER),)
+ USE_DFU_PROGRAMMER = no
+endif
+
+# Enable this if you want to use MICRONUCLEUS programmer.
+ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),)
+ USE_MICRONUCLEUS_PROGRAMMER = no
+endif
+
#
# Building and programming global options.
##############################################################################
@@ -67,7 +82,7 @@ endif
# Define project name here.
PROJECT = ch
-# Imported source files.
+# Imported source files and paths
CHIBIOS = ../../../..
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
@@ -95,8 +110,8 @@ CSRC = $(KERNSRC) \
CPPSRC =
INCDIR = $(CHIBIOS)/os/license $(PORTINC) $(KERNINC) \
- $(HALINC) $(OSALINC) $(PLATFORMINC) \
- $(BOARDINC) $(CHIBIOS)/os/various $(STREAMSINC)
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(TESTINC) \
+ $(BOARDINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths.
@@ -132,9 +147,6 @@ SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
-# AVR programming tool.
-AVRDUDE = avrdude
-
# Size of the elf binary file.
ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
@@ -175,18 +187,30 @@ ULIBS =
##############################################################################
##############################################################################
-# Start of programming Options (avrdude).
+# Start of programming Options.
#
-# TODO: Add the programmer for ATtiny, and for ATXmega.
-# AVR programmer.
-AVRDUDE_PROGRAMMER = wiring
+# List of available AVR programmer.
+AVRDUDE_PROGRAMMER = avrdude
+AVRDUDE_PROGRAMMER_ID = wiring
+DFU_PROGRAMMER = dfu-programmer
+MICRONUCLEUS = micronucleus
+
+# Set the AVR programmer according to the selection..
+ifeq ($(USE_AVRDUDE_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER)
+else ifeq ($(USE_DFU_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(DFU_PROGRAMMER)
+else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER)
+else
+ $(error ERROR: Please you need to configure the AVR programmer!)
+endif
# AVR serial port.
AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
# Check if the counter cycle erase must be performed after device programming.
ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
@@ -203,17 +227,37 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
AVRDUDE_VERBOSE = -v -v
endif
-# AVR programmer flags.
+# AVR programmer flags for AVRDUDE programmer.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -b 115200
-AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+endif
+
+# AVR programmer flags for DFU programmer.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+DFU_WRITE_FLASH = flash --force
+DFU_ERASE_FLASH = erase
+DFU_RESET=reset
+endif
+
+# AVR programmer flags for MICRONUCLEUS programmer.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+MICRONUCLEUS_TIMEOUT_ARG = --timeout 60
+MICRONUCLEUS_RUN_ARG = --run
+MICRONUCLEUS_TYPE_ARG = --type raw
+MICRONUCLEUS_DUMP_PROGRESS = --dump-progress
+MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG)
+endif
#
-# End of Programming Options (avrdude).
+# End of Programming Options.
##############################################################################
##############################################################################
@@ -227,4 +271,46 @@ include $(RULESPATH)/rules.mk
# End of include file.
##############################################################################
+##############################################################################
+# Programming rules
+#
+
+# AVRDUDE programming rules.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $<
+ @echo Done.
+endif
+
+# DFU programming rules.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $<
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET)
+ @echo Done.
+
+erase:
+ @echo
+ @echo Erasing $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH)
+ @echo Done.
+endif
+
+# MICRONUCLEUS programming rules.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).bin
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $<
+ @echo Done.
+endif
+
+#
+# End of programming rules.
+##############################################################################
+
# EOF
diff --git a/testhal/AVR/MEGA/PWM/Makefile b/testhal/AVR/MEGA/PWM/Makefile
index aafd4002f..97a49e120 100644
--- a/testhal/AVR/MEGA/PWM/Makefile
+++ b/testhal/AVR/MEGA/PWM/Makefile
@@ -56,6 +56,21 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),)
USE_VERBOSE_PROGRAMMATION = no
endif
+# Enable this if you want to use AVRDUDE programmer.
+ifeq ($(USE_AVRDUDE_PROGRAMMER),)
+ USE_AVRDUDE_PROGRAMMER = yes
+endif
+
+# Enable this if you want to use DFU programmer.
+ifeq ($(USE_DFU_PROGRAMMER),)
+ USE_DFU_PROGRAMMER = no
+endif
+
+# Enable this if you want to use MICRONUCLEUS programmer.
+ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),)
+ USE_MICRONUCLEUS_PROGRAMMER = no
+endif
+
#
# Building and programming global options.
##############################################################################
@@ -67,7 +82,7 @@ endif
# Define project name here.
PROJECT = ch
-# Imported source files.
+# Imported source files and paths
CHIBIOS = ../../../..
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
@@ -95,8 +110,8 @@ CSRC = $(KERNSRC) \
CPPSRC =
INCDIR = $(CHIBIOS)/os/license $(PORTINC) $(KERNINC) \
- $(HALINC) $(OSALINC) $(PLATFORMINC) \
- $(BOARDINC) $(CHIBIOS)/os/various $(STREAMSINC)
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(TESTINC) \
+ $(BOARDINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths.
@@ -132,9 +147,6 @@ SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
-# AVR programming tool.
-AVRDUDE = avrdude
-
# Size of the elf binary file.
ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
@@ -175,18 +187,30 @@ ULIBS =
##############################################################################
##############################################################################
-# Start of programming Options (avrdude).
+# Start of programming Options.
#
-# TODO: Add the programmer for ATtiny, and for ATXmega.
-# AVR programmer.
-AVRDUDE_PROGRAMMER = wiring
+# List of available AVR programmer.
+AVRDUDE_PROGRAMMER = avrdude
+AVRDUDE_PROGRAMMER_ID = wiring
+DFU_PROGRAMMER = dfu-programmer
+MICRONUCLEUS = micronucleus
+
+# Set the AVR programmer according to the selection..
+ifeq ($(USE_AVRDUDE_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER)
+else ifeq ($(USE_DFU_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(DFU_PROGRAMMER)
+else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER)
+else
+ $(error ERROR: Please you need to configure the AVR programmer!)
+endif
# AVR serial port.
AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
# Check if the counter cycle erase must be performed after device programming.
ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
@@ -203,17 +227,37 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
AVRDUDE_VERBOSE = -v -v
endif
-# AVR programmer flags.
+# AVR programmer flags for AVRDUDE programmer.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -b 115200
-AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+endif
+
+# AVR programmer flags for DFU programmer.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+DFU_WRITE_FLASH = flash --force
+DFU_ERASE_FLASH = erase
+DFU_RESET=reset
+endif
+
+# AVR programmer flags for MICRONUCLEUS programmer.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+MICRONUCLEUS_TIMEOUT_ARG = --timeout 60
+MICRONUCLEUS_RUN_ARG = --run
+MICRONUCLEUS_TYPE_ARG = --type raw
+MICRONUCLEUS_DUMP_PROGRESS = --dump-progress
+MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG)
+endif
#
-# End of Programming Options (avrdude).
+# End of Programming Options.
##############################################################################
##############################################################################
@@ -227,4 +271,46 @@ include $(RULESPATH)/rules.mk
# End of include file.
##############################################################################
+##############################################################################
+# Programming rules
+#
+
+# AVRDUDE programming rules.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $<
+ @echo Done.
+endif
+
+# DFU programming rules.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $<
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET)
+ @echo Done.
+
+erase:
+ @echo
+ @echo Erasing $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH)
+ @echo Done.
+endif
+
+# MICRONUCLEUS programming rules.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).bin
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $<
+ @echo Done.
+endif
+
+#
+# End of programming rules.
+##############################################################################
+
# EOF
diff --git a/testhal/AVR/MEGA/SPI/Makefile b/testhal/AVR/MEGA/SPI/Makefile
index aafd4002f..97a49e120 100644
--- a/testhal/AVR/MEGA/SPI/Makefile
+++ b/testhal/AVR/MEGA/SPI/Makefile
@@ -56,6 +56,21 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),)
USE_VERBOSE_PROGRAMMATION = no
endif
+# Enable this if you want to use AVRDUDE programmer.
+ifeq ($(USE_AVRDUDE_PROGRAMMER),)
+ USE_AVRDUDE_PROGRAMMER = yes
+endif
+
+# Enable this if you want to use DFU programmer.
+ifeq ($(USE_DFU_PROGRAMMER),)
+ USE_DFU_PROGRAMMER = no
+endif
+
+# Enable this if you want to use MICRONUCLEUS programmer.
+ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),)
+ USE_MICRONUCLEUS_PROGRAMMER = no
+endif
+
#
# Building and programming global options.
##############################################################################
@@ -67,7 +82,7 @@ endif
# Define project name here.
PROJECT = ch
-# Imported source files.
+# Imported source files and paths
CHIBIOS = ../../../..
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
@@ -95,8 +110,8 @@ CSRC = $(KERNSRC) \
CPPSRC =
INCDIR = $(CHIBIOS)/os/license $(PORTINC) $(KERNINC) \
- $(HALINC) $(OSALINC) $(PLATFORMINC) \
- $(BOARDINC) $(CHIBIOS)/os/various $(STREAMSINC)
+ $(HALINC) $(OSALINC) $(PLATFORMINC) $(TESTINC) \
+ $(BOARDINC) $(STREAMSINC) $(CHIBIOS)/os/various
#
# Project, sources and paths.
@@ -132,9 +147,6 @@ SZ = $(TRGT)size
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
-# AVR programming tool.
-AVRDUDE = avrdude
-
# Size of the elf binary file.
ELFSIZE = $(SZ) --mcu=$(MCU) --format=avr $(BUILDDIR)/$(PROJECT).elf
@@ -175,18 +187,30 @@ ULIBS =
##############################################################################
##############################################################################
-# Start of programming Options (avrdude).
+# Start of programming Options.
#
-# TODO: Add the programmer for ATtiny, and for ATXmega.
-# AVR programmer.
-AVRDUDE_PROGRAMMER = wiring
+# List of available AVR programmer.
+AVRDUDE_PROGRAMMER = avrdude
+AVRDUDE_PROGRAMMER_ID = wiring
+DFU_PROGRAMMER = dfu-programmer
+MICRONUCLEUS = micronucleus
+
+# Set the AVR programmer according to the selection..
+ifeq ($(USE_AVRDUDE_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(AVRDUDE_PROGRAMMER)
+else ifeq ($(USE_DFU_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(DFU_PROGRAMMER)
+else ifeq ($(USE_MICRONUCLEUS_PROGRAMMER),yes)
+ AVR_PROGRAMMER = $(MICRONUCLEUS_PROGRAMMER)
+else
+ $(error ERROR: Please you need to configure the AVR programmer!)
+endif
# AVR serial port.
AVRDUDE_PORT = /dev/ttyUSB0
AVRDUDE_WRITE_FLASH = -D -U flash:w:$(BUILDDIR)/$(PROJECT).hex
-#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(BUILDDIR)/$(PROJECT).eep
# Check if the counter cycle erase must be performed after device programming.
ifeq ($(USE_AVRDUDE_ERASE_COUNTER),yes)
@@ -203,17 +227,37 @@ ifeq ($(USE_VERBOSE_PROGRAMMATION),yes)
AVRDUDE_VERBOSE = -v -v
endif
-# AVR programmer flags.
+# AVR programmer flags for AVRDUDE programmer.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
AVRDUDE_FLAGS = -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -b 115200
-AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER)
+AVRDUDE_FLAGS += -c $(AVRDUDE_PROGRAMMER_ID)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
+endif
+
+# AVR programmer flags for DFU programmer.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+DFU_WRITE_FLASH = flash --force
+DFU_ERASE_FLASH = erase
+DFU_RESET=reset
+endif
+
+# AVR programmer flags for MICRONUCLEUS programmer.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+MICRONUCLEUS_TIMEOUT_ARG = --timeout 60
+MICRONUCLEUS_RUN_ARG = --run
+MICRONUCLEUS_TYPE_ARG = --type raw
+MICRONUCLEUS_DUMP_PROGRESS = --dump-progress
+MICRONUCLEUS_FLAGS=$(MICRONUCLEUS_TYPE_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_TIMEOUT_ARG)
+MICRONUCLEUS_FLAGS+=$(MICRONUCLEUS_RUN_ARG)
+endif
#
-# End of Programming Options (avrdude).
+# End of Programming Options.
##############################################################################
##############################################################################
@@ -227,4 +271,46 @@ include $(RULESPATH)/rules.mk
# End of include file.
##############################################################################
+##############################################################################
+# Programming rules
+#
+
+# AVRDUDE programming rules.
+ifeq ($(AVR_PROGRAMMER),$(AVRDUDE_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $<
+ @echo Done.
+endif
+
+# DFU programming rules.
+ifeq ($(AVR_PROGRAMMER),$(DFU_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).hex
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_WRITE_FLASH) $<
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_RESET)
+ @echo Done.
+
+erase:
+ @echo
+ @echo Erasing $(MCU) device.
+ $(AVR_PROGRAMMER) $(MCU) $(DFU_ERASE_FLASH)
+ @echo Done.
+endif
+
+# MICRONUCLEUS programming rules.
+ifeq ($(AVR_PROGRAMMER),$(MICRONUCLEUS_PROGRAMMER))
+program: $(BUILDDIR)/$(PROJECT).bin
+ @echo
+ @echo Programming $(MCU) device.
+ $(AVR_PROGRAMMER) $(MICRONUCLEUS_FLAGS) $<
+ @echo Done.
+endif
+
+#
+# End of programming rules.
+##############################################################################
+
# EOF