Skip to content

Commit

Permalink
refactor(Makefile.posix): DRY $SOFTDEVICE definedness check
Browse files Browse the repository at this point in the history
  • Loading branch information
wldhx committed Feb 10, 2017
1 parent db6b60b commit 91932ac
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions make/Makefile.posix
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,17 @@ flash.stlinkv2:
$(MAKE_BUILD_FOLDER)
$(OPENOCD) -c 'program $(HEX) verify reset exit'

test-softdevice: test-softdevice.jlink
ifndef SOFTDEVICE
define softdevice-defined=
$(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file")
endef
else
define softdevice-defined=
endef
endif

test-softdevice: test-softdevice.jlink $(softdevice-defined)

ifneq ($(SOFTDEVICE_MODEL),blank)
$(MAKE_BUILD_FOLDER)
@touch $(SOFTDEVICE_TEST_FLASH)
Expand All @@ -98,12 +104,9 @@ test-softdevice.jlink:
printf "r\nsavebin $(SOFTDEVICE_TEST_FLASH) $(SOFTDEVICE_TEST_ADDR) $(SOFTDEVICE_TEST_LEN)\nexit\n" > $(OUTPUT_PATH)test-softdevice.jlink

ifeq ($(PROGRAMMER),stlinkv2)
flash-softdevice: erase-all flash-softdevice.stlinkv2
flash-softdevice: erase-all $(softdevice-defined) flash-softdevice.stlinkv2
else
flash-softdevice: erase-all flash-softdevice.jlink
ifndef SOFTDEVICE
$(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file")
endif
flash-softdevice: erase-all $(softdevice-defined) flash-softdevice.jlink
$(MAKE_BUILD_FOLDER)
$(OBJCOPY) -Iihex -Obinary $(SOFTDEVICE) $(SOFTDEVICE_OUTPUT:.hex=.bin)
$(JLINK) $(OUTPUT_PATH)flash-softdevice.jlink
Expand All @@ -115,9 +118,6 @@ flash-softdevice.jlink:
printf "w4 4001e504 1\nloadbin \"$(SOFTDEVICE_OUTPUT:.hex=.bin)\" 0\nr\ng\nexit\n" > $(OUTPUT_PATH)flash-softdevice.jlink

flash-softdevice.stlinkv2:
ifndef SOFTDEVICE
$(error "You need to set the SOFTDEVICE command-line parameter to a path (without spaces) to the softdevice hex-file")
endif
$(MAKE_BUILD_FOLDER)
$(OPENOCD) -c 'program $(SOFTDEVICE) verify reset exit'

Expand Down

0 comments on commit 91932ac

Please sign in to comment.