|
@@ -1,138 +1,133 @@
|
|
|
/**
|
|
|
* @file Bikelight.c
|
|
|
- * @author Wang, Zhiyu(wangzy49@midea.com)
|
|
|
+ * @author
|
|
|
* @brief light of ebike
|
|
|
* @version 0.1
|
|
|
- * @date 2021-10-09
|
|
|
+ * @date 2023-06-20
|
|
|
*
|
|
|
* @copyright Copyright (c) 2021
|
|
|
*
|
|
|
*/
|
|
|
|
|
|
+#define BIKELIGHT_
|
|
|
/************************************************************************
|
|
|
Beginning of File, do not put anything above here except notes
|
|
|
Compiler Directives:
|
|
|
*************************************************************************/
|
|
|
#include "syspar.h"
|
|
|
#include "typedefine.h"
|
|
|
+#include "mathtool.h"
|
|
|
#include "bikelight.h"
|
|
|
#include "hwsetup.h"
|
|
|
-/******************************
|
|
|
- *
|
|
|
- * Parameter
|
|
|
- *
|
|
|
- ******************************/
|
|
|
-BIKELIGHT_OUT bikelight_stBikeLightOut = BIKELIGHT_OUT_DEFAULT;
|
|
|
-static BIKELIGHT_COEF bikelight_stBikeLightCoef = BIKELIGHT_COEF_DEFAULT;
|
|
|
+#include "power.h"
|
|
|
+#include "CodePara.h"
|
|
|
+#include "adc.h"
|
|
|
+//----------------------------
|
|
|
|
|
|
-/***************************************************************
|
|
|
- Function: bikelight_voSetBikeLightOn;
|
|
|
- Description: set bike light on
|
|
|
- Call by: functions in main loop;
|
|
|
- Input Variables: N/A
|
|
|
- Output/Return Variables: N/A
|
|
|
- Subroutine Call: N/A;
|
|
|
- Reference: N/A
|
|
|
-****************************************************************/
|
|
|
-static void bikelight_voSetBikeLightOn(void)
|
|
|
-{
|
|
|
- if (bikelight_stBikeLightOut.LightState == LIGHT_Off)
|
|
|
- {
|
|
|
- IO_BIKELIGHT_FRONT_ON;
|
|
|
- IO_BIKELIGHT_REAR_ON;
|
|
|
- bikelight_stBikeLightOut.LightState = LIGHT_On;
|
|
|
- }
|
|
|
-}
|
|
|
+static BIKELED_STR BikeLedPara;
|
|
|
+static BIKELEDCHECK_STR BikeLedCheckF;//前灯参数
|
|
|
+static BIKELEDCHECK_STR BikeLedCheckB;//尾灯参数
|
|
|
|
|
|
-/***************************************************************
|
|
|
- Function: bikelight_voSetBikeLightOff;
|
|
|
- Description: set bike off
|
|
|
- Call by: functions in main loop;
|
|
|
- Input Variables: N/A
|
|
|
- Output/Return Variables: N/A
|
|
|
- Subroutine Call: N/A;
|
|
|
- Reference: N/A
|
|
|
-****************************************************************/
|
|
|
-static void bikelight_voSetBikeLightOff(void)
|
|
|
-{
|
|
|
- if (bikelight_stBikeLightOut.LightState == LIGHT_On)
|
|
|
- {
|
|
|
- IO_BIKELIGHT_FRONT_OFF;
|
|
|
- IO_BIKELIGHT_REAR_OFF;
|
|
|
- bikelight_stBikeLightOut.LightState = LIGHT_Off;
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
/***************************************************************
|
|
|
- Function: bikelight_voBikeLightInit;
|
|
|
- Description: bike light control initialization
|
|
|
- Call by: functions in main loop;
|
|
|
- Input Variables: N/A
|
|
|
+ Function: bikelight_voGetBikeLightError;
|
|
|
+ Description: 前后灯电压检测
|
|
|
+ Call by: 1ms
|
|
|
+ Input Variables:LightPowerVolPu-LED灯的电压值,Ledsta-灯的开关状态,p-内部参数
|
|
|
Output/Return Variables: N/A
|
|
|
Subroutine Call: N/A;
|
|
|
Reference: N/A
|
|
|
****************************************************************/
|
|
|
-void bikelight_voGetBikeLightError(UWORD LightPowerVolPu)
|
|
|
+void bikelight_voGetBikeLightError(UWORD LightPowerVolPu,BOOL Ledsta,BIKELEDCHECK_STR *p)
|
|
|
{
|
|
|
- if (bikelight_stBikeLightOut.LightState == LIGHT_On && (LightPowerVolPu < bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuDown ||
|
|
|
- LightPowerVolPu > bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuUp))
|
|
|
+ //前灯电路检测,开灯故障
|
|
|
+ if(Ledsta==TRUE)
|
|
|
{
|
|
|
- bikelight_stBikeLightOut.uwBikeLightErrorCnt++;
|
|
|
- if (bikelight_stBikeLightOut.uwBikeLightErrorCnt == bikelight_stBikeLightCoef.uwBikeLightErrorCnt)
|
|
|
+ if( (LightPowerVolPu <p->LedOnVoltMin ) || (LightPowerVolPu > p->LedOnVoltMax))
|
|
|
+ {
|
|
|
+ p->blBike_LedOnErrCnt++;
|
|
|
+ if(p->blBike_LedOnErrCnt>LEDRISETIME)
|
|
|
{
|
|
|
- IO_BIKELIGHT_FRONT_OFF;
|
|
|
- IO_BIKELIGHT_REAR_OFF;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightErrorCnt = 0;
|
|
|
- bikelight_stBikeLightOut.LightState = LIGHT_Error;
|
|
|
- bikelight_stBikeLightOut.blBikeLightErrorFlg = TRUE;
|
|
|
+ if(p->blBike_LedOnErrAddNO< LEDERRTIME)
|
|
|
+ {
|
|
|
+ p->blBike_LedOnErrAddNO++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p->blBike_LedOnErr= TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ p->blBike_LedOnErrCnt=0;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- bikelight_stBikeLightOut.uwBikeLightErrorCnt = 0;
|
|
|
+ p->blBike_LedOnErrDCnt++;
|
|
|
+ if(p->blBike_LedOnErrDCnt >LEDRISETIME)
|
|
|
+ {
|
|
|
+ if(p->blBike_LedOnErrAddNO> 0)
|
|
|
+ {
|
|
|
+ p->blBike_LedOnErrAddNO--;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p->blBike_LedOnErr= FALSE;
|
|
|
+ }
|
|
|
+ p->blBike_LedOnErrDCnt=0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (bikelight_stBikeLightOut.LightState == LIGHT_Error)
|
|
|
+ p->blBike_LedOffErrCnt=0;
|
|
|
+ p->blBike_LedOffErrDCnt=0;
|
|
|
+ }
|
|
|
+ //----------关灯故障-----------
|
|
|
+ else
|
|
|
{
|
|
|
- IO_BIKELIGHT_FRONT_ON;
|
|
|
- IO_BIKELIGHT_REAR_ON;
|
|
|
- if (LightPowerVolPu > bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuDown &&
|
|
|
- LightPowerVolPu < bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuUp)
|
|
|
- {
|
|
|
- bikelight_stBikeLightOut.uwBikeLightRecoverCnt++;
|
|
|
- if (bikelight_stBikeLightOut.uwBikeLightRecoverCnt == bikelight_stBikeLightCoef.uwBikeLightRecoverCnt)
|
|
|
- {
|
|
|
- IO_BIKELIGHT_FRONT_OFF;
|
|
|
- IO_BIKELIGHT_REAR_OFF;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightRecoverCnt = 0;
|
|
|
- bikelight_stBikeLightOut.LightState = LIGHT_Off;
|
|
|
- bikelight_stBikeLightOut.blBikeLightErrorFlg = FALSE;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ if( LightPowerVolPu > p->LedOffVoltMax)
|
|
|
+ {
|
|
|
+ p->blBike_LedOffErrCnt++;
|
|
|
+ if(p->blBike_LedOffErrCnt>LEDFALLTIME)
|
|
|
{
|
|
|
- IO_BIKELIGHT_FRONT_OFF;
|
|
|
- IO_BIKELIGHT_REAR_OFF;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightShutCnt++;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightRecoverCnt = 0;
|
|
|
- if (bikelight_stBikeLightOut.uwBikeLightShutCnt == bikelight_stBikeLightCoef.uwBikeLightShutCnt)
|
|
|
- {
|
|
|
- bikelight_stBikeLightOut.LightState = LIGHT_Shut;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightShutCnt = 0;
|
|
|
- }
|
|
|
+ if(p->blBike_LedOffErrAddNO< LEDERRTIME)
|
|
|
+ {
|
|
|
+ p->blBike_LedOffErrAddNO++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p->blBike_LedOffErr= TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ p->blBike_LedOffErrCnt=0;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- bikelight_stBikeLightOut.uwBikeLightRecoverCnt = 0;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightShutCnt = 0;
|
|
|
+ p->blBike_LedOffErrDCnt++;
|
|
|
+ if(p->blBike_LedOffErrDCnt >LEDFALLTIME)
|
|
|
+ {
|
|
|
+ if(p->blBike_LedOffErrAddNO> 0)
|
|
|
+ {
|
|
|
+ p->blBike_LedOffErrAddNO--;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p->blBike_LedOffErr= FALSE;
|
|
|
+ }
|
|
|
+ p->blBike_LedOffErrDCnt=0;
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ p->blBike_LedOnErrCnt=0;
|
|
|
+ p->blBike_LedOnErrDCnt=0;
|
|
|
+}
|
|
|
/***************************************************************
|
|
|
Function: bikelight_voBikeLightInit;
|
|
|
Description: bike light control initialization
|
|
|
- Call by: functions in main loop;
|
|
|
+ Call by: FSM_voInit
|
|
|
Input Variables: N/A
|
|
|
Output/Return Variables: N/A
|
|
|
Subroutine Call: N/A;
|
|
@@ -140,18 +135,32 @@ void bikelight_voGetBikeLightError(UWORD LightPowerVolPu)
|
|
|
****************************************************************/
|
|
|
void bikelight_voBikeLightInit(void)
|
|
|
{
|
|
|
- bikelight_stBikeLightOut.uwBikeLightErrorCnt = 0;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightRecoverCnt = 0;
|
|
|
- bikelight_stBikeLightOut.uwBikeLightShutCnt = 0;
|
|
|
- bikelight_stBikeLightOut.LightState = LIGHT_Off;
|
|
|
- bikelight_stBikeLightOut.blBikeLightErrorFlg = FALSE;
|
|
|
|
|
|
+ BikeLedCheckF.blBike_LedOffErr=FALSE;
|
|
|
+ BikeLedCheckF.blBike_LedOffErrAddNO=0;
|
|
|
+ BikeLedCheckF.blBike_LedOffErrCnt=0;
|
|
|
+ BikeLedCheckF.blBike_LedOffErrDCnt=0;
|
|
|
+ BikeLedCheckF.blBike_LedOnErr=FALSE;
|
|
|
+ BikeLedCheckF.blBike_LedOnErrAddNO=0;
|
|
|
+ BikeLedCheckF.blBike_LedOnErrCnt=0;
|
|
|
+ BikeLedCheckF.blBike_LedOnErrDCnt=0;
|
|
|
+ BikeLedCheckF.LedOffVoltMax= ((ULONG)LIGHT_OFFERR_VOLTAGE << 15) / VBASE; //
|
|
|
+
|
|
|
+ BikeLedCheckB.blBike_LedOffErr=FALSE;
|
|
|
+ BikeLedCheckB.blBike_LedOffErrAddNO=0;
|
|
|
+ BikeLedCheckB.blBike_LedOffErrCnt=0;
|
|
|
+ BikeLedCheckB.blBike_LedOffErrDCnt=0;
|
|
|
+ BikeLedCheckB.blBike_LedOnErr=FALSE;
|
|
|
+ BikeLedCheckB.blBike_LedOnErrAddNO=0;
|
|
|
+ BikeLedCheckB.blBike_LedOnErrCnt=0;
|
|
|
+ BikeLedCheckB.blBike_LedOnErrDCnt=0;
|
|
|
+ BikeLedCheckB.LedOffVoltMax= ((ULONG)LIGHT_OFFERR_VOLTAGE << 15) / VBASE;
|
|
|
}
|
|
|
|
|
|
/***************************************************************
|
|
|
- Function: bikelight_voBikeLightInit;
|
|
|
- Description: bike light control initialization
|
|
|
- Call by: functions in main loop;
|
|
|
+ Function: bikelight_voBikeLightCoef;
|
|
|
+ Description: 滤波时间/阈值电压设定参数更新
|
|
|
+ Call by: 初始化,接收数据更新
|
|
|
Input Variables: N/A
|
|
|
Output/Return Variables: N/A
|
|
|
Subroutine Call: N/A;
|
|
@@ -160,45 +169,264 @@ void bikelight_voBikeLightInit(void)
|
|
|
void bikelight_voBikeLightCoef(UWORD volt)
|
|
|
{
|
|
|
|
|
|
- bikelight_stBikeLightCoef.uwBikeLightErrorCnt = LIGHT_POWER_ERROR_DETECT / LIGHT_POWER_ERROR_TIMEUNIT;
|
|
|
- bikelight_stBikeLightCoef.uwBikeLightRecoverCnt = LIGHT_POWER_ERROR_RECOVER / LIGHT_POWER_ERROR_TIMEUNIT;
|
|
|
- bikelight_stBikeLightCoef.uwBikeLightShutCnt = LIGHT_POWER_ERROR_SHUT / LIGHT_POWER_ERROR_TIMEUNIT;
|
|
|
+
|
|
|
if( volt == 12)
|
|
|
{
|
|
|
- bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuDown = ((ULONG)LIGHT_POWER_ERROR_VOLTAGE_DOWN << 15) / VBASE;
|
|
|
- bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuUp = ((ULONG)LIGHT_POWER_ERROR_VOLTAGE_UP << 15) / VBASE;
|
|
|
+ BikeLedCheckF.LedOnVoltMin = ((ULONG)LIGHT_ERR_VOLTAGE_MIN << 15) / VBASE;
|
|
|
+ BikeLedCheckF.LedOnVoltMax = ((ULONG)LIGHT_ERR_VOLTAGE_MAX << 15) / VBASE;
|
|
|
+
|
|
|
+ BikeLedCheckB.LedOnVoltMin = ((ULONG)LIGHT_ERR_VOLTAGE_MIN << 15) / VBASE;
|
|
|
+ BikeLedCheckB.LedOnVoltMax = ((ULONG)LIGHT_ERR_VOLTAGE_MAX << 15) / VBASE;
|
|
|
+
|
|
|
+ IO_FORWARDLED_12V_ENABLE();//12V使能
|
|
|
+ IO_BACKLED_12V_ENABLE();
|
|
|
|
|
|
- IO_BIKELIGHT_FRONT_12V_ENABLE;
|
|
|
- IO_BIKELIGHT_REAR_12V_ENABLE;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuDown = ((ULONG)LIGHT_POWER_ERROR_VOLTAGE_DOWN << 14) / VBASE;
|
|
|
- bikelight_stBikeLightCoef.uwBikeLightErrorVoltagePuUp = ((ULONG)LIGHT_POWER_ERROR_VOLTAGE_UP << 14) / VBASE;
|
|
|
+ BikeLedCheckF.LedOnVoltMin = ((ULONG)LIGHT_ERR_VOLTAGE_MIN << 14) / VBASE;
|
|
|
+ BikeLedCheckF.LedOnVoltMax = ((ULONG)LIGHT_ERR_VOLTAGE_MAX << 14) / VBASE;
|
|
|
|
|
|
- IO_BIKELIGHT_FRONT_12V_DISABLE;
|
|
|
- IO_BIKELIGHT_REAR_12V_DISABLE;
|
|
|
+ BikeLedCheckB.LedOnVoltMin = ((ULONG)LIGHT_ERR_VOLTAGE_MIN << 14) / VBASE;
|
|
|
+ BikeLedCheckB.LedOnVoltMax = ((ULONG)LIGHT_ERR_VOLTAGE_MAX << 14) / VBASE;
|
|
|
+
|
|
|
+ IO_FORWARDLED_12V_DISABLE();//6V输出使能
|
|
|
+ IO_BACKLED_12V_DISABLE();
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
/***************************************************************
|
|
|
Function: bikelight_voBikeLightInit;
|
|
|
Description: bike light control initialization
|
|
|
- Call by: functions in main loop;
|
|
|
- Input Variables: N/A
|
|
|
+ Call by: 10ms
|
|
|
+ Input Variables: switchAction-开灯情况,Brate_Sta-刹车状态,BackLedMode-尾灯模式
|
|
|
Output/Return Variables: N/A
|
|
|
Subroutine Call: N/A;
|
|
|
Reference: N/A
|
|
|
****************************************************************/
|
|
|
-void bikelight_voBikeLightControl(UWORD switchAction)
|
|
|
+void bikelight_voBikeLightControl(UWORD switchAction, BOOL Brate_Sta,UBYTE BackLedMode) /* parasoft-suppress METRICS-28 "本项目圈复杂度无法更改,后续避免" */
|
|
|
{
|
|
|
+
|
|
|
+ //if( power_stPowStateOut.powerstate != POWER_ON) //关机状态
|
|
|
+ if( power_stPowStateOut.blPowerStartupFlg ==FALSE)
|
|
|
+ {
|
|
|
+ IO_FORWARDLED_OFF();
|
|
|
+ IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ BikeLedGloFun.blBike_ForwardLedSta=FALSE;
|
|
|
+ BikeLedPara.ubBike_keyLedSta=0;
|
|
|
+ BikeLedPara.uwLedAddcnt=0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // ---------------尾灯6个状态处理------------
|
|
|
+ switch( BackLedMode)
|
|
|
+ {
|
|
|
+ case one_byte: //模式1
|
|
|
+ {
|
|
|
+ if(Brate_Sta==TRUE) //刹车
|
|
|
+ {
|
|
|
+ // IO_BACKLED_ON();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(switchAction==1)
|
|
|
+ {
|
|
|
+ BikeLedPara.uwLedAddcnt++;
|
|
|
+ if(BikeLedPara.uwLedAddcnt > BikeLedAddCycle)
|
|
|
+ {
|
|
|
+ BikeLedPara.uwLedAddcnt=0;
|
|
|
+ }
|
|
|
+ if(BikeLedPara.uwLedAddcnt<BikeLedAddDuty)
|
|
|
+ {
|
|
|
+ // IO_BACKLED_ON();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ BikeLedPara.uwLedAddcnt=0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case two_byte:
|
|
|
+ {
|
|
|
+
|
|
|
+ if(Brate_Sta==TRUE) //刹车
|
|
|
+ {
|
|
|
+ // IO_BACKLED_ON();
|
|
|
+ BikeLedPara.uwLedAddcnt++;
|
|
|
+ if(BikeLedPara.uwLedAddcnt > BikeLedFlickerCycle)
|
|
|
+ {
|
|
|
+ BikeLedPara.uwLedAddcnt=0;
|
|
|
+ }
|
|
|
+ if(BikeLedPara.uwLedAddcnt<BikeLedFlickerDuty)
|
|
|
+ {
|
|
|
+ // IO_BACKLED_ON();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(switchAction==1)
|
|
|
+ {
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ }
|
|
|
+ BikeLedPara.uwLedAddcnt=0;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case Three_byte:
|
|
|
+ {
|
|
|
+ if(switchAction==1)
|
|
|
+ {
|
|
|
+ //IO_BACKLED_ON();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case four_byte:
|
|
|
+ {
|
|
|
+ if(Brate_Sta==TRUE) //刹车
|
|
|
+ {
|
|
|
+ // IO_BACKLED_ON();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case five_byte:
|
|
|
+ {
|
|
|
+ // IO_BACKLED_ON();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case six_byte:
|
|
|
+ {
|
|
|
+ if(cp_stBikeRunInfoPara.BikeSpeedKmH>=BikeLedOverSpeedMax)
|
|
|
+ {
|
|
|
+ BikeLedPara.uwLedAddcnt++;
|
|
|
+ if(BikeLedPara.uwLedAddcnt > BikeLedOverSpedCycle)
|
|
|
+ {
|
|
|
+ BikeLedPara.uwLedAddcnt=0;
|
|
|
+ }
|
|
|
+ if(BikeLedPara.uwLedAddcnt<BikeLedOverSpedDuty)
|
|
|
+ {
|
|
|
+ // IO_BACKLED_ON();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(cp_stBikeRunInfoPara.BikeSpeedKmH<=BikeLedOverSpeedMin)
|
|
|
+ {
|
|
|
+ //IO_BACKLED_OFF();
|
|
|
+ BikeLedGloFun.blBike_BackLedSta=FALSE;
|
|
|
+ BikeLedPara.uwLedAddcnt=0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //do noting
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if( BikeLedGloFun.blBike_BackLedSta==TRUE) //尾灯控制
|
|
|
+ {
|
|
|
+ IO_BACKLED_ON();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IO_BACKLED_OFF();
|
|
|
+ }
|
|
|
+
|
|
|
+ // ---------------前灯处理------------
|
|
|
if (switchAction == 1)
|
|
|
{
|
|
|
- bikelight_voSetBikeLightOn();
|
|
|
+ if(BikeLedPara.ubBike_keyLedSta==0)
|
|
|
+ {
|
|
|
+ IO_FORWARDLED_ON(); //开前灯
|
|
|
+ BikeLedPara.ubBike_keyLedSta=1;
|
|
|
+ BikeLedGloFun.blBike_ForwardLedSta=TRUE;
|
|
|
+ }
|
|
|
}
|
|
|
if (switchAction == 0)
|
|
|
{
|
|
|
- bikelight_voSetBikeLightOff();
|
|
|
+ if(BikeLedPara.ubBike_keyLedSta!=0)
|
|
|
+ {
|
|
|
+ IO_FORWARDLED_OFF();//关前灯
|
|
|
+ BikeLedPara.ubBike_keyLedSta=0;
|
|
|
+ BikeLedGloFun.blBike_ForwardLedSta=FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //--------------LED电路检测----------
|
|
|
+ bikelight_voGetBikeLightError(adc_stUpOut.uwU6VPu,BikeLedGloFun.blBike_ForwardLedSta,&BikeLedCheckF); //前灯检测
|
|
|
+ bikelight_voGetBikeLightError(adc_stUpOut.uwU6VPu,BikeLedGloFun.blBike_BackLedSta,&BikeLedCheckB); //尾灯检测
|
|
|
+
|
|
|
+ if((BikeLedCheckF.blBike_LedOffErr == TRUE) ||(BikeLedCheckF.blBike_LedOnErr==TRUE) )
|
|
|
+ {
|
|
|
+ BikeLedGloFun.blBike_ForwardLedDetErr=TRUE;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(BikeLedGloFun.blBike_ForwardLedDetErr!=FALSE)
|
|
|
+ {
|
|
|
+ BikeLedGloFun.blBike_ForwardLedDetErr=FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if((BikeLedCheckB.blBike_LedOffErr == TRUE) ||(BikeLedCheckB.blBike_LedOnErr==TRUE) )
|
|
|
+ {
|
|
|
+ BikeLedGloFun.blBike_BackLedDetErr=TRUE;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if(BikeLedGloFun.blBike_BackLedDetErr!=FALSE)
|
|
|
+ {
|
|
|
+ BikeLedGloFun.blBike_BackLedDetErr=FALSE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/*************************************************************************
|