diff --git a/arduino/AC.h b/arduino/AC.h index bcc6c32..9792485 100644 --- a/arduino/AC.h +++ b/arduino/AC.h @@ -1,3 +1,7 @@ +/* + * Définition des fonctions utilisées pour échager entre l'Arduino et le chef + */ + #ifndef __SERIAL_H_ #define __SERIAL_H_ diff --git a/arduino/ACsignals.h b/arduino/ACsignals.h index b537d3d..c8dfd43 100644 --- a/arduino/ACsignals.h +++ b/arduino/ACsignals.h @@ -7,6 +7,13 @@ #define AC_BAUDRATE 9600UL +// Structures used everywhere +struct position { + float x; + float y; + float o; +}; + // D: Direct // Sens naturel : Envoi de donnée // Sens inverse : Accusé de réception @@ -33,11 +40,8 @@ struct C2ADD_STOPs { // Donne une destination #define C2AD_GOTO 'G' -struct C2AD_GOTOs { - float x; - float y; - float o; // Peut-être NaN ou autre valeur spécifique si indifférent -}; +#define C2AD_GOTOs position +// Peut-être o à NaN ou autre valeur spécifique si indifférent // Arduino → Chef @@ -52,9 +56,9 @@ struct A2CI_ERRs { // Envoie les infos de debug #define A2CI_DBG 'D' struct A2CI_DBGs { - float x; - float y; - float o; + struct position actuel; + struct position destination; + unsigned char movement; // ... }; diff --git a/arduino/Makefile b/arduino/Makefile index 1646056..e89302f 100644 --- a/arduino/Makefile +++ b/arduino/Makefile @@ -29,7 +29,7 @@ FORMAT = ihex # Target file name (without extension). TARGET = principal -OBJS = AC position movement +OBJS = AC position movement debug # Custom NAME = $(TARGET).c diff --git a/arduino/debug.c b/arduino/debug.c new file mode 100644 index 0000000..aa70c53 --- /dev/null +++ b/arduino/debug.c @@ -0,0 +1,32 @@ +#include +#include "debug.h" +#include "AC.h" + +#include "position.h" +#include "movement.h" + +void TaskDebug(void *pvParameters) { + (void) pvParameters; + for (;;) { + vTaskSuspend(tDebug); + + // Copie des valeurs à envoyer en debug + memcpy((void*) &debug.actuel, (const void*) &actuel, (unsigned long) sizeof(actuel)); + memcpy((void*) &debug.destination, (const void*) &destination, (unsigned long) sizeof(destination)); + debug.movement = movement; + + // Envoi des valeurs + sendAC(A2CI_DBG, &debug, sizeof(debug)); + } +} + +void onA2CI_DBG() { + vTaskResume(tDebug); +} + + +void configureDebug() { + registerRxHandler(A2CI_DBG, onA2CI_DBG); + xTaskCreate(TaskDebug, "Debug", 128, NULL, 10, &tDebug);; +} + diff --git a/arduino/debug.h b/arduino/debug.h new file mode 100644 index 0000000..0eff7ab --- /dev/null +++ b/arduino/debug.h @@ -0,0 +1,18 @@ +/* + * Outils pour envoyer des informations de debug au chef + */ + +#ifndef __DEBUG_H_ +#define __DEBUG_H_ + +#include +#include + +TaskHandle_t tDebug; + +struct A2CI_DBGs debug; + +void TaskDebug(); +void configureDebug(); + +#endif diff --git a/arduino/position.h b/arduino/position.h index febaf07..528f1f9 100644 --- a/arduino/position.h +++ b/arduino/position.h @@ -8,11 +8,9 @@ #include #include -struct position { - float x; - float y; - float o; -}; +#include "ACsignals.h" + +struct position actuel; TaskHandle_t tPosition; diff --git a/arduino/principal.c b/arduino/principal.c index 4da5670..88b55dc 100644 --- a/arduino/principal.c +++ b/arduino/principal.c @@ -6,6 +6,7 @@ #include "AC.h" #include "position.h" #include "movement.h" +#include "debug.h" unsigned char speed = 200; @@ -24,9 +25,10 @@ void TaskBlink(void *pvParameters) { } int main(void) { - configureAC(); + configureAC(); // Doit rester en premier :) configureMovement(); configurePosition(); + configureDebug(); xTaskCreate(TaskBlink, "Blink", 128, NULL, 2, NULL); sei();