author | Tero Marttila <terom@paivola.fi> |
Fri, 11 Apr 2014 19:51:19 +0300 | |
changeset 71 | 24f00b561a4a |
parent 64 | f9221fa50c75 |
child 89 | 1b3cea759eff |
permissions | -rw-r--r-- |
62
2d68a76322cb
hello-dmx: working basic dmx output using DmxSimple's frame-timing inline assembler code
Tero Marttila <terom@paivola.fi>
parents:
58
diff
changeset
|
1 |
PROG = hello-dmx |
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
|
2 |
|
51
ec6271f0637b
make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
3 |
ELF = build/src/$(PROG).elf |
50 | 4 |
HEX = build/src/$(PROG).hex |
5 |
||
6 |
all: $(HEX) |
|
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
|
7 |
|
48 | 8 |
build: |
50 | 9 |
mkdir -p build/src |
48 | 10 |
|
62
2d68a76322cb
hello-dmx: working basic dmx output using DmxSimple's frame-timing inline assembler code
Tero Marttila <terom@paivola.fi>
parents:
58
diff
changeset
|
11 |
dmx: dmx.hex |
2d68a76322cb
hello-dmx: working basic dmx output using DmxSimple's frame-timing inline assembler code
Tero Marttila <terom@paivola.fi>
parents:
58
diff
changeset
|
12 |
|
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
|
13 |
## 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
|
14 |
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
|
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 |
# 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
|
17 |
CPU = 16000000 |
64 | 18 |
STD = c99 |
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 |
CC = avr-gcc |
48 | 21 |
CPPFLAGS = -DF_CPU=$(CPU)UL |
64 | 22 |
CFLAGS = -mmcu=$(MCU) -std=$(STD) -Os -g |
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
|
23 |
|
50 | 24 |
build/%.elf: %.c |
48 | 25 |
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $*.c |
26 |
$(CC) -MM $(CPPFLAGS) -MT $@ -MF build/$*.d $*.c |
|
27 |
||
28 |
# existing .d files for rebuilding existing .o's |
|
51
ec6271f0637b
make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
29 |
-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
|
30 |
|
50 | 31 |
build/%.hex: build/%.elf |
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
|
32 |
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
|
33 |
|
50 | 34 |
.PRECIOUS: build/%.elf |
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
|
35 |
|
51
ec6271f0637b
make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
36 |
dump: $(ELF) |
ec6271f0637b
make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
37 |
avr-objdump -d $(ELF) |
ec6271f0637b
make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents:
50
diff
changeset
|
38 |
|
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
|
39 |
## Assembler |
5 | 40 |
AS = avra |
41 |
ASFLAGS = |
|
42 |
||
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
|
43 |
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
|
44 |
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
|
45 |
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
|
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 |
%.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
|
48 |
$(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
|
49 |
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
|
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 |
# 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
|
52 |
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
|
53 |
|
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
|
54 |
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
|
55 |
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
|
56 |
|
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
|
57 |
|
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
|
58 |
## 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
|
59 |
# Arduino Duemilanove |
5 | 60 |
AD_PART = m328p |
61 |
AD_PROG = arduino |
|
62 |
AD_BAUD = 57600 |
|
43 | 63 |
AD_PORT = /dev/arduino |
5 | 64 |
|
65 |
AD = avrdude |
|
66 |
ADFLAGS = -p $(AD_PART) -c $(AD_PROG) -b $(AD_BAUD) -P $(AD_PORT) |
|
67 |
||
50 | 68 |
upload: $(HEX) |
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
|
69 |
$(AD) $(ADFLAGS) -U flash:w:$< |
5 | 70 |
|
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
|
71 |
## Console |
10 | 72 |
SERIAL_BAUD = 9600 |
73 |
SERIAL_FLOW = n |
|
74 |
SERIAL_PARITY = n |
|
75 |
SERIAL_BITS = 8 |
|
76 |
SERIAL_PORT = $(AD_PORT) |
|
77 |
||
78 |
SERIAL_TERM = picocom |
|
79 |
SERIAL_FLAGS = -b $(SERIAL_BAUD) -f $(SERIAL_FLOW) -p $(SERIAL_PARITY) -d $(SERIAL_BITS) |
|
80 |
||
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
|
81 |
console: |
10 | 82 |
$(SERIAL_TERM) $(SERIAL_FLAGS) $(SERIAL_PORT) |
83 |