diff --git a/software/robot/.cproject b/software/robot/.cproject index ae4f467..2a15f6b 100644 --- a/software/robot/.cproject +++ b/software/robot/.cproject @@ -12,7 +12,7 @@ - + - - + + @@ -150,103 +150,131 @@ - - - - diff --git a/software/robot/.gitignore b/software/robot/.gitignore index 76f47ff..1d4345f 100644 --- a/software/robot/.gitignore +++ b/software/robot/.gitignore @@ -1,3 +1,4 @@ /Debug/ /html/ +/Release/ diff --git a/software/robot/.settings/language.settings.xml b/software/robot/.settings/language.settings.xml index d5df711..f0d85f1 100644 --- a/software/robot/.settings/language.settings.xml +++ b/software/robot/.settings/language.settings.xml @@ -10,7 +10,7 @@ - + diff --git a/software/robot/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/software/robot/.settings/org.eclipse.cdt.managedbuilder.core.prefs index bb95b28..5a96f79 100644 --- a/software/robot/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ b/software/robot/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -1,10 +1,20 @@ eclipse.preferences.version=1 +environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509.2045581985/CPATH/delimiter=\: +environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509.2045581985/CPATH/operation=remove +environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509.2045581985/C_INCLUDE_PATH/delimiter=\: +environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509.2045581985/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509.2045581985/append=true +environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509.2045581985/appendContributed=true environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509/CPATH/delimiter=\: environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509/CPATH/operation=remove environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509/C_INCLUDE_PATH/delimiter=\: environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509/C_INCLUDE_PATH/operation=remove environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509/append=true environment/buildEnvironmentInclude/com.atollic.truestudio.exe.debug.584431509/appendContributed=true +environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.584431509.2045581985/LIBRARY_PATH/delimiter=\: +environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.584431509.2045581985/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.584431509.2045581985/append=true +environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.584431509.2045581985/appendContributed=true environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.584431509/LIBRARY_PATH/delimiter=\: environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.584431509/LIBRARY_PATH/operation=remove environment/buildEnvironmentLibrary/com.atollic.truestudio.exe.debug.584431509/append=true diff --git a/software/robot/X-CTU_command_List.xml b/software/robot/X-CTU_command_List.xml index f093791..abb507d 100644 --- a/software/robot/X-CTU_command_List.xml +++ b/software/robot/X-CTU_command_List.xml @@ -38,5 +38,8 @@ 76760D + + 7A7A0D + diff --git a/software/robot/src/cmdManager.c b/software/robot/src/cmdManager.c index 3a5e3db..1e9c9d5 100644 --- a/software/robot/src/cmdManager.c +++ b/software/robot/src/cmdManager.c @@ -49,6 +49,7 @@ #define BusyStateCMD 'b' #define TestCMD 't' #define DebugCMD 'a' +#define PowerOffCMD 'z' #define OK_ANS "O\r" #define ERR_ANS "E\r" @@ -57,6 +58,23 @@ #define BAT_LOW "1\r" #define BAT_EMPTY "0\r" +/* Prototype des fonctions */ + +char cmdVerifyChecksum(void); +void cmdAddChecksum(void); +void cmdResetAction(void); +void cmdBusyStateAction(void); +void cmdPingAction(void); +void cmdVersionAction(void); +void cmdStartWithoutWatchdogAction(void); +void cmdMoveAction(void); +void cmdTurnAction(void); +void cmdBatteryVoltageAction(void); +void cmdStartWithWatchdogAction(void); +void cmdResetWatchdogAction(void); +void cmdDebugAction(void); +void cmdPowerOffAction(void); + /** @addtogroup Checksum * @{ */ @@ -138,8 +156,11 @@ void cmdManage(void) { if (cmdVerifyChecksum() != 0) { strcpy(sendString, UNKNOW_ANS); } else { // Checksum valide - if (Dumber.StateSystem==STATE_DISABLE) { // SI la batterie est trop faible, impossible d'accepter une commande: on reste dans ce mode - strcpy(sendString, ERR_ANS); + if (Dumber.StateSystem==STATE_DISABLE) { // SI la batterie est trop faible, impossible d'accepter une commande sauf poweroff: on reste dans ce mode + if (receiptString[0]==PowerOffCMD) + cmdPowerOffAction(); + else + strcpy(sendString, ERR_ANS); } else { switch (receiptString[0]) { case PingCMD: @@ -182,10 +203,13 @@ void cmdManage(void) { cmdBusyStateAction(); break; - case 'a': + case DebugCMD: cmdDebugAction(); break; + case PowerOffCMD: + cmdPowerOffAction(); + break; default: strcpy(sendString, UNKNOW_ANS); } @@ -418,6 +442,25 @@ void cmdDebugAction(void) { usartSendData(); } +/** + * @brief Eteint le robot + * + * @param None + * @retval None + */ +void cmdPowerOffAction(void) { + volatile int i; + + systemChangeState(STATE_DISABLE); + strcpy(sendString, OK_ANS); + + cmdAddChecksum(); + usartSendData(); + /* Attente d'un certain temps (100 ms), pour que la reponse parte */ + for (i=0; i<100000; i++); + + systemShutDown(); // Ne ressort jamais de cette fonction +} /** * @} */ diff --git a/software/robot/src/cmdManager.h b/software/robot/src/cmdManager.h index b2705d8..cfb10a8 100644 --- a/software/robot/src/cmdManager.h +++ b/software/robot/src/cmdManager.h @@ -22,19 +22,7 @@ #include void cmdManage(void); -char cmdVerifyChecksum(void); void cmdAddChecksum(void); -void cmdResetAction(void); -void cmdBusyStateAction(void); -void cmdPingAction(void); -void cmdVersionAction(void); -void cmdStartWithoutWatchdogAction(void); -void cmdMoveAction(void); -void cmdTurnAction(void); -void cmdBatteryVoltageAction(void); -void cmdStartWithWatchdogAction(void); -void cmdResetWatchdogAction(void); -void cmdDebugAction(void); #endif /* _CMD_MANAGER_H_ */ diff --git a/software/robot/src/system_dumby.h b/software/robot/src/system_dumby.h index 2bf8b65..c46acb6 100644 --- a/software/robot/src/system_dumby.h +++ b/software/robot/src/system_dumby.h @@ -33,7 +33,7 @@ #include "stm32f10x.h" /* Déclaration des Constantes */ -#define VERSION "version 1.3\r" +#define VERSION "version 1.4\r" #define SPI 10 #define USART 20 @@ -47,9 +47,9 @@ #define UNDEFINED 101 -#define TIMER_1s 1000 // 1 sec -#define TIMER_Watchdog 3050 // -#define TTMER_Inactivity 120000 // 2 min +#define TIMER_1s 1000 // 1 sec +//#define TIMER_Watchdog 3050 +//#define TTMER_Inactivity 120000 // 2 min #define WATCHDOG_MIN 970 #define WATCHDOG_MAX 1030