#include #include #include #define NB_TICK 104 //1563 #define CPU_FREQ 16000000L #define QUANTUM_ms 10 #define SAVE_CONTEXT() \ asm volatile ( \ "push r0 \n\t" \ "in r0, __SREG__ \n\t" \ "cli \n\t" \ "push r0 \n\t" \ "push r1 \n\t" \ "clr r1 \n\t" \ "push r2 \n\t" \ "push r3 \n\t" \ "push r4 \n\t" \ "push r5 \n\t" \ "push r6 \n\t" \ "push r7 \n\t" \ "push r8 \n\t" \ "push r9 \n\t" \ "push r10 \n\t" \ "push r11 \n\t" \ "push r12 \n\t" \ "push r13 \n\t" \ "push r14 \n\t" \ "push r15 \n\t" \ "push r16 \n\t" \ "push r17 \n\t" \ "push r18 \n\t" \ "push r19 \n\t" \ "push r20 \n\t" \ "push r21 \n\t" \ "push r22 \n\t" \ "push r23 \n\t" \ "push r24 \n\t" \ "push r25 \n\t" \ "push r26 \n\t" \ "push r27 \n\t" \ "push r28 \n\t" \ "push r29 \n\t" \ "push r30 \n\t" \ "push r31 \n\t" \ ); #define RESTORE_CONTEXT() \ asm volatile ( \ "pop r31 \n\t" \ "pop r30 \n\t" \ "pop r29 \n\t" \ "pop r28 \n\t" \ "pop r27 \n\t" \ "pop r26 \n\t" \ "pop r25 \n\t" \ "pop r24 \n\t" \ "pop r23 \n\t" \ "pop r22 \n\t" \ "pop r21 \n\t" \ "pop r20 \n\t" \ "pop r19 \n\t" \ "pop r18 \n\t" \ "pop r17 \n\t" \ "pop r16 \n\t" \ "pop r15 \n\t" \ "pop r14 \n\t" \ "pop r13 \n\t" \ "pop r12 \n\t" \ "pop r11 \n\t" \ "pop r10 \n\t" \ "pop r9 \n\t" \ "pop r8 \n\t" \ "pop r7 \n\t" \ "pop r6 \n\t" \ "pop r5 \n\t" \ "pop r4 \n\t" \ "pop r3 \n\t" \ "pop r2 \n\t" \ "pop r1 \n\t" \ "pop r0 \n\t" \ "out __SREG__, r0 \n\t" \ "pop r0 \n\t" \ ); struct task{ uint16_t sp_vise; uint8_t state; }; /** Démarre le timer pour l'ordonnancement */ void init_timer(){ TCCR1B |= _BV(WGM12); // CTC mode with value in OCR1A TCCR1B |= _BV(CS12); // CS12 = 1; CS11 = 1; CS10 =1 => CLK/1024 prescaler TCCR1B |= _BV(CS10); OCR1A = NB_TICK; TIMSK1 |= _BV(OCIE1A); } /** Configure les ports */ void init_ports(){ //TODO DDRXs } /** Alumme la LED 13 pour témoigné du bon fonctionnement de la carte */ void temoin_allumage(){ DDRA = 0x01; PORTA = 0x01; _delay_ms(500); PORTA = 0x00; } /** Reception de l'interruption généré par le timer (changement de contexte) */ ISR(TIMER1_COMPA_vect){ // TODO sei(); } int main(void){ temoin_allumage(); // Initialisation init_timer(); init_port(); sei(); while(1){} return 0; }