Browse Source

V2.1.7_20201224
1、增加尾灯功能的配置项,分为照明常亮、照明闪烁、刹车常亮、刹车闪烁共4种模式;
2、增加尾灯闪烁的点亮保持时间和闪烁周期的配置;
3、按照新增的尾灯工作模式,修改尾灯控制方式;
4、版本号:V2.1.7_20201224

dail.zhou 4 years ago
parent
commit
fb5a41229b

+ 1 - 1
Core/Src/main.c

@@ -264,7 +264,7 @@ int main(void)
 			Break_Check(&IsBreakTrig_Flag);
 			
 			//LightżŘÖĆ
-			LightDriver_Process(MC_ControlCode.LightSwitch);
+			LightDriver_Process(MC_ConfigParam2.MC_TailLight_Mode, MC_ConfigParam2.TailLightFlash_ON_Time, MC_ConfigParam2.TailLightFlash_Period, IsBreakTrig_Flag, MC_ControlCode.LightSwitch);
 			
 			//Đřş˝ŔďłĚźĆËă
 			if(HAL_GetTick() > 2000)

BIN
MDK-ARM/bin/MC_VOLANS_V2r1r7_20201224.bin


BIN
MDK-ARM/bin/QD007A_CTL_APP.bin


+ 1 - 1
User/Inc/light_driver.h

@@ -10,6 +10,6 @@
 #define LIGHT_B_GPIO_Port GPIOA
 
 void LightDriver_Init(void);
-void LightDriver_Process(MC_LightSwitch_Struct_t LightSwitchCode);
+void LightDriver_Process(MC_TailLight_Mode_Struct_t TailLight_Mode, uint8_t OnTime, uint8_t PeriodTime, TrueOrFalse_Flag_Struct_t IsBreakFlag, MC_LightSwitch_Struct_t LightSwitchCode);
 
 #endif

+ 12 - 1
User/Inc/var.h

@@ -139,6 +139,14 @@ typedef enum MC_SPEED_SIGNAL
 	MC_SPEED_COMMUNICATION = (uint8_t)0xEE //根据通信数据,车轮旋转1圈的时间
 }MC_SpeedSignal_Struct_t;
 
+typedef enum MC_TAIL_LIGHT_MODE
+{
+  MC_TAIL_LIGHT_LAMP = (uint8_t)0x11,        //照明
+	MC_TAIL_LIGHT_LAMP_FlASH = (uint8_t)0x22,  //照明闪烁
+	MC_TAIL_LIGHT_BREAK = (uint8_t)0x33,       //刹车
+	MC_TAIL_LIGHT_BREAK_FLASH = (uint8_t)0x44  //刹车闪烁
+}MC_TailLight_Mode_Struct_t;
+
 //用户配置参数1,占用空间32bytes
 typedef struct
 {
@@ -175,7 +183,10 @@ typedef struct
   int16_t ZeroAngle_Pitch;         //俯仰角零度偏移,地址偏移0
 	int16_t ZeroAngle_Roll;          //横滚角零度偏移,地址偏移2
 	MC_SupportFlag_Struct_t UseAttitudeAngle_Flag; //支持姿态角度传感器标志,地址偏移4
-	uint8_t RS2[27];//地址偏移5
+	MC_TailLight_Mode_Struct_t MC_TailLight_Mode;  //尾灯功能,地址偏移5
+	uint8_t TailLightFlash_ON_Time;                //尾灯闪烁时开通时间,地址偏移6
+	uint8_t TailLightFlash_Period;                 //尾灯闪烁周期,地址偏移7
+	uint8_t RS2[24];//地址偏移8
 }MC_ConfigParam2_Struct_t;
 
 //姿态传感器数值

+ 66 - 4
User/Src/light_driver.c

@@ -25,16 +25,78 @@ void LightDriver_Init(void)
   HAL_GPIO_Init(LIGHT_B_GPIO_Port, &GPIO_InitStruct);
 }
 
