Commit 0168f2baccf45522a4249a666df19eeb60fc4c00
1 parent
4f226353
premier tests pour avr sur atmega2560
Showing
4 changed files
with
54 additions
and
0 deletions
Show diff stats
README.md
@@ -0,0 +1,37 @@ | @@ -0,0 +1,37 @@ | ||
1 | +export CC = avr-gcc | ||
2 | + | ||
3 | +export MCU = atmega2560 | ||
4 | +export TARGET_ARCH = -mmcu=$(MCU) | ||
5 | + | ||
6 | +export CFLAGS = -Wall -I. -DF_CPU=16000000 -Os #-g | ||
7 | +export LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections # -Os | ||
8 | + | ||
9 | +TARGET = usb | ||
10 | +TERM = /dev/ttyACM0 | ||
11 | +CPPFLAGS = -mmcu=$(MCU) | ||
12 | +PGMERISP = -c stk500v2 -b 115200 -P $(TERM) | ||
13 | +ARVDUDECONF= -C /usr/local/arduino/arduino-0022/hardware/tools/avrdude.conf | ||
14 | +export DUDE = /usr/bin/avrdude -F -v -p $(MCU) $(AVRDUDECONF) | ||
15 | + | ||
16 | +C_SRC = $(wildcard *.c) | ||
17 | +OBJS = $(C_SRC:.c=.o) | ||
18 | + | ||
19 | +all: $(TARGET).hex | ||
20 | + | ||
21 | +clean: | ||
22 | + rm -f *.o *.hex *.elf | ||
23 | + | ||
24 | +%.o:%.c | ||
25 | + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@ | ||
26 | + | ||
27 | +$(TARGET).elf: $(OBJS) | ||
28 | + $(CC) $(LDFLAGS) -o $@ $(OBJS) | ||
29 | + | ||
30 | +$(TARGET).hex: $(TARGET).elf | ||
31 | + avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex | ||
32 | + avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(TARGET).elf eeprom.hex | ||
33 | + | ||
34 | +upload: $(TARGET).hex | ||
35 | + stty -F $(TERM) hupcl # reset | ||
36 | + $(DUDE) $(PGMERISP) -U flash:w:$(TARGET).hex | ||
37 | + make clean |