No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

system_dumby.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /**
  2. ******************************************************************************
  3. * @file system_dumby.h
  4. * @author Lucien Senaneuch
  5. * @version V1.0
  6. * @date 19-June-2017
  7. * @brief Configure les variables globals, les timers necessaires.
  8. *
  9. * Configure la pin de shutdown.
  10. * Initialise le systick.
  11. * Initialise les valeurs de shutdown avec le watchdog.
  12. * Initialise les variables global des commandes.
  13. * Initialise la strucutre Settings contenant les paramètres de dumber.
  14. *
  15. *@note Les différentes commande sont :
  16. * PingCMD 'p'
  17. * ResetCMD 'r'
  18. * SetMotorCMD 'm'
  19. * StartWWatchDogCMD 'W'
  20. * ResetWatchdogCMD 'w'
  21. * GetBatteryVoltageCMD 'v'
  22. * GetVersionCMD 'V'
  23. * StartWithoutWatchCMD 'u'
  24. * MoveCMD 'M'
  25. * TurnCMD 'T'
  26. * BusyStateCMD 'b'
  27. ******************************************************************************
  28. ******************************************************************************
  29. */
  30. #ifndef _SYSTEM_DUMBY_H_
  31. #define _SYSTEM_DUMBY_H_
  32. #include "stm32f10x.h"
  33. /* Déclaration des Constantes */
  34. #define VERSION "version 1.4\r"
  35. #define SPI 10
  36. #define USART 20
  37. #define I2C 30
  38. #define TRUE 40
  39. #define FALSE 50
  40. #define VOLTAGE 98
  41. #define CURRENT 99
  42. #define UNDEFINED 101
  43. #define TIMER_1s 1000 // 1 sec
  44. //#define TIMER_Watchdog 3050
  45. //#define TTMER_Inactivity 120000 // 2 min
  46. #define WATCHDOG_MIN 970
  47. #define WATCHDOG_MAX 1030
  48. #define WATCHDOG_INVALID_COUNTER_MAX 3
  49. #define COMMONSPEED 5
  50. #define LOWSPEED 2
  51. #define HYPERVITESSE 7
  52. /* Déclaration de structure */
  53. enum States {
  54. STATE_IDLE = 0,
  55. STATE_RUN,
  56. STATE_LOW,
  57. STATE_DISABLE,
  58. STATE_WATCHDOG_DISABLE
  59. };
  60. typedef enum States States;
  61. struct Settings
  62. {
  63. // Information
  64. uint16_t BatteryPercentage; // Retourne le pourcentage de charge de la batterie
  65. uint16_t BatteryCurrent; //
  66. States StateSystem; // État de la MAE
  67. char AddOn; // Un AddOn a été détecté
  68. // Les instructions seront sur le protocole SPI
  69. char BatterieChecking; // On doit vérifier la valeur de la batterie
  70. uint16_t cpt_systick;
  71. char WatchDogStartEnable; // Le Robot a été lancé en mode WithWatchDog ou WithoutWatchDog
  72. uint16_t cpt_watchdog;
  73. uint8_t InvalidWatchdogResetCpt; // Compteur de remise à zéro du watchdog en dehors du temps imparti
  74. char busyState;
  75. int cpt_inactivity;
  76. char acquisition;
  77. char stateBattery;
  78. char flagSystick;
  79. };
  80. typedef struct Settings Settings;
  81. /* Déclaration des variables systèmes */
  82. extern Settings Dumber;
  83. /* Prototype Fonctions */
  84. void systemConfigure(void);
  85. void systemChangeState(States state);
  86. char systemResetWatchdog(void);
  87. void systemShutDown(void);
  88. #endif /* _SYSTEM_DUMBY_H_ */