123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- /**
- * @file bikegearsensor.c
- * @author Zhou xiong(zhouxiong9@midea.com)
- * @brief Gear Sensor of ebike
- * @version 0.1
- * @date 2023-02-03
- *
- * @copyright Copyright (c) 2021
- *
- */
- /************************************************************************
- Beginning of File, do not put anything above here except notes
- Compiler Directives:
- *************************************************************************/
- #include "api.h"
- #include "board_config.h"
- #include "bikegearsensor.h"
- /******************************
- *
- * Parameter
- *
- ******************************/
- BIKE_GEARSENSOR_OUT bikegearsensor_stBikeGearsensorOut = GEARSENSOR_OUT_DEFAULT;
- /***************************************************************
- Function: bikegearsensor_voBikeGearsensorInit;
- 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 bikegearsensor_voBikeGearsensorInit(void)
- {
- bikegearsensor_stBikeGearsensorOut.uwDetectTimeCnt = 0;
- bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt = 0;
- bikegearsensor_stBikeGearsensorOut.blGearSensorOnFlg = FALSE;
- }
- /***************************************************************
- Function: bikegearsensor_voBikeGearsensorDetect;
- 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 bikegearsensor_voBikeGearsensorDetect(void)
- {
- if (bikegearsensor_stBikeGearsensorOut.blGearSensorOnFlg == FALSE && (iGpio_Read(HW_GPIO_UARTTX_PIN) == 0))
- {
- bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt++;
- if (bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt > 10)
- {
- bikegearsensor_stBikeGearsensorOut.blGearSensorOnFlg = TRUE;
- bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt = 0;
- bikegearsensor_stBikeGearsensorOut.uwDetectTimeCnt = 0;
- }
- }
- if (bikegearsensor_stBikeGearsensorOut.blGearSensorOnFlg == TRUE && (iGpio_Read(HW_GPIO_UARTTX_PIN) != 0))
- {
- bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt++;
- if (bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt++ > 10)
- {
- bikegearsensor_stBikeGearsensorOut.blGearSensorOnFlg = FALSE;
- bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt = 0;
- bikegearsensor_stBikeGearsensorOut.uwDetectTimeCnt = 0;
- }
- }
- if(bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt !=0 )
- {
- bikegearsensor_stBikeGearsensorOut.uwDetectTimeCnt++;
- if(bikegearsensor_stBikeGearsensorOut.uwDetectTimeCnt == 50)
- {
- bikegearsensor_stBikeGearsensorOut.uwGearSensorCnt = 0;
- bikegearsensor_stBikeGearsensorOut.uwDetectTimeCnt = 0;
- }
- }
- #if (GEARSENSOR_ENABLE == 0)
- bikegearsensor_stBikeGearsensorOut.blGearSensorOnFlg = FALSE;
- #endif
- }
- /***************************************************************
- Function: bikegearsensor_blBikeGetState;
- Description: get bike gearsensor state
- Call by: functions in main loop;
- Input Variables: N/A
- Output/Return Variables: N/A
- Subroutine Call: N/A;
- Reference: N/A
- ****************************************************************/
- BOOL bikegearsensor_blBikeGetState(void)
- {
- return bikegearsensor_stBikeGearsensorOut.blGearSensorOnFlg;
- }
- /*************************************************************************
- End of this File (EOF)!
- Do not put anything after this part!
- *************************************************************************/
|