author | Tero Marttila <terom@paivola.fi> |
Wed, 02 Apr 2014 19:10:05 +0300 | |
changeset 47 | 7f930a94ee1e |
parent 45 | 7c684d241675 |
child 48 | 50dc2f4d90fd |
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 |
|
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
|
7 |
## 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
|
8 |
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
|
9 |
|
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 |
# 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
|
11 |
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
|
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 |
CC = avr-gcc |
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 |
CFLAGS = -g -mmcu=$(MCU) -DF_CPU=$(CPU)UL -Os |
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 |
%.elf: %.c |
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
|
17 |
$(CC) $(CFLAGS) -o $@ $+ |
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
|
18 |
|
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 |
%.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
|
20 |
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
|
21 |
|
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
|
22 |
.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
|
23 |
|
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
|
24 |
## Assembler |
5 | 25 |
AS = avra |
26 |
ASFLAGS = |
|
27 |
||
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
|
28 |
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
|
29 |
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
|
30 |
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
|
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 |
%.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
|
33 |
$(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
|
34 |
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
|
35 |
|
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 |
# 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
|
37 |
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
|
38 |
|
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 |
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
|
40 |
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
|
41 |
|
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 |
|
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 |
## 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
|
44 |
# Arduino Duemilanove |
5 | 45 |
AD_PART = m328p |
46 |
AD_PROG = arduino |
|
47 |
AD_BAUD = 57600 |
|
43 | 48 |
AD_PORT = /dev/arduino |
5 | 49 |
|
50 |
AD = avrdude |
|
51 |
ADFLAGS = -p $(AD_PART) -c $(AD_PROG) -b $(AD_BAUD) -P $(AD_PORT) |
|
52 |
||
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
|
53 |
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
|
54 |
$(AD) $(ADFLAGS) -U flash:w:$< |
5 | 55 |
|
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
|
56 |
## Console |
10 | 57 |
SERIAL_BAUD = 9600 |
58 |
SERIAL_FLOW = n |
|
59 |
SERIAL_PARITY = n |
|
60 |
SERIAL_BITS = 8 |
|
61 |
SERIAL_PORT = $(AD_PORT) |
|
62 |
||
63 |
SERIAL_TERM = picocom |
|
64 |
SERIAL_FLAGS = -b $(SERIAL_BAUD) -f $(SERIAL_FLOW) -p $(SERIAL_PARITY) -d $(SERIAL_BITS) |
|
65 |
||
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
|
66 |
console: |
10 | 67 |
$(SERIAL_TERM) $(SERIAL_FLAGS) $(SERIAL_PORT) |
68 |