Skip to content

Commit

Permalink
Upload to flash works OK
Browse files Browse the repository at this point in the history
  • Loading branch information
rbarzic committed Apr 9, 2015
1 parent 9e1495a commit d2ba88e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ SDK_DRIVERS_NRF_HAL=yes
include misc/nRF51_Devices.mk
include misc/SDK_Makefile.mk
include misc/Makefile
include misc/nrftools_jlink.mk
include misc/check.mk
6 changes: 5 additions & 1 deletion misc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ LINKER_SCRIPT_TOP_DIR ?= $(SDK_PATH)/components/toolchain/gcc
LINKER_SCRIPT ?= $(LINKER_SCRIPT_TOP_DIR)/gcc_nrf51_$(SOFTDEVICE)_$(LINKER_FILE_SUFFIX).ld
LDFLAGS += $(CPUFLAGS) -T $(LINKER_SCRIPT) -L $(LINKER_SCRIPT_TOP_DIR)


# from
FLASH_START_ADDRESS = $(shell $(OBJDUMP) -h $(ELF) -j .text | grep .text | awk '{print $$4}')
test:
@echo "Source : " $(C_SOURCE_FILES)
@echo "Source AS: " $(SRCS_AS)
Expand All @@ -69,6 +70,9 @@ $(HEX): $(OBJS) $(OBJS_AS)
$(SIZE) $(ELF)


print_flash_address:
@echo "Flash address " $(FLASH_START_ADDRESS)

%.o: %.c

$(CC) $(LDFLAGS) $(CFLAGS) $< -o $@
Expand Down
34 changes: 34 additions & 0 deletions misc/check.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
NO_COLOR=\e[0m
OK_COLOR=\e[32;01m
ERROR_COLOR=\e[31;01m
WARN_COLOR='\e[33;01m'

OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)
ERROR_STRING=$(ERROR_COLOR)[ERROR]$(NO_COLOR)
WARN_STRING=$(WARN_COLOR)[WARNING]$(NO_COLOR)


check_file_func = \
@if [ -a $(1) ]; \
then \
echo -e "$(OK_STRING) $(2) File $(1) found";\
else \
echo -e "$(ERROR_STRING) $(2) File $(1) not found";\
fi;

check_exec_func = \
@if [ -x $(1) ]; \
then \
echo -e "$(OK_STRING) $(2) File $(1) found";\
else \
echo -e "$(ERROR_STRING) $(2) File $(1) not found";\
fi;





check_setup:
$(call check_exec_func,$(shell which nrftool),"nrf51 JLink programmer : ")
$(call check_exec_func,$(shell which $(CC)), "GCC for ARM compiler : ")

19 changes: 19 additions & 0 deletions misc/nrftools_jlink.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Using nrftool utiliy to do the erase/programming
# it avoid to deal directly with scripts as
# done in nrf51-pure-gcc-setup

PROGRAMMER ?= nrftool

JLINKEXE=JLinkExe

JLINKEXE_PATH=$(shell which $(JLINKEXE))

erase-all:
$(PROGRAMMER) --jlinkexe $(JLINKEXE_PATH) erase


program:
$(PROGRAMMER) --jlinkexe $(JLINKEXE_PATH) flash $(PROJECT_NAME).bin $(FLASH_START_ADDRESS)



8 changes: 5 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@


int main(void){
nrf_gpio_range_cfg_output(18,19);
nrf_gpio_range_cfg_output(21,22);
while(1){
nrf_gpio_port_write(2,8);
nrf_gpio_pin_write(21,0);
nrf_gpio_pin_write(22,1);
nrf_delay_ms(80);
nrf_gpio_port_write(2,4);
nrf_gpio_pin_write(21,1);
nrf_gpio_pin_write(22,0);
nrf_delay_ms(80);
}

Expand Down

0 comments on commit d2ba88e

Please sign in to comment.