123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /**
- * @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!
- *************************************************************************/
|