###
 # @author Henrik Makitaavola <henrik.makitaavola@gmail.com>
 ##

ifeq ($(SM16CF), )
#$(error SM16CF must be defined, try "make $(TARGETS) help")
SM16CF = /dev/ttyUSB0
endif

PROGRAM = sm16cf
PROGRAMMER = sm16cf

ifdef BOOTLOADER
  program: FORCE
	@echo "    installing $(PLATFORM) with bootloader using sm16cf"
	srec_cat $(BOOTLOADER_IMG) $(INSTALL_SREC) -exclude 0x000FFFDC 0x00100000 -o $(BUILDDIR)/main_boot.srec -CRLF
	sed '/S5/d' $(BUILDDIR)/main_boot.srec > $(BUILDDIR)/main_boot2.srec
	$(PROGRAMMER) --device=$(SM16CF) --input-file=$(BUILDDIR)/main_boot2.srec --flash-program
	rm $(BUILDDIR)/main_boot.srec
	rm $(BUILDDIR)/main_boot2.srec
else
program: FORCE
	@echo "    installing $(PLATFORM) using sm16cf"
	$(PROGRAMMER) --device=$(SM16CF) --input-file=$(INSTALL_SREC) --flash-program
endif

program_bl: FORCE
