Commit b191d7e72095896dfe733a44aec0fcaa178a248a

Authored by pfrison
2 parents 742429d1 7bb9b8f1

Merge branch 'master' of https://archives.plil.fr/pfrison/projet-crep

tests/atmega2560/ledControl/ledControl.c 0 โ†’ 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +#include <avr/io.h>
  2 +#include <util/delay.h>
  3 +
  4 +int main(void){
  5 + // SCLK PIN 37
  6 + // SIN PIN 35
  7 + DDRC = 0x03;
  8 + uint8_t LEDs = {10, 20, 30, 40, 50, 60, 70, 80, 90,
  9 + 100, 110, 120, 130, 140, 150, 160, 170, 180, 190
  10 + 200, 210, 220, 230, 240};
  11 + uint8_t ANDs = {0x001, 0x002, 0x004, 0x008, 0x010, 0x020, 0x040, 0x080,
  12 + 0x100, 0x200, 0x400, 0x800};
  13 +
  14 + while(1){
  15 + for(int i=0; i<24; i++){
  16 + uint16_t n = LEDs[i] << 4;
  17 + int clkStatus = 0;
  18 + for(int j=0; j<12; j++){
  19 + if(j == 6)
  20 + clkStatus = 1;
  21 + PORTC = (n & ANDs[j]) << 1 | clkStatus;
  22 + _delay_ms(1);
  23 + }
  24 + }
  25 + }
  26 + return 0;
  27 +}
tests/atmega2560/ledControl/makefile 0 โ†’ 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  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 = servoControl
  10 +TERM = /dev/ttyACM0
  11 +CPPFLAGS = -mmcu=$(MCU)
  12 +PGMERISP = -c wiring -b 115200 -P $(TERM) -D
  13 +export DUDE = /usr/bin/avrdude -F -v -p $(MCU)
  14 +
  15 +C_SRC = $(wildcard *.c)
  16 +OBJS = $(C_SRC:.c=.o)
  17 +
  18 +all: $(TARGET).hex
  19 +
  20 +clean:
  21 + rm -f *.o *.hex *.elf
  22 +
  23 +%.o:%.c
  24 + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
  25 +
  26 +$(TARGET).elf: $(OBJS)
  27 + $(CC) $(LDFLAGS) -o $@ $(OBJS)
  28 +
  29 +$(TARGET).hex: $(TARGET).elf
  30 + avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
  31 + avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(TARGET).elf eeprom.hex
  32 +
  33 +upload: $(TARGET).hex
  34 + stty -F $(TERM) hupcl # reset
  35 + $(DUDE) $(PGMERISP) -U flash:w:$(TARGET).hex
  36 + make clean
tests/atmega2560/makefile
@@ -6,12 +6,11 @@ export TARGET_ARCH = -mmcu=$(MCU) @@ -6,12 +6,11 @@ export TARGET_ARCH = -mmcu=$(MCU)
6 export CFLAGS = -Wall -I. -DF_CPU=16000000 -Os #-g 6 export CFLAGS = -Wall -I. -DF_CPU=16000000 -Os #-g
7 export LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections # -Os 7 export LDFLAGS = -g $(TARGET_ARCH) -lm -Wl,--gc-sections # -Os
8 8
9 -TARGET = usb 9 +TARGET = servoControl
10 TERM = /dev/ttyACM0 10 TERM = /dev/ttyACM0
11 CPPFLAGS = -mmcu=$(MCU) 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) 12 +PGMERISP = -c wiring -b 115200 -P $(TERM) -D
  13 +export DUDE = /usr/bin/avrdude -F -v -p $(MCU)
