1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "Maintenance.h"
/*** 保养里程 ***/
uint32_t DataServiceInterval = 0xFFFFu;
#pragma ghs section bss=".myNonInitArea"
uint32_t NVM_USER_SETTINGS_SERVICE ;
uint32_t MainTimer ; /*****100ms累加器****/
#pragma ghs section bss=default
MaintenanceStruct MaintenanceTime;
/******************************************************************************
函数名:Data_ODO_Service_KL30_Init
功 能: 首次上电初始化
参 数: 无
返回值:无
******************************************************************************/
void Data_Maintenance_Service_KL30_Init(void)
{
uint32_t TempBuf[1] = {0};
if (EEPROM_Get_Block_Status(EEPROM_BLOCK_SERVICE_INFO) == EEPROM_STAT_BLANK)
{
NVM_USER_SETTINGS_SERVICE = 50000u;
TempBuf[0] = NVM_USER_SETTINGS_SERVICE;
Data_User_EEPROM_Write(EEPROM_BLOCK_SERVICE_INFO, TempBuf, 1);
}
else
{
Data_User_EEPROM_Read(EEPROM_BLOCK_SERVICE_INFO, TempBuf, 1);
NVM_USER_SETTINGS_SERVICE = TempBuf[0];
}
/*保养里程*/
DataServiceInterval = 0xFFFFu;
/*保养时间*/
uint32_t MainTimer = 0u;
}
/******************************************************************************
函数名:Data_Service_Interval_Processing
功 能: 剩余保养里程处理
参 数: 无
返回值:无
******************************************************************************/
uint32_t Get_Data_Maintenace_Interval_Processing(void)
{
uint32_t MileageDev;
uint32_t Servicekm;
uint32_t ODO_Data;
ODO_Data = Data_ODO_Read();
if (Common_Get_IG_Sts() == COMMON_POWER_ON)
{
if (ODO_Data >= NVM_USER_SETTINGS_SERVICE)
{
Servicekm = 0u;
}
else
{
MileageDev = NVM_USER_SETTINGS_SERVICE - ODO_Data;
Servicekm = (uint32_t)MileageDev;
Servicekm += 9;
Servicekm /= 10u;
}
DataServiceInterval = Servicekm;
}
return DataServiceInterval;
}
/******************************************************************************
函数名:Data_Service_Interval_Reset
功 能: 重置保养里程
参 数: 无
返回值:无
******************************************************************************/
void Data_Maintenance_Interval_Reset(uint32_t Maintenance_def)
{
uint32_t ODO_Data;
uint32_t TempBuf[1] = {0};
ODO_Data = Data_ODO_Read();
NVM_USER_SETTINGS_SERVICE = ODO_Data + Maintenance_def;
TempBuf[0] = NVM_USER_SETTINGS_SERVICE;
Data_User_EEPROM_Write(EEPROM_BLOCK_SERVICE_INFO, TempBuf, 1);
//DataServiceInterval = Maintenance_def;
}
/******************************************************************************
函数名:Data_Service_Time_Procesing
功 能: 剩余保养天数处理
参 数: 无
返回值:无
******************************************************************************/
uint16_t Get_Calc_Service_Time_Procesing(void)/*ON*/
{
uint16_t Maintenance_Day ;
uint16_t MainDay;
uint32_t second;
Maintenance_Day = 0u;
MainDay = 0u;
second = 0u;
second = MaintenanceTime.u32second - MaintenanceTime.u32Lastsecond;
Maintenance_Day = (uint16_t)(MainTimer / 864000u);
Maintenance_Day = Maintenance_Day + (uint16_t)(second / 86400u);
if (Maintenance_Set_Days <= Maintenance_Day)
{
MainDay = 0u;
}
else
{
MainDay = Maintenance_Set_Days - Maintenance_Day;
}
return MainDay;
}
/******************************************************************************
函数名:ON到OFF存储当次的秒数
功 能: 唤醒获取上次的RTC秒数
参 数: 无
返回值:无
******************************************************************************/
void Maintenance_KL15_OFF_Init(void)
{
MaintenanceTime.u32Lastsecond = Get_RTC_SECOND();
}
/******************************************************************************
函数名:Main_WakeUp_Init
功 能: 唤醒获取上次的RTC秒数
参 数: 无
返回值:无
******************************************************************************/
void Maintenance_WakeUp_Init(void)
{
MaintenanceTime.u32second = Get_RTC_SECOND();
}
/******************************************************************************
函数名:Data_Service_Time_Reset
功 能: 重置保养时间
参 数: 无
返回值:无
******************************************************************************/
void Data_Service_Time_Reset(void)
{
/*NVM_Data_Update(NVM_USER_SETTINGS);*/
//Data_User_EEPROM_Write(EEPROM_BLOCK_SERVICE_INFO, uint32_t u32Data[], uint16_t u16Len)
MainTimer = 0u;
}