|
@@ -405,7 +405,7 @@ void bikelight_voBikeLightCoef(UWORD volt)
|
|
IO_LED1_6or12V_Choise_L();//6V输出使能
|
|
IO_LED1_6or12V_Choise_L();//6V输出使能
|
|
}
|
|
}
|
|
//DC2灯电压设置
|
|
//DC2灯电压设置
|
|
- if( BikeLedCheck_DC_1.uwBike_LedVolt == 12) //拉低短路
|
|
|
|
|
|
+ if( BikeLedCheck_DC_2.uwBike_LedVolt == 12) //拉低短路
|
|
{
|
|
{
|
|
IO_LED2_6or12V_Choise_H(); //12V使能
|
|
IO_LED2_6or12V_Choise_H(); //12V使能
|
|
}
|
|
}
|
|
@@ -427,10 +427,10 @@ void bikelight_voBikeLightCoef(UWORD volt)
|
|
****************************************************************/
|
|
****************************************************************/
|
|
void bikelight_voBikeLightControl(UWORD switchAction, BOOL Brate_Sta )
|
|
void bikelight_voBikeLightControl(UWORD switchAction, BOOL Brate_Sta )
|
|
{
|
|
{
|
|
- if( power_stPowStateOut.blPowerStartupFlg ==FALSE)
|
|
|
|
|
|
+ if( power_stPowStateOut.blPowerStartupFlg == FALSE)
|
|
{
|
|
{
|
|
BikeLedCheck_F.blBike_LedSta=FALSE;
|
|
BikeLedCheck_F.blBike_LedSta=FALSE;
|
|
- DL_TimerG_setCaptureCompareValue(PWM_F_INST, 0, GPIO_PWM_F_C1_IDX);//max=2304
|
|
|
|
|
|
+ DL_TimerG_setCaptureCompareValue(PWM_F_INST, 0, GPIO_PWM_F_C1_IDX);//max=2304
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -455,49 +455,63 @@ void bikelight_voBikeLightControl(UWORD switchAction, BOOL Brate_Sta )
|
|
IO_LED2_6or12V_EN_L();
|
|
IO_LED2_6or12V_EN_L();
|
|
}
|
|
}
|
|
//BAT灯控制
|
|
//BAT灯控制
|
|
- #if(BIKELEDOPEN_F_ENABLE!=0)
|
|
|
|
|
|
+#if 1
|
|
|
|
+ ledfunctions[BikeLedCheck_F.uwBike_LedMode](&BikeLedCheck_F);
|
|
|
|
+ if (BikeLedCheck_F.blBike_LedSta == TRUE)
|
|
|
|
+ {
|
|
|
|
+ DL_TimerG_startCounter(PWM_F_INST);
|
|
|
|
+ BikeLedCheck_F.uwBikeLight_PWM = 1500;
|
|
|
|
+ DL_TimerG_setCaptureCompareValue(PWM_F_INST, BikeLedCheck_F.uwBikeLight_PWM, GPIO_PWM_F_C1_IDX);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ BikeLedCheck_F.uwBikeLight_PWM = 0;
|
|
|
|
+ DL_TimerG_setCaptureCompareValue(PWM_F_INST, BikeLedCheck_F.uwBikeLight_PWM, GPIO_PWM_F_C1_IDX);
|
|
|
|
+ DL_TimerG_stopCounter(PWM_F_INST);
|
|
|
|
+ }
|
|
|
|
+#elif(BIKELEDOPEN_F_ENABLE != 0)
|
|
ledfunctions[BikeLedCheck_F.uwBike_LedMode](&BikeLedCheck_F);
|
|
ledfunctions[BikeLedCheck_F.uwBike_LedMode](&BikeLedCheck_F);
|
|
if (BikeLedCheck_F.blBike_LedSta == TRUE)
|
|
if (BikeLedCheck_F.blBike_LedSta == TRUE)
|
|
{
|
|
{
|
|
- if(BikeLedCheck_F.uwBike_keyLedHighSta==0)
|
|
|
|
|
|
+ if(BikeLedCheck_F.uwBike_keyLedHighSta == 0)
|
|
{
|
|
{
|
|
- BikeLedCheck_F.uwBike_keyLedHighSta=1;
|
|
|
|
- BikeLedCheck_F.uwBike_OpenLedEn=0;//开灯瞬间处理标志
|
|
|
|
- BikeLedCheck_F.uwBike_LedOffErrCnt=0; //10秒一检测计时
|
|
|
|
- BikeLedCheck_F.uwBike_OpenPreTime=0; //开灯瞬间5ms内处理计数
|
|
|
|
- BikeLedCheck_F.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
|
|
|
|
- BikeLedCheck_F.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
|
|
|
|
- BikeLedCheck_F.blBike_LedCurErr=FALSE;
|
|
|
|
|
|
+ BikeLedCheck_F.uwBike_keyLedHighSta = 1;
|
|
|
|
+ BikeLedCheck_F.uwBike_OpenLedEn = 0; //开灯瞬间处理标志
|
|
|
|
+ BikeLedCheck_F.uwBike_LedOffErrCnt = 0; //10秒一检测计时
|
|
|
|
+ BikeLedCheck_F.uwBike_OpenPreTime = 0; //开灯瞬间5ms内处理计数
|
|
|
|
+ BikeLedCheck_F.uwBike_LedCheckLowTime = 0; //检测过流IO出现低电平次数
|
|
|
|
+ BikeLedCheck_F.blBike_ForwardLedStart = TRUE; //前灯允许开灯启动,总开关
|
|
|
|
+ BikeLedCheck_F.blBike_LedCurErr = FALSE;
|
|
DL_TimerG_startCounter(PWM_F_INST);
|
|
DL_TimerG_startCounter(PWM_F_INST);
|
|
}
|
|
}
|
|
- if((BikeLedCheck_F.uwBike_OpenLedEn==0) &&(BikeLedCheck_F.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
|
|
|
|
|
|
+ if((BikeLedCheck_F.uwBike_OpenLedEn == 0) &&(BikeLedCheck_F.blBike_ForwardLedStart == TRUE)) //开灯检测,过流后每隔10秒检测1次
|
|
{
|
|
{
|
|
- LED_EnableDeal(&BikeLedCheck_F,1,F_PWM_byte);
|
|
|
|
|
|
+ LED_EnableDeal(&BikeLedCheck_F, 1 ,F_PWM_byte);
|
|
}
|
|
}
|
|
- BikeLedCheck_F.uwBike_keyLedLowSta=1;
|
|
|
|
|
|
+ BikeLedCheck_F.uwBike_keyLedLowSta = 1;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- BikeLedCheck_F.uwBike_keyLedHighSta=0;
|
|
|
|
- if(BikeLedCheck_F.uwBike_keyLedLowSta!=0)
|
|
|
|
|
|
+ BikeLedCheck_F.uwBike_keyLedHighSta = 0;
|
|
|
|
+ if(BikeLedCheck_F.uwBike_keyLedLowSta != 0)
|
|
{
|
|
{
|
|
- BikeLedCheck_F.uwBike_keyLedLowSta=0;
|
|
|
|
- BikeLedCheck_F.uwBikeLight_PWM=0;
|
|
|
|
|
|
+ BikeLedCheck_F.uwBike_keyLedLowSta = 0;
|
|
|
|
+ BikeLedCheck_F.uwBikeLight_PWM = 0;
|
|
DL_TimerG_setCaptureCompareValue(PWM_F_INST, BikeLedCheck_F.uwBikeLight_PWM, GPIO_PWM_F_C1_IDX);//max=2304
|
|
DL_TimerG_setCaptureCompareValue(PWM_F_INST, BikeLedCheck_F.uwBikeLight_PWM, GPIO_PWM_F_C1_IDX);//max=2304
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- #endif
|
|
|
|
|
|
+#endif
|
|
|
|
|
|
//BAT灯检测
|
|
//BAT灯检测
|
|
- if((BikeLedCheck_F.blBike_LedCurErr==TRUE )&&(BikeLedCheck_F.blBike_LedSta == TRUE)) //过流标志,前灯恢复检测
|
|
|
|
|
|
+ if((BikeLedCheck_F.blBike_LedCurErr == TRUE ) && (BikeLedCheck_F.blBike_LedSta == TRUE)) //过流标志,前灯恢复检测
|
|
{
|
|
{
|
|
BikeLedCheck_F.uwBike_LedOffErrCnt++;
|
|
BikeLedCheck_F.uwBike_LedOffErrCnt++;
|
|
- if(BikeLedCheck_F.uwBike_LedOffErrCnt>2000) //1000ms
|
|
|
|
|
|
+ if(BikeLedCheck_F.uwBike_LedOffErrCnt > 2000) //1000ms
|
|
{
|
|
{
|
|
- BikeLedCheck_F.uwBike_keyLedHighSta=0;
|
|
|
|
- BikeLedCheck_F.uwBike_LedOffErrCnt=0;
|
|
|
|
- BikeLedCheck_F.blBike_LedCurErr=FALSE;
|
|
|
|
- BikeLedCheck_F.blBike_ForwardLedStart=TRUE;//前灯允许开灯启动,总开关
|
|
|
|
|
|
+ BikeLedCheck_F.uwBike_keyLedHighSta = 0;
|
|
|
|
+ BikeLedCheck_F.uwBike_LedOffErrCnt = 0;
|
|
|
|
+ BikeLedCheck_F.blBike_LedCurErr = FALSE;
|
|
|
|
+ BikeLedCheck_F.blBike_ForwardLedStart = TRUE;//前灯允许开灯启动,总开关
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -509,50 +523,50 @@ void bikelight_voBikeLightControl(UWORD switchAction, BOOL Brate_Sta )
|
|
|
|
|
|
void LED_EnableDeal(BIKELEDCHECK_STR *p,UWORD switchAction,LED_PWM_STR mode )
|
|
void LED_EnableDeal(BIKELEDCHECK_STR *p,UWORD switchAction,LED_PWM_STR mode )
|
|
{
|
|
{
|
|
- if(switchAction!=0)
|
|
|
|
|
|
+ if(switchAction != 0)
|
|
{
|
|
{
|
|
- if(p->uwBike_OpenPreTime<2000)
|
|
|
|
|
|
+ if(p->uwBike_OpenPreTime < 2000)
|
|
p->uwBike_OpenPreTime++;
|
|
p->uwBike_OpenPreTime++;
|
|
- if(p->uwBike_OpenPreTime<=2)//2ms
|
|
|
|
|
|
+ if(p->uwBike_OpenPreTime <= 2)
|
|
{
|
|
{
|
|
- if(mode==F_PWM_byte)
|
|
|
|
|
|
+ if(mode == F_PWM_byte)
|
|
{
|
|
{
|
|
- p->uwBikeLight_PWM=LIGHT_FIRSTPWM;//
|
|
|
|
|
|
+ p->uwBikeLight_PWM = LIGHT_FIRSTPWM;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- p->uwBikeLight_PWM=LIGHTBLR_FIRSTPWM;//
|
|
|
|
|
|
+ p->uwBikeLight_PWM = LIGHTBLR_FIRSTPWM;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if(p->uwBike_OpenPreTime<=3) //4
|
|
|
|
|
|
+ else if(p->uwBike_OpenPreTime <= 3)
|
|
{
|
|
{
|
|
- if((p->uwBike_OpenLedEn ==0)&&(p->blBike_LedCurErr==TRUE))
|
|
|
|
|
|
+ if((p->uwBike_OpenLedEn == 0)&&(p->blBike_LedCurErr == TRUE))
|
|
{
|
|
{
|
|
- p->uwBikeLight_PWM =LIGHT_SECTPWM ;//720;//
|
|
|
|
|
|
+ p->uwBikeLight_PWM = LIGHT_SECTPWM ;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- p->uwBikeLight_PWM=0;
|
|
|
|
|
|
+ p->uwBikeLight_PWM = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if((p->uwBike_OpenPreTime>2) && (p->uwBikeLight_PWM!=0))// ||(p->uwBike_LedCheckLowTime>=2)
|
|
|
|
|
|
+ if((p->uwBike_OpenPreTime > 2) && (p->uwBikeLight_PWM != 0))
|
|
{
|
|
{
|
|
- p->blBike_LedCurErr=FALSE;
|
|
|
|
- p->uwBike_OpenLedEn=1;
|
|
|
|
|
|
+ p->blBike_LedCurErr = FALSE;
|
|
|
|
+ p->uwBike_OpenLedEn = 1;
|
|
}
|
|
}
|
|
- if(p->uwBike_OpenLedEn!=0) //
|
|
|
|
|
|
+ if(p->uwBike_OpenLedEn != 0)
|
|
{
|
|
{
|
|
- p->uwBikeLight_PWM=LIGHT_MAXPWM;//
|
|
|
|
|
|
+ p->uwBikeLight_PWM = LIGHT_MAXPWM;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- p->uwBikeLight_PWM=0;//
|
|
|
|
|
|
+ p->uwBikeLight_PWM = 0;
|
|
|
|
+ }
|
|
|
|
+ if(mode == F_PWM_byte)
|
|
|
|
+ {
|
|
|
|
+ DL_TimerG_setCaptureCompareValue(PWM_F_INST, p->uwBikeLight_PWM, GPIO_PWM_F_C1_IDX);//max=2304
|
|
}
|
|
}
|
|
- if(mode==F_PWM_byte)
|
|
|
|
- {
|
|
|
|
- DL_TimerG_setCaptureCompareValue(PWM_F_INST, p->uwBikeLight_PWM, GPIO_PWM_F_C1_IDX);//max=2304
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/*************************************************************************
|
|
/*************************************************************************
|