|
@@ -27,6 +27,39 @@ void LightDriver_Init(void)
|
|
|
|
|
|
void LightDriver_Process(MC_TailLight_Mode_Struct_t TailLight_Mode, TrueOrFalse_Flag_Struct_t IsBreakFlag, MC_LightSwitch_Struct_t LightSwitchCode)
|
|
void LightDriver_Process(MC_TailLight_Mode_Struct_t TailLight_Mode, TrueOrFalse_Flag_Struct_t IsBreakFlag, MC_LightSwitch_Struct_t LightSwitchCode)
|
|
{
|
|
{
|
|
|
|
+ //存在故障,车速为0时,前后灯闪烁,频率可粗略估计故障码
|
|
|
|
+ if((MC_ErrorCode.Code != 0) && (MC_RunInfo.BikeSpeed == 0))
|
|
|
|
+ {
|
|
|
|
+ static uint32_t FlashTimeCnt = 0;
|
|
|
|
+ uint16_t OnTime = 0;
|
|
|
|
+ uint8_t ErrorBit = 0;
|
|
|
|
+
|
|
|
|
+ for(ErrorBit = 0; ErrorBit < 32; ErrorBit++)
|
|
|
|
+ {
|
|
|
|
+ if(((MC_ErrorCode.Code >> ErrorBit) & 0x00000001) != 0)
|
|
|
|
+ {
|
|
|
|
+ OnTime = (ErrorBit + 1) * 4500;//300ms间隔
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(FlashTimeCnt < OnTime)
|
|
|
|
+ {
|
|
|
|
+ HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_SET);
|
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
|
|
|
|
+ }
|
|
|
|
+ else if(FlashTimeCnt < 150000)//周期10s
|
|
|
|
+ {
|
|
|
|
+ HAL_GPIO_WritePin(LIGHT_F_GPIO_Port, LIGHT_F_Pin, GPIO_PIN_RESET);
|
|
|
|
+ HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ FlashTimeCnt = 0;
|
|
|
|
+ }
|
|
|
|
+ FlashTimeCnt++;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
//控制前灯
|
|
//控制前灯
|
|
if(LightSwitchCode == MC_LightSwitch_ON)
|
|
if(LightSwitchCode == MC_LightSwitch_ON)
|
|
{
|
|
{
|