-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
45 lines (36 loc) · 865 Bytes
/
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
CC = avr-gcc
OBJCPY = avr-objcopy
SIZE = avr-size
MCU = atmega328p
F_CPU = 16000000
U8G2_SRC = u8g2_csrc
CFLAGS = \
-mmcu=$(MCU) \
-DF_CPU=$(F_CPU)UL \
-Os \
-std=gnu99 \
-Werror \
-ffunction-sections \
-fdata-sections \
-I $(U8G2_SRC)/ \
-I lib/ \
-DAVR_USE_HW_I2C
LDFLAGS = \
-Wl,--gc-sections \
-mmcu=$(MCU)
AVRDUDE=avrdude
#select serial port
PORT=/dev/ttyUSB0
SRC = $(shell ls $(U8G2_SRC)/*.c) $(shell ls lib/*.c) $(shell ls lib/avr-hw-i2c/*.c) $(shell ls *.c)
OBJ = $(SRC:.c=.o)
main.hex: main.elf
$(OBJCPY) -O ihex -R .eeprom main.elf main.hex
main.elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) -o $@
size: main.elf
$(SIZE) --mcu=$(MCU) --format=avr main.elf
clean:
rm -f $(OBJ) main.elf main.hex
# Example for Arduino Duemilanove
upload: main.hex
$(AVRDUDE) -F -v -p $(MCU) -c arduino -P $(PORT) -b 115200 -U flash:w:main.hex:i