12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /**
- * @file Bikebrake.c
- * @author Wang, Zhiyu(wangzy49@midea.com)
- * @brief throttle of ebike
- * @version 0.1
- * @date 2021-10-08
- *
- * @copyright Copyright (c) 2021
- *
- */
- /************************************************************************
- Beginning of File, do not put anything above here except notes
- Compiler Directives:
- *************************************************************************/
- #include "bikebrake.h"
- #include "api.h"
- #include "board_config.h"
- /******************************
- *
- * Parameter
- *
- ******************************/
- static BIKEBRAKE_OUT bikebrake_stBikeBrakeOut = BIKEBRAKE_OUT_DEFAULT;
- /***************************************************************
- Function: bikebrake_voBikeBrakeInit;
- Description: bike light control initialization
- Call by: functions in main loop;
- Input Variables: N/A
- Output/Return Variables: N/A
- Subroutine Call: N/A;
- Reference: N/A
- ****************************************************************/
- void bikebrake_voBikeBrakeInit(void)
- {
- bikebrake_stBikeBrakeOut.uwDetectTimeCnt = 0;
- bikebrake_stBikeBrakeOut.uwBikeBrakeCnt = 0;
- bikebrake_stBikeBrakeOut.blBikeBrakeOnFlg = FALSE;
- }
- /***************************************************************
- Function: bikelight_voBikeLightInit;
- Description: bike light control initialization
- Call by: functions in main loop;
- Input Variables: N/A
- Output/Return Variables: N/A
- Subroutine Call: N/A;
- Reference: N/A
- ****************************************************************/
- void bikebrake_voBikeBrakeDetect(void)
- {
- if (bikebrake_stBikeBrakeOut.blBikeBrakeOnFlg == FALSE && (iGpio_Read(HW_GPIO_BREAK_PIN) == 0))
- {
- bikebrake_stBikeBrakeOut.uwBikeBrakeCnt++;
- if (bikebrake_stBikeBrakeOut.uwBikeBrakeCnt > 10)
- {
- bikebrake_stBikeBrakeOut.blBikeBrakeOnFlg = TRUE;
- bikebrake_stBikeBrakeOut.uwBikeBrakeCnt = 0;
- bikebrake_stBikeBrakeOut.uwDetectTimeCnt = 0;
- }
- }
- if (bikebrake_stBikeBrakeOut.blBikeBrakeOnFlg == TRUE && (iGpio_Read(HW_GPIO_BREAK_PIN) != 0))
- {
- bikebrake_stBikeBrakeOut.uwBikeBrakeCnt++;
- if (bikebrake_stBikeBrakeOut.uwBikeBrakeCnt > 10)
- {
- bikebrake_stBikeBrakeOut.blBikeBrakeOnFlg = FALSE;
- bikebrake_stBikeBrakeOut.uwBikeBrakeCnt = 0;
- bikebrake_stBikeBrakeOut.uwDetectTimeCnt = 0;
- }
- }
- if(bikebrake_stBikeBrakeOut.uwBikeBrakeCnt !=0 )
- {
- bikebrake_stBikeBrakeOut.uwDetectTimeCnt ++;
- if(bikebrake_stBikeBrakeOut.uwDetectTimeCnt == 50)
- {
- bikebrake_stBikeBrakeOut.uwDetectTimeCnt = 0;
- bikebrake_stBikeBrakeOut.uwBikeBrakeCnt = 0;
- }
- }
- }
- BOOL BikeBrake_blGetstate(void)
- {
- return bikebrake_stBikeBrakeOut.blBikeBrakeOnFlg;
- }
- /*************************************************************************
- End of this File (EOF)!
- Do not put anything after this part!
- *************************************************************************/
|