FSM_2nd.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /**
  2. * @file ctrlmdfsm1.h
  3. * @author Zhang, Kai(zhangkai71@midea.com)
  4. * @brief Control mode FSM
  5. * @version 0.1
  6. * @date 2021-09-27
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. */
  11. #ifndef FSM2ND_H
  12. #define FSM2ND_H
  13. /****************************************
  14. *
  15. * Definitions & Macros
  16. *
  17. ****************************************/
  18. #define CTRLMD_FSM_FLG_DEFAULT \
  19. { \
  20. FALSE, TRUE \
  21. } // Default value of CTRLMD_FSM_FLG
  22. /***************************************
  23. *
  24. * Type Definations
  25. *
  26. ***************************************/
  27. /**
  28. * @brief Type of control mode FSM
  29. *
  30. */
  31. typedef enum
  32. {
  33. Assistance = 0,
  34. Boost = 1,
  35. Cruise = 2,
  36. Exit = 3,
  37. Charge1 = 4,
  38. } RUN_FSM_STATUS;
  39. /**
  40. * @brief Type of control mode function hook
  41. *
  42. */
  43. typedef struct
  44. {
  45. RUN_FSM_STATUS state;
  46. void (*Event_hook)(void);
  47. void (*Tbcup_hook)(void);
  48. void (*Tbcdown_hook)(void);
  49. void (*Tbs_hook)(void);
  50. } FSM_RUN_HOOK;
  51. /**
  52. * @brief Type of control mode flag
  53. *
  54. */
  55. typedef struct
  56. {
  57. BOOL blCmdRunFlg;
  58. BOOL blMotorStopFlg;
  59. } CTRLMD_FSM_FLG1;
  60. /****************************************
  61. *
  62. * Exported variable
  63. *
  64. ****************************************/
  65. extern FSM_RUN_HOOK FSM2nd_Run_state;
  66. extern FSM_RUN_HOOK Exit_state;
  67. extern CTRLMD_FSM_FLG1 cmfsm_stFlg;
  68. /***************************************
  69. *
  70. * Function Definations
  71. *
  72. ***************************************/
  73. /**
  74. *
  75. * @brief Process of control mode FSM during Assistance state
  76. *
  77. */
  78. void Assistance_hook(void);
  79. /**
  80. * @brief Process of tbc_up during Assistance state
  81. *
  82. */
  83. void Assistance_tbcuphook(void);
  84. /**
  85. * @brief @brief Process of tbc_down during Assistance state
  86. *
  87. */
  88. void Assistance_tbcdownhook(void);
  89. /**
  90. * @brief @brief Process of tbs during Assistance state
  91. *
  92. */
  93. void Assistance_tbshook(void);
  94. /**
  95. *
  96. * @brief Process of control mode FSM during Boost state
  97. *
  98. */
  99. void Boost_hook(void);
  100. /**
  101. *
  102. * @brief Process of tbc_up during Boost state
  103. *
  104. */
  105. void Boost_tbcuphook(void);
  106. /**
  107. *
  108. * @brief Process of tbc_down during Boost state
  109. *
  110. */
  111. void Boost_tbcdownhook(void);
  112. /**
  113. *
  114. * @brief Process of tbs during Boost state
  115. *
  116. */
  117. void Boost_tbshook(void);
  118. /**
  119. *
  120. * @brief Process of control mode FSM during Exit state
  121. *
  122. */
  123. void Exit_hook(void);
  124. /**
  125. *
  126. * @brief Process of tbc_up during Exit state
  127. *
  128. */
  129. void Exit_tbcuphook(void);
  130. /**
  131. *
  132. * @brief Process of tbc_down during Exit state
  133. *
  134. */
  135. void Exit_tbcdownhook(void);
  136. /**
  137. *
  138. * @brief Process of tbs during Exit state
  139. *
  140. */
  141. void Exit_tbshook(void);
  142. /**
  143. * @brief Switch current state to *in state
  144. *
  145. * @param in pointer to target state
  146. */
  147. void Switch_Second_FSM(const FSM_RUN_HOOK *in);
  148. /**
  149. *
  150. * @brief Control mode FSM running function
  151. *
  152. */
  153. void FSM_2nd_Main(void);
  154. /**
  155. *
  156. *
  157. * @brief Control mode FSM initialization
  158. *
  159. */
  160. void RUN_FSM_voInit(void);
  161. #endif