summaryrefslogtreecommitdiff
path: root/n/accel
diff options
context:
space:
mode:
Diffstat (limited to 'n/accel')
-rw-r--r--n/accel/accel.c77
-rw-r--r--n/accel/avrconfig.h11
2 files changed, 51 insertions, 37 deletions
diff --git a/n/accel/accel.c b/n/accel/accel.c
index 875ed82..55779f6 100644
--- a/n/accel/accel.c
+++ b/n/accel/accel.c
@@ -85,7 +85,7 @@ SIGNAL(SIG_INPUT_CAPTURE1)
if (mode !=0)
{
//va vers le mode config
- if(mode ==1 )
+ if(mode == 1 )
{
etat = rd_at_T2_x;
}
@@ -131,7 +131,10 @@ SIGNAL(SIG_INPUT_CAPTURE1)
calcul_rdy = 1; // Autorise le calcul
}
else
- proto_send1('E',6);// calcul trop long //
+ {
+ // calcul trop long //
+ proto_send1b('E',6);
+ }
etat = strt_at_Ta;
break;
case rd_at_T2_x :
@@ -149,61 +152,70 @@ SIGNAL(SIG_INPUT_CAPTURE1)
case record_T2_y:
etat = strt_at_Ta;
break;
- default :proto_send1('E',3);
+ default :proto_send1b('E',3);
break; // Ce cas ne doit pas arriver
}
}
SIGNAL(SIG_OVERFLOW1)
{
- proto_send1('E',1); //erreur 1 Overflow timer/compteur1
+ //erreur 1 Overflow timer/compteur1
+ proto_send1b('E',1);
}
void
-test_callback (uint8_t c, uint8_t argc, proto_arg_t argv[])
+proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
// fonction de gestion des communications
// {{{
{
//proto_send (c, argc, argv);
- if (argc == 0)
+ if (size == 0)
{
- switch (c)
+ switch (cmd)
{
case 'c' : proto_send0('C');
calibration();
break;
- case 'x' : proto_send2('X',Tx >> 8, Tx);
+ case 'x' : proto_send1w('X',Tx);
break;
- case 'y' : proto_send2('Y',Ty >> 8, Tx);
+ case 'y' : proto_send1w('Y',Ty);
break;
- case 'r' : proto_send2('z',T2x >> 8,T2x);
- proto_send2('e',T2y >> 8, T2y);
- proto_send2('R',T2 >> 8, T2);
+ case 'r' : proto_send1w('z',T2x);
+ proto_send1w('e',T2y);
+ proto_send1w('R',T2);
break;
- case 't' : proto_send2('T',Timer1 >> 8, Timer1);
+ case 't' : proto_send1w('T',Timer1);
break;
- case 'g' : proto_send2('x',Gx >> 8, Gx);
- proto_send2('y',Gy >> 8, Gy);
+ case 'g' : proto_send1w('x',Gx);
+ proto_send1w('y',Gy);
break;
- case 'k' : proto_send2('K',T2 >> 8, T2);
+ case 'k' : proto_send1w('K',T2);
break;
case 'v' : rs232_putc('V');
- proto_send2('x',Vx >> 8,Vx);
+ proto_send1w('x',Vx);
rs232_putc('V');
- proto_send2('y',Vy >> 8,Vy);
+ proto_send1w('y',Vy);
break;
case 'z' : reset();
- default : proto_send1('E',2); //erreur 2 Command incorrect
+ default : proto_send1b('E',2); //erreur 2 Command incorrect
}
}
else
{
- if (argc == 1)
+ if (size == 1)
+ {
+ if (cmd == 'i') command = args[0];
+ else
+ {
+ //erreur 4 command non reconnu
+ proto_send1b('E',4);
+ }
+ }
+ else
{
- if (c == 'i') command = argv[0];
- else proto_send1('E',4); //erreur 4 command non reconnu
+ //Trop d'argument
+ proto_send1b('E',5);
}
- else proto_send1('E',5); //Trop d'argument
}
}
//}}}
@@ -213,7 +225,7 @@ main (void)
{
//initialisation
rs232_init();
- proto_init(test_callback,rs232_putc);
+ //proto_init(test_callback,rs232_putc);
proto_send0('Z');
@@ -227,7 +239,6 @@ main (void)
//Boucle
while(1)
{
- //proto_send0('b');
if ( rs232_poll() )
{
/* polling sur la reception serie
@@ -254,35 +265,35 @@ main (void)
{
if (command & 0x01)
{
- proto_send2('P',Tx >> 8,Tx);
+ proto_send1w('P',Tx);
}
if (command & 0x02)
{
- proto_send2('Q', Ty >> 8, Ty);
+ proto_send1w('Q',Ty);
}
if (command & 0x04)
{
- proto_send2('R', Gx >> 8,Gx);
+ proto_send1w('R',Gx);
}
if (command & 0x08)
{
- proto_send2('S',Gy >> 8,Gy);
+ proto_send1w('S',Gy);
}
if (command & 0x10)
{
- proto_send2('T',Vx >> 8,Vx);
+ proto_send1w('T',Vx);
}
if (command & 0x20)
{
- proto_send2('U',Vy >> 8,Vy);
+ proto_send1w('U',Vy);
}
if (command & 0x40)
{
- proto_send2('V', Dx >> 8,Dx);
+ proto_send1w('V',Dx);
}
if (command & 0x80)
{
- proto_send2('W',Dy >> 8, Dy);
+ proto_send1w('W',Dy);
}
}
diff --git a/n/accel/avrconfig.h b/n/accel/avrconfig.h
index 018f0c1..88a3a8e 100644
--- a/n/accel/avrconfig.h
+++ b/n/accel/avrconfig.h
@@ -29,10 +29,13 @@
#define AC_FREQ 14745600
/* proto - Protocol module. */
-/** Maximum argument number. */
-#define AC_PROTO_MAX_ARGS 3
-/** Protocol arguments type. */
-#define AC_PROTO_ARG_TYPE uint8_t
+/** Maximum argument size. */
+#define AC_PROTO_ARGS_MAX_SIZE 8
+/** Callback function name. */
+#define AC_PROTO_CALLBACK proto_callback
+/** Putchar function name. */
+#define AC_PROTO_PUTC rs232_putc
+
/* rs232 - RS232 Module. */
/** Baudrate : 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 76800,