# Make file for PICkit2
# 
#
# targets:
#   hex -- the Intel hex file to be made from the source C file
#   upload -- upload the hex file to the PIC attached to the PICkit2
#   run -- allow the target to run by releasing /MCLR
#   deviceid -- display the device ID, name and revision
#   clean -- tidy the directory of all non-source files
#
# configure by changing down to # <<<<
CHIP=12F683
PROGRAM=bit-bang
ODIR=build
# <<<<

.DEFAULT_GOAL := upload

HEX=$(ODIR)/$(PROGRAM).hex

$(ODIR):
	mkdir $(ODIR)

$(HEX): $(PROGRAM).c $(ODIR)
	xc8 $(PROGRAM).c --outdir=$(ODIR) --chip=$(CHIP)

.PHONY: clean hex upload deviceid run

hex: $(HEX)

upload: $(HEX)
	pk2cmd -F$(HEX) -M -PPIC$(CHIP)

deviceid: 
	pk2cmd -I -PPIC$(CHIP)

run: 
	pk2cmd -R -PPIC$(CHIP)
	
clean:
	rm -rf $(ODIR)
