AVR_ASM/makefile

46 lines
960 B
Makefile

ASM=avra
#INCLUDE=/opt/microchip/mplabx/v6.05/packs/Microchip/ATmega_DFP/3.0.158/avrasm/inc/m328pdef.inc
INCLUDE=/opt/microchip/mplabx/v6.05/packs/Microchip/ATmega_DFP/3.0.158/avrasm/inc/
SRC=./src
PROG=main
OUT=./build
MAPFILE=prog.map
F_CPU=1000000UL
MCU=atmega328p
BAUD = 9600UL
PROGRAMMER_TYPE = usbasp-clone
PROGRAMMER_ARGS = -b 9600 -B 4 -v
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
AVRSIZE = avr-size
AVRDUDE = avrdude
#PROG=${OUT}/main.asm.hex
all:
if [ -d ${OUT} ]; then return 0; else mkdir ${OUT}; fi
${ASM} -I ${INCLUDE} ${SRC}/${PROG}.asm -I ${OUT}/${PROG}.hex -m ${OUT}/${MAPFILE}
mv ${SRC}/*.hex ${OUT}
mv ${SRC}/*.obj ${OUT}
mv ${SRC}/*.cof ${OUT}
flash: ${PROG}
$(AVRDUDE) -c $(PROGRAMMER_TYPE) -p $(MCU) $(PROGRAMMER_ARGS) -U flash:w:$<
clean:
echo "cleaing hex files!";
rm ${OUT}/*
flash_usbasp: PROGRAMMER_TYPE = usbasp
flash_usbasp: PROGRAMMER_ARGS = # USBasp works with no further arguments
flash_usbasp: flash