Commit c67bd76f authored by 高士达's avatar 高士达

feat:其他项目板子BU98驱动调试完成,待新板子到后调试

parent 6f94cc8b
......@@ -18,6 +18,7 @@
#include "Services_Mileage_User.h"
#include "U2_app_Service.h"
#include "System_Monitor.h"
#include "Services_Mileage.h"
#include "Flash_synchronizer.h"
......@@ -373,7 +374,7 @@ SEND_FAULT_END:
CopyData[6] = temp32>>8;
CopyData[7] = temp32&0xff;
}
extern uint8_t ModfyODORemainTimes;
/* extern uint8_t ModfyODORemainTimes; */
void Can_Set_Buff_522(uint8_t CopyData[])
{
uint32_t temp32 = 0;
......@@ -400,7 +401,7 @@ void Can_Set_Buff_522(uint8_t CopyData[])
CopyData[3] <<= 4;
CopyData[3] |= (temp32%10);
CopyData[4] |= ModfyODORemainTimes&0x0f;
/* CopyData[4] |= ModfyODORemainTimes&0x0f; */
temp16 = Common_Get_Disp_V_Speed();
if(temp16>1990) temp16=1990;
temp16 /= 10;
......
......@@ -4,7 +4,7 @@
#include "tim4.h"
#include "MCU_Core_Protocol.h"
#include "CAN_Communication_Matrix.h"
#include "SEG_LCD.h"
//static uint16_t VehSpeedBuf[3];
//static uint8_t VehSpeedCount;
......
#include "Services_Mileage_User.h"
#include "Common_Interface.h"
#include "eepromManage.h"
#include "Menus.h"
#include "CAN_Communication_Matrix.h"
#include "wdt.h"
uint32_t TotalODOTemp = 0;
uint16_t ODORemainder = 0;
Mileage_t g_WriteMileage __attribute__ ((aligned (4)));
Mileage_t g_ReadMileage __attribute__ ((aligned (4)));
uint8_t SaveODOValid = 0;
uint16_t odoVaild = 0;
uint8_t ModfyODORemainTimes = 0;
uint16_t ModfyODOTimeDelay_ms = 0;
#define EEPROM_BLOCK_00 0 //用来储存总计清零次数
#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
void Mileage_Delay_ms(uint32_t u32Ms)
{
uint32_t i, Counter;
for(Counter = 0; Counter < u32Ms; Counter++) {
for(i = 0; i < 44; i++) {
__NOP();
__NOP();
__NOP();
}
WDT_Restart();
}
}
void CalcODOKL30Init(void)
{
odoVaild = eeprom_ReadODO(&g_ReadMileage);
if(g_ReadMileage.Odo>= g_WriteMileage.Odo)
{
g_WriteMileage.Odo = g_ReadMileage.Odo;
}
if(g_ReadMileage.Trip>= g_WriteMileage.Trip)
{
g_WriteMileage.Trip = g_ReadMileage.Trip;
}
if(g_ReadMileage.Trip1>= g_WriteMileage.Trip1)
{
g_WriteMileage.Trip1 = g_ReadMileage.Trip1;
}
eeprom_ReadRecord(EEPROM_BLOCK_00,(uint8_t*)&ModfyODORemainTimes,1);
if(ModfyODORemainTimes == 0xff){
ModfyODORemainTimes = 3;
}
}
void CalcODOKL15Init(void)
{
SaveODOValid = 1;
}
void CalcODOIgnOffInit(void)
{
SaveODOValid = 1;
}
//=======================================
//+++++++50ms任务调度+++++++++++++++++
//
//根据车速计算里程数
//=======================================
void CalcODO_50ms_Services(void)
{
uint32_t mVspeed=0;
if(Common_Get_IG_Sts() == COMMON_POWER_OFF){
return;
}
mVspeed = Common_Get_Act_V_Speed();
if(mVspeed > 3600){
mVspeed = 3600;
}
TotalODOTemp += (mVspeed * 25) / 18; //50ms cycle
/*取余数*/
ODORemainder += (mVspeed * 25) % 18;
if(ODORemainder >= 18 )
{
ODORemainder -= 18;
TotalODOTemp ++;
}
if (TotalODOTemp > 10000)
{
TotalODOTemp -= 10000;
g_WriteMileage.Odo += 10;
if ((g_WriteMileage.Odo % 100) == 0)
{
SaveODOValid = 1;
}
g_WriteMileage.Trip += 10;
g_WriteMileage.Trip1 += 10;
if(Get_Unit_Setting() == Metric){
if (g_WriteMileage.Trip > 999999) { //999km999m
g_WriteMileage.Trip = 0;
}
if (g_WriteMileage.Trip1 > 999999) { //999km999m
g_WriteMileage.Trip1 = 0;
}
}
if(Get_Unit_Setting() == Imperial){
if (g_WriteMileage.Trip > 1609343) { //999mile999
g_WriteMileage.Trip = 0;
}
if (g_WriteMileage.Trip1 > 1609343) { //999mile999
g_WriteMileage.Trip1 = 0;
}
}
if (g_WriteMileage.Odo > 1609343999) { //999999mile
g_WriteMileage.Odo = 1609343999;
}
}
}
void CalcODO_100ms_Services(void)
{
uint8_t PwSts = 0;
uint32_t temp32 = 0;
static uint8_t clearEnFlag = 0;
static uint8_t TripClearCommandBak = 0;
if(odoVaild == 0)
{
/* qitiancun 防止上电读取失败 */
odoVaild = eeprom_ReadODO(&g_ReadMileage);
if(g_ReadMileage.Odo >= g_WriteMileage.Odo)
{
g_WriteMileage.Odo = g_ReadMileage.Odo;
}
if(g_ReadMileage.Trip>= g_WriteMileage.Trip)
{
g_WriteMileage.Trip = g_ReadMileage.Trip;
}
if(g_ReadMileage.Trip1>= g_WriteMileage.Trip1)
{
g_WriteMileage.Trip1 = g_ReadMileage.Trip1;
}
}
if (SaveODOValid) {
SaveODOValid = 0;
if(Common_Get_IG_Sts() == COMMON_POWER_ON) {
PwSts = 1;
}
else {
PwSts = 0;
}
eeprom_WriteODO( &g_WriteMileage , distance_100m , PwSts);
}
//厂家清大计,
//200km ODO以内,可以清除总里程,ODO可以改大,不能改小。
//两者共享次数为3次,仪表两次里程操作响应间隔时间为10s。触发后连发3次。
if(ModfyODOTimeDelay_ms >= 100){
ModfyODOTimeDelay_ms -= 100;
}
else{
if(ModfyODORemainTimes){
//0x01= 清零总里程(小于200km)
if((Get_ID_55C_Sig_ModifyODOSts() == 1) && (g_WriteMileage.Odo) && (g_WriteMileage.Odo < 200000)){
ModfyODOTimeDelay_ms = 10000;
g_WriteMileage.Odo = 0u;
g_WriteMileage.Trip = 0;
g_WriteMileage.Trip1 = 0;
TotalODOTemp = 0;
ModfyODORemainTimes--;
eeprom_ClearOdoSection();
Mileage_Delay_ms(40);
eeprom_WriteRecord(EEPROM_BLOCK_00,(uint8_t*)&ModfyODORemainTimes,1);
}
//0x02= 设置总里程(只能改大,改小不响应)
temp32 = Get_ID_55C_Sig_ModifyODOValue();
temp32 *= 100;
if((Get_ID_55C_Sig_ModifyODOSts() == 2) && (g_WriteMileage.Odo < temp32)){
ModfyODOTimeDelay_ms = 10000;
g_WriteMileage.Trip = 0;
g_WriteMileage.Trip1 = 0;
TotalODOTemp = 0;
ModfyODORemainTimes--;
for(uint32_t i=0; i<20; i++){
if(temp32 > i*100){
g_WriteMileage.Odo = temp32-((19-i)*100);
}
else{
g_WriteMileage.Odo = 0;
}
eeprom_WriteODO( &g_WriteMileage , distance_100m , 1);
Mileage_Delay_ms(20);
}
eeprom_WriteRecord(EEPROM_BLOCK_00,(uint8_t*)&ModfyODORemainTimes,1);
}
}
}
//TBOX控制清小计
temp32 = Get_ID_55C_Sig_ClearTrip();
//一定要判断数据发生变化再清一次,避免频繁写EEPROM
if((temp32 == 0) || (temp32 != TripClearCommandBak)){
clearEnFlag = 1;
}
if(clearEnFlag){
if(temp32 == 0x01){ //清零TRIPA
Data_Clear_Trip ( EM_TRIP_A );
clearEnFlag = 0;
}
else if(temp32 == 0x02){ //清零TRIPB
Data_Clear_Trip ( EM_TRIP_B );
clearEnFlag = 0;
}
else if(temp32 == 0x03){ //全部清零
Data_Clear_Trip ( EM_TRIP_A );
Data_Clear_Trip ( EM_TRIP_B );
clearEnFlag = 0;
}
}
TripClearCommandBak = temp32;
}
uint32_t Data_Read_Trip(DataTripEnum_t TripN)
{
uint32_t temp32 = 0;
if(TripN == EM_TRIP_A){
temp32 = g_WriteMileage.Trip;
}
else if(TripN == EM_TRIP_B){
temp32 = g_WriteMileage.Trip1;
}
return temp32;
}
uint32_t Data_ODO_Read ( void )
{
return g_WriteMileage.Odo;
}
void Data_Clear_Trip ( DataTripEnum_t TripN )
{
if(TripN == EM_TRIP_A){
g_WriteMileage.Trip = 0u;
g_WriteMileage.IsTripClear = 1;
}
else if(TripN == EM_TRIP_B){
g_WriteMileage.Trip1 = 0u;
g_WriteMileage.IsTrip1Clear = 1;
}
SaveODOValid = 1;
}
void Data_Mileage_Clear(void)
{
/*产线 清大计和flash校验使用*/
g_WriteMileage.Odo = 0u;
g_WriteMileage.Trip = 0;
g_WriteMileage.Trip1 = 0;
TotalODOTemp = 0;
ModfyODORemainTimes = 3;
eeprom_ClearOdoSection();
Mileage_Delay_ms(40);
eeprom_WriteRecord(EEPROM_BLOCK_00,(uint8_t*)&ModfyODORemainTimes,1);
}
#ifndef __SERVICE_MILEAGE_USER_H__
#define __SERVICE_MILEAGE_USER_H__
#include "common.h"
typedef unsigned char ee_uint8_t;
typedef unsigned short ee_uint16_t;
typedef unsigned int ee_uint32_t;
typedef enum
{
EM_TRIP_A,
EM_TRIP_B,
EM_TRIP_MAX,
} DataTripEnum_t;
void CalcODO_50ms_Services(void);
void CalcODO_100ms_Services(void);
void CalcODOKL30Init(void);
void CalcODOKL15Init(void);
void CalcODOIgnOffInit(void);
uint32_t Data_ODO_Read ( void );
uint32_t Data_Read_Trip(DataTripEnum_t TripN);
void Data_Clear_Trip ( DataTripEnum_t TripN );
void Data_Mileage_Clear(void);
#endif
#ifndef GUI_LCD_DIS_H
#define GUI_LCD_DIS_H
#endif
\ No newline at end of file
#ifndef _GUI_SEG_DIS_H_
#define _GUI_SEG_DIS_H_
#include "BU98R10.h"
#endif
#ifndef _GAUGES_H_
#define _GAUGES_H_
#include "SEG_LCD.h"
#include "Common_Interface.h"
/******************************************************************************
......
......@@ -8,7 +8,7 @@
#include "CalcFrequency.h"
#include "CAN_Communication_Matrix.h"
#include "Flash_synchronizer.h"
#include "Services_Mileage.h"
uint8_t MenuByte6 = 0;
uint8_t MenuByte7 = 0;
uint8_t MenuByte8 = 0;
......
......@@ -25,12 +25,12 @@
#include "U2_uds_includes.h"
#include "CAN_User.h"
#include "BU98R10.h"
#include "SEG_LCD.h"
#include "can.h"
#include "RTE_ADC.h"
#include "IS31FL3236.h"
#include "AW93015.h"
#include "Services_Mileage.h"
uint16_t g_sleepDelay = 0;
......@@ -44,11 +44,14 @@ void Power_KL30_Init ( void )
Fuel_KL30_Init();
CoolantTemp_KL30_Init();
// eeprom_StoreInfo_Init( );
// CalcODOKL30Init();
Data_Gear_KL30_Init();
//APP_CAN_Init();
//SEG_LCD_Init();
BU98R10_Init();
MenuKL30Init();
Data_User_Mileage_KL30Init();
}
......@@ -61,9 +64,11 @@ void Power_Sleep_Init(void)
Capture_Stop(39);
Capture_Stop(40);
Analog_Signal_Conv_Stop();
SEG_LCD_Shutdown();
IS31_Shutdown();
BU98R10_Shutdown();
GPIO_Init(GPIO_SLEEP_MODE );
INTC_DisableIRQ(LVI_IRQn );
INTC_DisableIRQ(INTP0_IRQn );
......@@ -200,9 +205,10 @@ void Power_Wakeup_Init ( void )
IS31_OFF_Wakeup();
IS31FL3236_Update();
Init93015_IIC();//4034
BU98R10_Init();
APP_CAN_Init();
IS31FL3236_Init();
Data_User_Mileage_WakeupInit();
}
......@@ -210,13 +216,6 @@ void Power_Wakeup_Init ( void )
void Power_IG_OFF_Init(void)
{
SEG_LCD_Vehicle_Speed_Num_Display(0, 0, 0);
SEG_LCD_Engine_Speed_Seg_Display(0, 0, 0);
SEG_LCD_ODO_Trip_Display(0, 0, 0, 0);
SEG_Fuel_Level_Display(0, 0);
SEG_LCD_Battery_Voltage_Display(0, 0 ,0);
SEG_LCD_Gear_Display(0, 0, 0);
SEG_Coolant_Temp_Display(0, 0);
Line_In_KL15_OFF_Init();
Common_Set_IG_Sts(COMMON_POWER_OFF);
......@@ -246,16 +245,15 @@ void Power_IG_ON_Init(void)
uart2_User_KL15_Init();
CalcFreq_KL15_Init();
APP_CAN_Init();
CalcODOKL15Init();
Common_Set_IG_Sts(COMMON_POWER_ON);
// UART2_Init(115200);
SEG_LCD_Init();
//IS31FL3236_Init();
Init93015_IIC(); // 4034
DtcFaultInit();
/*----------------------------------------*/
BatteryVoltageDelayInit();
Set_SEG_Check_Contrl(0);
}
void Power_IG_OVP_Init(void)
{
......
......@@ -25,36 +25,6 @@ typedef enum
} LED_Idx_t;
uint16_t LED_RIGHT_Judgement(void);
void LED_RIGHT_Execution(uint16_t led_status);
uint16_t LED_LEFT_Judgement(void);
void LED_LEFT_Execution(uint16_t led_status);
uint16_t LED_HI_BEAM_Judgement(void);
void LED_HI_BEAM_Execution(uint16_t led_status);
uint16_t LED_MIL_Judgement(void);
void LED_MIL_Execution(uint16_t led_status);
uint16_t LED_ABS_Judgement(void);
void LED_ABS_Execution(uint16_t led_status);
uint16_t LED_TSC_Judgement(void);
void LED_TSC_Execution(uint16_t led_status);
uint16_t LED_AutoStarStop_Judgement(void);
void LED_AutoStarStop_Execution(uint16_t led_status);
uint16_t LED_Batterylow_Judgement(void);
void LED_Batterylow_Execution(uint16_t led_status);
uint16_t LED_Auto_HI_BEAM_Judgement(void);
void LED_Auto_HI_BEAM_Execution(uint16_t led_status);
uint16_t LED_Shore_Judgement(void);
void LED_Shore_Execution(uint16_t led_status);
uint16_t LED_ENGINE_OIL_LOW_Judgement(void);
void LED_ENGINE_OIL_LOW_Execution(uint16_t led_status);
uint16_t LED_TPMS_Judgement(void);
void LED_TPMS_Execution(uint16_t led_status);
uint16_t LED_READY_Judgement(void);
void LED_READY_Execution(uint16_t led_status);
uint16_t LED_Fuel_Judgement(void);
void LED_Fuel_Execution(uint16_t led_status);
uint16_t LED_Temp_Judgement(void);
void LED_Temp_Execution(uint16_t led_status);
......
#ifndef _SEG_LCD_H_
#define _SEG_LCD_H_
#include "BU98R10.H"
/******************************************************************************
段码状态
******************************************************************************/
#define SEG_LCD_LIGHT 7
#define SEG_LCD_GRAY 1
#define SEG_LCD_GRAY_2 2
#define SEG_LCD_OFF 0
#define SEG_LCD_ON 255
/******************************************************************************
显示模式
******************************************************************************/
#define GUI_DISP_MODE_NORMAL 0x00 //正常
#define GUI_DISP_MODE_WARNING 0x01 //报警
#define GUI_DISP_MODE_NEGATIVE 0x01 //负数
#define GUI_DISP_MODE_BLANK 0x02 //空白
#define GUI_DISP_MODE_INVALID 0x03 //无效
/******************************************************************************
段码液晶显示数据备份结构
******************************************************************************/
typedef struct
{
uint8_t Brightness;
uint8_t Window;
uint8_t SetMode;
uint8_t VSpeedSeg;
uint8_t ESpeedSeg;
uint16_t VSpeed;
uint16_t ESpeed;
uint16_t Voltage;
uint8_t VolCANset;
uint8_t Gear;
uint8_t TempSeg;
uint8_t FuelSeg;
uint8_t ODOMode;
uint32_t ODOMileage;
uint8_t ODOUnit;
uint32_t ODOFaultCode;
}SEGLCDBackupStruct;
/******************************************************************************
图标状态寄存器SEGLCDIconxxxStatus位定义
================================================================
Bit 7 | SEG_LCD_ICON_FORCE | 强制显示标志
-------+-------------------------+------------------------------
Bit 6 | Rsvd. | 保留
-------+-------------------------+------------------------------
Bit 5 | Rsvd. | 保留
-------+-------------------------+------------------------------
Bit 4 | Rsvd. | 保留
-------+-------------------------+------------------------------
Bit 3 | Rsvd. | 保留
-------+-------------------------+------------------------------
Bit 2 | Rsvd. | 保留
-------+-------------------------+------------------------------
Bit 1 | SEG_LCD_ICON_FORCE_STAT | 强制显示状态 1-强制点亮 0-强制熄灭
-------+-------------------------+------------------------------
Bit 0 | SEG_LCD_ICON_STAT | 显示状态 1-点亮 0-熄灭
================================================================
******************************************************************************/
#define SEG_LCD_ICON_FORCE ((uint8_t)0x80)
#define SEG_LCD_ICON_FORCE_STAT ((uint8_t)0x02)
#define SEG_LCD_ICON_STAT ((uint8_t)0x01)
#define Clr_Bit(p, b) (p) &= (~(1u << (b)))
#define Set_Bit(p, b) (p) |= (1u << (b))
#define Bit_Is_Set(p, b) ((p) &(1u << (b)))
#define Bit_Is_Clr(p, b) (!((p) & (1u << (b))))
/******************************************************************************
Icon开关状态
******************************************************************************/
typedef enum
{
SEG_LCD_ICON_OFF = 0, //熄灭图标
SEG_LCD_ICON_ON, //点亮图标
SEG_LCD_ICON_FORCE_OFF, //强制熄灭图标,通过 SEG_LCD_ICON_OFF / SEG_LCD_ICON_ON 状态不能控制图标熄灭或点亮
SEG_LCD_ICON_FORCE_ON, //强制点亮图标,通过 SEG_LCD_ICON_OFF / SEG_LCD_ICON_ON 状态不能控制图标熄灭或点亮
SEG_LCD_ICON_FREE, //取消对图标的强制熄灭或点亮,将图标交由 SEG_LCD_ICON_OFF / SEG_LCD_ICON_ON 状态控制
}SEGLCDIconStatusEnum;
/**********************************************************************************
全局变量
***********************************************************************************/
extern SEGLCDBackupStruct SEGLCDBackup;
/******************************************************************************
函数声明
******************************************************************************/
void SEG_LCD_Init(void);
void SEG_LCD_Shutdown(void);
void SEG_LCD_Gear_Display(uint8_t m_Flag, uint8_t SegNum, uint8_t CanStand);
void SEG_LCD_Gear_Selftest(uint8_t Gear);
void SEG_LCD_Vehicle_Speed_Num_Display(uint8_t m_Flag, uint8_t SetMode, uint16_t Vspeed); //1:mph default:km/h
void SEG_LCD_Vehicle_Speed_Num_Selftest(uint16_t Vspeed);
void SEG_LCD_Engine_Speed_Seg_Display(uint8_t m_Flag, uint16_t SegNum, uint8_t SpeedStand);
void SEG_LCD_Engine_Speed_Seg_Selftest(uint16_t SegNum);
void SEG_LCD_ODO_Trip_Display(uint8_t m_Flag, uint8_t Mode, uint8_t Unit, uint32_t Mileage);
void SEG_LCD_FaultCode_Display(uint8_t m_Flag, uint32_t FaultCodeDisp);
void SEG_LCD_ODO_Trip_FaultCode_Selftest(uint8_t Mileage);
void SEG_LCD_BatteryErr_Display(uint8_t m_Flag, uint32_t ModeTime);
void SEG_Coolant_Temp_Display(uint8_t m_Flag, uint8_t Seg);
void SEG_Fuel_Level_Display(uint8_t m_Flag, uint8_t Seg);
void SEG_LCD_Battery_Voltage_Display(uint8_t m_Flag, uint8_t Voltage ,uint16_t VolCANset);
void SEG_LCD_Battery_Voltage_Selftest(uint8_t Voltage);
//Light
void SEG_LCD_OilPressure(uint8_t state);
void SEG_LCD_TirePressure(uint8_t state);
void SEG_LCD_READY(uint8_t state);
void SEG_LCD_ABS(uint8_t state);
void SEG_LCD_TSC(uint8_t state);
void SEG_LCD_AutoStarStop(uint8_t state);
void SEG_LCD_Batterylow(uint8_t state);
void SEG_LCD_HI_BEAM(uint8_t state);
void SEG_LCD_Shore(uint8_t state);
void SEG_LCD_OBD(uint8_t state);
void SEG_LCD_HighBeam(uint8_t state);
void SEG_LCD_LeftTurn(uint8_t state);
void SEG_LCD_RightTurn(uint8_t state);
void SEG_LCD_Fuel(uint8_t state);
void SEG_LCD_Temp(uint8_t state);
void Engine_Speed_Update(void);
#endif
#include "BU98R10.h"
#include "SEG_LCD.h"
#include "IS31FL3236.h"
/* 端口寄存器基地址 */
......
This diff is collapsed.
......@@ -23,12 +23,11 @@
#include "clk.h"
#include "rtc.h"
#include "can.h"
#include "SEG_LCD.h"
#include "eeManager_Interface.h"
#include "Services_Mileage_User.h"
#include "IS31_IIC_Master.h"
#include "IS31FL3236.h"
#include "Services_Mileage.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
......@@ -101,13 +100,6 @@ void Sys_Startup_Init(void)
Simulated_IIC_2_Init();
IS31FL3236_Init();
SEG_LCD_Init();
SEG_LCD_Vehicle_Speed_Num_Display(0, 0, 0);
SEG_LCD_Engine_Speed_Seg_Display(0, 0, 0);
SEG_LCD_ODO_Trip_Display(0, 0, 0, 0);
SEG_Fuel_Level_Display(0, 0);
SEG_LCD_Battery_Voltage_Display(0, 0 ,0);
SEG_LCD_Gear_Display(0, 0, 0);
Sys_Tick_Timer_Start();
......@@ -124,7 +116,7 @@ void Sys_Startup_Init(void)
Power_Management_Init(0u);
bsp_CAN_Init();
eeprom_StoreInfo_Init( ); //20221028
CalcODOKL30Init();
}
......
This diff is collapsed.
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