aboutsummaryrefslogtreecommitdiffstats
path: root/serial/Makefile
blob: 98f1efc23bae971dbb1d9bafeee860e1ee4e76ec (plain)
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
# settings for arduino 
DEVICE     = atmega328p
CLOCK      = 16000000
PORT=/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A400XJSH-if00-port0
#AVRDUDE=avrdude -V -F -p m328p -c arduino -b 115200 -P$(PORT)
#AVRDUDE=avrdude -p $(DEVICE) -c arduino -b 115200 -P $(PORT)
AVRDUDE=avrdude -p $(DEVICE) -c arduino -b 57600 -P $(PORT)

DEFS    = -DF_CPU=$(CLOCK)UL
LIBS    = -Wl,--relax,--gc-sections,--print-gc-sections,--entry=main
LIBS = -Wl,--entry=main,--gc-sections,--rela
CFLAGS  = -Wall -Werror -pedantic -std=c99
CFLAGS += -Os -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -mmcu=$(DEVICE) $(DEFS)
#LDFLAGS = $(LIBS)

all: main.hex size

main.hex: main.c
	avr-gcc -o main.elf $? $(CFLAGS) $(LDFLAGS)
	avr-objcopy -j .text -j .data -O ihex main.elf main.hex

f: flash
flash: all
	$(AVRDUDE) -U flash:w:main.hex:i

clean:
	rm -f *.o *.elf *.hex

size:
	avr-size --mcu=$(DEVICE) -t -A main.elf
	avr-size --mcu=$(DEVICE) -C main.elf
	avr-nm --size-sort main.elf