-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
68 lines (52 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
# Author: Mohammed Ahmed Abd Al-Fattah
# File: Makefile
# Purpose: This is a makefile used to compile and load AVR projects.
# The particular microcontroller I am using this file with is the
# AVR Atmega32.
#
MAIN = main.c
CC = avr-gcc
SRC = ./HAL/*c ./MCAL/*c ./APP/*.c
MICROCNTRL = atmega32
CFLAGS = -mmcu=$(MICROCNTRL) -I . -I ./HAL -I ./MCAL -I ./APP -I ./SERVICES -O3
PRO = avrdude
%.i :%.c
$(CC) $< $(CFLAGS) -E -o $@
%.asm : %.i
$(CC) $< $(CFLAGS) -S -o $@
%.o : %.c
$(CC) $< $(CFLAGS) -o $@
.PHONY : build
build:
$(CC) $(SRC) $(CFLAGS) -o main.o
.PHONY : generate_ctags
ctags -R
#rule to generate hex file
.PHONY : build-hex
build-hex:
avr-objcopy -O ihex main.o .main.hex
#Added pwd to distinguish between two or more similar projects being
#developed at the moment. The pwd command itself is not shown when
#making the project, this is done by prepending the command with @
.PHONY : load
load: clean generate_ctags build
@pwd
$(PRO) -p $(MICROCNTRL) -c usbasp -U flash:w:main.o
rm -f *.o *.i
.PHONY : flash
flash :
$(PRO) -V -v -p $(MICROCNTRL) -c usbasp -U flash:w:main.o
.PHONY : convert
convert: clean
unix2dos *
.PHONY : reconvert
reconvert : clean
dos2unix *
.PHONY : burn_fuses
burn_fuses:
$(PRO) -p m32 -c usbasp -U lfuse:w:0xD4:m
$(PRO) -p m32 -c usbasp -u hfuse:w:0xD9:m
.PHONY : clean
clean:
rm -f *.o *.i