Commit 0168f2baccf45522a4249a666df19eeb60fc4c00

Authored by pfrison
1 parent 4f226353

premier tests pour avr sur atmega2560

README.md
... ... @@ -2,3 +2,4 @@
2 2  
3 3 Git du projet CREP (projet IMA 2019 P42)
4 4  
  5 +
... ...
tests/atmega2560/makefile 0 โ†’ 100644
... ... @@ -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
... ...
tests/atmega2560/servoControl.c 0 โ†’ 100644
... ... @@ -0,0 +1,14 @@
  1 +#include <avr/io.h>
  2 +#include <util/delay.h>
  3 +
  4 +int main(void){
  5 + DDRC = 0x01;
  6 +
  7 + while(1){
  8 + PORTC = 0x01;
  9 + _delay_ms(200);
  10 + PORTC = 0x00;
  11 + _delay_ms(200);
  12 + }
  13 + return 0;
  14 +}
... ...
usefulllinks.txt 0 โ†’ 100644
... ... @@ -0,0 +1,2 @@
  1 +https://www.arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf
  2 +
... ...