/** * @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 /**************************************** * * Definitions & Macros * ****************************************/ #define POWER_START_TOUCHING_TIME 1000 // ms #define POWER_START_FULLYON_TIME 1000 // ms #define POWER_SHUT_TOUCHING_TIME 20 // ms #define POWER_SHUT_FULLYOFF_TIME 10 // ms #define POWER_ON2OFF_TIME 3000 // ms #define POWER_START_TIMERUNIT 1 // ms #define POWER_SHUT_TIMERUNIT 1 // 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 1 // PC1 #define POWER_SWSTATE_PORT 0 // PC0 /*************************************** * * 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_RESET = 5 } POWER_STATE; /** * @brief Cadence FSM * */ typedef struct { UWORD uwPowerStartupCnt; // Cnt of Startup UWORD uwPowerShutdnCnt; // Cnt of Shutdown UWORD uwPowerOn2OffCnt; // On 2 off Cnt 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 } POWER_COF; /**************************************** * * Exported variable * ****************************************/ extern POWER_OUT power_stPowStateOut; extern ULONG AutoPowerOffTimeCnt; extern ULONG PowerOffDTimeOut; /*************************************** * * Function Definations * ***************************************/ void power_voPowerInit(void); void power_voPowerManagement(UWORD uwPowerPara, ULONG SysTickCnt, ULONG OBC_ButtonSetTimeCnt, UWORD uwTorqueIn, UWORD CadenceIn, UWORD BikeSpeed, BOOL EESaveFinishFlg, BOOL ParaSaveEEFlg); /************************************************************************/ #endif /************************************************************************ End of this File (EOF): Do not put anything after this part! *************************************************************************/