/** * @file Power.h * @author Wang, Zhiyu(wangzy49@midea.com) * @brief Power Managemant of ebike * @version 0.1 * @date 2021-09-29 * * @copyright Copyright (c) 2021 * */ /************************************************************************ Beginning of File, do not put anything above here except notes Compiler Directives: *************************************************************************/ #ifndef POWER_H #define POWER_H #include "typedefine.h" typedef _Bool BOOL; /**************************************** * * Definitions & Macros * ****************************************/ #define POWERMINVOLT (250<<14)/480 //25V min volt #define POWER_START_TOUCHING_TIME 600 // ms #define POWER_START_FULLYON_TIME 1000 // ms #define POWER_SHUT_TOUCHING_TIME 20 // ms #define POWER_SHUT_FULLYOFF_TIME 1000 // ms #define POWER_ON2OFF_TIME 500 // ms #define POWER_START_TIMERUNIT 1 // ms #define POWER_SHUT_TIMERUNIT 1 // ms #define POWER_SHUT_STOPDELAY_TIME (2000/POWER_SHUT_TIMERUNIT) // ms #define POWER_OUT_DEFAULT \ { \ 0, 0, 0, FALSE, FALSE, POWER_START \ } // Default value of BIKELIGHT_OUT #define POWER_COF_DEFAULT \ { \ 0, 0, 0, 0, 0 \ } #define POWER_LOCK_PORT GPIOB // PC1 #define POWER_LOCK_PIN GPIO_Pin_4 // PC1 #define POWER_SWSTATE_PORT GPIOC // PC0 #define POWER_SWSTATE_PIN GPIO_Pin_12 // PC1 #define High_KEYVOL 2730 //2.2V #define LOW_KEYVOL 1241// 1V #define NULL_KEYMAXVOL 2730 //2.2V #define NULL_KEYMINVOL 2110 // 1.7V /*************************************** * * Type Definations * ***************************************/ /** * @brief Cadence FSM * */ typedef enum { POWER_START = 0, POWER_ON = 1, POWER_ON_END = 2, POWER_OFF = 3, POWER_OFF_END = 4 } POWER_STATE; /** * @brief Cadence FSM * */ typedef struct { UWORD uwPowerStartupCnt; // Cnt of Startup UWORD uwPowerShutdnCnt; // Cnt of Shutdown UWORD uwPowerOn2OffCnt; // On 2 off Cnt UWORD uwPOwerForceShutdnCnt; // Cnt of Shutdown UWORD uwPowerKeySta; // key sta UWORD uwPowerKeyMode; //key high or low BOOL blPowerStartupFlg; // Flg of Startup BOOL blPowerShutdownFlg; // Flg of Shutdown POWER_STATE powerstate; } POWER_OUT; /** * @brief Cadence FSM * */ typedef struct { UWORD uwPowerStartTouchTimeCnt; // Cnt of Startup button touching UWORD uwPowerShutTouchTimeCnt; // Cnt of Shutdown button touching UWORD uwPowerStartEndCnt; // Cnt of transfering to fully Power On UWORD uwPowerShutEndCnt; // Cnt of transfering to fully Power Off UWORD uwPowerOn2OffTimeCnt; // Cnt On 2 off Cnt SWORD uwPowerModeTime; } POWER_COF; /**************************************** * * Exported variable * ****************************************/ extern POWER_OUT power_stPowStateOut; /*************************************** * * Function Definations * ***************************************/ void power_voPowerInit(void); void power_voPowerManagement(BOOL ParaSaveEEFlg, BOOL PowerSleepFlg); /************************************************************************/ #endif /************************************************************************ End of this File (EOF): Do not put anything after this part! *************************************************************************/