Commit 9b993cfb authored by 李俭双's avatar 李俭双

🐞 fix:修改胎压逻辑

parent 2a5f4dfa
...@@ -2,47 +2,214 @@ ...@@ -2,47 +2,214 @@
#include "Data_TPMS\Data_TPMS.h" #include "Data_TPMS\Data_TPMS.h"
_TPMS_Display TPMS; _TPMS_Display TPMS;
uint32_t LearnTime_Count = 0;
uint32_t LearnTime_Count1 = 0;
void Data_TPMS_KL30_Init ( void ) void Data_TPMS_KL30_Init ( void )
{ {
uint32_t TPMS_L[2] = {0,0}; uint8_t TPMS_L[2] = {0,0};
Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, TPMS_L, 2u); Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1u);
MenuData.TPMS_Front_Learn = TPMS_L[0]; MenuData.TPMS_Front_Learn = TPMS_L[0];
MenuData.TPMS_Rear_Learn = TPMS_L[1]; MenuData.TPMS_Rear_Learn = TPMS_L[1];
//MenuData.TPMS_Front_FirstLearn_Flag = TPMS_L[2];
//MenuData.TPMS_Rear_FirstLearn_Flag = TPMS_L[3];
TPMS.Front_Press_Value = 0; TPMS.Front_Press_Value = 0;
TPMS.Rear_Press_Value = 0; TPMS.Rear_Press_Value = 0;
TPMS.Front_TPMS_Valid = 0; TPMS.Front_TPMS_Valid = 0;
TPMS.Rear_TPMS_Valid = 0; TPMS.Rear_TPMS_Valid = 0;
TPMS.TPMS_Warning = 0; TPMS.TPMS_Warning = 0;
TPMS.TPMS_Unit = Get_Dis_Tpms_Unit(); TPMS.TPMS_Unit = Get_Dis_Tpms_Unit();
TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn; TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn; TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
TPMS.TPMS_Front_FirstLearn_Flag = MenuData.TPMS_Front_FirstLearn_Flag;
TPMS.TPMS_Rear_FirstLearn_Flag = MenuData.TPMS_Rear_FirstLearn_Flag;
} }
void Data_TPMS_KL15_WAKE_UP_Init ( void ) void Data_TPMS_KL15_WAKE_UP_Init ( void )
{ {
uint32_t TPMS_L[2] = {0,0}; uint8_t TPMS_L[2] = {0,0};
Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, TPMS_L, 2u); Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1);
MenuData.TPMS_Front_Learn = TPMS_L[0]; MenuData.TPMS_Front_Learn = TPMS_L[0];
MenuData.TPMS_Rear_Learn = TPMS_L[1]; MenuData.TPMS_Rear_Learn = TPMS_L[1];
//MenuData.TPMS_Front_FirstLearn_Flag = TPMS_L[2];
//MenuData.TPMS_Rear_FirstLearn_Flag = TPMS_L[3];
TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn; TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn; TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
TPMS.TPMS_Front_FirstLearn_Flag = MenuData.TPMS_Front_FirstLearn_Flag;
TPMS.TPMS_Rear_FirstLearn_Flag = MenuData.TPMS_Rear_FirstLearn_Flag;
} }
void Data_TPMS_Processing_Service ( void ) void Data_TPMS_Processing_Service ( void )
{ {
uint16_t Front_TPMS = 0; uint16_t Front_TPMS = 0;
uint16_t Rear_TPMS = 0; uint16_t Rear_TPMS = 0;
uint32_t TPMS_L[2] = {0,0}; uint8_t TPMS_L[2] = {0,0};
if(CAN_MSG_Status(&CAN_CH0_CanMsgOp, CAN_CH0_ID_CAN_0x341_Msg_Count) != CAN_SIG_LOST)
{
TPMS.TPMS_Front_Learn = Get_CAN_CH0_ID_341_Sig_Front_LearningStatus(); TPMS.TPMS_Front_Learn = Get_CAN_CH0_ID_341_Sig_Front_LearningStatus();
TPMS.TPMS_Rear_Learn = Get_CAN_CH0_ID_341_Sig_Rear_LearningStatus(); TPMS.TPMS_Rear_Learn = Get_CAN_CH0_ID_341_Sig_Rear_LearningStatus();
}
else
{
TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
}
if(TPMS.TPMS_Front_Learn == 0x0)
{
if(LearnTime_Count <= 6000)
{
LearnTime_Count++;
TPMS.TPMS_Front_Learn = Unstudied;
}
else
{
if ((MenuData.TPMS_Front_Learn != 0x2) && (MenuData.TPMS_Front_Learn != 0x3) )
{
TPMS.TPMS_Front_Learn = LearningFailure;
}
else
{
TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
}
}
}
else if(TPMS.TPMS_Front_Learn == 0x1)
{
if(LearnTime_Count <= 6000)
{
LearnTime_Count++;
TPMS.TPMS_Front_Learn = Learning;
}
else
{
if ((MenuData.TPMS_Front_Learn != 0x2) && (MenuData.TPMS_Front_Learn != 0x3) )
{
TPMS.TPMS_Front_Learn = LearningFailure;
}
else
{
TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
}
}
}
else if (TPMS.TPMS_Front_Learn == 0x2)
{
LearnTime_Count = 0;
if((Get_CAN_CH0_ID_373_Sig_Front_id() != 0) && (Get_CAN_CH0_ID_373_Sig_Front_id() != 0xFFFFFFFF))
{
TPMS.TPMS_Front_Learn = LearningCompletion;
}
else
{
;
}
}
else if (TPMS.TPMS_Front_Learn == 0x3)
{
LearnTime_Count = 0;
TPMS.TPMS_Front_Learn = LearningFailure;
}
else
{
LearnTime_Count = 0;
TPMS.TPMS_Front_Learn = MenuData.TPMS_Front_Learn;
}
if(TPMS.TPMS_Rear_Learn == 0x0)
{
if(LearnTime_Count1 <= 6000)
{
LearnTime_Count1++;
TPMS.TPMS_Rear_Learn = Unstudied;
}
else
{
if ((MenuData.TPMS_Rear_Learn != 0x2) && (MenuData.TPMS_Rear_Learn != 0x3) )
{
TPMS.TPMS_Rear_Learn = LearningFailure;
}
else
{
TPMS.TPMS_Rear_Learn = MenuData.TPMS_Rear_Learn;
}
}
}
else if(TPMS.TPMS_Rear_Learn == 0x1)
{
if(LearnTime_Count1 <= 6000)
{
LearnTime_Count1++;
TPMS.TPMS_Rear_Learn = Learning;
}
else
{
if ((MenuData.TPMS_Rear_Learn != 0x2) && (MenuData.TPMS_Rear_Learn != 0x3) )
{
TPMS.TPMS_Rear_Learn = LearningFailure;
}
else
{
TPMS.TPMS_Rear_Learn = MenuData.TPMS_Front_Learn;
}
}
}
else if (TPMS.TPMS_Rear_Learn == 0x2)
{
LearnTime_Count1 = 0;
if((Get_CAN_CH0_ID_373_Sig_Rear_id() != 0) && (Get_CAN_CH0_ID_373_Sig_Rear_id() != 0xFFFFFFFF))
{
TPMS.TPMS_Rear_Learn = LearningCompletion;
}
else
{
;
}
}
else if (TPMS.TPMS_Rear_Learn == 0x3)
{
LearnTime_Count1 = 0;
TPMS.TPMS_Rear_Learn = LearningFailure;
}
else
{
LearnTime_Count1 = 0;
TPMS.TPMS_Rear_Learn = MenuData.TPMS_Front_Learn;
}
if((TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn) || (TPMS.TPMS_Rear_Learn != MenuData.TPMS_Rear_Learn)) if((TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn) || (TPMS.TPMS_Rear_Learn != MenuData.TPMS_Rear_Learn))
{ {
TPMS_L[0] = TPMS.TPMS_Front_Learn; if(TPMS.TPMS_Front_Learn != MenuData.TPMS_Front_Learn)
TPMS_L[1] = TPMS.TPMS_Rear_Learn; {
Data_User_EEPROM_Write(EM_MenuData_TPMS_LEARN, TPMS_L, 2u); TPMS.TPMS_Front_FirstLearn_Flag = 1;
}
if(TPMS.TPMS_Rear_Learn != MenuData.TPMS_Rear_Learn)
{
TPMS.TPMS_Rear_FirstLearn_Flag = 1;
}
if((TPMS.TPMS_Front_Learn == 0x2) || (TPMS.TPMS_Front_Learn == 0x3))
{
MenuData.TPMS_Front_Learn = TPMS.TPMS_Front_Learn; MenuData.TPMS_Front_Learn = TPMS.TPMS_Front_Learn;
}
if((TPMS.TPMS_Rear_Learn == 0x2) || (TPMS.TPMS_Rear_Learn == 0x3))
{
MenuData.TPMS_Rear_Learn = TPMS.TPMS_Rear_Learn; MenuData.TPMS_Rear_Learn = TPMS.TPMS_Rear_Learn;
} }
if((TPMS.TPMS_Front_Learn == 0x2) || (TPMS.TPMS_Front_Learn == 0x3) || (TPMS.TPMS_Rear_Learn == 0x2) || (TPMS.TPMS_Rear_Learn == 0x3))
{
TPMS_L[0] = MenuData.TPMS_Front_Learn;
TPMS_L[1] = MenuData.TPMS_Rear_Learn;
Data_User_EEPROM_Write(EM_MenuData_TPMS_LEARN, (uint32_t*)TPMS_L, 1u);
}
}
TPMS.TPMS_Unit = Get_Dis_Tpms_Unit(); TPMS.TPMS_Unit = Get_Dis_Tpms_Unit();
Front_TPMS = Get_CAN_CH0_ID_341_Sig_Front_Pressure(); Front_TPMS = Get_CAN_CH0_ID_341_Sig_Front_Pressure();
Rear_TPMS = Get_CAN_CH0_ID_341_Sig_Rear_Pressure(); Rear_TPMS = Get_CAN_CH0_ID_341_Sig_Rear_Pressure();
...@@ -61,10 +228,11 @@ void Data_TPMS_Processing_Service ( void ) ...@@ -61,10 +228,11 @@ void Data_TPMS_Processing_Service ( void )
{ {
if((Front_TPMS == 0xFF) || (Rear_TPMS == 0xFF)) if((Front_TPMS == 0xFF) || (Rear_TPMS == 0xFF))
{ {
if((Front_TPMS == 0xFF) && (Rear_TPMS != 0xFF)) if((Front_TPMS == 0xFF) && (Rear_TPMS != 0xFF))
{ {
TPMS.Front_TPMS_Valid = 0; TPMS.Front_TPMS_Valid = 0;
TPMS.Rear_TPMS_Valid = 2; TPMS.Rear_TPMS_Valid = 1;
TPMS.Front_Press_Value = 990; TPMS.Front_Press_Value = 990;
TPMS.Rear_Press_Value = Rear_TPMS * 275; TPMS.Rear_Press_Value = Rear_TPMS * 275;
TPMS.Rear_Press_Value /= 102 ; TPMS.Rear_Press_Value /= 102 ;
...@@ -83,7 +251,7 @@ void Data_TPMS_Processing_Service ( void ) ...@@ -83,7 +251,7 @@ void Data_TPMS_Processing_Service ( void )
} }
else if ((Front_TPMS != 0xFF) && (Rear_TPMS == 0xFF)) else if ((Front_TPMS != 0xFF) && (Rear_TPMS == 0xFF))
{ {
TPMS.Front_TPMS_Valid = 2; TPMS.Front_TPMS_Valid = 1;
TPMS.Rear_TPMS_Valid = 0; TPMS.Rear_TPMS_Valid = 0;
TPMS.Rear_Press_Value = 990; TPMS.Rear_Press_Value = 990;
TPMS.Front_Press_Value = Front_TPMS *275 ; TPMS.Front_Press_Value = Front_TPMS *275 ;
...@@ -105,15 +273,15 @@ void Data_TPMS_Processing_Service ( void ) ...@@ -105,15 +273,15 @@ void Data_TPMS_Processing_Service ( void )
{ {
TPMS.Front_Press_Value = 990; TPMS.Front_Press_Value = 990;
TPMS.Rear_Press_Value = 990; TPMS.Rear_Press_Value = 990;
TPMS.TPMS_Warning = 0; //TPMS.TPMS_Warning = 0;
TPMS.Front_TPMS_Valid = 0; TPMS.Front_TPMS_Valid = 0;
TPMS.Rear_TPMS_Valid = 0; TPMS.Rear_TPMS_Valid = 0;
} }
} }
else else
{ {
TPMS.Front_TPMS_Valid = 2; TPMS.Front_TPMS_Valid = 1;
TPMS.Rear_TPMS_Valid = 2; TPMS.Rear_TPMS_Valid = 1;
TPMS.Front_Press_Value = Front_TPMS * 275 ; TPMS.Front_Press_Value = Front_TPMS * 275 ;
TPMS.Front_Press_Value /= 102 ; TPMS.Front_Press_Value /= 102 ;
if(TPMS.Front_Press_Value > 990) if(TPMS.Front_Press_Value > 990)
...@@ -138,54 +306,56 @@ void Data_TPMS_Processing_Service ( void ) ...@@ -138,54 +306,56 @@ void Data_TPMS_Processing_Service ( void )
} }
} }
if(MenuData.TPMS_Front_Learn == Unstudied) if(TPMS.TPMS_Front_Learn == Unstudied)
{ {
TPMS.Front_TPMS_Valid = Unstudied; TPMS.TPMS_Front_FirstLearn_Flag = Unstudied;
} }
else if(MenuData.TPMS_Front_Learn == Learning) else if(TPMS.TPMS_Front_Learn == Learning)
{ {
TPMS.Front_TPMS_Valid = Learning; TPMS.TPMS_Front_FirstLearn_Flag = Learning;
} }
else if(MenuData.TPMS_Front_Learn == LearningCompletion) else if(TPMS.TPMS_Front_Learn == LearningCompletion)
{ {
TPMS.Front_TPMS_Valid = LearningCompletion; TPMS.TPMS_Front_FirstLearn_Flag = LearningCompletion;
TPMS.Rear_Press_Value = 990;
} }
else if(MenuData.TPMS_Front_Learn == LearningFailure) else if(TPMS.TPMS_Front_Learn == LearningFailure)
{ {
TPMS.Front_TPMS_Valid = LearningFailure; TPMS.TPMS_Front_FirstLearn_Flag = LearningFailure;
TPMS.Front_Press_Value = 990;
} }
else else
{ {
; ;
} }
if(MenuData.TPMS_Rear_Learn == Unstudied) if(TPMS.TPMS_Rear_Learn == Unstudied)
{ {
TPMS.Rear_TPMS_Valid = Unstudied; TPMS.TPMS_Rear_FirstLearn_Flag = Unstudied;
} }
else if(MenuData.TPMS_Rear_Learn == Learning) else if(TPMS.TPMS_Rear_Learn == Learning)
{ {
TPMS.Rear_TPMS_Valid = Learning; TPMS.TPMS_Rear_FirstLearn_Flag = Learning;
} }
else if(MenuData.TPMS_Rear_Learn == LearningCompletion) else if(TPMS.TPMS_Rear_Learn == LearningCompletion)
{ {
TPMS.Rear_TPMS_Valid = LearningCompletion; TPMS.TPMS_Rear_FirstLearn_Flag = LearningCompletion;
TPMS.Front_Press_Value = 990;
} }
else if(MenuData.TPMS_Rear_Learn == LearningFailure) else if(TPMS.TPMS_Rear_Learn == LearningFailure)
{ {
TPMS.Rear_TPMS_Valid = LearningFailure; TPMS.TPMS_Rear_FirstLearn_Flag = LearningFailure;
TPMS.Rear_Press_Value = 990;
} }
else else
{ {
; ;
} }
if ((MenuData.TPMS_Rear_Learn != LearningCompletion) && (MenuData.TPMS_Front_Learn != LearningCompletion)) //if ((MenuData.TPMS_Rear_Learn != LearningCompletion) && (MenuData.TPMS_Front_Learn != LearningCompletion))
{ //{
TPMS.TPMS_Warning = 0; // TPMS.TPMS_Warning = 0;
} //}
} }
else else
...@@ -215,7 +385,7 @@ uint8_t Get_Led_TPMS_Waring (void) ...@@ -215,7 +385,7 @@ uint8_t Get_Led_TPMS_Waring (void)
return TPMS.TPMS_Warning; return TPMS.TPMS_Warning;
} }
/*0:未学习,无效,常显-- 1:学习中,无效,闪烁-- 2:学习完成,有效,按实际胎压数值显示 3:学习失败,无效,最大值闪烁显示*/ /*0:无效,常显-- 1:有效,按实际胎压数值显示 */
uint8_t Get_Front_TPMS_Sig_Vaild (void) uint8_t Get_Front_TPMS_Sig_Vaild (void)
{ {
return TPMS.Front_TPMS_Valid; return TPMS.Front_TPMS_Valid;
...@@ -282,3 +452,15 @@ uint16_t Get_Front_TPMS_TX (void) ...@@ -282,3 +452,15 @@ uint16_t Get_Front_TPMS_TX (void)
} }
return value; return value;
} }
/*前轮胎压学习结果 0-未学习“--”常显 1-学习中“--”闪烁 2-学习成功,正常显示数值 3-学习失败,闪烁显示最大值99*/
uint8_t Get_Front_FirstLearn_Flag (void)
{
return TPMS.TPMS_Front_FirstLearn_Flag;
}
/*后轮胎压学习结果 0-未学习“--”常显 1-学习中“--”闪烁 2-学习成功,正常显示数值 3-学习失败,闪烁显示最大值99*/
uint8_t Get_Rear_FirstLearn_Flag (void)
{
return TPMS.TPMS_Rear_FirstLearn_Flag;
}
...@@ -10,8 +10,10 @@ typedef struct __attribute__((aligned(4))) ...@@ -10,8 +10,10 @@ typedef struct __attribute__((aligned(4)))
uint8_t Rear_TPMS_Valid; uint8_t Rear_TPMS_Valid;
uint8_t TPMS_Warning; uint8_t TPMS_Warning;
uint8_t TPMS_Unit; uint8_t TPMS_Unit;
uint32_t TPMS_Front_Learn; uint8_t TPMS_Front_Learn;
uint32_t TPMS_Rear_Learn; uint8_t TPMS_Rear_Learn;
uint8_t TPMS_Front_FirstLearn_Flag;
uint8_t TPMS_Rear_FirstLearn_Flag;
}_TPMS_Display; }_TPMS_Display;
typedef enum typedef enum
...@@ -32,4 +34,6 @@ uint16_t Get_Rear_TPMS_Sig_Value (void); ...@@ -32,4 +34,6 @@ uint16_t Get_Rear_TPMS_Sig_Value (void);
uint16_t Get_Rear_TPMS_TX (void); uint16_t Get_Rear_TPMS_TX (void);
uint16_t Get_Front_TPMS_TX (void); uint16_t Get_Front_TPMS_TX (void);
void Data_TPMS_KL15_WAKE_UP_Init ( void ); void Data_TPMS_KL15_WAKE_UP_Init ( void );
uint8_t Get_Front_FirstLearn_Flag (void);
uint8_t Get_Rear_FirstLearn_Flag (void);
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment