|
@@ -30,11 +30,12 @@
|
|
|
|
|
|
|
|
|
BIKELEDCHECK_STR BikeLedCheck_F;//前灯参数
|
|
|
-BIKELEDCHECK_STR BikeLedCheck_B;//尾灯参数
|
|
|
-BIKELEDCHECK_STR BikeLedCheck_L;//左灯参数
|
|
|
-BIKELEDCHECK_STR BikeLedCheck_R;//右灯参数
|
|
|
+//BIKELEDCHECK_STR BikeLedCheck_B;//尾灯参数
|
|
|
+//BIKELEDCHECK_STR BikeLedCheck_L;//左灯参数
|
|
|
+//BIKELEDCHECK_STR BikeLedCheck_R;//右灯参数
|
|
|
|
|
|
-BIKELEDCHECK_STR BikeLedCheck_DC;//DC12V端口参数
|
|
|
+BIKELEDCHECK_STR BikeLedCheck_DC_1; //DC12V端口参数
|
|
|
+BIKELEDCHECK_STR BikeLedCheck_DC_2; //DC12V端口参数
|
|
|
|
|
|
//LED_PWM_STR BikePwmChoice;
|
|
|
void LED_EnableDeal(BIKELEDCHECK_STR *p,UWORD switchAction,LED_PWM_STR mode );
|
|
@@ -384,32 +385,35 @@ void bikelight_voBikeLightInit(BIKELEDCHECK_STR *LedPoit)
|
|
|
****************************************************************/
|
|
|
void bikelight_voBikeLightCoef(UWORD volt)
|
|
|
{
|
|
|
-
|
|
|
-//前灯
|
|
|
- BikeLedCheck_F.uwBike_LedVolt =volt & 0x0f;
|
|
|
- BikeLedCheck_F.uwBike_LedMode=8; //前灯模式
|
|
|
-//尾灯
|
|
|
- BikeLedCheck_B.uwBike_LedMode = (volt & 0xf000)>>12;//尾灯模式
|
|
|
- BikeLedCheck_B.uwBike_LedVolt =(volt & 0x0f00)>>8;
|
|
|
-
|
|
|
-
|
|
|
-//左灯模式
|
|
|
- BikeLedCheck_L.uwBike_LedMode=5;
|
|
|
-//右灯模式
|
|
|
- BikeLedCheck_R.uwBike_LedMode=5;
|
|
|
-
|
|
|
- if( BikeLedCheck_F.uwBike_LedVolt == 12) //拉低短路
|
|
|
+ //DC1灯参数
|
|
|
+ BikeLedCheck_DC_1.uwBike_LedVolt =volt & 0x0f;//电压
|
|
|
+ BikeLedCheck_DC_1.uwBike_LedMode=8; //模式
|
|
|
+ //DC2灯参数
|
|
|
+ BikeLedCheck_DC_2.uwBike_LedVolt =(volt & 0x0f00)>>8; //电压
|
|
|
+ BikeLedCheck_DC_2.uwBike_LedMode = (volt & 0xf000)>>12;//模式
|
|
|
+ //BAT灯模式
|
|
|
+ BikeLedCheck_F.uwBike_LedMode=5;
|
|
|
+
|
|
|
+ //DC1灯电压设置
|
|
|
+ if( BikeLedCheck_DC_1.uwBike_LedVolt == 12) //拉低短路
|
|
|
+ {
|
|
|
+ IO_LED1_6or12V_Choise_H(); //12V使能
|
|
|
+ }
|
|
|
+ else //高阻
|
|
|
{
|
|
|
|
|
|
- IO_LED_6or12V_Choise_H(); //12V使能
|
|
|
- }
|
|
|
- else //高阻
|
|
|
- {
|
|
|
-
|
|
|
- IO_LED_6or12V_Choise_L();//6V输出使能
|
|
|
+ IO_LED1_6or12V_Choise_L();//6V输出使能
|
|
|
+ }
|
|
|
+ //DC2灯电压设置
|
|
|
+ if( BikeLedCheck_DC_1.uwBike_LedVolt == 12) //拉低短路
|
|
|
+ {
|
|
|
+ IO_LED2_6or12V_Choise_H(); //12V使能
|
|
|
}
|
|
|
+ else //高阻
|
|
|
+ {
|
|
|
|
|
|
- BikeLedCheck_DC.uwBike_LedMode=5;
|
|
|
+ IO_LED2_6or12V_Choise_L();//6V输出使能
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
/***************************************************************
|
|
@@ -423,381 +427,134 @@ void bikelight_voBikeLightCoef(UWORD volt)
|
|
|
****************************************************************/
|
|
|
void bikelight_voBikeLightControl(UWORD switchAction, BOOL Brate_Sta )
|
|
|
{
|
|
|
-
|
|
|
-if( power_stPowStateOut.blPowerStartupFlg ==FALSE)
|
|
|
-{
|
|
|
- BikeLedCheck_F.blBike_LedSta=FALSE;
|
|
|
- BikeLedCheck_B.blBike_LedSta=FALSE;
|
|
|
- BikeLedCheck_L.blBike_LedSta=FALSE;
|
|
|
- BikeLedCheck_R.blBike_LedSta=FALSE;
|
|
|
- DL_TimerG_setCaptureCompareValue(PWM_F_INST, 0, GPIO_PWM_F_C1_IDX);//max=2304
|
|
|
- // DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, 0, GPIO_PWM_B_L_C1_IDX);//max=2304
|
|
|
-// DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, 0, GPIO_PWM_B_L_C0_IDX);//max=2304
|
|
|
- // DL_TimerG_setCaptureCompareValue(PWM_R_INST, 0, GPIO_PWM_R_C1_IDX);//max=2304
|
|
|
-
|
|
|
-}
|
|
|
-else
|
|
|
-{
|
|
|
- ledfunctions[BikeLedCheck_DC.uwBike_LedMode](&BikeLedCheck_DC);
|
|
|
- if( BikeLedCheck_B.blBike_LedSta==TRUE) //尾灯控制
|
|
|
+ if( power_stPowStateOut.blPowerStartupFlg ==FALSE)
|
|
|
{
|
|
|
- IO_LED_6or12V_EN_H();
|
|
|
+ BikeLedCheck_F.blBike_LedSta=FALSE;
|
|
|
+ DL_TimerG_setCaptureCompareValue(PWM_F_INST, 0, GPIO_PWM_F_C1_IDX);//max=2304
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- IO_LED_6or12V_EN_L();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-//-----------尾灯处理--------
|
|
|
-#if(BIKELEDOPEN_R_ENABLE!=0)
|
|
|
-
|
|
|
- ledfunctions[BikeLedCheck_B.uwBike_LedMode](&BikeLedCheck_B);
|
|
|
- if( BikeLedCheck_B.blBike_LedSta==TRUE) //尾灯控制
|
|
|
- {
|
|
|
- if(BikeLedCheck_B.uwBike_keyLedHighSta==0)
|
|
|
- {
|
|
|
- BikeLedCheck_B.uwBike_keyLedHighSta=1;
|
|
|
- BikeLedCheck_B.uwBike_OpenLedEn=0;//开灯瞬间处理标志
|
|
|
- BikeLedCheck_B.uwBike_LedOffErrCnt=0; //10秒一检测计时
|
|
|
- BikeLedCheck_B.uwBike_OpenPreTime=0; //开灯瞬间5ms内处理计数
|
|
|
- BikeLedCheck_B.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
|
|
|
- BikeLedCheck_B.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
|
|
|
- BikeLedCheck_B.blBike_LedCurErr=FALSE;
|
|
|
- // DL_TimerG_startCounter(PWM_B_L_INST);
|
|
|
- // DL_Timer_overrideCCPOut(PWM_B_L_INST, DL_TIMER_FORCE_OUT_DISABLED, DL_TIMER_FORCE_CMPL_OUT_DISABLED, GPIO_PWM_B_L_C1_IDX);
|
|
|
- GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_15_EDGE_FALL |DL_GPIO_PIN_15_EDGE_RISE);
|
|
|
- GPIOB->POLARITY15_0 |=DL_GPIO_PIN_15_EDGE_RISE;
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if((BikeLedCheck_B.uwBike_OpenLedEn==0) &&(BikeLedCheck_B.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
|
|
|
- {
|
|
|
- LED_EnableDeal(&BikeLedCheck_B,1,B_PWM_byte);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_15_EDGE_FALL |DL_GPIO_PIN_15_EDGE_RISE);
|
|
|
- GPIOB->POLARITY15_0 |=DL_GPIO_PIN_15_EDGE_FALL;
|
|
|
- }
|
|
|
-
|
|
|
- BikeLedCheck_B.uwBike_keyLedLowSta=1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BikeLedCheck_B.uwBike_keyLedHighSta=0;
|
|
|
- if(BikeLedCheck_B.uwBike_keyLedLowSta!=0)
|
|
|
- {
|
|
|
- BikeLedCheck_B.uwBike_keyLedLowSta=0;
|
|
|
- BikeLedCheck_B.uwBikeLight_PWM=0;
|
|
|
- // DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, BikeLedCheck_B.uwBikeLight_PWM, GPIO_PWM_B_L_C1_IDX);//max=2304
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-#endif
|
|
|
-
|
|
|
-
|
|
|
-// ---------------前灯处理------------
|
|
|
-//#if(BIKELEDOPEN_F_ENABLE!=0)
|
|
|
-// ledfunctions[BikeLedCheck_F.uwBike_LedMode](&BikeLedCheck_F);
|
|
|
-//
|
|
|
-// if (BikeLedCheck_F.blBike_LedSta == TRUE)
|
|
|
-// {
|
|
|
-// 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; //前灯允许开灯启动,总开关
|
|
|
-// DL_COMP_setDACCode0(COMP_FLEDCHECK_INST, 0x0f);
|
|
|
-// BikeLedCheck_F.blBike_LedCurErr=FALSE;
|
|
|
-// DL_TimerG_startCounter(PWM_F_INST);
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// if((BikeLedCheck_F.uwBike_OpenLedEn==0) &&(BikeLedCheck_F.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
|
|
|
-// {
|
|
|
-// LED_EnableDeal(&BikeLedCheck_F,1,F_PWM_byte);
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-//#if(DCDC_12S6V_SEL_EN!=1)
|
|
|
-// DL_COMP_setDACCode0(COMP_FLEDCHECK_INST, 0x4f);
|
|
|
-//#endif
|
|
|
-// }
|
|
|
-//
|
|
|
-// BikeLedCheck_F.uwBike_keyLedLowSta=1;
|
|
|
-// }
|
|
|
-// else
|
|
|
-// {
|
|
|
-// BikeLedCheck_F.uwBike_keyLedHighSta=0;
|
|
|
-// if(BikeLedCheck_F.uwBike_keyLedLowSta!=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
|
|
|
-//
|
|
|
-//
|
|
|
-// }
|
|
|
-// }
|
|
|
-//#endif
|
|
|
-
|
|
|
-//------------右灯处理------
|
|
|
- ledfunctions[BikeLedCheck_R.uwBike_LedMode](&BikeLedCheck_R);
|
|
|
-
|
|
|
- if(BikeLedCheck_R.blBike_LedSta==TRUE) //
|
|
|
- {
|
|
|
- if(BikeLedCheck_R.uwBike_keyLedHighSta==0)
|
|
|
- {
|
|
|
- BikeLedCheck_R.uwBike_keyLedHighSta=1;
|
|
|
- BikeLedCheck_R.uwBike_OpenLedEn=0;//开灯瞬间处理标志
|
|
|
- BikeLedCheck_R.uwBike_LedOffErrCnt=0; //10秒一检测计时
|
|
|
- BikeLedCheck_R.uwBike_OpenPreTime=0; //开灯瞬间5ms内处理计数
|
|
|
- BikeLedCheck_R.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
|
|
|
- BikeLedCheck_R.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
|
|
|
- BikeLedCheck_R.blBike_LedCurErr=FALSE;
|
|
|
- // DL_TimerG_startCounter(PWM_R_INST);
|
|
|
- GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_8_EDGE_RISE |DL_GPIO_PIN_8_EDGE_FALL);
|
|
|
- GPIOB->POLARITY15_0 |=DL_GPIO_PIN_8_EDGE_RISE;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- if((BikeLedCheck_R.uwBike_OpenLedEn==0) &&(BikeLedCheck_R.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
|
|
|
- {
|
|
|
- LED_EnableDeal(&BikeLedCheck_R,1,R_PWM_byte);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- GPIOB->POLARITY15_0 &= ~(DL_GPIO_PIN_8_EDGE_RISE |DL_GPIO_PIN_8_EDGE_FALL);
|
|
|
- GPIOB->POLARITY15_0 |=DL_GPIO_PIN_8_EDGE_FALL;
|
|
|
- }
|
|
|
-
|
|
|
- BikeLedCheck_R.uwBike_keyLedLowSta=1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BikeLedCheck_R.uwBike_keyLedHighSta=0;
|
|
|
- if(BikeLedCheck_R.uwBike_keyLedLowSta!=0)
|
|
|
- {
|
|
|
- BikeLedCheck_R.uwBike_keyLedLowSta=0;
|
|
|
- BikeLedCheck_R.uwBikeLight_PWM=0;
|
|
|
- // DL_TimerG_setCaptureCompareValue(PWM_R_INST, BikeLedCheck_R.uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
|
|
|
- }
|
|
|
- }
|
|
|
-//------------左灯处理------
|
|
|
- ledfunctions[BikeLedCheck_L.uwBike_LedMode](&BikeLedCheck_L);
|
|
|
- if(BikeLedCheck_L.blBike_LedSta==TRUE) //
|
|
|
- {
|
|
|
- if(BikeLedCheck_L.uwBike_keyLedHighSta==0)
|
|
|
- {
|
|
|
- BikeLedCheck_L.uwBike_keyLedHighSta=1;
|
|
|
- BikeLedCheck_L.uwBike_OpenLedEn=0;//开灯瞬间处理标志
|
|
|
- BikeLedCheck_L.uwBike_LedOffErrCnt=0; //10秒一检测计时
|
|
|
- BikeLedCheck_L.uwBike_OpenPreTime=0; //开灯瞬间5ms内处理计数
|
|
|
- BikeLedCheck_L.uwBike_LedCheckLowTime=0;//检测过流IO出现低电平次数
|
|
|
- BikeLedCheck_L.blBike_ForwardLedStart=TRUE; //前灯允许开灯启动,总开关
|
|
|
- BikeLedCheck_L.blBike_LedCurErr=FALSE;
|
|
|
- //DL_TimerG_startCounter(PWM_B_L_INST);
|
|
|
-// DL_Timer_overrideCCPOut(PWM_B_L_INST, DL_TIMER_FORCE_OUT_DISABLED, DL_TIMER_FORCE_CMPL_OUT_DISABLED, GPIO_PWM_B_L_C0_IDX);
|
|
|
- GPIOA->POLARITY15_0 &= ~(DL_GPIO_PIN_3_EDGE_RISE |DL_GPIO_PIN_3_EDGE_FALL);
|
|
|
- GPIOA->POLARITY15_0 |=DL_GPIO_PIN_3_EDGE_RISE;
|
|
|
- }
|
|
|
-
|
|
|
- if((BikeLedCheck_L.uwBike_OpenLedEn==0) &&(BikeLedCheck_L.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
|
|
|
- {
|
|
|
- LED_EnableDeal(&BikeLedCheck_L,1,L_PWM_byte);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- GPIOA->POLARITY15_0 &= ~(DL_GPIO_PIN_3_EDGE_RISE |DL_GPIO_PIN_3_EDGE_FALL);
|
|
|
- GPIOA->POLARITY15_0 |=DL_GPIO_PIN_3_EDGE_FALL;
|
|
|
- }
|
|
|
-
|
|
|
- BikeLedCheck_L.uwBike_keyLedLowSta=1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BikeLedCheck_L.uwBike_keyLedHighSta=0;
|
|
|
- if(BikeLedCheck_L.uwBike_keyLedLowSta!=0)
|
|
|
- {
|
|
|
- BikeLedCheck_L.uwBike_keyLedLowSta=0;
|
|
|
- BikeLedCheck_L.uwBikeLight_PWM=0;
|
|
|
- // DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, BikeLedCheck_L.uwBikeLight_PWM, GPIO_PWM_B_L_C0_IDX);//max=2304
|
|
|
- }
|
|
|
- }
|
|
|
-//---------------------
|
|
|
-
|
|
|
-#if(BIKE_OXFORD_EN!=0)
|
|
|
- IO_FORWARDLED_ON(); //开前灯
|
|
|
- IO_BACKLED_ON();
|
|
|
-
|
|
|
-#endif
|
|
|
-
|
|
|
- //--------------LED电路检测----------
|
|
|
-//-------F_LED
|
|
|
- if((BikeLedCheck_F.blBike_LedCurErr==TRUE )&&(BikeLedCheck_F.blBike_LedSta == TRUE)) //过流标志,前灯恢复检测
|
|
|
- {
|
|
|
- BikeLedCheck_F.uwBike_LedOffErrCnt++;
|
|
|
- if(BikeLedCheck_F.uwBike_LedOffErrCnt>2000) //1000ms
|
|
|
+ //DC1灯控制
|
|
|
+ ledfunctions[BikeLedCheck_DC_1.uwBike_LedMode](&BikeLedCheck_DC_1);
|
|
|
+ if( BikeLedCheck_DC_1.blBike_LedSta==TRUE)
|
|
|
{
|
|
|
- BikeLedCheck_F.uwBike_keyLedHighSta=0;
|
|
|
- BikeLedCheck_F.uwBike_LedOffErrCnt=0;
|
|
|
- BikeLedCheck_F.blBike_LedCurErr=FALSE;
|
|
|
- BikeLedCheck_F.blBike_ForwardLedStart=TRUE;//前灯允许开灯启动,总开关
|
|
|
-
|
|
|
+ IO_LED1_6or12V_EN_H();
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BikeLedCheck_F.uwBike_LedOffErrCnt=0;
|
|
|
- }
|
|
|
-
|
|
|
-//------B_LED
|
|
|
- if((BikeLedCheck_B.blBike_LedCurErr==TRUE)&&(BikeLedCheck_B.blBike_LedSta == TRUE)) //后灯恢复检测
|
|
|
- {
|
|
|
-
|
|
|
- BikeLedCheck_B.uwBike_LedOffErrCnt++;
|
|
|
- if(BikeLedCheck_B.uwBike_LedOffErrCnt>2000)
|
|
|
- {
|
|
|
- BikeLedCheck_B.uwBike_keyLedHighSta=0;
|
|
|
- BikeLedCheck_B.uwBike_LedOffErrCnt=0;
|
|
|
- BikeLedCheck_B.blBike_LedCurErr=FALSE;
|
|
|
- BikeLedCheck_B.blBike_ForwardLedStart=TRUE;//前灯允许开灯启动,总开关
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BikeLedCheck_B.uwBike_LedOffErrCnt=0;
|
|
|
- }
|
|
|
-
|
|
|
-//------R_LED
|
|
|
-
|
|
|
- if((BikeLedCheck_R.blBike_LedCurErr==TRUE )&&(BikeLedCheck_R.blBike_LedSta == TRUE)) //过流标志,前灯恢复检测
|
|
|
- {
|
|
|
- BikeLedCheck_R.uwBike_LedOffErrCnt++;
|
|
|
- if(BikeLedCheck_R.uwBike_LedOffErrCnt>2000) //1000ms
|
|
|
+ else
|
|
|
{
|
|
|
- BikeLedCheck_R.uwBike_keyLedHighSta=0;
|
|
|
- BikeLedCheck_R.uwBike_LedOffErrCnt=0;
|
|
|
- BikeLedCheck_R.blBike_LedCurErr=FALSE;
|
|
|
- BikeLedCheck_R.blBike_ForwardLedStart=TRUE;//前灯允许开灯启动,总开关
|
|
|
-
|
|
|
+ IO_LED1_6or12V_EN_L();
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BikeLedCheck_R.uwBike_LedOffErrCnt=0;
|
|
|
- }
|
|
|
-
|
|
|
-//------L_LED
|
|
|
- if((BikeLedCheck_L.blBike_LedCurErr==TRUE )&&(BikeLedCheck_L.blBike_LedSta == TRUE)) //过流标志,前灯恢复检测
|
|
|
- {
|
|
|
- BikeLedCheck_L.uwBike_LedOffErrCnt++;
|
|
|
- if(BikeLedCheck_L.uwBike_LedOffErrCnt>2000) //1000ms
|
|
|
+ //DC2灯控制
|
|
|
+ ledfunctions[BikeLedCheck_DC_2.uwBike_LedMode](&BikeLedCheck_DC_2);
|
|
|
+ if( BikeLedCheck_DC_2.blBike_LedSta==TRUE)
|
|
|
{
|
|
|
- BikeLedCheck_L.uwBike_keyLedHighSta=0;
|
|
|
- BikeLedCheck_L.uwBike_LedOffErrCnt=0;
|
|
|
- BikeLedCheck_L.blBike_LedCurErr=FALSE;
|
|
|
- BikeLedCheck_L.blBike_ForwardLedStart=TRUE;//前灯允许开灯启动,总开关
|
|
|
+ IO_LED2_6or12V_EN_H();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ IO_LED2_6or12V_EN_L();
|
|
|
+ }
|
|
|
+ //BAT灯控制
|
|
|
+ #if(BIKELEDOPEN_F_ENABLE!=0)
|
|
|
+ ledfunctions[BikeLedCheck_F.uwBike_LedMode](&BikeLedCheck_F);
|
|
|
+ if (BikeLedCheck_F.blBike_LedSta == TRUE)
|
|
|
+ {
|
|
|
+ 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;
|
|
|
+ DL_TimerG_startCounter(PWM_F_INST);
|
|
|
+ }
|
|
|
+ if((BikeLedCheck_F.uwBike_OpenLedEn==0) &&(BikeLedCheck_F.blBike_ForwardLedStart==TRUE)) //开灯检测,过流后每隔10秒检测1次
|
|
|
+ {
|
|
|
+ LED_EnableDeal(&BikeLedCheck_F,1,F_PWM_byte);
|
|
|
+ }
|
|
|
+ BikeLedCheck_F.uwBike_keyLedLowSta=1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BikeLedCheck_F.uwBike_keyLedHighSta=0;
|
|
|
+ if(BikeLedCheck_F.uwBike_keyLedLowSta!=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
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endif
|
|
|
|
|
|
+ //BAT灯检测
|
|
|
+ if((BikeLedCheck_F.blBike_LedCurErr==TRUE )&&(BikeLedCheck_F.blBike_LedSta == TRUE)) //过流标志,前灯恢复检测
|
|
|
+ {
|
|
|
+ BikeLedCheck_F.uwBike_LedOffErrCnt++;
|
|
|
+ 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;//前灯允许开灯启动,总开关
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BikeLedCheck_F.uwBike_LedOffErrCnt=0;
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BikeLedCheck_L.uwBike_LedOffErrCnt=0;
|
|
|
}
|
|
|
- //------
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
void LED_EnableDeal(BIKELEDCHECK_STR *p,UWORD switchAction,LED_PWM_STR mode )
|
|
|
{
|
|
|
-
|
|
|
-if(switchAction!=0)
|
|
|
-{
|
|
|
-
|
|
|
-
|
|
|
- if(p->uwBike_OpenPreTime<2000)
|
|
|
- p->uwBike_OpenPreTime++;
|
|
|
- if(p->uwBike_OpenPreTime<=2)//2ms
|
|
|
+ if(switchAction!=0)
|
|
|
{
|
|
|
- if(mode==F_PWM_byte)
|
|
|
- {
|
|
|
- p->uwBikeLight_PWM=LIGHT_FIRSTPWM;//
|
|
|
- }
|
|
|
- else
|
|
|
+ if(p->uwBike_OpenPreTime<2000)
|
|
|
+ p->uwBike_OpenPreTime++;
|
|
|
+ if(p->uwBike_OpenPreTime<=2)//2ms
|
|
|
{
|
|
|
- p->uwBikeLight_PWM=LIGHTBLR_FIRSTPWM;//
|
|
|
+ if(mode==F_PWM_byte)
|
|
|
+ {
|
|
|
+ p->uwBikeLight_PWM=LIGHT_FIRSTPWM;//
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p->uwBikeLight_PWM=LIGHTBLR_FIRSTPWM;//
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- else if(p->uwBike_OpenPreTime<=3) //4
|
|
|
- {
|
|
|
- // p->uwBikeLight_PWM =691 ;//720;//
|
|
|
- if((p->uwBike_OpenLedEn ==0)&&(p->blBike_LedCurErr==TRUE))
|
|
|
+ else if(p->uwBike_OpenPreTime<=3) //4
|
|
|
{
|
|
|
- p->uwBikeLight_PWM =LIGHT_SECTPWM ;//720;//
|
|
|
+ if((p->uwBike_OpenLedEn ==0)&&(p->blBike_LedCurErr==TRUE))
|
|
|
+ {
|
|
|
+ p->uwBikeLight_PWM =LIGHT_SECTPWM ;//720;//
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ p->uwBikeLight_PWM=0;
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+ if((p->uwBike_OpenPreTime>2) && (p->uwBikeLight_PWM!=0))// ||(p->uwBike_LedCheckLowTime>=2)
|
|
|
{
|
|
|
- p->uwBikeLight_PWM=0;
|
|
|
+ p->blBike_LedCurErr=FALSE;
|
|
|
+ p->uwBike_OpenLedEn=1;
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
-// else if(p->uwBike_OpenPreTime>=1000)
|
|
|
-// {
|
|
|
-// p->uwBikeLight_PWM=0;//
|
|
|
-// p->uwBike_OpenLedEn=1;
|
|
|
-// }
|
|
|
- if((p->uwBike_OpenPreTime>2) && (p->uwBikeLight_PWM!=0))// ||(p->uwBike_LedCheckLowTime>=2)
|
|
|
- {
|
|
|
- p->blBike_LedCurErr=FALSE;
|
|
|
- p->uwBike_OpenLedEn=1;
|
|
|
- }
|
|
|
-
|
|
|
- if(p->uwBike_OpenLedEn!=0) //
|
|
|
+ if(p->uwBike_OpenLedEn!=0) //
|
|
|
{
|
|
|
p->uwBikeLight_PWM=LIGHT_MAXPWM;//
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
-else
|
|
|
-{
|
|
|
- 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
|
|
|
- }
|
|
|
-// else if(mode==B_PWM_byte)
|
|
|
-// {
|
|
|
-// DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, p->uwBikeLight_PWM, GPIO_PWM_B_L_C1_IDX);//max=2304
|
|
|
-// }
|
|
|
-// else if(mode==L_PWM_byte)
|
|
|
-// {
|
|
|
-// DL_TimerG_setCaptureCompareValue(PWM_B_L_INST, p->uwBikeLight_PWM, GPIO_PWM_B_L_C0_IDX);//max=2304
|
|
|
-// }
|
|
|
-// else if(mode==R_PWM_byte)
|
|
|
-// {
|
|
|
-// DL_TimerG_setCaptureCompareValue(PWM_R_INST, p->uwBikeLight_PWM, GPIO_PWM_R_C1_IDX);//max=2304
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ 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
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/*************************************************************************
|
|
|
Local Functions (N/A)
|
|
|
*************************************************************************/
|