15 14
16 C_SRC = $(wildcard *.c) 15 C_SRC = $(wildcard *.c)
17 OBJS = $(C_SRC:.c=.o) 16 OBJS = $(C_SRC:.c=.o)
tests/atmega2560/ordonanceur/makefile 0 โ†’ 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  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 = servoControl
  10 +TERM = /dev/ttyACM0
  11 +CPPFLAGS = -mmcu=$(MCU)
  12 +PGMERISP = -c wiring -b 115200 -P $(TERM) -D
  13 +export DUDE = /usr/bin/avrdude -F -v -p $(MCU)
  14 +
  15 +C_SRC = $(wildcard *.c)
  16 +OBJS = $(C_SRC:.c=.o)
  17 +
  18 +all: $(TARGET).hex
  19 +
  20 +clean:
  21 + rm -f *.o *.hex *.elf
  22 +
  23 +%.o:%.c
  24 + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
  25 +
  26 +$(TARGET).elf: $(OBJS)
  27 + $(CC) $(LDFLAGS) -o $@ $(OBJS)
  28 +
  29 +$(TARGET).hex: $(TARGET).elf
  30 + avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
  31 + avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(TARGET).elf eeprom.hex
  32 +
  33 +upload: $(TARGET).hex
  34 + stty -F $(TERM) hupcl # reset
  35 + $(DUDE) $(PGMERISP) -U flash:w:$(TARGET).hex
  36 + make clean
tests/atmega2560/ordonanceur.c renamed to tests/atmega2560/ordonanceur/ordonanceur.c
tests/atmega2560/servoAndStepperControl/makefile 0 โ†’ 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  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 = servoAndStepperControl
  10 +TERM = /dev/ttyACM0
  11 +CPPFLAGS = -mmcu=$(MCU)
  12 +PGMERISP = -c wiring -b 115200 -P $(TERM) -D
  13 +export DUDE = /usr/bin/avrdude -F -v -p $(MCU)
  14 +
  15 +C_SRC = $(wildcard *.c)
  16 +OBJS = $(C_SRC:.c=.o)
  17 +
  18 +all: $(TARGET).hex
  19 +
  20 +clean:
  21 + rm -f *.o *.hex *.elf
  22 +
  23 +%.o:%.c
  24 + $(CC) -c $(CPPFLAGS) $(CFLAGS) $< -o $@
  25 +
  26 +$(TARGET).elf: $(OBJS)
  27 + $(CC) $(LDFLAGS) -o $@ $(OBJS)
  28 +
  29 +$(TARGET).hex: $(TARGET).elf
  30 + avr-objcopy -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex
  31 + avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex $(TARGET).elf eeprom.hex
  32 +
  33 +upload: $(TARGET).hex
  34 + stty -F $(TERM) hupcl # reset
  35 + $(DUDE) $(PGMERISP) -U flash:w:$(TARGET).hex
  36 + make clean
tests/atmega2560/servoControl.c renamed to tests/atmega2560/servoAndStepperControl/servoAndStepperControl.c
@@ -2,13 +2,15 @@ @@ -2,13 +2,15 @@
2 #include <util/delay.h> 2 #include <util/delay.h>
3 3
4 int main(void){ 4 int main(void){
5 - DDRC = 0x01; 5 + // pin 13
  6 + DDRB = 0x80;
6 7
7 while(1){ 8 while(1){
8 - PORTC = 0x01;  
9 - _delay_ms(200);  
10 - PORTC = 0x00;  
11 - _delay_ms(200); 9 + PORTB = 0x80;
  10 + _delay_us(1000);
  11 + PORTB = 0x00;
  12 + _delay_us(1000);
12 } 13 }
13 return 0; 14 return 0;
14 } 15 }
  16 +
tests/atmega2560/stepperControl.c deleted
@@ -1,20 +0,0 @@ @@ -1,20 +0,0 @@
1 -#include <avr/io.h>  
2 -#include <util/delay.h>  
3 -  
4 -int vitesseToDelay(int vitesse){  
5 - return ;  
6 -}  
7 -  
8 -int main(void){  
9 - DDRC = 0x01;  
10 - PORTC |= 0x02; // Direction horraire ?  
11 - //PORTC &= 0xFD; // Direction anti-horraire ?  
12 - while(1){  
13 - // 1 Step  
14 - PORTC |= 0x01;  
15 - _delay_ms(10);  
16 - PORTC &= 0xFE;  
17 - _delay_ms(10);  
18 - }  
19 - return 0;  
20 -}