1 |
PRG = fluxgate |
1 |
PRG = fluxgate |
2 |
OBJ = main.o ./libs/usart.o ./libs/spi.o ./libs/mcp4922.o |
2 |
OBJ = main.o ./libs/usart.o ./libs/spi.o ./libs/mcp4922.o |
3 |
MCU_TARGET = atmega8 |
3 |
MCU_TARGET = atmega8 |
4 |
AVRDUDE_PART = m8 |
4 |
AVRDUDE_PART = m8 |
5 |
|
5 |
|
6 |
# OPTIMIZE = -O1 |
6 |
# OPTIMIZE = -O1 |
7 |
OPTIMIZE = -Os |
7 |
OPTIMIZE = -Os |
8 |
|
8 |
|
9 |
CC = avr-gcc |
9 |
CC = avr-gcc |
10 |
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
10 |
override CFLAGS = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) |
11 |
OBJCOPY = avr-objcopy |
11 |
OBJCOPY = avr-objcopy |
12 |
OBJDUMP = avr-objdump |
12 |
OBJDUMP = avr-objdump |
13 |
|
13 |
|
14 |
all: hex |
14 |
all: hex |
15 |
|
15 |
|
16 |
#./libs/adc.o: ./libs/adc.h |
16 |
#./libs/adc.o: ./libs/adc.h |
17 |
./libs/spi.o: ./libs/spi.h |
17 |
./libs/spi.o: ./libs/spi.h |
18 |
./libs/usart.o: ./libs/usart.h |
18 |
./libs/usart.o: ./libs/usart.h |
19 |
./libs/mcp4922.o: ./libs/mcp4922.h |
19 |
./libs/mcp4922.o: ./libs/mcp4922.h |
20 |
#./libs/timer.o: ./libs/timer.h |
20 |
#./libs/timer.o: ./libs/timer.h |
21 |
|
21 |
|
22 |
hex: $(PRG).hex |
22 |
hex: $(PRG).hex |
23 |
|
23 |
|
24 |
%.hex: %.elf |
24 |
%.hex: %.elf |
25 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
25 |
$(OBJCOPY) -j .text -j .data -O ihex $< $@ |
26 |
|
26 |
|
27 |
$(PRG).elf: $(OBJ) |
27 |
$(PRG).elf: $(OBJ) |
28 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
28 |
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
29 |
|
29 |
|
30 |
load: $(PRG).hex |
30 |
load: $(PRG).hex |
31 |
avrdude -p $(AVRDUDE_PART) -c stk500v2 -P /dev/ttyUSB1 -B 1 -U flash:w:$< |
31 |
avrdude -p $(AVRDUDE_PART) -c stk500v2 -P /dev/ttyUSB1 -B 1 -U flash:w:$< |
32 |
|
32 |
|
33 |
clean: |
33 |
clean: |
34 |
rm -rf *.o $(PRG).elf $(PRG).hex ./libs/*.o |
34 |
rm -rf *.o $(PRG).elf $(PRG).hex ./libs/*.o |
35 |
|
35 |
|