summaryrefslogtreecommitdiff
path: root/n/accel/accel.c
diff options
context:
space:
mode:
authorburg2004-08-02 19:17:00 +0000
committerburg2004-08-02 19:17:00 +0000
commitc90d35b179b53cb42dbb75e6f1f2d6fa439ebc9b (patch)
treebfaa53d2d6c5584063739a58ac04ba84d5aa2158 /n/accel/accel.c
parent341a550e99775227ba751566bb8cc99535889922 (diff)
Vielle modif
Diffstat (limited to 'n/accel/accel.c')
-rw-r--r--n/accel/accel.c100
1 files changed, 54 insertions, 46 deletions
diff --git a/n/accel/accel.c b/n/accel/accel.c
index 0ec6552..2051614 100644
--- a/n/accel/accel.c
+++ b/n/accel/accel.c
@@ -76,36 +76,36 @@ SIGNAL(SIG_INPUT_CAPTURE1)
debug_putc('A');
TCNT1 = 0; // remise de TCNT1 (counter 16bits)
TCCR1B &= ~_BV(ICES1); // trigge sur le front descendant
- TIMSK |= 0x20; //autorise les interruptions Input Capture
+ //TIMSK |= 0x20; //autorise les interruptions Input Capture
etat = rd_at_Tb;
break;
case rd_at_Tb :
debug_putc('B');
Tb = ICR1; // sauvegarde du registre Input Capture
etat = rd_at_Tc;
- TIMSK &= ~0x20; //désactive les interruptions Input Capture
+ //TIMSK &= ~0x20; //désactive les interruptions Input Capture
ACSR |= 0x04; //change d'entrée : analogue comparator
TCCR1B |= _BV(ICES1); //trigge sur le front montant
- TIMSK |= 0x20; // Réactive les interruptions Input Capture
+ //TIMSK |= 0x20; // Réactive les interruptions Input Capture
break;
case rd_at_Tc :
debug_putc('C');
Tc = ICR1; // sauvegarde du registre Input Capture
- TIMSK &= ~0x20; //désactive les interruptions Input Capture
+ //TIMSK &= ~0x20; //désactive les interruptions Input Capture
TCCR1B &= ~_BV(ICES1); // trigge sur le front descendant
- TIMSK |= 0x20; // Réactive les interruptions Input Capture
+ //TIMSK |= 0x20; // Réactive les interruptions Input Capture
etat = rd_at_Td;
break;
case rd_at_Td :
debug_putc('D');
Td = ICR1; // sauvegarde du registre Input Capture
etat = calcul;
- TIMSK &= ~0x20; //désactive les interruptions Input Capture
+ //TIMSK &= ~0x20; //désactive les interruptions Input Capture
ACSR &= ~0x04; //change d'entrée : IPC
TCCR1B |= _BV(ICES1); //trigge sur le front montant
- TIMSK |= 0x20; // Réactive les interruptions Input Capture
+ //TIMSK |= 0x20; // Réactive les interruptions Input Capture
break;
- default :debug_putc('L');
+ default :proto_send1('E',3);
break; // Ce cas ne doit pas arriver
}
}
@@ -119,30 +119,35 @@ void
test_callback (uint8_t c, uint8_t argc, proto_arg_t argv[])
{
//proto_send (c, argc, argv);
- switch (c)
+ if (argc == 0)
+ {
+ switch (c)
+ {
+ case 'c' : proto_send0('C');
+ calibration();
+ break;
+ case 'x' : proto_send2('X',Tx >> 8, Tx);
+ break;
+ case 'y' : proto_send2('Y',Ty >> 8, Tx);
+ break;
+ case 't' : proto_send2('T',Timer1 >> 8, Timer1);
+ break;
+ case 'g' : proto_send2('x',Gx >> 8, Gx);
+ proto_send2('y',Gy >> 8, Gy);
+ break;
+ case 'k' : proto_send2('K',T2 >> 8, T2);
+ break;
+ case 'v' : rs232_putc('V');
+ proto_send2('x',Vx >> 8,Vx);
+ rs232_putc('V');
+ proto_send2('y',Vy >> 8,Vy);
+ break;
+ default : proto_send1('E',2); //erreur 2 Command incorrect
+ }
+ }
+ else
{
- case 'c' : proto_send0('C');
- calibration();
- break;
- case 'x' : proto_send2('X',Tx >> 8, Tx);
- break;
- case 'y' : proto_send2('Y',Ty >> 8, Tx);
- break;
- case 't' : proto_send2('T',Timer1 >> 8, Timer1);
- break;
- case 'g' : proto_send2('x',Gx >> 8, Gx);
- proto_send2('y',Gy >> 8, Gy);
- break;
- case 'k' : proto_send2('K',T2 >> 8, T2);
- break;
- case 'v' : rs232_putc('V');
- proto_send2('x',Vx >> 8,Vx);
- rs232_putc('V');
- proto_send2('y',Vy >> 8,Vy);
- break;
- default : proto_send1('E',2); //erreur 2 Command incorrect
}
-
}
int
@@ -164,25 +169,28 @@ main (void)
{
if ( rs232_poll() )
{
- proto_accept(rs232_getc());
+ /* polling sur la reception serie
+ * */
+ proto_accept(rs232_getc());
}
// calcul des Tons
if (etat == calcul)
- {
- Tx = Tb; // Calcul des Ton
- Ty = Td - Tc;
- // Todo T2 ne doit pas être calculer tout le temps
- //T2 = (Td - (Ty/2)) - Tb/2; //Calcul de T2
- T2 = (Td + Tc - Tb) /2;
- TCNT1 = 0; // remise de TCNT1 (counter 16bits)
- Gx = calculG(Tx,T2_cal,G0x);
- Gy = calculG(Ty,T2_cal,G0y);
- Vx += (Gx) >> 8;
- Vy += (Gy) >> 8;
- Timer1 = TCNT1;
- //remise dans l'état de capture
- etat = strt_at_Ta;
- }
+ {
+ Tx = Tb; // Calcul des Ton
+ Ty = Td - Tc;
+ // Todo T2 ne doit pas être calculer tout le temps
+ T2 = (Td + Tc - Tb) /2;
+ // remise de TCNT1 pour mesurer le temps
+ TCNT1 = 0;
+ Gx = calculG(Tx,T2_cal,G0x);
+ Gy = calculG(Ty,T2_cal,G0y);
+ Vx += (Gx) >> 8;
+ Vy += (Gy) >> 8;
+ Timer1 = TCNT1;
+ //remise dans l'état de capture
+ //Todo : remettre dans cette état plutôt
+ etat = strt_at_Ta;
+ }
}
return 0;