Blame view

Makefile 964 Bytes
d2a71b92   henyxia   Initial serial co...
1
  CC = avr-gcc
7565f6e8   henyxia   C Style with doub...
2
  
d2a71b92   henyxia   Initial serial co...
3
4
  MCU = atmega328p
  TARGET_ARCH = -mmcu=$(MCU)
7565f6e8   henyxia   C Style with doub...
5
  
d2a71b92   henyxia   Initial serial co...
6
7
  CFLAGS =  -Wall -I. -DF_CPU=16000000 -Os #-g
  LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections #	-Os
7565f6e8   henyxia   C Style with doub...
8
9
  
  TARGET = usb
d2a71b92   henyxia   Initial serial co...
10
  TERM = /dev/ttyACM1
7565f6e8   henyxia   C Style with doub...
11
12
13
14
  CPPFLAGS = -mmcu=$(MCU)
  PGMER = -c stk500v1 -b 57600 -P $(TERM)
  PGMERISP = -c stk500v1 -b 115200 -P $(TERM)
  ARVDUDECONF= -C /usr/local/arduino/arduino-0022/hardware/tools/avrdude.conf
d2a71b92   henyxia   Initial serial co...
15
  DUDE = /usr/bin/avrdude -F -v -p $(MCU) $(AVRDUDECONF)
7565f6e8   henyxia   C Style with doub...
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  
  C_SRC = $(wildcard *.c)
  OBJS = $(C_SRC:.c=.o)
  
  all: $(TARGET).hex
  
  clean:
  	rm -f *.o *.hex *.elf
  
  %.o:%.c
  	$(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
  
  $(TARGET).elf: $(OBJS)
  	$(CC) $(LDFLAGS) -o $@ $(OBJS)
  
  $(TARGET).hex: $(TARGET).elf
  	avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
  	avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(TARGET).elf eeprom.hex
  
  upload: $(TARGET).hex
  	stty -F $(TERM) hupcl # reset
  	$(DUDE) $(PGMERISP) -U flash:w:$(TARGET).hex