/** * @file bikethrottle.h * @author Wang, Zhiyu(wangzy49@midea.com) * @brief Throttle 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 BIKETHROTTLE_H #define BIKETHROTTLE_H /**************************************** * * Definitions & Macros * ****************************************/ #define BIKETHROTTLE_VOLTAGE_MAX_RANGE 5000 // MAX voltage of throttle sensor, mV #define BIKETHROTTLE_VOLTAGE_MIN_RANGE 0 // MIN voltage of throttle sensor, mV #define BIKETHROTTLE_VOLTAGE_SEN2MCUGAIN 100 * 3 / 5 // gain of sensor output to Mcu ADC 0.01 #define BIKETHROTTLE_LPF_FRQ 10 // Hz bandwidth of LPF #define BIKETHROTTLE_LPF_DISCRETEHZ 200 // Hz T=1/f,T is used in discreting LPF s function #define BIKETHROTTLE_ERROR_TIME 2000 // ms #define BIKETHROTTLE_RECOVER_TIME 2000 // ms #define BIKETHROTTLE_ERROE_TIMEUNIT 5 // ms #define BIKETHROTTLE_OUT_DEFAULT \ { \ 0, 0, 0, 0, 0, FALSE, FALSE \ } // Default value of CADENCE_OUT #define BIKETHROTTLE_COF_DEFAULT \ { \ 0, 0, 0, 0, 0, 0, 0 \ } // Default value of CADENCE_OUT /*************************************** * * Type Definations * ***************************************/ /** * @brief Throttle out * */ typedef struct { // Output of " Throttle " UWORD uwThrottleVolReg; // register data of Throttle voltage UWORD uwThrottleVolPu; // Q14 Throttle voltage Pu UWORD uwThrottleVolLPFPu; // Q14 Throttle voltage Pu UWORD uwThrottlePercent; // Throttle voltage in output range % UWORD uwThrottleErrorCnt; UWORD uwThrottleRecoverCnt; BOOL blThrottleErrorFlg; // Flg of Throttle sensor flg } BIKETHROTTLE_OUT; /** * @brief Throttle coef * */ typedef struct { UWORD uwMaxThrottleVolOutputPu; // mV,the max voltage of Throttle sensor output UWORD uwMinThrottleVolOutputPu; // mV,the min voltage of Throttle sensor output UWORD uwThrottleVolLPFFrq; // Hz,LPF bandwidth UWORD uwThrottleVolLPFDisFrq; // Hz,used in discreting LPF s function UWORD uwThrottleVolSen2McuGain; // gain of sensor output to Mcu ADC UWORD uwThrottleVolReg2Pu; // Gain of register to Pu UWORD uwThrottleOffsetPu; // offset of register UWORD uwThrottleErrorCnt; UWORD uwThrottleRecoverCnt; } BIKETHROTTLE_COF; /**************************************** * * Exported variable * ****************************************/ extern UWORD Bikethrottle_uwDMAReg; extern BIKETHROTTLE_OUT bikethrottle_stBikeThrottleOut; /*************************************** * * Function Definations * ***************************************/ void bikethrottle_voBikeThrottleInit(void); void bikethrottle_voBikeThrottleCof(void); void bikethrottle_voBikeThrottleADC(void); /************************************************************************/ #endif /************************************************************************ End of this File (EOF): Do not put anything after this part! *************************************************************************/