author | Tero Marttila <terom@paivola.fi> |
Thu, 03 Apr 2014 18:49:02 +0300 | |
changeset 48 | 50dc2f4d90fd |
parent 47 | 7f930a94ee1e |
child 50 | e4ac5a591dcd |
permissions | -rw-r--r-- |
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
1 |
PROG = hello |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
2 |
# console |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
3 |
# dmx |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
4 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
5 |
all: $(PROG).hex |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
6 |
|
48 | 7 |
build: |
8 |
mkdir -p build/ |
|
9 |
||
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
10 |
## Compiler |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
11 |
MCU = atmega328p |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
12 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
13 |
# CPU clock frequency |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
14 |
CPU = 16000000 |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
15 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
16 |
CC = avr-gcc |
48 | 17 |
CPPFLAGS = -DF_CPU=$(CPU)UL |
18 |
CFLAGS = -g -mmcu=$(MCU) -Os |
|
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
19 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
20 |
%.elf: %.c |
48 | 21 |
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $*.c |
22 |
$(CC) -MM $(CPPFLAGS) -MT $@ -MF build/$*.d $*.c |
|
23 |
||
24 |
# existing .d files for rebuilding existing .o's |
|
25 |
-include $(wildcard build/*.d) |
|
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
26 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
27 |
%.hex: %.elf |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
28 |
avr-objcopy -O ihex -R .eeprom $< $@ |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
29 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
30 |
.PRECIOUS: %.elf |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
31 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
32 |
## Assembler |
5 | 33 |
AS = avra |
34 |
ASFLAGS = |
|
35 |
||
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
36 |
matrix.hex: spi.inc matrix.inc timer.inc delay.inc macros.inc font.inc font.def |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
37 |
led7seg.hex: spi.inc led7seg.inc adc.inc timer.inc delay.inc macros.inc |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
38 |
timer.hex: timer.inc macros.inc |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
39 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
40 |
%.hex: %.s |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
41 |
$(AS) $(ASFLAGS) $< |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
42 |
mv $<.hex $@ |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
43 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
44 |
# fonts |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
45 |
font.inc: font.def |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
46 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
47 |
font.def: font.txt font-compile.py |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
48 |
python font-compile.py $< $@ > /dev/null |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
49 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
50 |
|
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
51 |
## Flashing |
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
52 |
# Arduino Duemilanove |
5 | 53 |
AD_PART = m328p |
54 |
AD_PROG = arduino |
|
55 |
AD_BAUD = 57600 |
|
43 | 56 |
AD_PORT = /dev/arduino |
5 | 57 |
|
58 |
AD = avrdude |
|
59 |
ADFLAGS = -p $(AD_PART) -c $(AD_PROG) -b $(AD_BAUD) -P $(AD_PORT) |
|
60 |
||
17
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
10
diff
changeset
|
61 |
upload: $(PROG).hex |
a7c668003a19
split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents:
10
diff
changeset
|
62 |
$(AD) $(ADFLAGS) -U flash:w:$< |
5 | 63 |
|
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
64 |
## Console |
10 | 65 |
SERIAL_BAUD = 9600 |
66 |
SERIAL_FLOW = n |
|
67 |
SERIAL_PARITY = n |
|
68 |
SERIAL_BITS = 8 |
|
69 |
SERIAL_PORT = $(AD_PORT) |
|
70 |
||
71 |
SERIAL_TERM = picocom |
|
72 |
SERIAL_FLAGS = -b $(SERIAL_BAUD) -f $(SERIAL_FLOW) -p $(SERIAL_PARITY) -d $(SERIAL_BITS) |
|
73 |
||
47
7f930a94ee1e
bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents:
45
diff
changeset
|
74 |
console: |
10 | 75 |
$(SERIAL_TERM) $(SERIAL_FLAGS) $(SERIAL_PORT) |
76 |