NAME=test
SRCS=   cr_startup_lpc43xx_m0.c \
	../../software/lpc_core/lpc_chip/chip_18xx_43xx/gpio_18xx_43xx.c \
	main.c

INC=-I../../software/lpc_core/lpc_chip/chip_18xx_43xx \
	-I../../software/lpc_core/lpc_chip/chip_common \
	-I../../software/lpc_core/lpc_ip \
	-I../../software/CMSIS/CMSIS/Include \
	-I..

LINK=-lc -lgcc -lrdimon -lm --specs=rdimon.specs

DEFS=-D__LPC43XX__

OBJS=$(SRCS:.c=.o)

default: $(NAME).elf $(NAME).hex $(NAME).bin

disassemble:
	arm-none-eabi-objdump -d test.elf

%.o:%.c
	arm-none-eabi-gcc -std=c99 -mcpu=cortex-m0 -mthumb -c -Wall -O2 -g -I. $(INC) $(LINK) $(DEFS) -o $@ $<

$(NAME).elf:$(OBJS)
	arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb $(INC) $(LINK) $(DEFS) -T 4330_m0.ld -nostartfiles -Xlinker --gc-sections -Xlinker -M -Xlinker -Map=$(NAME).map -o $@ $(OBJS)

%.hex:%.elf
	arm-none-eabi-objcopy -Oihex $< $@

%.bin:%.elf
	arm-none-eabi-objcopy -Obinary $< $@

clean:
	rm -f $(OBJS) $(NAME).elf $(NAME).hex $(NAME).bin

flash: FORCE
	gpio -g mode 10 out; gpio -g mode 11 out; gpio -g write 10 0; gpio -g write 11 0; sleep 0.1s && gpio -g write 11 1 & /home/pi/radio_receiver/lpc21isp_197/lpc21isp -bin test.bin /dev/ttyAMA0 19200 12500; gpio -g write 10 1; gpio -g write 11 0; gpio -g write 11 1;
FORCE:

# kate: replace-tabs off
