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

Merge branch 'shihao' into 'dev'

🐞 fix:替换保养库,更改保养相关的指示灯和按键的逻辑,增加保养初始化函数,唤醒函数调用,保养服务函数调用,

See merge request !50
parents 8c42b5aa 6d96ff56
......@@ -275,7 +275,7 @@
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x8000</StartAddress>
<StartAddress>0x0</StartAddress>
<Size>0x40000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
......@@ -849,24 +849,34 @@
<FilePath>..\..\..\..\Source\Component\LED_Driver\LED_Driver_V1.3.lib</FilePath>
</File>
<File>
<FileName>Maintenance.c</FileName>
<FileName>System_Monitor.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Component\Maintenance\Maintenance.c</FilePath>
<FilePath>..\..\..\..\Source\Component\System_Monitor\System_Monitor.c</FilePath>
</File>
<File>
<FileName>Maintenance.h</FileName>
<FileName>System_Monitor.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Component\Maintenance\Maintenance.h</FilePath>
<FilePath>..\..\..\..\Source\Component\System_Monitor\System_Monitor.h</FilePath>
</File>
<File>
<FileName>System_Monitor.c</FileName>
<FileName>Service_Interval.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Component\System_Monitor\System_Monitor.c</FilePath>
<FilePath>..\..\..\..\Source\Component\Service_Interval\Service_Interval.c</FilePath>
</File>
<File>
<FileName>System_Monitor.h</FileName>
<FileName>Service_Interval.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Component\System_Monitor\System_Monitor.h</FilePath>
<FilePath>..\..\..\..\Source\Component\Service_Interval\Service_Interval.h</FilePath>
</File>
<File>
<FileName>Service_Interval_User.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Component\Service_Interval\Service_Interval_User.c</FilePath>
</File>
<File>
<FileName>Service_Interval_User.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Component\Service_Interval\Service_Interval_User.h</FilePath>
</File>
</Files>
</Group>
......
......@@ -36,8 +36,9 @@ 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\system_monitor.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\service_interval.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\service_interval_user.__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"
......
......@@ -31,7 +31,8 @@
#include "TrmerM\TrmerM.h"
#include "RTC\RTE_RTC.h"
#include "AD\RTE_AD.h"
#include "Maintenance\Maintenance.h"
#include "Service_Interval\Service_Interval.h"
#include "Service_Interval\Service_Interval_User.h"
......
......@@ -494,6 +494,7 @@ void TYW_RESET_ODO(void)
{
ClearODO_Flag = 1;
Data_Mileage_Clear();
Service_Interval_First_Reset( ); /*保养*/
eeprom_WriteRecord(EEPROM_BLOCK_00, ( uint8_t * )&Clear_EE, 4);
eeprom_WriteRecord(EEPROM_BLOCK_01, ( uint8_t * )&Clear_EE, 4);
eeprom_WriteRecord(EEPROM_BLOCK_02, ( uint8_t * )&Clear_EE, 4);
......@@ -512,9 +513,16 @@ void TYW_RESET_ODO(void)
void Maintain_Reset_Service(void)
{
if((Get_Data_Maintenace_Interval_Processing() == 0) && (PageMenu != Page_Trip) && (PageMenu != Page_TCS) && (PageType == Page_Menu))
if((Get_SERVICE_WARNING_ForCan() == 1) && (PageMenu != Page_Trip) && (PageMenu != Page_TCS) && (PageType == Page_Menu))
{
Data_Maintenance_Interval_Reset();
if(Get_Interval_SetKm() == 5000)//0.1
{
Service_Interval_Second_Reset();
}
else
{
Service_Interval_SetKm(2000);
}
}
}
......
#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
#include "Components.h"
__align(4)
uint8_t DataMilleageBuf[Data_MEM_Block_Mileage];
uint8_t DataMilleageBuf[Data_MEM_Block_Mileage];
uint8_t DataODOBuf[Data_MEM_Block_ODO];
uint8_t DataTripBuf[Data_MEM_Block_Trip * EM_TRIP_MAX];
Mileage_t g_WriteMileage;
Mileage_t g_ReadMileage;
uint8_t odo_writeState;
uint8_t odo_readState;
extern uint32_t NVM_User_Settings_Service;
uint32_t Milleage_InitFlag = 0U;
/******************************************************************************
Function:Data_ODO_KL30Init
Description:
......@@ -97,14 +89,6 @@ 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);
}
Data_User_EEPROM_Read(EM_MenuData_Tcs_Val, TempBuf, 1u);
if (TempBuf[0u] == 0xFFFFFFFF)
{
......@@ -167,13 +151,13 @@ uint32_t Get_MileageInit_Status(void)
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_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;
// case EM_Maintenance_Firstflg:
// eeprom_ReadRecord(EEPROM_BLOCK_07, (uint8_t *)u32Data, u16Len * 4);
// break;
case EM_MenuData_Tcs_Val:
eeprom_ReadRecord(EEPROM_BLOCK_08, (uint8_t *)u32Data, u16Len * 4);
break;
......@@ -216,13 +200,13 @@ uint32_t Get_MileageInit_Status(void)
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_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;
// case EM_Maintenance_Firstflg:
// eeprom_WriteRecord(EEPROM_BLOCK_07, (uint8_t *)u32Data, u16Len * 4);
// break;
case EM_MenuData_Tcs_Val:
eeprom_WriteRecord(EEPROM_BLOCK_08, (uint8_t *)u32Data, u16Len * 1);
break;
......
......@@ -78,7 +78,7 @@ static void Power_KL30_Init(void)
// TimerM_PWM_CH_Output_init(TIMERM_COUNTER0, TIMERM_CHC, ActiveLevel_High);
// TimerM_PWM_CH_Output_init(TIMERM_COUNTER0, TIMERM_CHD, ActiveLevel_High);
TimerM_PWM_CH_Output_init(TIMERM_COUNTER1, TIMERM_CHB, ActiveLevel_High);
Service_Interval_User_KL30Init();
Telltales_Init();
Telltales_UserInit();
MenuData_Unit_Init();
......@@ -140,7 +140,7 @@ static void Power_Wakeup_Init(void)
Data_TPMS_KL15_WAKE_UP_Init();
RTE_DEEPSLEEP_GPIO_Interrupt_Enable(WAKEUP_KL15_In,Trigger_Rising);
FaultCode_Init();
Service_Interval_User_WakeupInit();
CAN_TX_Count_Init();
}
......
#include "Service_Interval.h"
/**
* @file Service_Interval.c
* @brief 保养里程
* @details 保养里程
* @author myliu
* @date 2022.05.15
* @version V1.0
* @copyright myliu
*/
typedef struct
{
Intlib_uint32_t Interval100m; /*设定的里程间隔 0.1km */
Intlib_uint32_t MilAfterReset; /*上次复位后里程值 0.1km */
Intlib_uint32_t IntervalDayEnable;
Intlib_uint32_t Interval1s; /*设定的时间间隔 100ms */
Intlib_uint32_t CurODO_100m; /*当前里程值 0.1km */
Intlib_uint32_t CurTimer_1s; /*已走动时间 100ms */
} DataIntervalCalc_t;
typedef struct
{
Intlib_uint32_t Flag; /*存储标志 7887A55A */
Intlib_uint32_t Interval100m; /*设定的里程间隔 0.1km */
Intlib_uint32_t Interval1s; /*设定的时间间隔 1s */
Intlib_uint32_t MilAfterReset; /*上次复位后里程值 0.1km */
Intlib_uint32_t TotalTimer; /*已走动时间 1s */
} DataIntervalSave_t;
static Int_PowerSts g_PowerSts_Cbk;
static Int_ReadODO g_ReadODO_Cbk;
static Int_EEPromWrite g_EEPromWrite_Cbk;
static Int_EEPromRead g_EEPromRead_Cbk;
static Intlib_uint32_t g_TimerCnt = 0u;
static Intlib_uint32_t g_InitCompleteFlag = 0u;
static DataIntervalCalc_t *g_IntervalCalc;
#pragma ghs section bss = ".myNonInitArea"
static Intlib_uint32_t g_ServiceMil100m;
static Intlib_uint32_t g_ServiceTimer1s;
#pragma ghs section bss = default
/**
* @brief 保养服务初始化函数,KL30调用
* @param[in] pMemSpace 此功能库需要的内存空间,大小为Data_MEM_Block_Maintain,此内存需在休眠唤醒后不丢失
* @param[in] pInitData 初始化数据,详见Maintain_Init_t
* @param[in] pFunc 回调函数,详见Maintain_Func_t
* @return 参数错误类型
*
* @warning 必须在EEPROM初始化之后调用
*
* @since 1.0.0
*/
void Service_Interval_KL30_Init(Intlib_uint8_t *pMemSpace, Maintain_Init_t *pInitData, Maintain_Func_t *pFunc)
{
DataIntervalSave_t DataIntervalSave;
g_PowerSts_Cbk = pFunc->PowerSts_Cbk;
g_ReadODO_Cbk = pFunc->ReadODO_Cbk;
g_EEPromWrite_Cbk = pFunc->EEPromWrite_Cbk;
g_EEPromRead_Cbk = pFunc->EEPromRead_Cbk;
if ( pMemSpace != Intlib_NULL )
{
g_IntervalCalc = ( DataIntervalCalc_t * )pMemSpace;
if ( pInitData != Intlib_NULL )
{
g_IntervalCalc->IntervalDayEnable = pInitData->IntervalDayEnable;
if ( g_EEPromRead_Cbk != Intlib_NULL )
{
g_EEPromRead_Cbk(( Intlib_uint32_t * )&DataIntervalSave, sizeof(DataIntervalSave_t) / 4);
if ( DataIntervalSave.Flag != 0x7887A55A )
{
g_IntervalCalc->Interval100m = pInitData->IntervalKm * 10;
g_IntervalCalc->MilAfterReset = g_ReadODO_Cbk( );
g_IntervalCalc->Interval1s = pInitData->IntervalDay * 24 * 60 * 60;
g_IntervalCalc->CurTimer_1s = 0u;
DataIntervalSave.Flag = 0x7887A55A;
DataIntervalSave.Interval100m = g_IntervalCalc->Interval100m;
DataIntervalSave.MilAfterReset = g_IntervalCalc->MilAfterReset;
DataIntervalSave.Interval1s = g_IntervalCalc->Interval1s;
DataIntervalSave.TotalTimer = g_IntervalCalc->CurTimer_1s;
if ( g_EEPromWrite_Cbk != Intlib_NULL )
{
g_EEPromWrite_Cbk(( Intlib_uint32_t * )&DataIntervalSave, sizeof(DataIntervalSave_t) / 4);
}
}
else
{
g_IntervalCalc->Interval100m = DataIntervalSave.Interval100m;
g_IntervalCalc->MilAfterReset = DataIntervalSave.MilAfterReset;
g_IntervalCalc->Interval1s = DataIntervalSave.Interval1s;
g_IntervalCalc->CurTimer_1s = DataIntervalSave.TotalTimer;
}
}
else
{
g_IntervalCalc->Interval100m = pInitData->IntervalKm * 10;
g_IntervalCalc->MilAfterReset = g_ReadODO_Cbk( );
g_IntervalCalc->Interval1s = pInitData->IntervalDay * 24 * 60 * 60;
g_IntervalCalc->CurTimer_1s = 0u;
}
}
}
g_TimerCnt = 0u;
g_InitCompleteFlag = 0x78875AA5ul;
}
/**
* @brief 保养服务初始化函数,唤醒时调用
* @param[in] pMemSpace 此功能库需要的内存空间,大小为Data_MEM_Block_Maintain,此内存需在休眠唤醒后不丢失
* @param[in] pFunc 回调函数,详见Maintain_Func_t
* @return 参数错误类型
*
* @warning 必须在EEPROM初始化之后调用
*
* @since 1.0.0
*/
void Service_Interval_Wakeup_Init(Intlib_uint8_t *pMemSpace, Maintain_Func_t *pFunc)
{
g_PowerSts_Cbk = pFunc->PowerSts_Cbk;
g_ReadODO_Cbk = pFunc->ReadODO_Cbk;
g_EEPromWrite_Cbk = pFunc->EEPromWrite_Cbk;
g_EEPromRead_Cbk = pFunc->EEPromRead_Cbk;
if ( pMemSpace != Intlib_NULL )
{
g_IntervalCalc = ( DataIntervalCalc_t * )pMemSpace;
}
g_TimerCnt = 0u;
g_InitCompleteFlag = 0x78875AA5ul;
}
/**
* @brief 保养里程计算函数,100ms任务调用
*
* @since 1.0.0
*/
void Service_Interval_Processing(void)
{
DataIntervalSave_t DataIntervalSave;
Intlib_uint32_t IntervalKm = 0;
if ( g_PowerSts_Cbk( ) == Int_PowerON )
{
if(g_IntervalCalc != Intlib_NULL)
{
g_IntervalCalc->CurODO_100m = g_ReadODO_Cbk( );
if ( g_IntervalCalc->CurODO_100m >= g_IntervalCalc->MilAfterReset )
{
IntervalKm = g_IntervalCalc->CurODO_100m - g_IntervalCalc->MilAfterReset;
}
else
{
IntervalKm = 0;
}
if ( g_IntervalCalc->Interval100m >= IntervalKm )
{
g_ServiceMil100m = g_IntervalCalc->Interval100m - IntervalKm;
}
else
{
g_ServiceMil100m = 0u;
}
if ( g_IntervalCalc->IntervalDayEnable )
{
if ( g_IntervalCalc->Interval1s >= g_IntervalCalc->CurTimer_1s )
{
g_ServiceTimer1s = g_IntervalCalc->Interval1s - g_IntervalCalc->CurTimer_1s;
}
else
{
g_ServiceTimer1s = 0u;
}
}
}
}
else
{
g_IntervalCalc->CurODO_100m = g_ReadODO_Cbk( );
if ( g_IntervalCalc->CurODO_100m >= g_IntervalCalc->MilAfterReset )
{
IntervalKm = g_IntervalCalc->CurODO_100m - g_IntervalCalc->MilAfterReset;
}
else
{
IntervalKm = 0;
}
if ( g_IntervalCalc->Interval100m >= IntervalKm )
{
g_ServiceMil100m = g_IntervalCalc->Interval100m - IntervalKm;
}
else
{
g_ServiceMil100m = 0u;
}
}
if ( g_IntervalCalc->IntervalDayEnable )
{
if((g_IntervalCalc->CurTimer_1s % 216000) == 0)
{
DataIntervalSave.Flag = 0x7887A55A;
DataIntervalSave.Interval100m = g_IntervalCalc->Interval100m;
DataIntervalSave.MilAfterReset = g_IntervalCalc->MilAfterReset;
DataIntervalSave.Interval1s = g_IntervalCalc->Interval1s;
DataIntervalSave.TotalTimer = g_IntervalCalc->CurTimer_1s;
g_EEPromWrite_Cbk(( Intlib_uint32_t * )&DataIntervalSave, sizeof(DataIntervalSave_t) / 4);
}
}
}
/**
* @brief 保养天数计算函数,100ms中断调用,如不支持此功能,可不调用
*
* @since 1.0.0
*/
void Service_Interval_TimerISR(void)
{
if ( g_InitCompleteFlag == 0x78875AA5ul )
{
if(g_IntervalCalc != Intlib_NULL)
{
if ( g_IntervalCalc->IntervalDayEnable ) /*配置为显示保养天数*/
{
g_TimerCnt++;
if ( g_TimerCnt >= 10 )
{
g_TimerCnt = 0u;
if ( g_IntervalCalc->CurTimer_1s <= 0xFFFFFFFFul )
{
g_IntervalCalc->CurTimer_1s++;
}
}
}
}
}
}
/**
* @brief 保养天数添加睡眠时间,请参数例程使用,如不支持此功能,可不调用
* Sleep之后停止计时 唤醒后 把这一阶段的时间差补正回来
*
* @since 1.0.0
*/
void Service_Interval_TimerSleepFix(Intlib_uint32_t FixTimer)
{
if ( g_InitCompleteFlag == 0x78875AA5ul )
{
if(g_IntervalCalc != Intlib_NULL)
{
if ( g_IntervalCalc->IntervalDayEnable )
{
if ( g_IntervalCalc->CurTimer_1s <= 0xFFFFFFFFul )
{
g_IntervalCalc->CurTimer_1s += (FixTimer / 10);
}
}
}
}
}
/**
* @brief 设置保养里程间隔,单位km
* @param[in] IntervalKm 保养里程间隔,单位km
*
* @since 1.0.0
*/
void Service_Interval_SetKm(Intlib_uint32_t IntervalKm)
{
DataIntervalSave_t DataIntervalSave;
if ( g_IntervalCalc != Intlib_NULL )
{
g_IntervalCalc->Interval100m = IntervalKm * 10;
g_IntervalCalc->MilAfterReset = g_ReadODO_Cbk( );
DataIntervalSave.Flag = 0x7887A55A;
DataIntervalSave.Interval100m = g_IntervalCalc->Interval100m;
DataIntervalSave.MilAfterReset = g_IntervalCalc->MilAfterReset;
if ( g_IntervalCalc->IntervalDayEnable )
{
DataIntervalSave.Interval1s = g_IntervalCalc->Interval1s;
DataIntervalSave.TotalTimer = g_IntervalCalc->CurTimer_1s;
}
else
{
DataIntervalSave.Interval1s = 0u;
DataIntervalSave.TotalTimer = 0u;
}
if ( g_EEPromWrite_Cbk != Intlib_NULL )
{
g_EEPromWrite_Cbk(( Intlib_uint32_t * )&DataIntervalSave, sizeof(DataIntervalSave_t) / 4);
}
}
}
Intlib_uint32_t Get_Interval_SetKm(void)
{
Intlib_uint32_t Temp = 0;
if(g_IntervalCalc != Intlib_NULL)
{
Temp = g_IntervalCalc->Interval100m;
}
else
{
Temp = 30000u;
}
return Temp;
}
/**
* @brief 设置保养天数间隔,单位天,每个月按30天计算,如不支持此功能,可不调用
* @param[in] IntervalDay 保养天数间隔,单位天
*
* @since 1.0.0
*/
void Service_Interval_SetDay(Intlib_uint32_t IntervalDay)
{
DataIntervalSave_t DataIntervalSave;
if ( g_IntervalCalc != Intlib_NULL )
{
g_IntervalCalc->CurTimer_1s = 0u;
g_IntervalCalc->Interval1s = IntervalDay * 24 * 60 * 60;
DataIntervalSave.Flag = 0x7887A55A;
DataIntervalSave.Interval100m = g_IntervalCalc->Interval100m;
DataIntervalSave.MilAfterReset = g_IntervalCalc->MilAfterReset;
DataIntervalSave.Interval1s = g_IntervalCalc->Interval1s;
DataIntervalSave.TotalTimer = g_IntervalCalc->CurTimer_1s;
if ( g_EEPromWrite_Cbk != Intlib_NULL )
{
g_EEPromWrite_Cbk(( Intlib_uint32_t * )&DataIntervalSave, sizeof(DataIntervalSave_t) / 4);
}
}
}
/**
* @brief 获取剩余保养里程,单位100m
* @return 剩余保养里程,单位100m
*
* @since 1.0.0
*/
Intlib_uint32_t Service_Interval_GetMil100m(void)
{
if((g_ServiceMil100m % 10) > 0)
{
return g_ServiceMil100m + 10u;
}
else
{
return g_ServiceMil100m;
}
}
/**
* @brief 获取剩余保养天数,单位天,如不支持此功能,可不调用
* @return 剩余保养天数,单位天
*
* @since 1.0.0
*/
Intlib_uint32_t Service_Interval_GetDay(void)
{
Intlib_uint32_t ServiceIntervalDay = 0u;
ServiceIntervalDay = (g_ServiceTimer1s / 60 / 60 / 24) + 1;
return ServiceIntervalDay;
}
#ifndef SERVICE_INTERVAL_H
#define SERVICE_INTERVAL_H
/*
Platform_32Bit
Platform_16Bit
*/
#ifdef Platform_16Bit
#define Intlib_uint8_t unsigned char
#define Intlib_uint16_t unsigned int
#define Intlib_uint32_t unsigned long
#else
#define Intlib_uint8_t unsigned char
#define Intlib_uint16_t unsigned short
#define Intlib_uint32_t unsigned int
#define Intlib_uint64_t unsigned long long
#endif
#ifndef Intlib_NULL
#define Intlib_NULL ( void * )0u
#endif /* NULL */
#define Int_PowerON 1u /**< 电源状态 KL15 ON */
#define Int_PowerOFF 0u /**< 电源状态 KL15 ON */
typedef Intlib_uint8_t (*Int_PowerSts)(void);
typedef Intlib_uint32_t (*Int_ReadODO)(void);
typedef void (*Int_EEPromWrite)(Intlib_uint32_t u32Data [], Intlib_uint16_t u16Len);
typedef void (*Int_EEPromRead)(Intlib_uint32_t u32Data [], Intlib_uint16_t u16Len);
typedef struct
{
Int_PowerSts PowerSts_Cbk; /**< 获取系统电源状态回调 */
Int_ReadODO ReadODO_Cbk; /**< 获取当前总计里程回调 */
Int_EEPromWrite EEPromWrite_Cbk; /**< 写EEPROM回调函数 */
Int_EEPromRead EEPromRead_Cbk; /**< 从EEPROM读取保养相关数据回调 */
} Maintain_Func_t;
typedef struct
{
Intlib_uint32_t IntervalDayEnable; /**< 保养天数功能使能,0:无此功能 1:使能 */
Intlib_uint32_t IntervalKm; /**< 系统设定的保养里程间隔,单位km,这里特指首次保养的里程间隔,如不区分首次,则为默认值 */
Intlib_uint32_t IntervalDay; /**< 系统设定的保养天数间隔,单位天,这里特指首次保养的天数间隔,如不区分首次,则为默认值 */
} Maintain_Init_t;
#define Data_MEM_Block_Maintain (( Intlib_uint8_t )32u) /**< 此功能库,需要的内存空间大小,此为最小值 */
void Service_Interval_KL30_Init(Intlib_uint8_t *pMemSpace, Maintain_Init_t *pInitData, Maintain_Func_t *pFunc);
void Service_Interval_Wakeup_Init(Intlib_uint8_t *pMemSpace, Maintain_Func_t *pFunc);
void Service_Interval_Processing(void);
void Service_Interval_TimerISR(void);
void Service_Interval_TimerSleepFix(Intlib_uint32_t FixTimer);
void Service_Interval_SetKm(Intlib_uint32_t IntervalKm);
void Service_Interval_SetDay(Intlib_uint32_t IntervalDay);
Intlib_uint32_t Service_Interval_GetMil100m(void);
Intlib_uint32_t Service_Interval_GetDay(void);
Intlib_uint32_t Get_Interval_SetKm(void);
#endif
#include "Service_Interval.h"
#include "Service_Interval_User.h"
uint8_t __attribute__((aligned(4))) DataMaintainBuf [ Data_MEM_Block_Maintain ];
static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len);
static void Service_Interval_Read_EEProm(uint32_t u32Data [], uint16_t u16Len);
void Service_Interval_User_KL30Init(void)
{
Maintain_Init_t InitData;
Maintain_Func_t Func;
InitData.IntervalDayEnable = 0;
//默认值
InitData.IntervalDay = 90;
InitData.IntervalKm = 500;
//回调函数
Func.PowerSts_Cbk = Common_Get_IG_Sts;
Func.ReadODO_Cbk = Data_ODO_Read;
Func.EEPromWrite_Cbk = Service_Interval_Write_EEProm;
Func.EEPromRead_Cbk = Service_Interval_Read_EEProm;
Service_Interval_KL30_Init(DataMaintainBuf, &InitData, &Func);
}
void Service_Interval_User_WakeupInit(void)
{
Maintain_Func_t Func;
//回调函数
Func.PowerSts_Cbk = Common_Get_IG_Sts;
Func.ReadODO_Cbk = Data_ODO_Read;
Func.EEPromWrite_Cbk = Service_Interval_Write_EEProm;
Func.EEPromRead_Cbk = Service_Interval_Read_EEProm;
Service_Interval_Wakeup_Init(DataMaintainBuf, &Func);
}
void Service_Interval_First_Reset(void)
{
Service_Interval_SetKm(500); // 500km
}
void Service_Interval_Second_Reset(void)
{
Service_Interval_SetKm(1000); // 1000km
}
static void Service_Interval_Write_EEProm(uint32_t u32Data [], uint16_t u16Len)
{
// uint32_t i = 0;
// uint32_t j = 1;
// uint32_t retryCnt = 0;
// r_eel_status_t status = R_EEL_BUSY;
// while ( status != R_EEL_OK )
// {
// if ( j == 1 )
// {
// j = 0;
// retryCnt++;
// status = Internal_EEL_Write(INTERNAL_EE_BLOCK_09, ( uint8_t * )u32Data, u16Len * 4);
// }
// else
// {
// i++;
// if ( i >= 100 )
// {
// i = 0;
// j = 1;
// }
// }
// if ( retryCnt > 3 )
// {
// break;
// }
// }
eeprom_WriteRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
}
static void Service_Interval_Read_EEProm(uint32_t u32Data [], uint16_t u16Len)
{
// uint32_t i = 0;
// r_eel_status_t status = R_EEL_BUSY;
// status = Internal_EEL_Read(INTERNAL_EE_BLOCK_09, ( uint8_t * )u32Data, u16Len * 4);
// if ( status != R_EEL_OK )
// {
// for ( i = 0; i < u16Len; i++ )
// {
// u32Data [ i ] = 0u;
// }
// }
eeprom_ReadRecord(EEPROM_BLOCK_05, (uint8_t *)u32Data, u16Len * 4);
}
uint32_t g_ServiceMil100m = 0;
uint8_t Get_SERVICE_WARNING_ForCan(void)
{
uint8_t Res;
uint32_t m_Condition_1;
m_Condition_1 = Service_Interval_GetMil100m();
g_ServiceMil100m = Service_Interval_GetMil100m();
if (m_Condition_1 <= 0u)
{
Res = 1u; /*87606-4*/
}
else
{
Res = 0u; /*87606-5*/
}
return Res;
}
#ifndef SERVICE_INTERVAL_USER_H
#define SERVICE_INTERVAL_USER_H
#include "Components.h"
void Service_Interval_User_KL30Init(void);
void Service_Interval_User_WakeupInit(void);
void Service_Interval_First_Reset(void);
void Service_Interval_Second_Reset(void);
void Service_Interval_WriteKm(uint32_t IntervalKm);
uint8_t Get_SERVICE_WARNING_ForCan(void);
#endif
......@@ -496,7 +496,7 @@ static void LED_Auto_Start_Execution(Tellib_uint16_t led_status)
static Tellib_uint16_t LED_Maintain_Judgement(void)
{
Tellib_uint16_t LED_STATE = 0u;
if(Get_Data_Maintenace_Interval_Processing() == 0)
if(Get_SERVICE_WARNING_ForCan() == 1)
{
LED_STATE = 1;
}
......
......@@ -88,6 +88,7 @@ void Sys_100ms_Tasks(void)
counter_val.time.RTC_Hours = RTC_Bcd2ToByte(counter_val.time.RTC_Hours);
counter_val.time.RTC_Minutes = RTC_Bcd2ToByte(counter_val.time.RTC_Minutes);
}
Service_Interval_Processing();
Fuel_Cal_Sevice(100u);
BackLight_Process();
Services_Mileage_Callback();
......
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