Commit 28e3e310 authored by 高士达's avatar 高士达

Merge branch 'CJL' into 'dev'

Cjl

See merge request ty/tianying_ty100!104
parents 6c0fb34f e414aefc
...@@ -844,9 +844,9 @@ ...@@ -844,9 +844,9 @@
<FilePath>..\..\..\..\Source\Component\CAN_Signal\CAN_Signal.lib</FilePath> <FilePath>..\..\..\..\Source\Component\CAN_Signal\CAN_Signal.lib</FilePath>
</File> </File>
<File> <File>
<FileName>eepromManage_TestVersion.lib</FileName> <FileName>eepromManage_20240926.lib</FileName>
<FileType>4</FileType> <FileType>4</FileType>
<FilePath>..\..\..\..\Source\Component\Eeprom\eepromManage_TestVersion.lib</FilePath> <FilePath>..\..\..\..\Source\Component\Eeprom\eepromManage_20240926.lib</FilePath>
</File> </File>
</Files> </Files>
</Group> </Group>
......
...@@ -317,13 +317,12 @@ void Can_QuickTimer_Init(void) ...@@ -317,13 +317,12 @@ void Can_QuickTimer_Init(void)
* @param deltaTime 调用时间 单位ms 10MS调用 * @param deltaTime 调用时间 单位ms 10MS调用
*/ */
uint16_t cjl_cantest = 0; uint16_t CanRxInitflag = 0;
uint16_t cjl_canflag = 0;
void Can_BusOff_Recover(uint8_t deltaTime) void Can_BusOff_Recover(uint8_t deltaTime)
{ {
if (get_can_busoff(CAN_CH_0) == 2) if (get_can_busoff(CAN_CH_0) == 2)
{ {
cjl_canflag = 1; CanRxInitflag = 1;
CAN_TX_Count_Init(); CAN_TX_Count_Init();
if (RSCAN0Busoff.Status == RSCAN0_BUS_STABLE) if (RSCAN0Busoff.Status == RSCAN0_BUS_STABLE)
{ {
...@@ -379,9 +378,9 @@ void Can_BusOff_Recover(uint8_t deltaTime) ...@@ -379,9 +378,9 @@ void Can_BusOff_Recover(uint8_t deltaTime)
RSCAN0Busoff.Timer = 0; RSCAN0Busoff.Timer = 0;
RSCAN0Busoff.Cnt = 0; RSCAN0Busoff.Cnt = 0;
} }
if(cjl_canflag == 1) if(CanRxInitflag == 1)
{ {
cjl_canflag = 0; CanRxInitflag = 0;
Can_RX_Apply_Buff(); Can_RX_Apply_Buff();
} }
} }
......
...@@ -35,9 +35,20 @@ void eeprom_comm_DelayUs(ee_uint32_t time) ...@@ -35,9 +35,20 @@ void eeprom_comm_DelayUs(ee_uint32_t time)
EE_FeedDog(); EE_FeedDog();
for (i = 0; i < dalayCnt; i++) for (i = 0; i < dalayCnt; i++)
{ {
EE_NOP(); //EE_NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
__NOP();
} }
EE_FeedDog(); //EE_FeedDog();
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
...@@ -50,7 +61,8 @@ void eeprom_comm_DelayUs(ee_uint32_t time) ...@@ -50,7 +61,8 @@ void eeprom_comm_DelayUs(ee_uint32_t time)
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
void EE_SDA_InConfig(void) void EE_SDA_InConfig(void)
{ {
RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_IN); //RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_IN);
PORT->PM6 |= (1<<1);
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function Name : EE_SDA_OutConfig * Function Name : EE_SDA_OutConfig
...@@ -62,7 +74,8 @@ void EE_SDA_InConfig(void) ...@@ -62,7 +74,8 @@ void EE_SDA_InConfig(void)
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
void EE_SDA_OutConfig(void) void EE_SDA_OutConfig(void)
{ {
RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT); //RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT);
PORT->PM6 &= ~(1<<1);
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function Name : EE_SDA_GetValue * Function Name : EE_SDA_GetValue
...@@ -90,7 +103,16 @@ ee_uint8_t EE_SDA_GetValue(void) ...@@ -90,7 +103,16 @@ ee_uint8_t EE_SDA_GetValue(void)
void EE_SDA_OUT(ee_uint8_t data) void EE_SDA_OUT(ee_uint8_t data)
{ {
// RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT | data); // RTE_GPIO_Config(EE_SDA, RTE_GPIO_DIR_OUT | data);
RTE_GPIO_Set_Level(EE_SDA, data); //RTE_GPIO_Set_Level(EE_SDA, data);
if(data)
{
PORT->P6 |= (1<<1);
}
else
{
PORT->P6 &= ~(1<<1);
}
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
...@@ -103,7 +125,8 @@ void EE_SDA_OUT(ee_uint8_t data) ...@@ -103,7 +125,8 @@ void EE_SDA_OUT(ee_uint8_t data)
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
void EE_SCL_OutConfig(void) void EE_SCL_OutConfig(void)
{ {
RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT); //RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT);
PORT->PM6 &= ~(1<<0);
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function Name : EE_SCL_OUT * Function Name : EE_SCL_OUT
...@@ -116,7 +139,16 @@ void EE_SCL_OutConfig(void) ...@@ -116,7 +139,16 @@ void EE_SCL_OutConfig(void)
void EE_SCL_OUT(ee_uint8_t data) void EE_SCL_OUT(ee_uint8_t data)
{ {
// RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT | data); // RTE_GPIO_Config(EE_SCL, RTE_GPIO_DIR_OUT | data);
RTE_GPIO_Set_Level(EE_SCL, data); //RTE_GPIO_Set_Level(EE_SCL, data);
if(data)
{
PORT->P6 |= (1<<0);
}
else
{
PORT->P6 &= ~(1<<0);
}
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
......
...@@ -38,7 +38,9 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode ...@@ -38,7 +38,9 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode
if (Common_GetIgnOnTime() >= 3030) if (Common_GetIgnOnTime() >= 3030)
{ {
Key_Left_Long_Press(); Key_Left_Long_Press();
TYW_RESET_ODO();
} }
Key_Clear_Time(); Key_Clear_Time();
break; break;
case KEY_EVENT_LONG_PRESS_1: //7 case KEY_EVENT_LONG_PRESS_1: //7
...@@ -84,7 +86,7 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode ...@@ -84,7 +86,7 @@ void Key_Operation_Left(Key_Event_en_t enKeyEvent)//Mode
Tpms_TX_Flag = 0; Tpms_TX_Flag = 0;
} }
TYW_RESET_ODO(); // TYW_RESET_ODO();
} }
Key_Clear_Time(); Key_Clear_Time();
break; break;
......
...@@ -7,6 +7,10 @@ uint8_t DataTripBuf[Data_MEM_Block_Trip * EM_TRIP_MAX]; ...@@ -7,6 +7,10 @@ uint8_t DataTripBuf[Data_MEM_Block_Trip * EM_TRIP_MAX];
Mileage_t g_WriteMileage; Mileage_t g_WriteMileage;
Mileage_t g_ReadMileage; Mileage_t g_ReadMileage;
uint8_t odo_writeState; uint8_t odo_writeState;
uint8_t odoclr_writeState;
uint8_t trip_writeState;
uint8_t trip_readState;
uint8_t odo_readState;
uint8_t odo_readState; uint8_t odo_readState;
uint32_t Milleage_InitFlag = 0U; uint32_t Milleage_InitFlag = 0U;
/****************************************************************************** /******************************************************************************
...@@ -31,9 +35,9 @@ void Data_User_Mileage_KL30Init(void) ...@@ -31,9 +35,9 @@ void Data_User_Mileage_KL30Init(void)
if (TempBuf[0] == 0xFFFFFFFF) if (TempBuf[0] == 0xFFFFFFFF)
{ {
MileInit.Mileage = 0u; MileInit.Mileage = 0u;
} }
else else
{ {
MileInit.Mileage = TempBuf[0]; MileInit.Mileage = TempBuf[0];
} }
Func.Get_Sys_IG_Sts = Common_Get_IG_Sts; Func.Get_Sys_IG_Sts = Common_Get_IG_Sts;
...@@ -98,7 +102,7 @@ void Data_User_Mileage_KL30Init(void) ...@@ -98,7 +102,7 @@ void Data_User_Mileage_KL30Init(void)
Data_Trip_KL30_Init(DataTripBuf, TripInit, EM_TRIP_MAX, Func.EEPromWrite_Cbk); Data_Trip_KL30_Init(DataTripBuf, TripInit, EM_TRIP_MAX, Func.EEPromWrite_Cbk);
//Data_User_EEPROM_Read(EM_MenuData_Tcs_Val, TempBuf, 1u); //Data_User_EEPROM_Read(EM_MenuData_Tcs_Val, TempBuf, 1u);
eeprom_ReadRecord(EEPROM_BLOCK_08, (uint8_t *)TempBufUser, 1); eeprom_ReadRecord(EEPROM_BLOCK_08, (uint8_t *)TempBufUser, 1);
if (TempBufUser[0u] == 0xFF) if (TempBufUser[0u] == 0xFF)
{ {
MenuData.Tcs_Val = 1; MenuData.Tcs_Val = 1;
...@@ -107,7 +111,7 @@ void Data_User_Mileage_KL30Init(void) ...@@ -107,7 +111,7 @@ void Data_User_Mileage_KL30Init(void)
} }
//Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, TempBuf, 1u); //Data_User_EEPROM_Read(EM_MenuData_TPMS_LEARN, TempBuf, 1u);
eeprom_ReadRecord(EEPROM_BLOCK_09, (uint8_t *)TempBufUser, 2); eeprom_ReadRecord(EEPROM_BLOCK_09, (uint8_t *)TempBufUser, 2);
if (TempBufUser[0u] == 0xFF) if (TempBufUser[0u] == 0xFF)
{ {
TPMSLearn[0] = 0;//MenuData.TPMS_Front_Learn; TPMSLearn[0] = 0;//MenuData.TPMS_Front_Learn;
...@@ -145,6 +149,7 @@ uint32_t Get_MileageInit_Status(void) ...@@ -145,6 +149,7 @@ uint32_t Get_MileageInit_Status(void)
uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t u16Len) uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t u16Len)
{ {
uint16_t timeout = 0;
switch (u16BlockID) switch (u16BlockID)
{ {
case EM_MILEAGE_BLOCK: case EM_MILEAGE_BLOCK:
...@@ -153,12 +158,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t ...@@ -153,12 +158,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
break; break;
case EM_ODO_BLOCK: case EM_ODO_BLOCK:
timeout = 0;
eeprom_ReadRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4); odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
while(odo_readState != WRITE_COMPLETE)
{
//eeprom_comm_DelayUs(5000);
odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
timeout++;
if(odo_readState == WRITE_COMPLETE)
{
break;
}
if(timeout >= 3)
{
break;
}
}
break; break;
case EM_TRIP_BLOCK: case EM_TRIP_BLOCK:
eeprom_ReadRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4); timeout = 0;
odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
while(odo_readState != WRITE_COMPLETE)
{
//eeprom_comm_DelayUs(5000);
odo_readState = eeprom_ReadRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
timeout++;
if(odo_readState == WRITE_COMPLETE)
{
break;
}
if(timeout >= 3)
{
break;
}
}
break; break;
// case EM_Maintenance_BLOCK: // case EM_Maintenance_BLOCK:
...@@ -186,7 +220,7 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t ...@@ -186,7 +220,7 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
void Data_User_EEPROM_Write(Data_EEPROM_Enum_t BlockID, uint32_t u32Data[], uint16_t u16Len) void Data_User_EEPROM_Write(Data_EEPROM_Enum_t BlockID, uint32_t u32Data[], uint16_t u16Len)
{ {
// uint8_t i = 0u; // uint8_t i = 0u;
uint8_t timeout = 0;
switch (BlockID) switch (BlockID)
{ {
case EM_MILEAGE_BLOCK: case EM_MILEAGE_BLOCK:
...@@ -203,11 +237,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t ...@@ -203,11 +237,41 @@ uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t
break; break;
case EM_ODO_BLOCK: case EM_ODO_BLOCK:
eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4); timeout = 0;
odoclr_writeState = eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
while(odoclr_writeState != WRITE_COMPLETE)
{
//eeprom_comm_DelayUs(5000);
odoclr_writeState = eeprom_WriteRecord(EEPROM_BLOCK_01, (uint8_t *)u32Data, u16Len * 4);
timeout++;
if(odoclr_writeState == WRITE_COMPLETE)
{
break;
}
if(timeout >= 3)
{
return;
}
}
break; break;
case EM_TRIP_BLOCK: case EM_TRIP_BLOCK:
eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4); timeout = 0;
trip_writeState = eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
while(trip_writeState != WRITE_COMPLETE)
{
//eeprom_comm_DelayUs(5000);
trip_writeState = eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
timeout++;
if(trip_writeState == WRITE_COMPLETE)
{
break;
}
if(timeout >= 3)
{
return;
}
}
break; break;
// case EM_Maintenance_BLOCK: // case EM_Maintenance_BLOCK:
......
...@@ -52,31 +52,42 @@ static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len) ...@@ -52,31 +52,42 @@ static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len)
{ {
ee_uint16_t tmpWritestatus = 0; ee_uint16_t tmpWritestatus = 0;
ee_uint16_t Cnt = 0; ee_uint16_t Cnt = 0;
ee_uint16_t TimeOut = 0;
tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
while(tmpWritestatus == WRITING) while(tmpWritestatus != WRITE_COMPLETE)
{ {
//eeprom_comm_DelayUs(5000);
tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpWritestatus = eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
Cnt++; TimeOut++;
if(Cnt >= 1000) if(tmpWritestatus == WRITE_COMPLETE)
{ {
break; break;
} }
if(TimeOut >= 3)
{
return;
}
} }
} }
static void Service_Interval_Read_EEProm(uint32_t u32Data [], uint16_t u16Len) static void Service_Interval_Read_EEProm(uint32_t u32Data [], uint16_t u16Len)
{ {
ee_uint16_t tmpReadstatus = 0; ee_uint16_t tmpReadstatus = 0;
ee_uint16_t Cnt = 0; ee_uint16_t TimeOut = 0;
tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
while(tmpReadstatus == READING) while(tmpReadstatus != WRITE_COMPLETE)
{ {
//eeprom_comm_DelayUs(5000);
tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4); tmpReadstatus = eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
Cnt++; TimeOut++;
if(Cnt >= 1000) if(tmpReadstatus == WRITE_COMPLETE)
{ {
break; break;
} }
if(TimeOut >= 3)
{
return;
}
} }
} }
......
...@@ -103,7 +103,96 @@ void sci_error_log_internal(int8_t err, const char *file, int32_t line) ...@@ -103,7 +103,96 @@ void sci_error_log_internal(int8_t err, const char *file, int32_t line)
/* Do nothing. */ /* Do nothing. */
} }
} }
#if 1
/**
* @brief Calculate the register setting options for baud rate to UART peripheral.
* @param fclk_freq: System clock value on chip.
* @param baud: The target baud rate which want to setting.
* @param pValue: UART baud rate setting option data structure.
* @param cur_sps: current SPS register value, clock sharing it with other channels, Try not to modify it as much as possible.
* if 'cur_sps = 0x00' or 'cur_sps = FORCE_RECONF', Ignore the original register value and force reconfiguration. laidi
* @retval None
*/
float SCIPeriphal_ClockUpdate(SCIAFSelect_TypeDef func, uint32_t fclk, uint32_t ftclk, uint8_t cur_sps, SCIPeriph_Clock_TypeDef *clock)
{
#define CALCULATE_MAX_SPS 0x0F
#define CALCULATE_MAX_SDR 0x7F
#define FORCE_RECONF 0xFF
uint8_t i;
uint8_t min_sdr, max_sps;
uint32_t cal_fmck = 0;
int16_t idea_sdr;
uint8_t sdr_int;
uint16_t max_err = 0xFFFF, temp_err = 0xFFFF;
float ret_err = 100.0;
if(ftclk == 0)
{
return ret_err;
}
if (func & SCI_UART_MASK)
{
min_sdr = 2;
}
else if (func & SCI_I2C_MASK)
{
min_sdr = 1;
}
else
{
min_sdr = 0;
}
if ((cur_sps == 0x00) || (cur_sps == FORCE_RECONF))
{
max_sps = CALCULATE_MAX_SPS + 1;
}
else
{
clock->sps = cur_sps;
max_sps = 1; /* for (i..) loop once */
}
for (i = 0; i < max_sps; i++)
{
/* cac fMCK, SPS reg*/
if ((cur_sps == 0x00) || (cur_sps == FORCE_RECONF))
{
cal_fmck = fclk / sps_tab[i];
}
else
{
i = cur_sps;
cal_fmck = fclk / sps_tab[cur_sps];
}
/* cal_ftclk = cal_fmck /2 /(SDR[15:9]+1), data scaled up 100 times for calculations.*/
idea_sdr = ((cal_fmck >> 1) *100) / ftclk;
if((idea_sdr > (min_sdr*100 +50)) && (idea_sdr < (CALCULATE_MAX_SDR*100 +50)))
{
sdr_int = (idea_sdr + 50)/100;
temp_err = abs((sdr_int * 100) - idea_sdr) * 10000 / idea_sdr;
if(temp_err < max_err)
{
clock->sps = i;
clock->sdr = sdr_int - 1;
max_err = temp_err;
}
if(max_err == 0)
{
return (float)0.0;
}
}
}
ret_err = max_err /(float)100.0;
return ret_err;
}
#endif
#if 0
/** /**
* @brief Calculate the register setting options for baud rate to UART peripheral. * @brief Calculate the register setting options for baud rate to UART peripheral.
* @param fclk_freq: System clock value on chip. * @param fclk_freq: System clock value on chip.
...@@ -167,6 +256,7 @@ float SCIPeriphal_ClockUpdate(SCIAFSelect_TypeDef func, uint32_t fclk, uint32_t ...@@ -167,6 +256,7 @@ float SCIPeriphal_ClockUpdate(SCIAFSelect_TypeDef func, uint32_t fclk, uint32_t
return max_err; return max_err;
} }
#endif
/** /**
* @brief This function is aimed to check sci unit and its channel is used or not * @brief This function is aimed to check sci unit and its channel is used or not
* @param func: The AF function for SCI channel periphal. * @param func: The AF function for SCI channel periphal.
......
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