Commit 2f72df95 authored by 时昊's avatar 时昊

feat:增加保养功能

parent 82c58e4f
......@@ -808,6 +808,16 @@
<FileType>4</FileType>
<FilePath>..\..\..\..\Source\Component\LED_Driver\LED_Driver_V1.3.lib</FilePath>
</File>
<File>
<FileName>Maintenance.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Component\Maintenance\Maintenance.c</FilePath>
</File>
<File>
<FileName>Maintenance.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Component\Maintenance\Maintenance.h</FilePath>
</File>
</Files>
</Group>
<Group>
......
SET PATH=C:\Keil_v5\ARM\ARMCC\Bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\tyw05\AppData\Local\Microsoft\WindowsApps;
SET ARMCC5_ASMOPT=--diag_suppress=9931
SET ARMCC5_CCOPT=--diag_suppress=9931
SET ARMCC5_LINKOPT=--diag_suppress=9931
SET CPU_TYPE=BAT32G139GK64FB
SET CPU_VENDOR=Cmsemicon
SET UV2_TARGET=TianYing200
......@@ -34,6 +31,7 @@ SET CPU_CLOCK=0x00B71B00
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\powermanag_user.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\system_monitor_user.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\telltales_user.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\maintenance.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\rte_tick_timer_bat32a239.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\rte_wdt_bat32a239.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\rte_gpio_bat32a239.__i"
......
......@@ -363,6 +363,8 @@ void MenuData_Unit_Init(void)
uint8_t ClearODO_Flag = 0;
void TYW_RESET_ODO(void)
{
uint8_t Clear_EE[1] = {0xff};
uint32_t EE_Count = 0U;
if(SYS_OPR_STAT_IGN_ON)
{
if(ClearODO_Flag < 1)
......@@ -371,6 +373,10 @@ void TYW_RESET_ODO(void)
{
ClearODO_Flag = 1;
Data_Mileage_Clear();
for(EE_Count = 0 ; EE_Count < 255; EE_Count++)
{
eeprom_WriteRecord(EE_Count, ( uint8_t * )&Clear_EE, 1);
}
}
}
}
......@@ -382,7 +388,10 @@ void TYW_RESET_ODO(void)
void Maintain_Reset_Service(void)
{
;
if(Get_Data_Maintenace_Interval_Processing() == 0)
{
Data_Maintenance_Interval_Reset();
}
}
uint8_t Get_Dis_Hour_Time(void)
......
#include "Maintenance.h"
/*** 保养里程 ***/
uint32_t DataServiceInterval = 0xFFFFu;
uint32_t NVM_User_Settings_Service; /***********临时接口*********/
/******************************************************************************
Data_Maintenance_Interval_Set
功 能: 写入保养
参 数: 无
返回值:无
******************************************************************************/
void Data_Maintenance_Interval_Set(uint32_t u32Data)
{
uint32_t u32Data1[1u] = {0};
u32Data1[0u] = u32Data;
Data_User_EEPROM_Write(EM_Maintenance_BLOCK, u32Data1, 1u);
}
/******************************************************************************
Data_Maintenance_Interval_Set_Flag
功 能: 写入保养标志
参 数: 无
返回值:无
******************************************************************************/
void Data_Maintenance_Interval_Set_Flag(uint32_t u32Data)
{
uint32_t u32Data1[1u] = {0};
u32Data1[0u] = u32Data;
Data_User_EEPROM_Write(EM_Maintenance_Firstflg, u32Data1, 1u);
}
/******************************************************************************
函数名:Data_Service_Interval_Processing
功 能: 剩余保养里程处理
参 数: 无
返回值:无
******************************************************************************/
uint32_t Get_Data_Maintenace_Interval_Processing(void)
{
uint32_t MileageDev = 0;
uint32_t Servicekm = 0;
uint32_t ODO_Data = 0;
ODO_Data = Data_ODO_Read() / 10;
if (ODO_Data >= NVM_User_Settings_Service)
{
Servicekm = 0u;
}
else
{
MileageDev = NVM_User_Settings_Service - ODO_Data;
Servicekm = MileageDev;
}
if (Servicekm >= 2000u)
{
Servicekm = 2000u;
}
DataServiceInterval = Servicekm;
return DataServiceInterval;
}
/******************************************************************************
函数名:Data_Service_Interval_Reset
功 能: 重置保养里程
参 数: 无
返回值:无
******************************************************************************/
void Data_Maintenance_Interval_Reset(void)
{
uint32_t ODO_Data = 0;
uint32_t u32Data[1u] = {0};
uint32_t Maintenance_Firstflg[1u] = {0};
ODO_Data = Data_ODO_Read() / 10u;
Data_User_EEPROM_Read(EM_Maintenance_Firstflg, Maintenance_Firstflg, 1u);
if (Maintenance_Firstflg[0u] == 0xFFFFFFFF)
{
NVM_User_Settings_Service = ODO_Data + 1000;
u32Data[0u] = NVM_User_Settings_Service;
Data_User_EEPROM_Write(EM_Maintenance_BLOCK, u32Data, 1u);
Maintenance_Firstflg[0u] = 1;
Data_User_EEPROM_Write(EM_Maintenance_Firstflg, Maintenance_Firstflg, 1u);
}
else if (Maintenance_Firstflg[0u] == 1)
{
NVM_User_Settings_Service = ODO_Data + 2000;
u32Data[0u] = NVM_User_Settings_Service;
Data_User_EEPROM_Write(EM_Maintenance_BLOCK, u32Data, 1u);
}
}
#ifndef MAINTENANCE_H
#define MAINTENANCE_H
#include "Components.h"
#include "Application.h"
extern uint32_t NVM_User_Settings_Service;
/******获取剩余保养里程*******/
uint32_t Get_Data_Maintenace_Interval_Processing(void);//用来判断
/********重置保养里程*********/
void Data_Maintenance_Interval_Reset(void);//用按键重置
extern void Data_Maintenance_Interval_Set(uint32_t u32Data);
void Data_Maintenance_Interval_Set_Flag(uint32_t u32Data);
#endif
......@@ -52,7 +52,7 @@ typedef enum
EM_ODO_BLOCK, /**< 总计里程 */
EM_TRIP_BLOCK, /**< 小计里程 */
EM_Maintenance_BLOCK, /**< 保养里程 */
EM_ODOSYNC_CNT_BLOCK, /**< 里程备份次数 */
EM_Maintenance_Firstflg, /**< 保养标志 */
EM_ENGODO_BLOCK, /**< 发动机总里程 */
} Data_EEPROM_Enum_t;
......
......@@ -8,16 +8,16 @@ Mileage_t g_WriteMileage;
Mileage_t g_ReadMileage;
uint8_t odo_writeState;
uint8_t odo_readState;
static uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t u16Len);
static void Data_User_EEPROM_Write(Data_EEPROM_Enum_t BlockID, uint32_t u32Data[], uint16_t u16Len);
extern uint32_t NVM_User_Settings_Service;
#define EEPROM_BLOCK_00 0X00
#define EEPROM_BLOCK_01 0X16
#define EEPROM_BLOCK_02 0X32
#define EEPROM_BLOCK_03 0X48
#define EEPROM_BLOCK_04 0X64
#define EEPROM_BLOCK_05 0X80
#define EEPROM_BLOCK_06 0X90
#define EEPROM_BLOCK_00 00
#define EEPROM_BLOCK_01 16
#define EEPROM_BLOCK_02 32
#define EEPROM_BLOCK_03 48
#define EEPROM_BLOCK_04 64
#define EEPROM_BLOCK_05 80
#define EEPROM_BLOCK_06 96
#define EEPROM_BLOCK_07 112
uint32_t Milleage_InitFlag = 0U;
......@@ -36,7 +36,7 @@ void Data_User_Mileage_KL30Init(void)
Mileage_Init_t MileInit = {0};
Mileage_Func_t Func = {0};
ODO_Init_t ODOInit = {0};
// EngODO_Init_t EngODOInit = {0};
uint32_t Maintenance_Firstflg[1u] = {0};
Trip_Init_t TripInit[4] = {0};
Milleage_InitFlag = 0U;
// �������ݴ�EEPROM�ж�ȡ
......@@ -102,6 +102,14 @@ void Data_User_Mileage_KL30Init(void)
TripInit[EM_TRIP_D].IsRestart = 1u;
Data_Trip_KL30_Init(DataTripBuf, TripInit, EM_TRIP_MAX, Func.EEPromWrite_Cbk);
Data_User_EEPROM_Read(EM_Maintenance_BLOCK, TempBuf, 1u);
NVM_User_Settings_Service = TempBuf[0u];
if (TempBuf[0u] == 0xFFFFFFFF)
{
NVM_User_Settings_Service = 500;
Data_User_EEPROM_Write(EM_Maintenance_BLOCK, &NVM_User_Settings_Service, 1u);
}
Milleage_InitFlag = 0X5AA53AA3UL;
}
......@@ -126,10 +134,11 @@ void Data_User_Mileage_WakeupInit(void)
uint32_t Get_MileageInit_Status(void)
{
return Milleage_InitFlag;
}
static 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)
{
switch (u16BlockID)
{
......@@ -147,6 +156,14 @@ static uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], u
eeprom_ReadRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
break;
case EM_Maintenance_BLOCK:
eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
break;
case EM_Maintenance_Firstflg:
eeprom_ReadRecord(EEPROM_BLOCK_07, (uint8_t *)u32Data, u16Len * 4);
break;
default:
break;
}
......@@ -154,7 +171,7 @@ static uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], u
return 0;
}
static 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;
......@@ -181,6 +198,14 @@ static void Data_User_EEPROM_Write(Data_EEPROM_Enum_t BlockID, uint32_t u32Data[
eeprom_WriteRecord(EEPROM_BLOCK_03, (uint8_t *)u32Data, u16Len * 4);
break;
case EM_Maintenance_BLOCK:
eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
break;
case EM_Maintenance_Firstflg:
eeprom_WriteRecord(EEPROM_BLOCK_07, (uint8_t *)u32Data, u16Len * 4);
break;
default:
break;
}
......
......@@ -20,4 +20,6 @@ extern uint32_t Get_ODO_Value(void);
extern uint32_t Get_Trip_Value(void);
extern void Trip_Clear_Km_Service(void);
extern void Unit_Convert_Service(void);
uint32_t Data_User_EEPROM_Read(uint16_t u16BlockID, uint32_t u32Data[], uint16_t u16Len);
void Data_User_EEPROM_Write(Data_EEPROM_Enum_t BlockID, uint32_t u32Data[], uint16_t u16Len);
#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