Commit c52f6592fbf9fb3f8883488385ba3caf4d4108ec

Authored by pfrison
1 parent 0168f2ba

Rédaction de quelques tests. Tests sur l'arduino mega a venir

tests/atmega2560/ordonanceur.c 0 → 100644
... ... @@ -0,0 +1,132 @@
  1 +#include <avr/io.h>
  2 +#include <avr/interrupt.h>
  3 +#include <util/delay.h>
  4 +
  5 +#define NB_TICK 104 //1563
  6 +#define CPU_FREQ 16000000L
  7 +#define QUANTUM_ms 10
  8 +
  9 +#define SAVE_CONTEXT() \
  10 +asm volatile ( \
  11 +"push r0 \n\t" \
  12 +"in r0, __SREG__ \n\t" \
  13 +"cli \n\t" \
  14 +"push r0 \n\t" \
  15 +"push r1 \n\t" \
  16 +"clr r1 \n\t" \
  17 +"push r2 \n\t" \
  18 +"push r3 \n\t" \
  19 +"push r4 \n\t" \
  20 +"push r5 \n\t" \
  21 +"push r6 \n\t" \
  22 +"push r7 \n\t" \
  23 +"push r8 \n\t" \
  24 +"push r9 \n\t" \
  25 +"push r10 \n\t" \
  26 +"push r11 \n\t" \
  27 +"push r12 \n\t" \
  28 +"push r13 \n\t" \
  29 +"push r14 \n\t" \
  30 +"push r15 \n\t" \
  31 +"push r16 \n\t" \
  32 +"push r17 \n\t" \
  33 +"push r18 \n\t" \
  34 +"push r19 \n\t" \
  35 +"push r20 \n\t" \
  36 +"push r21 \n\t" \
  37 +"push r22 \n\t" \
  38 +"push r23 \n\t" \
  39 +"push r24 \n\t" \
  40 +"push r25 \n\t" \
  41 +"push r26 \n\t" \
  42 +"push r27 \n\t" \
  43 +"push r28 \n\t" \
  44 +"push r29 \n\t" \
  45 +"push r30 \n\t" \
  46 +"push r31 \n\t" \
  47 +);
  48 +
  49 +#define RESTORE_CONTEXT() \
  50 +asm volatile ( \
  51 +"pop r31 \n\t" \
  52 +"pop r30 \n\t" \
  53 +"pop r29 \n\t" \
  54 +"pop r28 \n\t" \
  55 +"pop r27 \n\t" \
  56 +"pop r26 \n\t" \
  57 +"pop r25 \n\t" \
  58 +"pop r24 \n\t" \
  59 +"pop r23 \n\t" \
  60 +"pop r22 \n\t" \
  61 +"pop r21 \n\t" \
  62 +"pop r20 \n\t" \
  63 +"pop r19 \n\t" \
  64 +"pop r18 \n\t" \
  65 +"pop r17 \n\t" \
  66 +"pop r16 \n\t" \
  67 +"pop r15 \n\t" \
  68 +"pop r14 \n\t" \
  69 +"pop r13 \n\t" \
  70 +"pop r12 \n\t" \
  71 +"pop r11 \n\t" \
  72 +"pop r10 \n\t" \
  73 +"pop r9 \n\t" \
  74 +"pop r8 \n\t" \
  75 +"pop r7 \n\t" \
  76 +"pop r6 \n\t" \
  77 +"pop r5 \n\t" \
  78 +"pop r4 \n\t" \
  79 +"pop r3 \n\t" \
  80 +"pop r2 \n\t" \
  81 +"pop r1 \n\t" \
  82 +"pop r0 \n\t" \
  83 +"out __SREG__, r0 \n\t" \
  84 +"pop r0 \n\t" \
  85 +);
  86 +
  87 +struct task{
  88 + uint16_t sp_vise;
  89 + uint8_t state;
  90 +};
  91 +
  92 +/** Démarre le timer pour l'ordonnancement */
  93 +void init_timer(){
  94 + TCCR1B |= _BV(WGM12); // CTC mode with value in OCR1A
  95 + TCCR1B |= _BV(CS12); // CS12 = 1; CS11 = 1; CS10 =1 => CLK/1024 prescaler
  96 + TCCR1B |= _BV(CS10);
  97 + OCR1A = NB_TICK;
  98 + TIMSK1 |= _BV(OCIE1A);
  99 +}
  100 +
  101 +/** Configure les ports */
  102 +void init_ports(){
  103 + //TODO DDRXs
  104 +}
  105 +
  106 +/** Alumme la LED 13 pour témoigné du bon fonctionnement de la carte */
  107 +void temoin_allumage(){
  108 + DDRA = 0x01;
  109 + PORTA = 0x01;
  110 + _delay_ms(500);
  111 + PORTA = 0x00;
  112 +}
  113 +
  114 +/** Reception de l'interruption généré par le timer (changement de contexte) */
  115 +ISR(TIMER1_COMPA_vect){
  116 + // TODO
  117 + sei();
  118 +}
  119 +
  120 +int main(void){
  121 + temoin_allumage();
  122 +
  123 + // Initialisation
  124 + init_timer();
  125 + init_port();
  126 + sei();
  127 +
  128 + while(1){}
  129 + return 0;
  130 +}
  131 +
  132 +
... ...
tests/atmega2560/stepperControl.c 0 → 100644
... ... @@ -0,0 +1,20 @@
  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 +}
... ...