power.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * @file Power.h
  3. * @author Wang, Zhiyu(wangzy49@midea.com)
  4. * @brief Power Managemant of ebike
  5. * @version 0.1
  6. * @date 2021-09-29
  7. *
  8. * @copyright Copyright (c) 2021
  9. *
  10. */
  11. /************************************************************************
  12. Beginning of File, do not put anything above here except notes
  13. Compiler Directives:
  14. *************************************************************************/
  15. #ifndef POWER_H
  16. #define POWER_H
  17. /****************************************
  18. *
  19. * Definitions & Macros
  20. *
  21. ****************************************/
  22. #define POWER_START_TOUCHING_TIME 1000 // ms
  23. #define POWER_START_FULLYON_TIME 1000 // ms
  24. #define POWER_SHUT_TOUCHING_TIME 20 // ms
  25. #define POWER_SHUT_FULLYOFF_TIME 10 // ms
  26. #define POWER_ON2OFF_TIME 3000 // ms
  27. #define POWER_START_TIMERUNIT 1 // ms
  28. #define POWER_SHUT_TIMERUNIT 1 // ms
  29. #define POWER_OUT_DEFAULT \
  30. { \
  31. 0, 0, 0, FALSE, FALSE, POWER_START \
  32. } // Default value of BIKELIGHT_OUT
  33. #define POWER_COF_DEFAULT \
  34. { \
  35. 0, 0, 0, 0, 0 \
  36. }
  37. #define POWER_LOCK_PORT 1 // PC1
  38. #define POWER_SWSTATE_PORT 0 // PC0
  39. /***************************************
  40. *
  41. * Type Definations
  42. *
  43. ***************************************/
  44. /**
  45. * @brief Cadence FSM
  46. *
  47. */
  48. typedef enum
  49. {
  50. POWER_START = 0,
  51. POWER_ON = 1,
  52. POWER_ON_END = 2,
  53. POWER_OFF = 3,
  54. POWER_OFF_END = 4
  55. } POWER_STATE;
  56. /**
  57. * @brief Cadence FSM
  58. *
  59. */
  60. typedef struct
  61. {
  62. UWORD uwPowerStartupCnt; // Cnt of Startup
  63. UWORD uwPowerShutdnCnt; // Cnt of Shutdown
  64. UWORD uwPowerOn2OffCnt; // On 2 off Cnt
  65. BOOL blPowerStartupFlg; // Flg of Startup
  66. BOOL blPowerShutdownFlg; // Flg of Shutdown
  67. POWER_STATE powerstate;
  68. } POWER_OUT;
  69. /**
  70. * @brief Cadence FSM
  71. *
  72. */
  73. typedef struct
  74. {
  75. UWORD uwPowerStartTouchTimeCnt; // Cnt of Startup button touching
  76. UWORD uwPowerShutTouchTimeCnt; // Cnt of Shutdown button touching
  77. UWORD uwPowerStartEndCnt; // Cnt of transfering to fully Power On
  78. UWORD uwPowerShutEndCnt; // Cnt of transfering to fully Power Off
  79. UWORD uwPowerOn2OffTimeCnt; // Cnt On 2 off Cnt
  80. } POWER_COF;
  81. /****************************************
  82. *
  83. * Exported variable
  84. *
  85. ****************************************/
  86. extern POWER_OUT power_stPowStateOut;
  87. extern ULONG AutoPowerOffTimeCnt;
  88. extern ULONG PowerOffDTimeOut;
  89. /***************************************
  90. *
  91. * Function Definations
  92. *
  93. ***************************************/
  94. void power_voPowerInit(void);
  95. void power_voPowerManagement(ULONG ulAutoPowerOffDelayTime, ULONG SysTickCnt, ULONG OBC_ButtonSetTimeCnt, UWORD uwTorqueIn, UWORD CadenceIn, UWORD BikeSpeed, BOOL EESaveFinishFlg, BOOL ParaSaveEEFlg);
  96. /************************************************************************/
  97. #endif
  98. /************************************************************************
  99. End of this File (EOF):
  100. Do not put anything after this part!
  101. *************************************************************************/