FSM_1st.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /**
  2. * @file sysfsm1.h
  3. * @author Zhang, Kai(zhangkai71@midea.com)
  4. * @brief System FSM
  5. * @version 0.1
  6. * @date 2021-09-27
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. */
  11. #ifndef FSM1ST_H
  12. #define FSM1ST_H
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif // __cplusplus
  16. /****************************************
  17. *
  18. * Definitions & Macros
  19. *
  20. ****************************************/
  21. #define SYS_RDY_FLG_DEFAULT \
  22. { \
  23. FALSE, FALSE, FALSE, FALSE, FALSE \
  24. }
  25. #define SYS_FSM_FLG_DEFAULT \
  26. { \
  27. FALSE, FALSE, FALSE, FALSE, FALSE, FALSE \
  28. }
  29. /***************************************
  30. *
  31. * Type Definations
  32. *
  33. ***************************************/
  34. /**
  35. * @brief Type of signal
  36. *
  37. */
  38. typedef struct
  39. {
  40. BOOL Switched;
  41. BOOL Sensor;
  42. BOOL Assist;
  43. BOOL Light;
  44. BOOL Display;
  45. } SIGNAL_STATE;
  46. /**
  47. * @brief Type of system FSM
  48. *
  49. */
  50. typedef enum
  51. {
  52. SysInit = 0,
  53. SysRdy = 1,
  54. SysFault = 2,
  55. } SYS_FSM_STATUS;
  56. /**
  57. * @brief Type of system FSM flag
  58. *
  59. */
  60. typedef struct
  61. {
  62. BOOL HMI_Flag;
  63. BOOL SysCoef_Flag;
  64. BOOL SysRdy_Flag;
  65. BOOL SysRun_Flag;
  66. BOOL SysWarnning_Flag;
  67. BOOL SysFault_Flag;
  68. } SYS_FMS_FLAG;
  69. /**
  70. * @brief Type of system ready flag
  71. *
  72. */
  73. typedef struct
  74. {
  75. BOOL blAlmOccrFlg;
  76. BOOL CommuRdy_Flag;
  77. BOOL blADCInitOvrFlg;
  78. BOOL blFSMRstOvrFlg;
  79. BOOL blCtrlMdVarClcOvrFlg;
  80. } SYS_RDY_FLG;
  81. /**
  82. * @brief Type of system hook function
  83. *
  84. */
  85. typedef struct
  86. {
  87. SYS_FSM_STATUS state;
  88. void (*Event_hook)(void);
  89. void (*Tbcup_hook)(void);
  90. void (*TbcDown_hook)(void);
  91. void (*Tbs_hook)(void);
  92. } FSM_SYS_HOOK;
  93. /****************************************
  94. *
  95. * Exported variable
  96. *
  97. ****************************************/
  98. extern FSM_SYS_HOOK FSM1st_Sys_state;
  99. extern FSM_SYS_HOOK SysFault_state;
  100. extern SYS_RDY_FLG sysfsm_stFlg;
  101. extern SIGNAL_STATE signal_state;
  102. extern SYS_FMS_FLAG switch_flg;
  103. /***************************************
  104. *
  105. * Function Definations
  106. *
  107. ***************************************/
  108. /**
  109. * @brief Process when switching state from Ready to Run
  110. *
  111. */
  112. void ReadytoRun(void);
  113. /**
  114. * @brief Process of FSM during SysInit state
  115. *
  116. */
  117. void SysInit_hook(void);
  118. /**
  119. * @brief Process of FSM during SysRdy state
  120. *
  121. */
  122. void SysRdy_hook(void);
  123. /**
  124. * @brief Process of FSM during SysFualt state
  125. *
  126. */
  127. void SysFault_hook(void);
  128. /**
  129. * @brief Process of Tbc up during SysInit state
  130. *
  131. */
  132. void SysInit_TbcUphook(void);
  133. /**
  134. * @brief Process of Tbc up during sysRdy state
  135. *
  136. */
  137. void SysRdy_TbcUphook(void);
  138. /**
  139. * @brief Process of Tbc up during SysFault state
  140. *
  141. */
  142. void SysFault_TbcDownhook(void);
  143. /**
  144. * @brief Process of Tbc down during SysInit state
  145. *
  146. */
  147. void SysInit_TbcDownhook(void);
  148. /**
  149. * @brief Process of Tbc down during sysRdy state
  150. *
  151. */
  152. void SysRdy_TbcDownhook(void);
  153. /**
  154. * @brief Process of Tbc down during SysFault state
  155. *
  156. */
  157. void SysFault_TbcUphook(void);
  158. /**
  159. * @brief Process of Tbs during SysInit state
  160. *
  161. */
  162. void SysInit_Tbshook(void);
  163. /**
  164. * @brief Process of Tbs during sysRdy state
  165. *
  166. */
  167. void SysRdy_Tbshook(void);
  168. /**
  169. * @brief Process of Tbs during SysFault state
  170. *
  171. */
  172. void SysFault_Tbshook(void);
  173. /**
  174. * @brief Switch current state to *in state
  175. *
  176. * @param in pointer to target state
  177. */
  178. void Switch_sys_FSM(const FSM_SYS_HOOK *in);
  179. /**
  180. * @brief System FSM running function
  181. *
  182. */
  183. void FSM_1st_Main(void);
  184. /**
  185. * @brief Relay power on
  186. *
  187. */
  188. void RlyOnInit(void);
  189. /**
  190. * @brief System FSM initialization
  191. *
  192. */
  193. void FSM_voInit(void);
  194. #ifdef __cplusplus
  195. }
  196. #endif // __cplusplus
  197. #endif