-void LightDriver_Process(MC_LightSwitch_Struct_t LightSwitchCode)
+void LightDriver_Process(MC_TailLight_Mode_Struct_t TailLight_Mode, uint8_t OnTime, uint8_t PeriodTime, TrueOrFalse_Flag_Struct_t IsBreakFlag, MC_LightSwitch_Struct_t LightSwitchCode)
 {
-  if(LightSwitchCode == MC_LightSwitch_ON)
+  //控制前灯
+	if(LightSwitchCode == MC_LightSwitch_ON)
 	{
 		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(LightSwitchCode == MC_LightSwitch_OFF)
 	{
 		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);
 	}
+	
+	//控制后灯
+	uint8_t Light_CrlCode = 0;//高4位:控制方式,1-常亮,2-闪烁; 低4位:开关状态,1-开,2-关
+	static uint32_t FlashTimeCnt = 0;
+	switch(TailLight_Mode)
+	{
+		case MC_TAIL_LIGHT_LAMP_FlASH:  //照明闪烁	
+		{
+		  Light_CrlCode = (LightSwitchCode == MC_LightSwitch_ON) ? 0x21 : 0x20;
+			break;
+		}			
+		case MC_TAIL_LIGHT_BREAK_FLASH: //刹车闪烁
+		{
+		  Light_CrlCode = (IsBreakFlag == TRUE) ? 0x21 : 0x20;
+			break;
+		}
+		case MC_TAIL_LIGHT_BREAK: //刹车常亮
+		{
+		  Light_CrlCode = (IsBreakFlag == TRUE) ? 0x11 : 0x10;
+			break;
+		}
+		case MC_TAIL_LIGHT_LAMP:  //照明常亮
+		default:                  //未配置时为照明常亮
+		{
+		  Light_CrlCode = (LightSwitchCode == MC_LightSwitch_ON) ? 0x11 : 0x10;
+			break;
+		}
+	}
+	if((Light_CrlCode & 0xF0) == 0x10)//常亮
+	{
+	  if((Light_CrlCode & 0x0F) == 0x01)//开
+		{
+		  HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
+		}
+		else if((Light_CrlCode & 0x0F) == 0x00)//关
+		{
+		  HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+		}
+	}
+	else if((Light_CrlCode & 0xF0) == 0x20)//闪烁
+	{
+	  if((Light_CrlCode & 0x0F) == 0x01)//开
+		{
+		  if((HAL_GetTick() - FlashTimeCnt) < OnTime * 20)
+			{
+		  	HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_SET);
+			}
+			else if((HAL_GetTick() - FlashTimeCnt) < PeriodTime * 20)
+			{
+		  	HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+			}
+			else
+			{
+			  FlashTimeCnt = HAL_GetTick();
+			}
+		}
+		else if((Light_CrlCode & 0x0F) == 0x00)//关
+		{
+		  HAL_GPIO_WritePin(LIGHT_B_GPIO_Port, LIGHT_B_Pin, GPIO_PIN_RESET);
+			FlashTimeCnt = HAL_GetTick();
+		}
+	}
+	
 }

+ 7 - 4
User/Src/var.c

@@ -90,7 +90,10 @@ const MC_ConfigParam2_Struct_t MC_ConfigParam2_Default =
 {
   (int16_t)0,
 	(int16_t)0,
-	(MC_SupportFlag_Struct_t)MC_SUPPORT_DISABLE     //0x55-不支持,0x-AA支持
+	(MC_SupportFlag_Struct_t)MC_SUPPORT_DISABLE,     //0x55-不支持,0xAA-支持
+	(MC_TailLight_Mode_Struct_t)MC_TAIL_LIGHT_LAMP,  //照明常亮
+	(uint8_t)10,                                     //闪烁亮时间,单位20ms
+	(uint8_t)20,                                     //闪烁周期,单位20ms
 };
 
 const MC_TorqueCorrectParam_Struct_t MC_TorqueCorrectParam_Default =
@@ -229,7 +232,7 @@ const nGearParam_Struct_t GearParam_Default_TURBO_Volans =
 const nGearParam_Struct_t GearParam_Default_SMART_Volans =
 {
   (uint16_t)0,
-	(uint16_t)980,
+	(uint16_t)500,
 	(uint16_t)100,
 	(uint16_t)2100,
 	(uint8_t)4,
@@ -290,7 +293,7 @@ const nGearParam_Struct_t GearParam_Default_TURBO_Volans_Plus =
 const nGearParam_Struct_t GearParam_Default_SMART_Volans_Plus =
 {
   (uint16_t)0,
-	(uint16_t)960,
+	(uint16_t)500,
 	(uint16_t)100,
 	(uint16_t)2100,
 	(uint8_t)4,
@@ -489,7 +492,7 @@ void Var_Init(void)
 		
 	//MC版本信息初始化,Mode和SN从EEPROM读取
   strncpy(MC_VerInfo.HW_Version, (char*)"QD007H.         ", 16);
-	strncpy(MC_VerInfo.FW_Version, (char*)"V2r1r6_20201203.", 16);
+	strncpy(MC_VerInfo.FW_Version, (char*)"V2r1r7_20201224.", 16);
 	strncpy(Firmware_Special, (char*)"TC011000-MS0000-V0r0.           ", 32);
 		
 	//电机型号

+ 5 - 0
修改说明.txt

@@ -346,6 +346,11 @@ V2.1.6_20201203
 1、修改刹车和GearSensor信号的检测方法,增加延时,避免信号抖动引起异常停机;
 2、版本号:V2.1.6_20201203
 
+V2.1.7_20201224
+1、增加尾灯功能的配置项,分为照明常亮、照明闪烁、刹车常亮、刹车闪烁共4种模式;
+2、增加尾灯闪烁的点亮保持时间和闪烁周期的配置;
+3、按照新增的尾灯工作模式,修改尾灯控制方式;
+4、版本号:V2.1.7_20201224