Commit 6a7302aa authored by 李俭双's avatar 李俭双

Merge branch 'lijianshuang' into 'dev'

Lijianshuang

See merge request !24
parents 90633f28 41d98451
......@@ -18,7 +18,7 @@ User definitions
typedef unsigned short MD_STATUS;
#define HAS_BOOTLOADER (1u) // 仅仿真App时设置为0
#define HAS_BOOTLOADER (0u) // 仅仿真App时设置为0
#define APP_BASE (0x00008000ul)
/* Status list definition */
......
......@@ -275,7 +275,7 @@
</OCR_RVCT3>
<OCR_RVCT4>
<Type>1</Type>
<StartAddress>0x8000</StartAddress>
<StartAddress>0x0</StartAddress>
<Size>0x40000</Size>
</OCR_RVCT4>
<OCR_RVCT5>
......@@ -543,6 +543,46 @@
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Application\Data_Voltage\Data_Voltage.h</FilePath>
</File>
<File>
<FileName>BlueTooth.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\BlueTooth.c</FilePath>
</File>
<File>
<FileName>BlueTooth.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\BlueTooth.h</FilePath>
</File>
<File>
<FileName>Protocol_CRC16.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\Protocol_CRC16.c</FilePath>
</File>
<File>
<FileName>Protocol_CRC16.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\Protocol_CRC16.h</FilePath>
</File>
<File>
<FileName>Protocol_Lib.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\Protocol_Lib.c</FilePath>
</File>
<File>
<FileName>Protocol_Lib.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\Protocol_Lib.h</FilePath>
</File>
<File>
<FileName>Protocol_User.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\Protocol_User.c</FilePath>
</File>
<File>
<FileName>Protocol_User.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Application\BLUETOOTH\Protocol_User.h</FilePath>
</File>
</Files>
</Group>
<Group>
......@@ -818,6 +858,11 @@
<FileType>5</FileType>
<FilePath>..\..\..\..\Source\Component\Maintenance\Maintenance.h</FilePath>
</File>
<File>
<FileName>System_Monitor.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\..\..\Source\Component\System_Monitor\System_Monitor.c</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
......@@ -18,6 +21,10 @@ SET CPU_CLOCK=0x00B71B00
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\data_tpms.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\faultcode.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\data_voltage.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\bluetooth.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\protocol_crc16.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\protocol_lib.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\protocol_user.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\bu98r10.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\services_mileage_user.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\eemanager_interface.__i"
......@@ -32,6 +39,7 @@ SET CPU_CLOCK=0x00B71B00
"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_1.__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"
......@@ -71,7 +79,7 @@ SET CPU_CLOCK=0x00B71B00
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\tima.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\timb.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\timm.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\uart_1.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\uart.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\wdt.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\isr.__i"
"C:\Keil_v5\ARM\ARMCC\Bin\ArmCC" --Via ".\objects\docan_iso15765.__i"
......
......@@ -18,6 +18,8 @@
#include "Data_TPMS/Data_TPMS.h"
#include "Data_Voltage/Data_Voltage.h"
#include "FaultCode/FaultCode.h"
#include "BLUETOOTH/BlueTooth.h"
#include "BLUETOOTH/Protocol_CRC16.h"
#include "BLUETOOTH/Protocol_Lib.h"
#include "BLUETOOTH/Protocol_User.h"
#endif
#include "BlueTooth.h"
BlueTooth_t BlueTooth;
uint8_t UUIDData[32] = {"tywtywtywtywtywtywtywtywtywtyw03"};
void BlueTooth_KL30_KL15_Wakeup_Init(void)
{
BlueTooth.BLE_St = BLUE_STATE_Starting;
BlueTooth.Navigation_St = EM_ESP32_NAVI_ST_STANDBY;
BlueTooth.Navigation_Code = 0;
BlueTooth.Navigation_Mileage = 0;
}
void Send_UUID_To_Esp32(void)
{
Protocol_Send(MCU_ESP32_0x03, UUIDData, 32);
}
uint8_t Get_Navigation_St_Dis(void)
{
return BlueTooth.Navigation_St;
}
uint8_t Get_Navigation_Code_Dis(void)
{
return BlueTooth.Navigation_Code;
}
uint32_t Get_Navigation_Mileage_Dis(void)
{
return BlueTooth.Navigation_Mileage;
}
\ No newline at end of file
#ifndef __BLUE_TOOTH_H_
#define __BLUE_TOOTH_H_
#include "Protocol_Lib.h"
#include <stdio.h>
#include <stdint.h>
#include "Components.h"
#include "Application.h"
#define ESP32_MCU_0x10 0x10 //蓝牙模组启动发送ID
#define MCU_ESP32_0x20 0x20 //蓝牙模组启动后,MCU回复ID
#define ESP32_MCU_0x01 0x01 //ESP32发送蓝牙导航信息的ID
#define ESP32_MCU_0x12 0x12 //低功耗蓝牙启动状态及蓝牙名称
#define MCU_ESP32_0x03 0x03 //MCU发送UUID
enum
{
BLUE_STATE_Starting, //蓝牙模组启动中
BLUE_STATE_ON, //蓝牙模组启动完成
BLUE_STATE_OFF,
};
typedef struct __attribute__((aligned(4)))
{
uint8_t BlueTooth_St; /*蓝牙模组启动状态 0启动中 1启动完成*/
uint8_t Navigation_St;/*导航状态 0x35 未导航或导航结束 0x33 正在导航*/
uint8_t Navigation_Code;/*蓝牙导向编码*/
uint32_t Navigation_Mileage;/*剩余里程*/
uint8_t BLE_St;
} BlueTooth_t;
typedef enum __attribute__((aligned(4)))
{
EM_ESP32_BT_STARTUP_ST_STANDBY = 0,
EM_ESP32_BT_STARTUP_ST_SUCCESS,
} EM_ESP32_BT_STARTUP_ST_T;
typedef enum __attribute__((aligned(4)))
{
EM_ESP32_NAVI_ST_STANDBY = 0,
EM_ESP32_NAVI_ST_NAVIGATING,
} EM_ESP32_NAVI_ST_T;
typedef struct __attribute__((aligned(4)))
{
EM_ESP32_BT_STARTUP_ST_T Startup;
EM_ESP32_NAVI_ST_T NaviSt;
uint8_t NaviCode;
uint8_t BlueToothConnectSt;
uint32_t NaviMileage;
uint8_t BlueName[6];
} ESP32_COMM_INFO_T;
extern BlueTooth_t BlueTooth;
uint8_t Get_Navigation_St_Dis(void);
uint8_t Get_Navigation_Code_Dis(void);
uint32_t Get_Navigation_Mileage_Dis(void);
void Send_UUID_To_Esp32(void);
void BlueTooth_KL30_KL15_Wakeup_Init(void);
#endif
/**
* @file Protocol_CRC16.c
* @brief CRC16计算
* @details CRC16计算
* @author myliu
* @date 2022.05.09
* @version V1.0
* @copyright myiu
*/
#include "Protocol_CRC16.h"
static const Protocol_uint8_t CRC16_TAB_H [ 256 ] = {0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x01u, 0xC0u, 0x80u, 0x41u, 0x00u, 0xC1u, 0x81u, 0x40u};
static const Protocol_uint8_t CRC16_TAB_L [ 256 ] = {0x00u, 0xC0u, 0xC1u, 0x01u, 0xC3u, 0x03u, 0x02u, 0xC2u, 0xC6u, 0x06u, 0x07u, 0xC7u, 0x05u, 0xC5u, 0xC4u, 0x04u, 0xCCu, 0x0Cu, 0x0Du, 0xCDu, 0x0Fu, 0xCFu, 0xCEu, 0x0Eu, 0x0Au, 0xCAu, 0xCBu, 0x0Bu, 0xC9u, 0x09u, 0x08u, 0xC8u, 0xD8u, 0x18u, 0x19u, 0xD9u, 0x1Bu, 0xDBu, 0xDAu, 0x1Au, 0x1Eu, 0xDEu, 0xDFu, 0x1Fu, 0xDDu, 0x1Du, 0x1Cu, 0xDCu, 0x14u, 0xD4u, 0xD5u, 0x15u, 0xD7u, 0x17u, 0x16u, 0xD6u, 0xD2u, 0x12u, 0x13u, 0xD3u, 0x11u, 0xD1u, 0xD0u, 0x10u, 0xF0u, 0x30u, 0x31u, 0xF1u, 0x33u, 0xF3u, 0xF2u, 0x32u, 0x36u, 0xF6u, 0xF7u, 0x37u, 0xF5u, 0x35u, 0x34u, 0xF4u, 0x3Cu, 0xFCu, 0xFDu, 0x3Du, 0xFFu, 0x3Fu, 0x3Eu, 0xFEu, 0xFAu, 0x3Au, 0x3Bu, 0xFBu, 0x39u, 0xF9u, 0xF8u, 0x38u, 0x28u, 0xE8u, 0xE9u, 0x29u, 0xEBu, 0x2Bu, 0x2Au, 0xEAu, 0xEEu, 0x2Eu, 0x2Fu, 0xEFu, 0x2Du, 0xEDu, 0xECu, 0x2Cu, 0xE4u, 0x24u, 0x25u, 0xE5u, 0x27u, 0xE7u, 0xE6u, 0x26u, 0x22u, 0xE2u, 0xE3u, 0x23u, 0xE1u, 0x21u, 0x20u, 0xE0u, 0xA0u, 0x60u, 0x61u, 0xA1u, 0x63u, 0xA3u, 0xA2u, 0x62u, 0x66u, 0xA6u, 0xA7u, 0x67u, 0xA5u, 0x65u, 0x64u, 0xA4u, 0x6Cu, 0xACu, 0xADu, 0x6Du, 0xAFu, 0x6Fu, 0x6Eu, 0xAEu, 0xAAu, 0x6Au, 0x6Bu, 0xABu, 0x69u, 0xA9u, 0xA8u, 0x68u, 0x78u, 0xB8u, 0xB9u, 0x79u, 0xBBu, 0x7Bu, 0x7Au, 0xBAu, 0xBEu, 0x7Eu, 0x7Fu, 0xBFu, 0x7Du, 0xBDu, 0xBCu, 0x7Cu, 0xB4u, 0x74u, 0x75u, 0xB5u, 0x77u, 0xB7u, 0xB6u, 0x76u, 0x72u, 0xB2u, 0xB3u, 0x73u, 0xB1u, 0x71u, 0x70u, 0xB0u, 0x50u, 0x90u, 0x91u, 0x51u, 0x93u, 0x53u, 0x52u, 0x92u, 0x96u, 0x56u, 0x57u, 0x97u, 0x55u, 0x95u, 0x94u, 0x54u, 0x9Cu, 0x5Cu, 0x5Du, 0x9Du, 0x5Fu, 0x9Fu, 0x9Eu, 0x5Eu, 0x5Au, 0x9Au, 0x9Bu, 0x5Bu, 0x99u, 0x59u, 0x58u, 0x98u, 0x88u, 0x48u, 0x49u, 0x89u, 0x4Bu, 0x8Bu, 0x8Au, 0x4Au, 0x4Eu, 0x8Eu, 0x8Fu, 0x4Fu, 0x8Du, 0x4Du, 0x4Cu, 0x8Cu, 0x44u, 0x84u, 0x85u, 0x45u, 0x87u, 0x47u, 0x46u, 0x86u, 0x82u, 0x42u, 0x43u, 0x83u, 0x41u, 0x81u, 0x80u, 0x40u};
/**
* 获取CRC16校验和
*/
/**
* @brief 计算传入数据的CRC16
* @param[in] pData 计算的数据内容
* @param[in] len 计算的数据长度
*
* @return 校验和
*
* @since 1.0.0
*/
Protocol_uint16_t getCheckSum(const Protocol_uint8_t *pData, int len)
{
Protocol_uint8_t u8_crc_h = 0xFFu;
Protocol_uint8_t u8_crc_l = 0xFFu;
Protocol_uint8_t u8_index = 0u;
Protocol_uint8_t i = 0u;
Protocol_uint16_t re_value;
while ( len-- )
{
u8_index = u8_crc_h ^ (pData [ i++ ]);
u8_crc_h = u8_crc_l ^ CRC16_TAB_H [ u8_index ];
u8_crc_l = CRC16_TAB_L [ u8_index ];
}
re_value = ( Protocol_uint16_t )u8_crc_h << 8u;
re_value |= u8_crc_l;
return re_value;
}
#ifndef PROTOCOL_CRC16_H
#define PROTOCOL_CRC16_H
//#include "Application.h"
#include "Protocol_Lib.h"
#include <stdio.h>
#include <stdint.h>
Protocol_uint16_t getCheckSum(const Protocol_uint8_t *pData, int len);
#endif
/**
* @file Protocol_Lib.c
* @brief 串口协议解析
* @details 串口协议解析
* @author myliu
* @date 2022.05.09
* @version V1.0
* @copyright myiu
*/
#include <stdio.h>
#include <string.h>
#include "Protocol_Lib.h"
static UARTOpen UARTOpen_Cbk;
static UARTSend UARTSend_Cbk;
static UARTRead UARTRead_Cbk;
static ProcParse ProcParseCbk;
static UARTClose UARTClose_Cbk;
static ProtocolSetData ProtocolSetData_Cbk;
static Protocol_uint8_t *mDataBufPtr = Protocol_NULL;
static Protocol_uint16_t mDataBufLen = 0;
static Protocol_uint32_t DataBufMaxLen = 0;
//#define DEBUG_PRO_DATA 0
/**
* @brief 初始化函数
* @param[in] pMemSpace 分配给协议库的内存空间,用来缓存串口数据
* @param[in] MemLen 分配的内存空间大小
* @param[in] pFunc 回调函数,包括串口打开、发送、读取、关闭,也包括解析后数据回传
* @param[in] ProcParseCbk 此回调函数,返回数据从FrameNo开始到CRC16之前,和ProtocolSetData_Cbk二选一
* @param[in] ProtocolSetData_Cbk 此回调函数,返回数据区分命令字、电源状态等,和ProcParseCbk二选一,详见结构体Protocol_Data_t
*
* @warning 此函数KL30和Wakeup都要调用,否则未分配内存,功能不好使,也有可能造成野指针复位
*
* @since 1.0.0
*/
void Protocol_Init(Protocol_uint8_t *pMemSpace, Protocol_uint32_t MemLen, Protocol_Func_t *pFunc)
{
mDataBufPtr = pMemSpace;
DataBufMaxLen = MemLen;
UARTOpen_Cbk = pFunc->UARTOpen_Cbk;
UARTSend_Cbk = pFunc->UARTSend_Cbk;
UARTRead_Cbk = pFunc->UARTRead_Cbk;
ProcParseCbk = pFunc->ProcParseCbk;
UARTClose_Cbk = pFunc->UARTClose_Cbk;
ProtocolSetData_Cbk = pFunc->ProtocolSetData_Cbk;
if ( UARTOpen_Cbk != Protocol_NULL )
{
UARTOpen_Cbk( );
}
return;
}
/**
* @brief 串口协议服务函数,包括读取数据,解析数据,如在外部读取数据,可不调用此函数
*
* @warning 此函数可自定义周期调用,建议20ms周期调用,最大不可超过协议的最小发送周期
*
* @since 1.0.0
*/
void Protocol_Service(void)
{
int len;
Protocol_uint32_t readNum = 0;
if ( UARTRead_Cbk != Protocol_NULL )
{
readNum = UARTRead_Cbk(mDataBufPtr + mDataBufLen, 256 - mDataBufLen);
if ( readNum > 0 )
{
mDataBufLen += readNum;
// 解析协议
len = Protocol_Parse(mDataBufPtr, mDataBufLen);
if ( (len > 0) && (len < mDataBufLen) )
{
// 将未解析的数据移到头部
// Move unparsed data to the head
memcpy(mDataBufPtr, mDataBufPtr + len, mDataBufLen - len);
}
mDataBufLen -= len;
}
}
}
/**
* @brief 协议解析函数,如外部获取数据(例如中断),可直接调用此函数解析数据
* @param[in] pData 协议数据内容
* @param[in] len 需要处理的协议数据长度
*
* @return 剩余已处理的数据长度
*
* @since 1.0.0
*/
Protocol_uint32_t Protocol_Parse(const Protocol_uint8_t *pData, Protocol_uint32_t len)
{
Protocol_uint32_t remainLen = len; // 剩余数据长度 Remaining data length
Protocol_uint32_t dataLen; // 数据包长度 Packet length
Protocol_uint32_t frameLen; // 帧长度 Frame length
Protocol_uint32_t frameSum;
Protocol_Data_t ProcData;
int i = 0;
int dataBuf [ 256 ];
/**
* 以下部分需要根据协议格式进行相应的修改,解析出每一帧的数据
*/
while ( remainLen >= DATA_PACKAGE_MIN_LEN )
{
// 找到一帧数据的数据头
// Find the data header of a frame of data
while ( (remainLen >= 2) && ((pData [ 0 ] != CMD_HEAD1) || (pData [ 1 ] != CMD_HEAD2)) )
{
pData++;
remainLen--;
continue;
}
if ( remainLen < DATA_PACKAGE_MIN_LEN )
{
#ifdef DEBUG_PRO_DATA
d_printf("too short!!!!!!\n");
#endif
break;
}
dataLen = pData [ 2 ];
frameLen = dataLen + DATA_PACKAGE_FIXED_LEN;
if ( frameLen > remainLen )
{
// 数据内容不全
#ifdef DEBUG_PRO_DATA
d_printf("Incomplete data packet!!!!!!\n");
#endif
break;
}
// 打印一帧数据,需要时在CommDef.h文件中打开DEBUG_PRO_DATA宏
#ifdef DEBUG_PRO_DATA
for ( i = 0; i < frameLen; ++i )
{
d_printf("%x ", pData [ i ]);
}
d_printf("\n");
#endif
// 检测校验码 Checksum
frameSum = (pData [ frameLen - 2 ] << 8) | (pData [ frameLen - 1 ]);
if ( frameLen > 4 )
{
if ( getCheckSum(pData + 2, frameLen - 4) == frameSum )
{
// 解析一帧数据
if ( ProcParseCbk != Protocol_NULL )
{
ProcParseCbk(pData + 3, dataLen - 2);
}
if ( ProtocolSetData_Cbk != Protocol_NULL )
{
ProcData.FrameNo = pData [ 3 ];
ProcData.PowerSts = (pData [ 4 ] >> 6) & 0x03;
ProcData.CmdID = pData [ 4 ] & 0x3F;
if ( ProcData.CmdID == 0x10 )
{
#ifdef DEBUG_PRO_DATA
for ( i = 0; i < frameLen; ++i )
{
d_printf("%x ", pData [ i ]);
}
d_printf("\n");
#endif
}
if ( ProcData.CmdID == 0x12 )
{
#ifdef DEBUG_PRO_DATA
for ( i = 0; i < frameLen; ++i )
{
d_printf("%x ", pData [ i ]);
}
d_printf("\n");
#endif
}
ProcData.DataLen = dataLen - 4;
memcpy(ProcData.Data, pData + 5, ProcData.DataLen);
ProtocolSetData_Cbk(&ProcData);
}
}
else
{
for ( i = 0; i < frameLen; ++i )
{
// dataBuf [ i ] = pData [ i ];
}
i = 0;
#ifdef DEBUG_PRO_DATA
d_printf("CheckSum error: new = %x, old = %x!!!!!!\n", getCheckSum(pData + 2, frameLen - 4), frameSum);
#endif
}
}
pData += frameLen;
remainLen -= frameLen;
}
return len - remainLen;
}
/**
* 根据协议格式进行拼接
*/
/**
* @brief 串口协议数据拼接,如初始化发送函数,调用此函数后,数据已通过串口发送
* @param[in] cmdID 命令字
* @param[in] pData 协议数据内容(不包括协议头、长度、帧序号、命令字、校验和,从数据域算起)
* @param[in] len 数据域长度
*
* @return 已发送的数据长度
*
* @since 1.0.0
*/
Protocol_uint32_t Protocol_Send(const Protocol_uint16_t cmdID, const Protocol_uint8_t *pData, Protocol_uint8_t len)
{
int i = 0;
Protocol_uint16_t checksum = 0;
Protocol_uint8_t dataBuf [ 256 ];
Protocol_uint32_t frameLen;
if ( len + DATA_PACKAGE_MIN_LEN > 256 )
{
// printf("sendProtocol data is too len !!!\n");
return 0;
}
dataBuf [ 0 ] = CMD_HEAD1;
dataBuf [ 1 ] = CMD_HEAD2; // 同步帧头 Sync frame header
dataBuf [ 2 ] = len + 4;
dataBuf [ 3 ] = 0; // 命令字节 Command byte
dataBuf [ 4 ] = ( Protocol_uint8_t )cmdID;
frameLen = 5;
// 数据 Data
for ( i = 0; i < len; ++i )
{
dataBuf [ frameLen ] = pData [ i ];
frameLen++;
}
// 校验码 Checksum
checksum = getCheckSum(dataBuf + 2, frameLen - 2);
dataBuf [ frameLen ] = (checksum >> 8) & 0x00FF;
frameLen++;
dataBuf [ frameLen ] = checksum & 0x00FF;
frameLen++;
if ( UARTSend_Cbk != Protocol_NULL )
{
return UARTSend_Cbk(dataBuf, frameLen);
}
else
{
return 0;
}
}
#ifndef PROTOCOL_LIB_H
#define PROTOCOL_LIB_H
/*
Platform_32Bit
Platform_16Bit
*/
#ifdef Platform_16Bit
#define Protocol_uint8_t unsigned char
#define Protocol_uint16_t unsigned int
#define Protocol_uint32_t unsigned long
#else
#define Protocol_uint8_t unsigned char
#define Protocol_uint16_t unsigned short
#define Protocol_uint32_t unsigned int
#define Protocol_uint64_t unsigned long long
#endif
#ifndef Protocol_NULL
#define Protocol_NULL ( void * )0u
#endif /* NULL */
/**<0xEB 0x90 长度 帧序号 命令字 DATA0-DATAN CRC16_1 CRC16_2*/
#define DATA_PACKAGE_MIN_LEN 7 /**< 0xEB 0x90 + 长度 + 数据包序号 + CMDID + CRC16_1 + CRC16_2 */
#define DATA_PACKAGE_FIXED_LEN 3 /**< 未计算在长度内的数据 0xEB 0x90 + 长度位 */
#define CMD_HEAD1 0xEB
#define CMD_HEAD2 0x90
/**@struct Protocol_Data_t
* @brief 解析后的协议数据
*/
typedef struct __attribute__((aligned(4)))
{
Protocol_uint8_t FrameNo; /**< 帧序号 */
Protocol_uint8_t PowerSts; /**< 电源状态 */
Protocol_uint8_t CmdID; /**< 命令字 */
Protocol_uint8_t DataLen; /**< 有效数据长度 DATA0-DATAN*/
Protocol_uint8_t Data [ 256 ]; /**< 有效数据内容 DATA0-DATAN*/
} Protocol_Data_t;
typedef Protocol_uint8_t (*UARTOpen)(void);
typedef Protocol_uint32_t (*UARTSend)(const Protocol_uint8_t *pData, Protocol_uint32_t u32Len);
typedef Protocol_uint32_t (*UARTRead)(Protocol_uint8_t *pData, Protocol_uint32_t u32Len);
typedef void (*ProtocolSetData)(const Protocol_Data_t *pData);
typedef void (*ProcParse)(const Protocol_uint8_t *pData, Protocol_uint32_t u32Len);
typedef void (*UARTClose)(void);
/**@struct Protocol_Func_t
* @brief 协议解析回调函数
*/
typedef struct __attribute__((aligned(4)))
{
UARTOpen UARTOpen_Cbk; /**< 串口打开回调 */
UARTSend UARTSend_Cbk; /**< 串口发送回调 */
UARTRead UARTRead_Cbk; /**< 串口读取回调 */
UARTClose UARTClose_Cbk; /**< 串口关闭回调 */
ProcParse ProcParseCbk; /**< 解析后的数据, 处理了数据包序号,命令字和电源状态,和ProcParse二选一 */
ProtocolSetData ProtocolSetData_Cbk; /**< 不包含 0xEB 0x90 + 长度 + CRC16_1 + CRC16_2,和ProtocolSetData二选一 */
} Protocol_Func_t;
void Protocol_Init(Protocol_uint8_t *pMemSpace, Protocol_uint32_t MemLen, Protocol_Func_t *pFunc);
void Protocol_Service(void);
Protocol_uint32_t Protocol_Parse(const Protocol_uint8_t *pData, Protocol_uint32_t len);
Protocol_uint32_t Protocol_Send(const Protocol_uint16_t cmdID, const Protocol_uint8_t *pData, Protocol_uint8_t len);
#endif
#include "Protocol_User.h"
#include "RTE.h"
#define UART_TX_MAX_DEPTH 1024UL //(2 * 1024UL) // 4K
#define UART_RX_MAX_DEPTH (2 * 1024UL) // 4K
#define UART_DATA_BUF_LEN (2 * 1024UL) // 4K
typedef struct __attribute__((aligned(4)))
{
Protocol_uint32_t read_pos;
Protocol_uint32_t write_pos;
Protocol_uint8_t Rx_Buffer [ UART_RX_MAX_DEPTH ];
} UARTRxBuf_t;
typedef struct __attribute__((aligned(4)))
{
Protocol_uint32_t read_pos;
Protocol_uint32_t write_pos;
Protocol_uint8_t Tx_Buffer [ UART_TX_MAX_DEPTH ];
} UARTTxBuf_t;
static UARTRxBuf_t UARTRxBuf;
static UARTTxBuf_t UARTTxBuf;
static Protocol_uint8_t UsartDataBuf [ 256 ];
static Protocol_uint8_t mDataBufPtr [ UART_DATA_BUF_LEN ];
static Protocol_uint8_t Protocol_OpenUart(void);
static Protocol_uint32_t Protocol_UartRead(Protocol_uint8_t *pData, Protocol_uint32_t u32Len);
static Protocol_uint32_t Protocol_UartSend(const Protocol_uint8_t *pData, Protocol_uint32_t u32Len);
static void Protocol_UartHandle(const Protocol_Data_t *pData);
void Protocol_KL30_Wakeup_Init(void)
{
Protocol_Func_t pFunc;
pFunc.UARTOpen_Cbk = Protocol_OpenUart;
pFunc.UARTSend_Cbk = Protocol_UartSend;
pFunc.UARTRead_Cbk = Protocol_UartRead;
pFunc.UARTClose_Cbk = Protocol_NULL;
pFunc.ProcParseCbk = Protocol_NULL;
pFunc.ProtocolSetData_Cbk = Protocol_UartHandle;
UARTTxBuf.read_pos = 0;
UARTTxBuf.write_pos = 0;
UARTRxBuf.read_pos = 0;
UARTRxBuf.write_pos = 0;
Protocol_Init(mDataBufPtr, UART_DATA_BUF_LEN, &pFunc);
}
void Protocol_Send_Service(void)
{
Protocol_uint32_t i = 0u;
Protocol_uint32_t DataLen = 0u;
Protocol_uint32_t SendLen = 0u;
if ( UARTTxBuf.write_pos == UARTTxBuf.read_pos )
{
return;
}
if ( UARTTxBuf.write_pos > UARTTxBuf.read_pos )
{
DataLen = UARTTxBuf.write_pos - UARTTxBuf.read_pos;
}
else
{
DataLen = UART_TX_MAX_DEPTH - (UARTTxBuf.read_pos - UARTTxBuf.write_pos);
}
if ( DataLen > 255 )
{
SendLen = 255;
}
else
{
SendLen = DataLen;
}
for ( i = 0u; i < SendLen; i++ )
{
UsartDataBuf [ i ] = UARTTxBuf.Tx_Buffer [ UARTTxBuf.read_pos ];
UARTTxBuf.read_pos = (UARTTxBuf.read_pos + 1) % UART_TX_MAX_DEPTH;
}
Uart0_IntSend(UsartDataBuf, SendLen);
}
static Protocol_uint8_t Protocol_OpenUart(void)
{
#if 0
UART_Channel_Config_st_t loc_config;
loc_config.u32UARTChEn = 1;
loc_config.u32UARTbps = 115200;
loc_config.pfnUARTConfirmCallBack = Protocol_NULL;
loc_config.pfnUARTReadMsgCallBack = UART_Put;
UART_Init(UART_RLIN31, &loc_config);
#endif
return 1;
}
static Protocol_uint32_t Protocol_UartRead(Protocol_uint8_t *pData, Protocol_uint32_t len)
{
Protocol_uint32_t i = 0;
Protocol_uint32_t DataLen = 0u;
Protocol_uint32_t ReadLen = 0u;
if ( UARTRxBuf.write_pos == UARTRxBuf.read_pos )
{
return 0; //队列空
}
if ( UARTRxBuf.write_pos > UARTRxBuf.read_pos )
{
DataLen = UARTRxBuf.write_pos - UARTRxBuf.read_pos;
}
else
{
DataLen = UART_RX_MAX_DEPTH - (UARTRxBuf.read_pos - UARTRxBuf.write_pos);
}
if ( len > DataLen )
{
ReadLen = DataLen;
}
else
{
ReadLen = len;
}
for ( i = 0u; i < ReadLen; i++ )
{
pData [ i ] = UARTRxBuf.Rx_Buffer [ UARTRxBuf.read_pos ];
UARTRxBuf.read_pos = (UARTRxBuf.read_pos + 1) % UART_RX_MAX_DEPTH;
}
return ReadLen;
}
static Protocol_uint32_t Protocol_UartSend(const Protocol_uint8_t *pData, Protocol_uint32_t u32Len)
{
Protocol_uint32_t i = 0;
Protocol_uint32_t RemainLen = 0u;
if ( UARTTxBuf.write_pos >= UARTTxBuf.read_pos )
{
RemainLen = UART_TX_MAX_DEPTH - (UARTTxBuf.write_pos - UARTTxBuf.read_pos);
}
else
{
RemainLen = UARTTxBuf.read_pos - UARTTxBuf.write_pos;
}
if ( u32Len > RemainLen )
{
return 1; //队列已满,无法插入队列
}
for ( i = 0; i < u32Len; i++ )
{
UARTTxBuf.Tx_Buffer [ UARTTxBuf.write_pos ] = pData [ i ];
UARTTxBuf.write_pos = (UARTTxBuf.write_pos + 1) % UART_TX_MAX_DEPTH;
}
return 0;
}
static void Protocol_UartHandle(const Protocol_Data_t *pData)
{
if ( pData->CmdID == ESP32_MCU_0x10 )
{
BlueTooth.BlueTooth_St = pData->Data[0];
if (BlueTooth.BlueTooth_St == BLUE_STATE_ON)
{
Protocol_Send(MCU_ESP32_0x20, Protocol_NULL, 0);
}
}
else if ( pData->CmdID == ESP32_MCU_0x12 )
{
BlueTooth.BLE_St = pData->Data[0];
}
else if(pData->CmdID == ESP32_MCU_0x01 )
{
if (pData->Data[0] == 0x33)
{
BlueTooth.Navigation_St = EM_ESP32_NAVI_ST_NAVIGATING;
}
else if (pData->Data[0] == 0x35)
{
BlueTooth.Navigation_St = EM_ESP32_NAVI_ST_STANDBY;
}
else
{
;
}
BlueTooth.Navigation_Code = pData->Data[1];
BlueTooth.Navigation_Mileage = ((pData->Data[5] << 24) | (pData->Data[4] << 16) |
(pData->Data[3] << 8) | pData->Data[2]);
}
else
{
//非本协议数据,不处理
}
}
void UART_Put(Protocol_uint16_t Data)
{
Protocol_uint32_t nextPos = 0u;
nextPos = (UARTRxBuf.write_pos + 1) % UART_RX_MAX_DEPTH;
if ( nextPos == UARTRxBuf.read_pos )
{
//队列已满,无法插入队列
}
else
{
UARTRxBuf.Rx_Buffer [ UARTRxBuf.write_pos ] = Data;
UARTRxBuf.write_pos = (UARTRxBuf.write_pos + 1) % UART_RX_MAX_DEPTH;
}
//return;
}
#ifndef PROTOCOL_USER_H
#define PROTOCOL_USER_H
//#include "Application.h"
#include "Protocol_Lib.h"
#include <stdio.h>
#include <stdint.h>
void Protocol_KL30_Wakeup_Init(void);
void Protocol_Send_Service(void); // 10ms任务调用
void UART_Put(Protocol_uint16_t Data);
#endif
......@@ -23,7 +23,7 @@ const st_CANMsgAttribute CAN_CH0_CAN_MSG_CONST_ARRAY[CAN_CH0_ID_TOTAL_MAX] =
1000ul,
0x402ul,
(( void * )0),
(( void * )0),
(Fault_Code_Receive),
(( void * )0),
},
{
......
......@@ -67,7 +67,7 @@ void Can_Set_Buff_6EF(canlib_uint8_t CopyData[])
uint8_t i = 0;
uint16_t Espeed_tx = 0;
uint16_t TripA_tx = 0;
Espeed_tx = Get_DispEngineSpeed()/100;
Espeed_tx = Get_ActualEngineSpeed()/100;
TripA_tx = Data_Read_Trip(EM_TRIP_A);
p6EF = (CANMsg6EFUnion *)CopyData;
if ( p6EF != ( void * )0 )
......@@ -95,7 +95,10 @@ void Can_Set_Buff_450(canlib_uint8_t CopyData[])
p450->Msg [ i ] = 0xFFu;
}
}
p450 -> Sig.Front_Pressure_TX = Get_Front_TPMS_TX();
p450 -> Sig.Rear_Pressure_TX = Get_Rear_TPMS_TX();
p450 -> Sig.Front_Pressure_TX_H = (Get_Front_TPMS_TX() >> 8) & 0xFF;
p450 -> Sig.Front_Pressure_TX_L = Get_Front_TPMS_TX() & 0xFF;
p450 -> Sig.Rear_Pressure_TX_H = (Get_Rear_TPMS_TX() >> 8) & 0xFF;
p450 -> Sig.Rear_Pressure_TX_L = Get_Rear_TPMS_TX() & 0xFF;
}
......@@ -72,10 +72,10 @@ typedef union
uint8_t Msg [ 8 ];
struct
{
uint32_t Front_Pressure_TX : 16;
uint32_t Rear_Pressure_TX : 16;
uint16_t Front_Pressure_TX_H : 8;
uint16_t Front_Pressure_TX_L : 8;
uint16_t Rear_Pressure_TX_H : 8;
uint16_t Rear_Pressure_TX_L : 8;
//uint32_t Front_Air_Leakage_TX : 1;
//uint32_t Rear_Air_Leakage_TX : 1;
//uint32_t Front_Low_Voltage_TX : 1;
......
......@@ -142,13 +142,20 @@ void Data_Coolant_Temp_Display ( void )
else
{
DataCoolantTemp_Dis.Dis_Valid = 1;
if(DataCoolantTemp_Dis.u8_Flg == 0)
if (DataCoolantTemp_Dis.u8_Flg == 2)
{
DataCoolantTemp_Dis.u8_Flg = 1;
DataCoolantTemp_Dis.u8_Flg = 1;
DataCoolantTemp_Dis.u8_UpFlashtimer = 0;
DataCoolantTemp_Dis.u8_DownFlashtimer = 0;
}
else if(DataCoolantTemp_Dis.u8_Flg == 0)
{
DataCoolantTemp_Dis.u8_Flg = 2;
DataCoolantTemp_Dis.u8_CurSeg = DataCoolantTemp_Dis.u8_DestSeg;
DataCoolantTemp_Dis.u8_UpFlashtimer = DataCoolantTemp_Dis.u8_Uptimer;
DataCoolantTemp_Dis.u8_DownFlashtimer = DataCoolantTemp_Dis.u8_Downtimer;
}
}
}
}
......
......@@ -11,7 +11,7 @@
/*** 控制结构 ***/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint8_t Dis_Valid;
uint8_t u8_DestSeg;
......@@ -29,7 +29,7 @@ typedef struct
extern DataCoolantTempDisStruct DataCoolantTemp_Dis;
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Value;
uint8_t Valid;
......
......@@ -18,20 +18,20 @@
#define DATA_ESPEED_HYSTERESIS 80 //回差
/*** 控制结构 ***/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Buffer[5];
uint8_t Cnt;
} DataESpeedSamplerStruct; //转速采样结构
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Speed;
uint16_t Delta;
uint8_t Dir;
} DataESPeedDampingStruct; //转速阻尼结构
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t ESpeedBackup;
uint16_t Timer;
......
......@@ -38,15 +38,14 @@ void Data_TPMS_Processing_Service ( void )
{
TPMS.Front_TPMS_Valid = 0;
TPMS.Rear_TPMS_Valid = 1;
TPMS.Front_Press_Value = 99;
TPMS.Front_Press_Value = 990;
TPMS.Rear_Press_Value = Rear_TPMS * 275;
TPMS.Rear_Press_Value /= 10 ;
TPMS.Rear_Press_Value /= 102 ;
if(TPMS.Rear_Press_Value > 99)
if(TPMS.Rear_Press_Value > 990)
{
TPMS.Rear_Press_Value = 99;
TPMS.Rear_Press_Value = 990;
}
if((TPMS.Rear_Press_Value < 17) || (TPMS.Rear_Press_Value > 25))
if((TPMS.Rear_Press_Value < 170) || (TPMS.Rear_Press_Value > 250))
{
TPMS.TPMS_Warning = 1;
}
......@@ -55,19 +54,18 @@ void Data_TPMS_Processing_Service ( void )
TPMS.TPMS_Warning = 0;
}
}
else if ((Front_TPMS != 0xFF) || (Rear_TPMS == 0xFF))
else if ((Front_TPMS != 0xFF) && (Rear_TPMS == 0xFF))
{
TPMS.Front_TPMS_Valid = 1;
TPMS.Rear_TPMS_Valid = 0;
TPMS.Rear_Press_Value = 99;
TPMS.Rear_Press_Value = 990;
TPMS.Front_Press_Value = Front_TPMS *275 ;
TPMS.Front_Press_Value /= 10 ;
TPMS.Front_Press_Value /= 102 ;
if(TPMS.Front_Press_Value > 99)
if(TPMS.Front_Press_Value > 990)
{
TPMS.Front_Press_Value = 99;
TPMS.Front_Press_Value = 990;
}
if((TPMS.Front_Press_Value < 17) || (TPMS.Front_Press_Value > 23))
if((TPMS.Front_Press_Value < 170) || (TPMS.Front_Press_Value > 230))
{
TPMS.TPMS_Warning = 1;
}
......@@ -78,8 +76,8 @@ void Data_TPMS_Processing_Service ( void )
}
else
{
TPMS.Front_Press_Value = 99;
TPMS.Rear_Press_Value = 99;
TPMS.Front_Press_Value = 990;
TPMS.Rear_Press_Value = 990;
TPMS.TPMS_Warning = 0;
TPMS.Front_TPMS_Valid = 0;
TPMS.Rear_TPMS_Valid = 0;
......@@ -89,22 +87,20 @@ void Data_TPMS_Processing_Service ( void )
{
TPMS.Front_TPMS_Valid = 1;
TPMS.Rear_TPMS_Valid = 1;
TPMS.Front_Press_Value = Front_TPMS * 275 ;
TPMS.Front_Press_Value /= 10 ;
TPMS.Front_Press_Value = Front_TPMS * 275 ;
TPMS.Front_Press_Value /= 102 ;
if(TPMS.Front_Press_Value > 99)
if(TPMS.Front_Press_Value > 990)
{
TPMS.Front_Press_Value = 99;
TPMS.Front_Press_Value = 990;
}
TPMS.Rear_Press_Value = Rear_TPMS * 275;
TPMS.Rear_Press_Value /= 10 ;
TPMS.Rear_Press_Value = Rear_TPMS * 275;
TPMS.Rear_Press_Value /= 102 ;
if(TPMS.Rear_Press_Value > 99)
if(TPMS.Rear_Press_Value > 990)
{
TPMS.Rear_Press_Value = 99;
TPMS.Rear_Press_Value = 990;
}
if ((TPMS.Front_Press_Value < 17) || (TPMS.Front_Press_Value > 23) || (TPMS.Rear_Press_Value < 17) || (TPMS.Rear_Press_Value > 25))
if ((TPMS.Front_Press_Value < 170) || (TPMS.Front_Press_Value > 230) || (TPMS.Rear_Press_Value < 170) || (TPMS.Rear_Press_Value > 250))
{
TPMS.TPMS_Warning = 1;
}
......@@ -125,14 +121,11 @@ void Data_TPMS_Processing_Service ( void )
TPMS.TPMS_Warning = 0;
}
}
uint16_t Data_Bar_To_Psi (uint16_t bar)
uint32_t Data_Bar_To_Psi (uint32_t bar)
{
bar *= 145;
bar /= 10;
if((bar % 5) >= 5)
{
bar += 5;
}
bar += 5;
return bar;
}
uint8_t Get_Led_TPMS_Waring (void)
......@@ -153,15 +146,16 @@ uint16_t Get_Front_TPMS_Sig_Value (void)
uint16_t value = 0;
if (TPMS.TPMS_Unit == 1)
{
value = Data_Bar_To_Psi(TPMS.Front_Press_Value) / 10;
value = Data_Bar_To_Psi(TPMS.Front_Press_Value) / 100;
if(value > 99)
{
value = 99;
}
}
else
{
value = TPMS.Front_Press_Value;
{
value = TPMS.Front_Press_Value + 5;
value = value / 10;
}
return value;
}
......@@ -170,7 +164,7 @@ uint16_t Get_Rear_TPMS_Sig_Value (void)
uint16_t value = 0;
if (TPMS.TPMS_Unit == 1)
{
value = Data_Bar_To_Psi(TPMS.Rear_Press_Value) / 10;
value = Data_Bar_To_Psi(TPMS.Rear_Press_Value) / 100;
if(value > 99)
{
value = 99;
......@@ -178,16 +172,29 @@ uint16_t Get_Rear_TPMS_Sig_Value (void)
}
else
{
value = TPMS.Rear_Press_Value;
{
value = TPMS.Rear_Press_Value + 5;
value = value / 10;
}
return value;
}
uint16_t Get_Rear_TPMS_TX (void)
{
return TPMS.Rear_Press_Value;
uint16_t value = 0;
value = Data_Bar_To_Psi(TPMS.Rear_Press_Value) / 10;
if(value > 990)
{
value = 990;
}
return value;
}
uint16_t Get_Front_TPMS_TX (void)
{
return TPMS.Front_Press_Value;
uint16_t value = 0;
value = Data_Bar_To_Psi(TPMS.Front_Press_Value) / 10;
if(value > 990)
{
value = 990;
}
return value;
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
#define _DATA_TPMS_H_
#include "common.h"
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint32_t Front_Press_Value;
uint32_t Rear_Press_Value;
......@@ -14,7 +14,7 @@ typedef struct
}_TPMS_Display;
void Data_TPMS_KL30_Init ( void );
void Data_TPMS_Processing_Service ( void );
uint16_t Data_Bar_To_Psi (uint16_t bar);
uint32_t Data_Bar_To_Psi (uint32_t bar);
uint8_t Get_Led_TPMS_Waring (void);
uint8_t Get_Front_TPMS_Sig_Vaild (void);
uint8_t Get_Rear_TPMS_Sig_Vaild (void);
......
......@@ -14,7 +14,7 @@
#define DATA_VSPEED_HYSTERESIS 15 //回差
/*** 控制结构 ***/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Timer;
uint16_t Timer1;
......@@ -23,7 +23,7 @@ typedef struct
uint8_t Cnt;
} DataVSpeedSamplerStruct; //车速采样结构
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint16_t Speed;
uint16_t Delta;
......
#include "FaultCode\FaultCode.h"
#include "Application.h"
uint8_t DTC_Amnt_Number = 0; //Diag402ReceiveDTCNumberTemp
uint8_t DTC_Amnt_Number_Count = 0; //Diag402ReceiveDTCCount
uint8_t FaultCode_Number = 0; //Diag402ReceiveDTCNumber
uint32_t DTC_Data[254] = {0}; //Diag402ReceiveDTC
uint32_t DTC_Data_Count[254] = {0}; //Diag402ReceiveDTCTemp
uint32_t FaultCode_Data[254] = {0}; //DtcCurFaultGrpup
uint8_t DTC_Amnt_Number = 0;
uint8_t DTC_Amnt_Number_Count = 0;
uint8_t FaultCode_Number = 0;
uint32_t DTC_Data[FualtCodeMax] = {0};
uint32_t DTC_Data_Count[FualtCodeMax] = {0};
uint32_t FaultCode_Data[FualtCodeMax] = {0};
uint32_t u32Countbuf = 0UL;
void Fault_Code_Receive(uint8_t CopyData[])
{
uint8_t i = 0;
ECU_FaultCode_Processing_Service();
}
uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len)
{
uint8_t i = 0;
......@@ -22,7 +28,28 @@ uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len)
}
return result;
}
static void Fault_Code_App_Swap(uint32_t *pData1, uint32_t *pData2)
{
uint32_t psw;
if ((*pData1) > (*pData2))
{
psw = (*pData2);
(*pData2) = (*pData1);
(*pData1) = psw;
}
}
static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len)
{
uint8_t n = 0, m;
for (; n < len - 1; n++)
{
for (m = n + 1; m < len; m++)
{
Fault_Code_App_Swap((SortData + n), (SortData + m));
}
}
}
void ECU_FaultCode_Processing_Service ( void )
{
uint8_t DTCH1 = 0;
......@@ -121,12 +148,16 @@ void ECU_FaultCode_Processing_Service ( void )
DTC2 |= DTCM2 & 0xF ;
}
if(DTC_Amnt_Number == 0)
if (DTC_Amnt_Number == 0)
{
for (i = 0; i < 255; i++)
for (i = 0; i < FualtCodeMax; i++)
{
FaultCode_Data[i] = 0;
DTC_Data_Count[i] = 0;
DTC_Data[i] = 0;
}
DTC_Amnt_Number_Count = 0;
}
if(DTC_Amnt_Number_Count < DTC_Amnt_Number)
{
......@@ -134,6 +165,7 @@ void ECU_FaultCode_Processing_Service ( void )
{
DTC_Data_Count[DTC_Amnt_Number_Count] = DTC1;
DTC_Amnt_Number_Count ++;
Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count);
}
}
if(DTC_Amnt_Number_Count < DTC_Amnt_Number)
......@@ -142,21 +174,37 @@ void ECU_FaultCode_Processing_Service ( void )
{
DTC_Data_Count[DTC_Amnt_Number_Count] = DTC2;
DTC_Amnt_Number_Count ++;
Fault_Code_App_SortNByte(DTC_Data_Count, DTC_Amnt_Number_Count);
}
}
if(DTC_Amnt_Number_Count > DTC_Amnt_Number)
{
for (i = 0; i < FualtCodeMax; i++)
{
//FaultCode_Data[i] = 0;
DTC_Data_Count[i] = 0;
DTC_Data[i] = 0;
}
DTC_Amnt_Number_Count = 0;
}
if (DTC_Amnt_Number_Count == DTC_Amnt_Number)
{
for(i = 0; i < DTC_Amnt_Number_Count; i++)
{
DTC_Data[i] = DTC_Data_Count[i];
DTC_Data_Count[i] = 0;
Fault_Code_App_SortNByte(DTC_Data, FaultCode_Number);
}
FaultCode_Number = DTC_Amnt_Number;
DTC_Amnt_Number_Count = 0;
for(i = 0; i < FaultCode_Number; i++)
{
FaultCode_Data[i] = DTC_Data[i];
if(FaultCode_Data[i] != DTC_Data[i])
{
FaultCode_Data[i] = DTC_Data[i];
Fault_Code_App_SortNByte(FaultCode_Data, FaultCode_Number);
}
}
}
......
......@@ -3,8 +3,13 @@
#include "Application.h"
#include "common.h"
extern uint32_t FaultCode_Data[254] ;
#define FualtCodeMax 72
extern uint32_t FaultCode_Data[FualtCodeMax] ;
extern uint8_t FaultCode_Number;
uint8_t FaultCode_Compare(uint32_t FaultCode, uint32_t* CodeList, uint8_t len);
void ECU_FaultCode_Processing_Service ( void );
//void Fault_Code_Sort(void);
extern void Fault_Code_Receive(uint8_t CopyData[]);
static void Fault_Code_App_SortNByte(uint32_t *SortData, uint8_t len);
static void Fault_Code_App_Swap(uint32_t *pData1, uint32_t *pData2);
#endif
\ No newline at end of file
......@@ -183,7 +183,7 @@ void Fuel_State_Check(uint8_t deltaTime)
void Fuel_Gauges_Cal(uint8_t deltaTime)
{
static uint16_t time = 0;
static uint32_t time = 0;
if ((FuelSensorState == FuelSensorNormal) && (FuelR < 10000))
{ // 32000 //FuelR >10 change FuelR >20
/*采集完第一组数据后,开始计算燃油格数*/
......
......@@ -4,7 +4,8 @@
#include "Components.h"
typedef enum{
typedef enum __attribute__((aligned(4)))
{
FuelSensorNormal = 0,
FuelSensorShortCircuit,
FuelSensorOpenCircuit,
......
......@@ -66,16 +66,38 @@ void Clear_Bu98(void)
void Gauge_Service(void)
{
static uint16_t VSpeed_Count = 0u;
uint8_t k = 0;
if (ClearODO_Flag == 1)
{
if ( Common_Get_IG_Sts( ) == COMMON_POWER_ON )
{
Check_SEG_Display();
Check_SEG_Display();
for(k = 0; k < LampCh0_MAX; k ++)
{
if (k == 24)
{
k ++;
}
else
{
LED_Driver_Channel_Set(LampChannel_0, k, LED_ON);
}
}
}
else
{
Clear_Bu98();
Clear_Bu98();
for(k = 0; k < LampCh0_MAX; k ++)
{
LED_Driver_Channel_Set(LampChannel_0, k, LED_OFF);
}
//LED_Driver_Channel_Set(LampChannel_0, LampCh0_35_ODO, LED_OFF);
//LED_Driver_Channel_Set(LampChannel_0, LampCh0_34_TRIP, LED_OFF);
//LED_Driver_Channel_Set(LampChannel_0, LampCh0_07_Screen_Time, LED_OFF);
//LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
//LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
}
}
else
......@@ -107,6 +129,7 @@ void Gauge_Service(void)
SEG_SET_CoolantDial(1, GET_DataCoolantTempSegDisp(), GET_DataCoolantTempValueDisp(), GET_DataCollantTempSegValid());
SEG_SET_Voltage_NUM(1, Get_Battery_Voltage());
SEG_SET_TPMS_NUM(1, Get_Front_TPMS_Sig_Value(), Get_Rear_TPMS_Sig_Value(), Get_Dis_Tpms_Unit(),Get_Front_TPMS_Sig_Vaild(), Get_Rear_TPMS_Sig_Vaild());
SEG_SET_Navigation_STS(Get_Navigation_St_Dis(),Get_Navigation_Code_Dis(),Get_Navigation_Mileage_Dis());
}
else
{
......@@ -116,6 +139,16 @@ void Gauge_Service(void)
else
{
Clear_Bu98();
LED_Driver_Channel_Set(LampChannel_0, LampCh0_35_ODO, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_34_TRIP, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_07_Screen_Time, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_17_Length2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_18_Length1, LED_OFF);
}
}
......
......@@ -9,6 +9,7 @@
uint8_t DTC_DISCount = 0;
uint32_t Current_DTC_CODE = 0;
uint32_t Current_DTC_CODE_BACK = 0;
uint8_t DTC_DISTimer = 0;
/*数字显示数组*/ /*0, 1 2 3 4 5 6 7 8 9 null - P A b C d E F*/
const uint8_t SEG_DISPLAY_NUMBER0[] = {0x3Fu, 0x06u, 0x5Bu, 0x4Fu, 0x66u, 0x6Du, 0x7Du, 0x07u, 0x7Fu, 0x6Fu, 0x00, 0x40, 0x73, 0x77, 0x7C, 0x39, 0x5E, 0x79, 0x71};
......@@ -328,6 +329,639 @@ void SEG_SET_LED_STS(uint8_t LED_NUM, uint8_t m_Flag)
}
}
/**@brief 导航显示函数
* @param[in] m_Flag 导航是否开启显示 -1 显示 -0 不显示
* @param[in] m_Code 导航指示编码
* @param[in] m_Mileage 剩余距离
*/
void SEG_SET_Navigation_STS(uint8_t m_Flag, uint8_t m_Code, uint32_t m_Mileage)
{
uint32_t Num = 0;
uint8_t m8 = 0;
if ((ClearODO_Flag == 1) || (Common_GetIgnOnTime() < 3000))
{
IC2_SEG164 = IC_SEG_ON;
IC2_SEG165 = IC_SEG_ON;
IC2_SEG169 = IC_SEG_ON;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_ON;
IC2_SEG167 = IC_SEG_ON;
IC2_SEG168 = IC_SEG_ON;
IC2_SEG163 = IC_SEG_ON;
IC2_SEG171 = IC_SEG_ON;
IC2_SEG172 = IC_SEG_ON;
IC2_SEG162 = IC_SEG_ON;
IC2_SEG161 = IC_SEG_ON;
IC2_SEG160 = IC_SEG_ON;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_17_Length2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_18_Length1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
}
else
{
switch(m_Code)
{
case NaviIconType_LEFT:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_ON;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_ON;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_RIGHT:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_ON;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_ON;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_LEFT_FRONT:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_ON;
IC2_SEG169 = IC_SEG_ON;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_ON;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_RIGHT_FRONT:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_ON;
IC2_SEG169 = IC_SEG_ON;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_ON;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_LEFT_BACK:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_OFF;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_ON;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_RIGHT_BACK:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_OFF;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_ON;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_STRAIGHT:
IC2_SEG164 = IC_SEG_ON;
IC2_SEG165 = IC_SEG_ON;
IC2_SEG169 = IC_SEG_ON;
IC2_SEG170 = IC_SEG_ON;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_ARRIVED_SERVICE_AREA:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_OFF;
IC2_SEG170 = IC_SEG_OFF;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_ON;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_ARRIVED_TOLLGATE:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_OFF;
IC2_SEG170 = IC_SEG_OFF;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_ON;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
case NaviIconType_ARRIVED_TUNNEL:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_OFF;
IC2_SEG170 = IC_SEG_OFF;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_ON;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_ON);
break;
default:
IC2_SEG164 = IC_SEG_OFF;
IC2_SEG165 = IC_SEG_OFF;
IC2_SEG169 = IC_SEG_OFF;
IC2_SEG170 = IC_SEG_OFF;
IC2_SEG166 = IC_SEG_OFF;
IC2_SEG167 = IC_SEG_OFF;
IC2_SEG168 = IC_SEG_OFF;
IC2_SEG163 = IC_SEG_OFF;
IC2_SEG171 = IC_SEG_OFF;
IC2_SEG172 = IC_SEG_OFF;
IC2_SEG162 = IC_SEG_OFF;
IC2_SEG161 = IC_SEG_OFF;
IC2_SEG160 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
break;
}
}
if(m_Flag)
{
LED_Driver_Channel_Set(LampChannel_0, LampCh0_17_Length2, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_18_Length1, LED_ON);
if ((ClearODO_Flag == 1) || (Common_GetIgnOnTime() < 3000))
{
IC1_SEG030 = IC_SEG_ON;
IC1_SEG130 = IC_SEG_ON;
IC1_SEG129 = IC_SEG_ON;
}
else
{
if(m_Mileage < 1000)
{
IC1_SEG030 = IC_SEG_OFF;
IC1_SEG130 = IC_SEG_ON;
IC1_SEG129 = IC_SEG_OFF;
}
else
{
IC1_SEG030 = IC_SEG_ON;
IC1_SEG130 = IC_SEG_OFF;
IC1_SEG129 = IC_SEG_ON;
}
}
{
if (m_Mileage < 1000)
{
Num = m_Mileage / 1000;
}
else
{
Num = m_Mileage / 100000;
}
m8 = SEG_UNDISPLAY_NUMBER0[Num];
if (Bit_Is_Set(m8, 0))
{
IC1_SEG135 = IC_SEG_ON;
}
else
{
IC1_SEG135 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG015 = IC_SEG_ON;
}
else
{
IC1_SEG015 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG013 = IC_SEG_ON;
}
else
{
IC1_SEG013 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG012 = IC_SEG_ON;
}
else
{
IC1_SEG012 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG011 = IC_SEG_ON;
}
else
{
IC1_SEG011 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG010 = IC_SEG_ON;
}
else
{
IC1_SEG010 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG014 = IC_SEG_ON;
}
else
{
IC1_SEG014 = IC_SEG_OFF;
}
if (m_Mileage < 1000)
{
Num = m_Mileage / 100;
m8 = SEG_UNDISPLAY_NUMBER0[Num];
}
else
{
Num = (m_Mileage / 100) % 1000 / 100;
if (m_Mileage >= 10000)
{
m8 = SEG_DISPLAY_NUMBER0[Num];
}
else
{
m8 = SEG_UNDISPLAY_NUMBER0[Num];
}
}
if (Bit_Is_Set(m8, 0))
{
IC1_SEG134 = IC_SEG_ON;
}
else
{
IC1_SEG134 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG021 = IC_SEG_ON;
}
else
{
IC1_SEG021 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG019 = IC_SEG_ON;
}
else
{
IC1_SEG019 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG018 = IC_SEG_ON;
}
else
{
IC1_SEG018 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG017 = IC_SEG_ON;
}
else
{
IC1_SEG017 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG016 = IC_SEG_ON;
}
else
{
IC1_SEG016 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG020 = IC_SEG_ON;
}
else
{
IC1_SEG020 = IC_SEG_OFF;
}
if (m_Mileage < 1000)
{
Num = (m_Mileage / 10) % 10;
if(m_Mileage >= 10)
{
m8 = SEG_DISPLAY_NUMBER0[Num];
}
else
{
m8 = SEG_UNDISPLAY_NUMBER0[Num];
}
}
else
{
Num = ((m_Mileage / 100) / 10) % 10;
m8 = SEG_DISPLAY_NUMBER0[Num];
}
if (Bit_Is_Set(m8, 0))
{
IC1_SEG133 = IC_SEG_ON;
}
else
{
IC1_SEG133 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG029 = IC_SEG_ON;
}
else
{
IC1_SEG029 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG027 = IC_SEG_ON;
}
else
{
IC1_SEG027 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG026 = IC_SEG_ON;
}
else
{
IC1_SEG026 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG023 = IC_SEG_ON;
}
else
{
IC1_SEG023 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG022 = IC_SEG_ON;
}
else
{
IC1_SEG022 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG028 = IC_SEG_ON;
}
else
{
IC1_SEG028 = IC_SEG_OFF;
}
if (m_Mileage < 1000)
{
Num = m_Mileage % 10;
m8 = SEG_DISPLAY_NUMBER0[Num];
}
else
{
Num = (m_Mileage / 100) % 10;
m8 = SEG_DISPLAY_NUMBER0[Num];
}
if (Bit_Is_Set(m8, 0))
{
IC1_SEG132 = IC_SEG_ON;
}
else
{
IC1_SEG132 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG131 = IC_SEG_ON;
}
else
{
IC1_SEG131 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG034 = IC_SEG_ON;
}
else
{
IC1_SEG034 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG033 = IC_SEG_ON;
}
else
{
IC1_SEG033 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG032 = IC_SEG_ON;
}
else
{
IC1_SEG032 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG031 = IC_SEG_ON;
}
else
{
IC1_SEG031 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG035 = IC_SEG_ON;
}
else
{
IC1_SEG035 = IC_SEG_OFF;
}
}
}
else
{
LED_Driver_Channel_Set(LampChannel_0, LampCh0_10_Navigator1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_19_Navigator2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_17_Length2, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_18_Length1, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_14_ARRIVED_SERVICE_AREA, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_15_ARRIVED_TOLLGATE, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_16_ARRIVED_TUNNEL, LED_OFF);
IC1_SEG135 = IC_SEG_OFF;
IC1_SEG015 = IC_SEG_OFF;
IC1_SEG013 = IC_SEG_OFF;
IC1_SEG012 = IC_SEG_OFF;
IC1_SEG011 = IC_SEG_OFF;
IC1_SEG010 = IC_SEG_OFF;
IC1_SEG014 = IC_SEG_OFF;
IC1_SEG134 = IC_SEG_OFF;
IC1_SEG021 = IC_SEG_OFF;
IC1_SEG019 = IC_SEG_OFF;
IC1_SEG018 = IC_SEG_OFF;
IC1_SEG017 = IC_SEG_OFF;
IC1_SEG016 = IC_SEG_OFF;
IC1_SEG020 = IC_SEG_OFF;
IC1_SEG133 = IC_SEG_OFF;
IC1_SEG029 = IC_SEG_OFF;
IC1_SEG027 = IC_SEG_OFF;
IC1_SEG026 = IC_SEG_OFF;
IC1_SEG023 = IC_SEG_OFF;
IC1_SEG022 = IC_SEG_OFF;
IC1_SEG028 = IC_SEG_OFF;
IC1_SEG132 = IC_SEG_OFF;
IC1_SEG131 = IC_SEG_OFF;
IC1_SEG034 = IC_SEG_OFF;
IC1_SEG033 = IC_SEG_OFF;
IC1_SEG032 = IC_SEG_OFF;
IC1_SEG031 = IC_SEG_OFF;
IC1_SEG035 = IC_SEG_OFF;
IC1_SEG030 = IC_SEG_OFF;
IC1_SEG130 = IC_SEG_OFF;
IC1_SEG129 = IC_SEG_OFF;
}
}
/**@brief 燃油表显示函数
* @param[in] m_Flag 段与数字是否显示 -1 显示 -0 不显示
......@@ -345,7 +979,7 @@ void SEG_SET_FuelDial(uint8_t m_Flag, uint8_t m_SEG)
IC2_SEG102 = IC_SEG_GREY;
IC2_SEG101 = IC_SEG_GREY;
if ((Get_Fuel_Sensor_State() == 2) && (ClearODO_Flag != 1))
if ((Get_Fuel_Sensor_State() == 2) && (ClearODO_Flag != 1) && (Common_GetIgnOnTime() >= 3000))
{
if (FLASH_SYNC_1Hz)
{
......@@ -372,7 +1006,8 @@ void SEG_SET_FuelDial(uint8_t m_Flag, uint8_t m_SEG)
}
else
{
if(Get_CurFuelSetp() == 0)
if((Get_CurFuelSetp() == 0) && (Common_GetIgnOnTime() >= 3000))
{
if (FLASH_SYNC_1Hz)
{
......@@ -385,6 +1020,11 @@ void SEG_SET_FuelDial(uint8_t m_Flag, uint8_t m_SEG)
IC2_SEG100 = IC_SEG_GREY;
}
}
else
{
IC2_SEG108 = IC_SEG_ON;
IC2_SEG100 = IC_SEG_ON;
}
if ((Get_CurFuelSetp() == 1) && (ClearODO_Flag != 1) && (Common_GetIgnOnTime() >= 3000))
{
IC2_SEG108 = IC_SEG_ON;
......@@ -896,20 +1536,42 @@ void SEG_SET_VSpeed_NUM(uint8_t m_Flag, uint16_t m_NUM, uint8_t m_Unit)
{
if (Get_Current_PageType() == Page_Km_Unit)
{
if(FLASH_SYNC_1Hz)
if (m_Unit == 0)
{
IC2_SEG156 = IC_SEG_ON;
IC2_SEG159 = IC_SEG_ON;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_ON);
if(FLASH_SYNC_1Hz)
{
IC2_SEG156 = IC_SEG_OFF;
IC2_SEG159 = IC_SEG_ON;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
}
else
{
IC2_SEG156 = IC_SEG_OFF;
IC2_SEG159 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
}
}
else
{
IC2_SEG156 = IC_SEG_OFF;
IC2_SEG159 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
if(FLASH_SYNC_1Hz)
{
IC2_SEG156 = IC_SEG_ON;
IC2_SEG159 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_ON);
}
else
{
IC2_SEG156 = IC_SEG_OFF;
IC2_SEG159 = IC_SEG_OFF;
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
}
}
}
else
{
......@@ -1044,257 +1706,294 @@ void SEG_SET_VSpeed_NUM(uint8_t m_Flag, uint16_t m_NUM, uint8_t m_Unit)
}
else
{
IC2_SEG152 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC2_SEG151 = IC_SEG_ON;
}
else
{
IC2_SEG151 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC2_SEG149 = IC_SEG_ON;
}
else
{
IC2_SEG149 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC2_SEG150 = IC_SEG_ON;
}
else
{
IC2_SEG150 = IC_SEG_OFF;
}
}
else
{
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
IC2_SEG156 = IC_SEG_OFF;
IC2_SEG159 = IC_SEG_OFF;
IC2_SEG093 = IC_SEG_OFF;
IC2_SEG148 = IC_SEG_OFF;
IC2_SEG147 = IC_SEG_OFF;
IC2_SEG098 = IC_SEG_OFF;
IC2_SEG097 = IC_SEG_OFF;
IC2_SEG096 = IC_SEG_OFF;
IC2_SEG094 = IC_SEG_OFF;
IC2_SEG095 = IC_SEG_OFF;
IC2_SEG155 = IC_SEG_OFF;
IC2_SEG154 = IC_SEG_OFF;
IC2_SEG153 = IC_SEG_OFF;
IC2_SEG152 = IC_SEG_OFF;
IC2_SEG151 = IC_SEG_OFF;
IC2_SEG150 = IC_SEG_OFF;
IC2_SEG149 = IC_SEG_OFF;
}
}
/**@brief 电压数字显示函数
* @param[in] m_Flag 电压是否显示 -1 显示 -0 不显示
* @param[in] m_NUM 电压数值
*/
void SEG_SET_Voltage_NUM(uint8_t m_Flag, uint16_t m_NUM)
{
uint16_t Num = 0;
uint8_t m8;
if(m_Flag)
{
IC1_SEG079 = IC_SEG_ON;
IC1_SEG086 = IC_SEG_ON;
Num = m_NUM / 100;
m8 = SEG_UNDISPLAY_NUMBER0[Num];
if (Bit_Is_Set(m8, 0))
{
IC1_SEG096 = IC_SEG_ON;
}
else
{
IC1_SEG096 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG095 = IC_SEG_ON;
}
else
{
IC1_SEG095 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG093 = IC_SEG_ON;
}
else
{
IC1_SEG093 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG099 = IC_SEG_ON;
}
else
{
IC1_SEG099 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG098 = IC_SEG_ON;
}
else
{
IC1_SEG098 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG097 = IC_SEG_ON;
}
else
{
IC1_SEG097 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG094 = IC_SEG_ON;
}
else
{
IC1_SEG094 = IC_SEG_OFF;
}
/*十位*/
Num = (m_NUM / 10u) % 10u;
if ((m_NUM >= 100u) || (m_NUM == 0))
{
m8 = SEG_DISPLAY_NUMBER0[Num];
}
else
{
m8 = SEG_UNDISPLAY_NUMBER0[Num];
}
if (Bit_Is_Set(m8, 0))
{
IC1_SEG090 = IC_SEG_ON;
}
else
{
IC1_SEG090 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG089 = IC_SEG_ON;
}
else
{
IC1_SEG089 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG087 = IC_SEG_ON;
}
else
{
IC1_SEG087 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG100 = IC_SEG_ON;
}
else
{
IC1_SEG100 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG092 = IC_SEG_ON;
}
else
{
IC1_SEG092 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG091 = IC_SEG_ON;
}
else
{
IC1_SEG091 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG088 = IC_SEG_ON;
}
else
{
IC1_SEG088 = IC_SEG_OFF;
}
/*个位*/
Num = m_NUM % 10u;
m8 = SEG_DISPLAY_NUMBER0[Num];
if (Bit_Is_Set(m8, 0))
{
IC1_SEG083 = IC_SEG_ON;
}
else
{
IC1_SEG083 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG082 = IC_SEG_ON;
}
else
{
IC1_SEG082 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG080 = IC_SEG_ON;
}
else
{
IC1_SEG080 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG101 = IC_SEG_ON;
}
else
{
IC1_SEG101 = IC_SEG_OFF;
IC2_SEG152 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG085 = IC_SEG_ON;
IC2_SEG151 = IC_SEG_ON;
}
else
{
IC1_SEG085 = IC_SEG_OFF;
IC2_SEG151 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG084 = IC_SEG_ON;
IC2_SEG149 = IC_SEG_ON;
}
else
{
IC1_SEG084 = IC_SEG_OFF;
IC2_SEG149 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG081 = IC_SEG_ON;
IC2_SEG150 = IC_SEG_ON;
}
else
{
IC1_SEG081 = IC_SEG_OFF;
IC2_SEG150 = IC_SEG_OFF;
}
}
else
{
LED_Driver_Channel_Set(LampChannel_0, LampCh0_08_KMH, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_09_MPH, LED_OFF);
IC2_SEG156 = IC_SEG_OFF;
IC2_SEG159 = IC_SEG_OFF;
IC2_SEG093 = IC_SEG_OFF;
IC2_SEG148 = IC_SEG_OFF;
IC2_SEG147 = IC_SEG_OFF;
IC2_SEG098 = IC_SEG_OFF;
IC2_SEG097 = IC_SEG_OFF;
IC2_SEG096 = IC_SEG_OFF;
IC2_SEG094 = IC_SEG_OFF;
IC2_SEG095 = IC_SEG_OFF;
IC2_SEG155 = IC_SEG_OFF;
IC2_SEG154 = IC_SEG_OFF;
IC2_SEG153 = IC_SEG_OFF;
IC2_SEG152 = IC_SEG_OFF;
IC2_SEG151 = IC_SEG_OFF;
IC2_SEG150 = IC_SEG_OFF;
IC2_SEG149 = IC_SEG_OFF;
}
}
/**@brief 电压数字显示函数
* @param[in] m_Flag 电压是否显示 -1 显示 -0 不显示
* @param[in] m_NUM 电压数值
*/
void SEG_SET_Voltage_NUM(uint8_t m_Flag, uint16_t m_NUM)
{
uint16_t Num = 0;
uint8_t m8;
if(m_Flag)
{
IC1_SEG079 = IC_SEG_ON;
IC1_SEG086 = IC_SEG_ON;
if((Get_Battery_Voltage_Valid() != 1)&&(ClearODO_Flag != 1)&&(Common_GetIgnOnTime() > 3000))
{
IC1_SEG088 = IC_SEG_ON;
IC1_SEG081 = IC_SEG_ON;
IC1_SEG096 = IC_SEG_OFF;
IC1_SEG095 = IC_SEG_OFF;
IC1_SEG093 = IC_SEG_OFF;
IC1_SEG099 = IC_SEG_OFF;
IC1_SEG098 = IC_SEG_OFF;
IC1_SEG097 = IC_SEG_OFF;
IC1_SEG094 = IC_SEG_OFF;
IC1_SEG090 = IC_SEG_OFF;
IC1_SEG089 = IC_SEG_OFF;
IC1_SEG087 = IC_SEG_OFF;
IC1_SEG100 = IC_SEG_OFF;
IC1_SEG092 = IC_SEG_OFF;
IC1_SEG091 = IC_SEG_OFF;
IC1_SEG083 = IC_SEG_OFF;
IC1_SEG082 = IC_SEG_OFF;
IC1_SEG080 = IC_SEG_OFF;
IC1_SEG101 = IC_SEG_OFF;
IC1_SEG085 = IC_SEG_OFF;
IC1_SEG084 = IC_SEG_OFF;
}
else
{
Num = m_NUM / 100;
if((ClearODO_Flag == 1) || (Common_GetIgnOnTime() <= 3000))
{
m8 = SEG_DISPLAY_NUMBER0[Num];
}
else
{
m8 = SEG_UNDISPLAY_NUMBER0[Num];
}
if (Bit_Is_Set(m8, 0))
{
IC1_SEG096 = IC_SEG_ON;
}
else
{
IC1_SEG096 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG095 = IC_SEG_ON;
}
else
{
IC1_SEG095 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG093 = IC_SEG_ON;
}
else
{
IC1_SEG093 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG099 = IC_SEG_ON;
}
else
{
IC1_SEG099 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG098 = IC_SEG_ON;
}
else
{
IC1_SEG098 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG097 = IC_SEG_ON;
}
else
{
IC1_SEG097 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG094 = IC_SEG_ON;
}
else
{
IC1_SEG094 = IC_SEG_OFF;
}
/*十位*/
Num = (m_NUM / 10u) % 10u;
if ((m_NUM >= 100u) || (m_NUM == 0))
{
m8 = SEG_DISPLAY_NUMBER0[Num];
}
else
{
m8 = SEG_UNDISPLAY_NUMBER0[Num];
}
if (Bit_Is_Set(m8, 0))
{
IC1_SEG090 = IC_SEG_ON;
}
else
{
IC1_SEG090 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG089 = IC_SEG_ON;
}
else
{
IC1_SEG089 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG087 = IC_SEG_ON;
}
else
{
IC1_SEG087 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG100 = IC_SEG_ON;
}
else
{
IC1_SEG100 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG092 = IC_SEG_ON;
}
else
{
IC1_SEG092 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG091 = IC_SEG_ON;
}
else
{
IC1_SEG091 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG088 = IC_SEG_ON;
}
else
{
IC1_SEG088 = IC_SEG_OFF;
}
/*个位*/
Num = m_NUM % 10u;
m8 = SEG_DISPLAY_NUMBER0[Num];
if (Bit_Is_Set(m8, 0))
{
IC1_SEG083 = IC_SEG_ON;
}
else
{
IC1_SEG083 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 1))
{
IC1_SEG082 = IC_SEG_ON;
}
else
{
IC1_SEG082 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 2))
{
IC1_SEG080 = IC_SEG_ON;
}
else
{
IC1_SEG080 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 3))
{
IC1_SEG101 = IC_SEG_ON;
}
else
{
IC1_SEG101 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 4))
{
IC1_SEG085 = IC_SEG_ON;
}
else
{
IC1_SEG085 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 5))
{
IC1_SEG084 = IC_SEG_ON;
}
else
{
IC1_SEG084 = IC_SEG_OFF;
}
if (Bit_Is_Set(m8, 6))
{
IC1_SEG081 = IC_SEG_ON;
}
else
{
IC1_SEG081 = IC_SEG_OFF;
}
}
}
}
......@@ -1319,16 +2018,37 @@ void SEG_SET_TPMS_NUM(uint8_t m_Flag, uint16_t m_NUM1, uint16_t m_NUM2, uint8_t
{
if (Get_Current_PageType() == Page_Tpms_Unit)
{
if(FLASH_SYNC_1Hz)
if (m_Unit == 0)
{
IC2_SEG109 = IC_SEG_ON;
IC2_SEG110 = IC_SEG_ON;
IC2_SEG118 = IC_SEG_ON;
IC2_SEG138 = IC_SEG_ON;
if(FLASH_SYNC_1Hz)
{
IC2_SEG109 = IC_SEG_OFF;
IC2_SEG110 = IC_SEG_ON;
}
else
{
IC2_SEG109 = IC_SEG_OFF;
IC2_SEG110 = IC_SEG_OFF;
}
}
else
{
IC2_SEG109 = IC_SEG_OFF;
IC2_SEG110 = IC_SEG_OFF;
IC2_SEG118 = IC_SEG_OFF;
IC2_SEG138 = IC_SEG_OFF;
if(FLASH_SYNC_1Hz)
{
IC2_SEG109 = IC_SEG_ON;
IC2_SEG110 = IC_SEG_OFF;
}
else
{
IC2_SEG109 = IC_SEG_OFF;
IC2_SEG110 = IC_SEG_OFF;
}
}
}
else
{
......@@ -1693,18 +2413,35 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
RTE_GPIO_Set_Level(ODO_Thousand, 1);
if ((ClearODO_Flag != 1) && (Common_GetIgnOnTime() >= 3000))
{
if (Get_Current_PageType() == Page_Km_Unit)
if ((Get_Current_PageType() == Page_Km_Unit) && ((Get_Current_PageMenu() == Page_Odo) || (Get_Current_PageMenu() == Page_Trip)))
{
if(FLASH_SYNC_1Hz)
if (m_Uint == 0)
{
IC1_SEG036 = IC_SEG_ON;
IC1_SEG037 = IC_SEG_ON;
if(FLASH_SYNC_1Hz)
{
IC1_SEG036 = IC_SEG_OFF;
IC1_SEG037 = IC_SEG_ON;
}
else
{
IC1_SEG036 = IC_SEG_OFF;
IC1_SEG037 = IC_SEG_OFF;
}
}
else
{
IC1_SEG036 = IC_SEG_OFF;
IC1_SEG037 = IC_SEG_OFF;
if(FLASH_SYNC_1Hz)
{
IC1_SEG036 = IC_SEG_ON;
IC1_SEG037 = IC_SEG_OFF;
}
else
{
IC1_SEG036 = IC_SEG_OFF;
IC1_SEG037 = IC_SEG_OFF;
}
}
}
else
{
......@@ -2385,7 +3122,8 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
{
SEG_SET_DTC_NUM(0);
DTC_DISTimer = 0;
Current_DTC_CODE = 0;
Current_DTC_CODE = 0;
Current_DTC_CODE_BACK = 0;
}
else
{
......@@ -2400,6 +3138,7 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
DTC_DISTimer = 0;
}
Current_DTC_CODE_BACK = Current_DTC_CODE;
}
else if (DTC_DISTimer >= 100)
{
......@@ -2410,6 +3149,11 @@ void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint
}
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
DTC_DISTimer = 0;
if(Current_DTC_CODE == Current_DTC_CODE_BACK)
{
DTC_DISCount ++ ;
Current_DTC_CODE = FaultCode_Data[DTC_DISCount] ;
}
}
SEG_SET_DTC_NUM(Current_DTC_CODE);
}
......@@ -2825,7 +3569,8 @@ void Check_SEG_Display(void)
SEG_SET_Clock(((a * 10u) + a), ((a * 10u) + a), 1u, 1u, 1u);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_07_Screen_Time, LED_ON);
SEG_SET_TPMS_NUM(1, a * 11, a * 11, 0, 1, 1);
SEG_SET_Voltage_NUM(1, a * 111);
SEG_SET_Voltage_NUM(1, a * 111);
SEG_SET_Navigation_STS(1, 3, a * 111100);
for (i = 0; i < SEG_LED_MAX; i++)
{
......@@ -2860,6 +3605,7 @@ void Checkself_SEG_Display(void)
uint16_t hour = 0;
uint16_t min = 0;
uint32_t ODO = 0;
uint32_t Mileage = 0;
//uint32_t i = 0;
//for(i = 0; i < BU98R10_DDRAM_SIZE; i ++)
......@@ -2867,6 +3613,8 @@ void Checkself_SEG_Display(void)
// BU98R10Chip0DDRAM.Byte[i] = 1;
// BU98R10Chip1DDRAM.Byte[i] = 1;
//}
Mileage = ((Checkself_SEG_step / 3) * 111100);
SEG_SET_Navigation_STS(1, 3, Mileage);
Fuel = Checkself_SEG_step / 5u;
SEG_SET_FuelDial(1, Fuel);
......
......@@ -28,6 +28,16 @@ typedef enum
SEG_LED_MAX,
} SEG_LED_Idx_t;
#define NaviIconType_LEFT 0x02
#define NaviIconType_RIGHT 0x03
#define NaviIconType_LEFT_FRONT 0x04
#define NaviIconType_RIGHT_FRONT 0x05
#define NaviIconType_LEFT_BACK 0x06
#define NaviIconType_RIGHT_BACK 0x07
#define NaviIconType_STRAIGHT 0x08
#define NaviIconType_ARRIVED_SERVICE_AREA 0x0D
#define NaviIconType_ARRIVED_TOLLGATE 0x0E
#define NaviIconType_ARRIVED_TUNNEL 0x10
......@@ -41,7 +51,7 @@ void SEG_SET_Voltage_NUM(uint8_t m_Flag, uint16_t m_NUM);
void SEG_SET_TPMS_NUM(uint8_t m_Flag, uint16_t m_NUM1, uint16_t m_NUM2, uint8_t m_Unit, uint8_t m_valid1, uint8_t m_valid2);
void SEG_SET_ODO_TRIP_FAULTCODE_TCS_DIS(uint8_t m_Uint, uint32_t m_NUM_ODO, uint32_t m_NUM_TRIP);
void SEG_SET_Clock(uint8_t m_hour, uint8_t m_minute, uint8_t m_icon, uint8_t m_Flag1, uint8_t m_Flag2);
void SEG_SET_Navigation_STS(uint8_t m_Flag, uint8_t m_Code, uint32_t m_Mileage);
void Check_SEG_Display(void);
extern uint8_t check_SEG_step;
......
......@@ -22,7 +22,7 @@ extern {
#endif
/* Exported types ------------------------------------------------------------*/
typedef struct
typedef struct __attribute__((aligned(4)))
{
uint32_t u32Res1;
uint32_t u32Res2;
......
......@@ -10,6 +10,7 @@ _Menu_Data MenuData;
uint8_t PageType = 0;
uint8_t PageMenu = 0;
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;
RTC_CounterTypeDef counter_val;
......@@ -234,6 +235,7 @@ void Key_Left_Short_Press(void)
datmax = 23u;
datmin = 0u;
Menu_u8Data_Updata_Process(updataDir, datmax, datmin, 1u, (uint8_t*)&(counter_val.time.RTC_Hours));
RTC_SetTime(&counter_val.time);
}
else if(PageType == Page_Time_Minute)
{
......@@ -241,9 +243,12 @@ void Key_Left_Short_Press(void)
datmax = 59u;
datmin = 0u;
Menu_u8Data_Updata_Process(updataDir, datmax, datmin, 1u, (uint8_t*)&(counter_val.time.RTC_Minutes));
RTC_SetTime(&counter_val.time);
}
else if(PageType == Page_Km_Unit)
{
{
if(Get_Dis_KM_Unit() == 0)
{
MenuData.KM_Unit = 1;//mile
......@@ -371,10 +376,12 @@ void MenuData_Unit_Init(void)
MenuData.KM_Unit = 0;
MenuData.Tpms_Unit = 0;
MenuData.Tcs_Val = 1;
}
void MenuData_TCS_Init(void)
{
MenuData.Tcs_Val = 1;
MenuData.Tcs_Val = 1;
PageType = Page_Menu;
}
uint8_t ClearODO_Flag = 0;
......@@ -397,10 +404,7 @@ void TYW_RESET_ODO(void)
}
}
}
else
{
ClearODO_Flag = 0;
}
}
void Maintain_Reset_Service(void)
......
......@@ -25,17 +25,17 @@ typedef enum
LampCh0_08_KMH,
LampCh0_09_MPH,
LampCh0_10_Navigator,
LampCh0_10_Navigator1,
LampCh0_11_Temp_AlarmR,
LampCh0_12_ABS_Alarm,
LampCh0_13_Temp_AlarmW,
LampCh0_14_Resting_Area,
LampCh0_14_ARRIVED_SERVICE_AREA,
LampCh0_15_Tollbooth,
LampCh0_16_Underpass1,
LampCh0_15_ARRIVED_TOLLGATE,
LampCh0_16_ARRIVED_TUNNEL,
LampCh0_17_Length2,
LampCh0_18_Length1,
LampCh0_19_Underpass2,
LampCh0_19_Navigator2,
LampCh0_20_Fuel_Y,
LampCh0_21_Fuel_W,
......
......@@ -52,8 +52,9 @@ static void Power_KL30_Init(void)
DFlash_init();
Analog_Signal_Conv_Init();
BU98R10_Init();
//Uart0_Init(115200);
Uart0_Init(115200);
Protocol_KL30_Wakeup_Init();
BlueTooth_KL30_KL15_Wakeup_Init();
Sys_KL30_Init();
Checkself_Init();
Data_Vehicle_Speed_KL30_Init();
......@@ -111,6 +112,9 @@ static void Power_Wakeup_Init(void)
MenuData_TCS_Init();
//Light_Sensor_Init_Example();//注意顺序1
LED_Driver_Init_Example();//注意顺序2
Protocol_KL30_Wakeup_Init();
Uart0_Init(115200);
BlueTooth_KL30_KL15_Wakeup_Init();
Fuel_KL30_Init();
Data_Voltage_Init();
TimerM_PWM_counter_Output_Init(TIMERM_COUNTER0, 400, 64000000);
......@@ -143,8 +147,7 @@ static void Power_IG_OFF_Init(void)
}
static void Power_IG_ON_Init(void)
{
ClearODO_Flag = 0;
{
Checkself_Init();
Line_In_KL15_ON_Init();
Telltales_KL15_Init();
......@@ -153,6 +156,7 @@ static void Power_IG_ON_Init(void)
Data_Voltage_Init();
MenuData_TCS_Init();
Data_Coolant_Temp_KL15_Init();
BlueTooth_KL30_KL15_Wakeup_Init();
CAN_TX_SetEnable(&CAN_CH0_CanMsgTxOp, CAN_N_TX_Enable);
}
......
#include "System_Monitor.h"
#include <stdio.h>
typedef struct
{
monitorlib_uint8_t SumCnt;
monitorlib_uint16_t DebounceTimer;
monitorlib_uint32_t ActVoltage;
monitorlib_uint8_t FinalSts;
monitorlib_uint8_t ActSts;
} MonitorStruct;
MonitorStruct SysFun_KL30Monitor;
MonitorStruct SysFun_KL15Monitor;
MonitorStruct SysNM_KL30Monitor;
MonitorStruct SysNM_KL15Monitor;
#define Base_Vol 0u
#define ENTER_LOW_N_RANGE 6500U
#define EXIT_LOW_N_RANGE 7000U
#define ENTER_LOW_Y_RANGE 9000U
#define EXIT_LOW_Y_RANGE 9500U
#define EXIT_HIGH_Y_RANGE 16000U
#define ENTER_HIGH_Y_RANGE 16500U
#define EXIT_HIGH_N_RANGE 18500U
#define ENTER_HIGH_N_RANGE 19000U
#define Top_Vol 0xffffu
static monitorlib_uint8_t System_Calc_NMRange(monitorlib_uint16_t u16Vol);
static monitorlib_uint8_t System_Calc_FunRange(monitorlib_uint16_t u16Vol);
static void System_Fast_WakeUp(void);
static void System_Fun_Process(void);
static void System_NM_Process(void);
MonitorExt_st pfunction;
monitorlib_uint8_t SysWakeUpMode = 0u;
monitorlib_uint8_t SetVolFlag = 0u;
monitorlib_uint16_t FUNSysVol_Range [ 10u ] = {
Base_Vol,
ENTER_LOW_N_RANGE,
EXIT_LOW_N_RANGE,
ENTER_LOW_Y_RANGE,
EXIT_LOW_Y_RANGE,
EXIT_HIGH_Y_RANGE,
ENTER_HIGH_Y_RANGE,
EXIT_HIGH_N_RANGE,
ENTER_HIGH_N_RANGE,
Top_Vol,
};
monitorlib_uint16_t NMSysVol_Range [ 10u ] = {
Base_Vol,
ENTER_LOW_N_RANGE,
EXIT_LOW_N_RANGE,
ENTER_LOW_Y_RANGE,
EXIT_LOW_Y_RANGE,
EXIT_HIGH_Y_RANGE,
ENTER_HIGH_Y_RANGE,
EXIT_HIGH_N_RANGE,
ENTER_HIGH_N_RANGE,
Top_Vol,
};
monitorlib_uint16_t t_FUN_KL30_Debounce;
monitorlib_uint16_t t_FUN_KL15_Debounce;
monitorlib_uint16_t t_NM_KL30_Debounce;
monitorlib_uint16_t t_NM_KL15_Debounce;
monitorlib_uint16_t t_NM_KL30_Debounce_Cancel;
monitorlib_uint16_t t_NM_KL15_Debounce_Cancel;
monitorlib_uint16_t t_FUN_KL30_Debounce_Cancel;
monitorlib_uint16_t t_FUN_KL15_Debounce_Cancel;
monitorlib_uint16_t t_NM_KL30_timer;
monitorlib_uint16_t t_FUN_KL30_timer;
monitorlib_uint8_t Read_KL30_ConvertFinish(void)
{
return SysWakeUpMode;
}
static monitorlib_uint8_t System_Calc_FunRange(monitorlib_uint16_t u16Vol)
{
monitorlib_uint8_t i;
for ( i = 0u; i < (sizeof(FUNSysVol_Range) / sizeof(FUNSysVol_Range [ 0 ])); i++ )
{
if ( u16Vol < FUNSysVol_Range [ i ] )
{
break;
}
}
return i;
}
static monitorlib_uint8_t System_Calc_NMRange(monitorlib_uint16_t u16Vol)
{
monitorlib_uint8_t i;
for ( i = 0u; i < (sizeof(NMSysVol_Range) / sizeof(NMSysVol_Range [ 0 ])); i++ )
{
if ( u16Vol < NMSysVol_Range [ i ] )
{
break;
}
}
return i;
}
void Sys_Set_Pata(const monitorlib_uint16_t FUN_Vol [], MonitorExt_st *pfunc)
{
FUNSysVol_Range [ 0 ] = FUN_Vol [ 0 ];
FUNSysVol_Range [ 1 ] = FUN_Vol [ 1 ];
FUNSysVol_Range [ 2 ] = FUN_Vol [ 2 ];
FUNSysVol_Range [ 3 ] = FUN_Vol [ 3 ];
FUNSysVol_Range [ 4 ] = FUN_Vol [ 4 ];
FUNSysVol_Range [ 5 ] = FUN_Vol [ 5 ];
FUNSysVol_Range [ 6 ] = FUN_Vol [ 6 ];
FUNSysVol_Range [ 7 ] = FUN_Vol [ 7 ];
FUNSysVol_Range [ 8 ] = FUN_Vol [ 8 ];
FUNSysVol_Range [ 9 ] = FUN_Vol [ 9 ];
t_FUN_KL30_Debounce = FUN_Vol [ 10 ];
t_FUN_KL15_Debounce = FUN_Vol [ 11 ];
NMSysVol_Range [ 0 ] = FUN_Vol [ 12 ];
NMSysVol_Range [ 1 ] = FUN_Vol [ 13 ];
NMSysVol_Range [ 2 ] = FUN_Vol [ 14 ];
NMSysVol_Range [ 3 ] = FUN_Vol [ 15 ];
NMSysVol_Range [ 4 ] = FUN_Vol [ 16 ];
NMSysVol_Range [ 5 ] = FUN_Vol [ 17 ];
NMSysVol_Range [ 6 ] = FUN_Vol [ 18 ];
NMSysVol_Range [ 7 ] = FUN_Vol [ 19 ];
NMSysVol_Range [ 8 ] = FUN_Vol [ 20 ];
NMSysVol_Range [ 9 ] = FUN_Vol [ 21 ];
t_NM_KL30_Debounce = FUN_Vol [ 22 ];
t_NM_KL15_Debounce = FUN_Vol [ 23 ];
t_NM_KL30_Debounce_Cancel = FUN_Vol [ 24 ];
t_FUN_KL30_Debounce_Cancel = FUN_Vol [ 25 ];
pfunction.SysGet_KL30_Valid = pfunc->SysGet_KL30_Valid;
pfunction.SysGet_KL15_Valid = pfunc->SysGet_KL15_Valid;
pfunction.SysGet_KL30_value_Force = pfunc->SysGet_KL30_value_Force;
pfunction.SysGet_KL15_value_Force = pfunc->SysGet_KL15_value_Force;
pfunction.SysGet_KL30_value = pfunc->SysGet_KL30_value;
pfunction.SysGet_KL15_value = pfunc->SysGet_KL15_value;
pfunction.SysGet_KL15Line = pfunc->SysGet_KL15Line;
pfunction.COM_Delay = pfunc->COM_Delay;
pfunction.SysMonitorLogic = pfunc->SysMonitorLogic;
SetVolFlag = 0x55u;
}
void System_Monitor_KL30Init(void)
{
SysWakeUpMode = 0u;
SysFun_KL30Monitor.SumCnt = 0u;
SysFun_KL30Monitor.DebounceTimer = 0u;
SysFun_KL30Monitor.ActVoltage = 0u;
SysFun_KL30Monitor.FinalSts = 0u;
SysFun_KL30Monitor.ActSts = 0u;
SysFun_KL15Monitor.SumCnt = 0u;
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.ActVoltage = 0u;
SysFun_KL15Monitor.FinalSts = 0u;
SysFun_KL15Monitor.ActSts = 0u;
SysNM_KL30Monitor.SumCnt = 0u;
SysNM_KL30Monitor.DebounceTimer = 0u;
SysNM_KL30Monitor.ActVoltage = 0u;
SysNM_KL30Monitor.FinalSts = 0u;
SysNM_KL30Monitor.ActSts = 0u;
SysNM_KL15Monitor.SumCnt = 0u;
SysNM_KL15Monitor.DebounceTimer = 0u;
SysNM_KL15Monitor.ActVoltage = 0u;
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
if ( SetVolFlag != 0x55u )
{
t_NM_KL30_Debounce = 1000u;
t_NM_KL15_Debounce = 2u;
t_FUN_KL30_Debounce = 1000u;
t_FUN_KL15_Debounce = 2u;
t_NM_KL30_Debounce_Cancel = 1000U;
t_NM_KL15_Debounce_Cancel = 2U;
t_FUN_KL30_Debounce_Cancel = 1000U;
t_FUN_KL15_Debounce_Cancel = 2U;
FUNSysVol_Range [ 0 ] = Base_Vol;
FUNSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
FUNSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
FUNSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
FUNSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
FUNSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
FUNSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
FUNSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
FUNSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
FUNSysVol_Range [ 9 ] = Top_Vol;
NMSysVol_Range [ 0 ] = Base_Vol;
NMSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
NMSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
NMSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
NMSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
NMSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
NMSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
NMSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
NMSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
NMSysVol_Range [ 9 ] = Top_Vol;
SetVolFlag = 0x55u;
}
if ( pfunction.COM_Delay != (( void * )0) )
{
pfunction.COM_Delay(260U);
}
System_Fast_WakeUp( );
}
void System_Monitor_WakeupInit(void)
{
SysWakeUpMode = 0u;
SysFun_KL30Monitor.SumCnt = 0u;
SysFun_KL30Monitor.DebounceTimer = 0u;
SysFun_KL30Monitor.ActVoltage = 0u;
SysFun_KL30Monitor.FinalSts = 0u;
SysFun_KL30Monitor.ActSts = 0u;
SysFun_KL15Monitor.SumCnt = 0u;
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.ActVoltage = 0u;
SysFun_KL15Monitor.FinalSts = 0u;
SysFun_KL15Monitor.ActSts = 0u;
SysNM_KL30Monitor.SumCnt = 0u;
SysNM_KL30Monitor.DebounceTimer = 0u;
SysNM_KL30Monitor.ActVoltage = 0u;
SysNM_KL30Monitor.FinalSts = 0u;
SysNM_KL30Monitor.ActSts = 0u;
SysNM_KL15Monitor.SumCnt = 0u;
SysNM_KL15Monitor.DebounceTimer = 0u;
SysNM_KL15Monitor.ActVoltage = 0u;
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
if ( SetVolFlag != 0x55u )
{
t_NM_KL30_Debounce = 1000u;
t_NM_KL15_Debounce = 2u;
t_FUN_KL30_Debounce = 1000u;
t_FUN_KL15_Debounce = 2u;
t_NM_KL30_Debounce_Cancel = 1000U;
t_NM_KL15_Debounce_Cancel = 2U;
t_FUN_KL30_Debounce_Cancel = 1000U;
t_FUN_KL15_Debounce_Cancel = 2U;
FUNSysVol_Range [ 0 ] = Base_Vol;
FUNSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
FUNSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
FUNSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
FUNSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
FUNSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
FUNSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
FUNSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
FUNSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
FUNSysVol_Range [ 9 ] = Top_Vol;
NMSysVol_Range [ 0 ] = Base_Vol;
NMSysVol_Range [ 1 ] = ENTER_LOW_N_RANGE;
NMSysVol_Range [ 2 ] = EXIT_LOW_N_RANGE;
NMSysVol_Range [ 3 ] = ENTER_LOW_Y_RANGE;
NMSysVol_Range [ 4 ] = EXIT_LOW_Y_RANGE;
NMSysVol_Range [ 5 ] = EXIT_HIGH_Y_RANGE;
NMSysVol_Range [ 6 ] = ENTER_HIGH_Y_RANGE;
NMSysVol_Range [ 7 ] = EXIT_HIGH_N_RANGE;
NMSysVol_Range [ 8 ] = ENTER_HIGH_N_RANGE;
NMSysVol_Range [ 9 ] = Top_Vol;
SetVolFlag = 0x55u;
}
System_Fast_WakeUp( );
}
void Sys_Status_Update_Service(void)
{
System_Fun_Process( );
System_NM_Process( );
if ( pfunction.SysMonitorLogic != (( void * )0) )
{
pfunction.SysMonitorLogic( );
}
}
static void System_Fast_WakeUp(void)
{
monitorlib_uint16_t KL30_Voltage;
monitorlib_uint16_t KL15_Voltage;
monitorlib_uint16_t Voltage;
monitorlib_uint8_t NormalKL30Cnt = 0U;
monitorlib_uint8_t abnormalKL30Cnt = 0U;
monitorlib_uint8_t AttemptCnt = 0U;
AttemptCnt = 0u;
while ( SysNM_KL30Monitor.FinalSts == 0u )
{
if ( pfunction.COM_Delay != (( void * )0) )
{
pfunction.COM_Delay(2U);
}
/*KL30 KL15 voltage */
if ( pfunction.SysGet_KL30_value_Force != ( void * )0 )
{
KL30_Voltage = pfunction.SysGet_KL30_value_Force( );
}
else
{
KL30_Voltage = 0u;
}
if ( pfunction.SysGet_KL15_value_Force != ( void * )0 )
{
KL15_Voltage = pfunction.SysGet_KL15_value_Force( );
}
else
{
KL15_Voltage = 0u;
}
if ( KL30_Voltage > KL15_Voltage )
{
Voltage = KL30_Voltage;
}
else
{
Voltage = KL15_Voltage;
}
if ( (Voltage <= NMSysVol_Range [ 2 ]) || (Voltage >= NMSysVol_Range [ 7 ]) )
{
NormalKL30Cnt = 0U;
abnormalKL30Cnt++;
}
else
{
NormalKL30Cnt++;
abnormalKL30Cnt = 0U;
}
AttemptCnt++;
if ( AttemptCnt >= 10u )
{
break;
}
if ( NormalKL30Cnt >= 5U )
{
SysNM_KL30Monitor.FinalSts = 5u;
}
if ( abnormalKL30Cnt >= 5U )
{
SysNM_KL30Monitor.FinalSts = 9u;
}
}
if ( (SysNM_KL30Monitor.FinalSts != 0u) )
{
SysWakeUpMode = 0x55U;
if ( pfunction.SysGet_KL15Line != (( void * )0) )
{
SysNM_KL15Monitor.FinalSts = pfunction.SysGet_KL15Line( );
SysNM_KL15Monitor.ActSts = pfunction.SysGet_KL15Line( );
}
else
{
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
}
if ( pfunction.SysMonitorLogic != ( void * )0 )
{
pfunction.SysMonitorLogic( );
}
}
}
static void System_NM_Process(void)
{
monitorlib_uint8_t m8;
static monitorlib_uint16_t DebpounceTimer;
monitorlib_uint16_t Voltage;
monitorlib_uint8_t VoltageKL30Valid;
monitorlib_uint8_t VoltageKL15Valid;
monitorlib_uint16_t Voltage_KL15;
monitorlib_uint16_t Voltage_KL30;
if ( pfunction.SysGet_KL15Line != (( void * )0) )
{
if ( SysNM_KL15Monitor.ActSts == pfunction.SysGet_KL15Line( ) )
{
if ( SysNM_KL15Monitor.DebounceTimer < t_NM_KL15_Debounce )
{
SysNM_KL15Monitor.DebounceTimer++;
}
else
{
SysNM_KL15Monitor.FinalSts = SysNM_KL15Monitor.ActSts;
}
}
else
{
SysNM_KL15Monitor.DebounceTimer = 0u;
SysNM_KL15Monitor.ActSts = pfunction.SysGet_KL15Line( );
}
}
else
{
SysNM_KL15Monitor.FinalSts = 0u;
SysNM_KL15Monitor.ActSts = 0u;
SysNM_KL15Monitor.DebounceTimer = 0u;
}
if ( pfunction.SysGet_KL30_Valid != ( void * )0 )
{
VoltageKL30Valid = pfunction.SysGet_KL30_Valid( );
}
else
{
VoltageKL30Valid = 0u;
}
if ( pfunction.SysGet_KL15_Valid != ( void * )0 )
{
VoltageKL15Valid = pfunction.SysGet_KL15_Valid( );
}
else
{
VoltageKL15Valid = 0u;
}
if ( (VoltageKL30Valid == 1U) && (VoltageKL15Valid == 1U) )
{
if ( pfunction.SysGet_KL15_value != (( void * )0) )
{
Voltage_KL15 = pfunction.SysGet_KL15_value( );
}
else
{
Voltage_KL15 = 0u;
}
if ( pfunction.SysGet_KL15_value != (( void * )0) )
{
Voltage_KL30 = pfunction.SysGet_KL30_value( );
}
else
{
Voltage_KL30 = 0u;
}
if ( Voltage_KL30 > Voltage_KL15 )
{
Voltage = Voltage_KL30;
}
else
{
Voltage = Voltage_KL15;
}
if ( SysNM_KL30Monitor.SumCnt < 50u )
{
SysNM_KL30Monitor.ActVoltage += Voltage;
SysNM_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysNM_KL30Monitor.ActVoltage / SysNM_KL30Monitor.SumCnt);
}
else
{
SysNM_KL30Monitor.SumCnt = 0u;
SysNM_KL30Monitor.ActVoltage = 0u;
SysNM_KL30Monitor.ActVoltage += Voltage;
SysNM_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysNM_KL30Monitor.ActVoltage / SysNM_KL30Monitor.SumCnt);
}
m8 = System_Calc_NMRange(Voltage);
if ( SysNM_KL30Monitor.ActSts == m8 )
{
switch ( SysNM_KL30Monitor.FinalSts )
{
case 0:
case 1:
case 9:
t_NM_KL30_timer = t_NM_KL30_Debounce_Cancel;
break;
default:
t_NM_KL30_timer = t_NM_KL30_Debounce;
break;
}
if ( SysNM_KL30Monitor.DebounceTimer < t_NM_KL30_timer ) /*40202-8*/
{
SysNM_KL30Monitor.DebounceTimer++;
}
else
{
DebpounceTimer = 0u;
if ( SysNM_KL30Monitor.FinalSts == 9u ) /* 高压 */
{
if ( (m8 == 9u) || (m8 == 8u) )
{
SysNM_KL30Monitor.FinalSts = 9u; /** 维持不变 **/
}
else
{
SysNM_KL30Monitor.FinalSts = m8; /**退�?*/
}
}
if ( SysNM_KL30Monitor.FinalSts == 1u ) /* 低压 */
{
if ( (m8 == 1u) || (m8 == 2u) )
{
SysNM_KL30Monitor.FinalSts = 1u; /** 维持不变 */
}
else
{
SysNM_KL30Monitor.FinalSts = m8; /**退�?*/
}
}
/* 非高低压 */
if ( (SysNM_KL30Monitor.FinalSts != 1u) && (SysNM_KL30Monitor.FinalSts != 9u) )
{
SysNM_KL30Monitor.FinalSts = m8; /** 进入*/
}
}
}
else
{
/* 计时时间清除 */
SysNM_KL30Monitor.DebounceTimer = 0U;
DebpounceTimer++;
if ( DebpounceTimer >= 5u )
{
DebpounceTimer = 0u;
SysNM_KL30Monitor.ActSts = m8;
}
}
}
}
static void System_Fun_Process(void)
{
monitorlib_uint8_t m8;
monitorlib_uint8_t VoltageKL30Valid;
monitorlib_uint8_t VoltageKL15Valid;
monitorlib_uint16_t Voltage;
monitorlib_uint16_t Voltage_KL15;
monitorlib_uint16_t Voltage_KL30;
static monitorlib_uint16_t DebpounceTimer;
if ( pfunction.SysGet_KL15Line != (( void * )0) )
{
if ( SysFun_KL15Monitor.ActSts == pfunction.SysGet_KL15Line( ) )
{
if ( SysFun_KL15Monitor.DebounceTimer < t_FUN_KL15_Debounce )
{
SysFun_KL15Monitor.DebounceTimer++;
}
else
{
SysFun_KL15Monitor.FinalSts = SysFun_KL15Monitor.ActSts;
}
if(SysFun_KL15Monitor.ActSts)
{
SysFun_KL15Monitor.FinalSts = SysFun_KL15Monitor.ActSts;
}
}
else
{
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.ActSts = pfunction.SysGet_KL15Line( );
}
}
else
{
SysFun_KL15Monitor.DebounceTimer = 0u;
SysFun_KL15Monitor.FinalSts = 0u;
SysFun_KL15Monitor.ActSts = 0u;
}
if ( pfunction.SysGet_KL30_Valid != (( void * )0) )
{
VoltageKL30Valid = pfunction.SysGet_KL30_Valid( );
}else
{
VoltageKL30Valid = 0u;
}
if ( pfunction.SysGet_KL15_Valid != (( void * )0) )
{
VoltageKL15Valid = pfunction.SysGet_KL15_Valid( );
}else
{
VoltageKL15Valid = 0u;
}
if ( (VoltageKL30Valid == 1U) && (VoltageKL15Valid == 1U) )
{
if ( pfunction.SysGet_KL15_value != (( void * )0) )
{
Voltage_KL15 = pfunction.SysGet_KL15_value( );
}
else
{
Voltage_KL15 = 0u;
}
if ( pfunction.SysGet_KL30_value != (( void * )0) )
{
Voltage_KL30 = pfunction.SysGet_KL30_value( );
}
else
{
Voltage_KL30 = 0u;
}
if ( Voltage_KL30 > Voltage_KL15 )
{
Voltage = Voltage_KL30;
}
else
{
Voltage = Voltage_KL15;
}
if ( SysFun_KL30Monitor.SumCnt < 50u )
{
SysFun_KL30Monitor.ActVoltage += Voltage;
SysFun_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysFun_KL30Monitor.ActVoltage / SysFun_KL30Monitor.SumCnt);
}
else
{
SysFun_KL30Monitor.SumCnt = 0u;
SysFun_KL30Monitor.ActVoltage = 0u;
SysFun_KL30Monitor.ActVoltage += Voltage;
SysFun_KL30Monitor.SumCnt += 1u;
Voltage = ( monitorlib_uint16_t )(SysFun_KL30Monitor.ActVoltage / SysFun_KL30Monitor.SumCnt);
}
m8 = System_Calc_FunRange(Voltage);
// //printf("1 is %d, 2 is %d\r\n", m8, SysFun_KL30Monitor.FinalSts);
if ( SysFun_KL30Monitor.ActSts == m8 )
{
DebpounceTimer = 0u;
switch ( SysFun_KL30Monitor.FinalSts )
{
case 0:
case 1:
case 9:
t_FUN_KL30_timer = t_FUN_KL30_Debounce_Cancel;
break;
default:
t_FUN_KL30_timer = t_FUN_KL30_Debounce;
break;
}
/* 计时�?计时�?1000*2ms */
if ( SysFun_KL30Monitor.DebounceTimer < t_FUN_KL30_timer ) /*40202-8*/
{
SysFun_KL30Monitor.DebounceTimer++;
}
else
{
if ( SysFun_KL30Monitor.FinalSts > 7u ) /* 高压 */
{
if ( (m8 == 9u) || (m8 == 8u) || (m8 == 7u) )
{
SysFun_KL30Monitor.FinalSts = 9u;
SysFun_KL15Monitor.FinalSts = 0u;
}
else
{
SysFun_KL30Monitor.FinalSts = m8;
}
}
if ( SysFun_KL30Monitor.FinalSts == 1u ) /* 低压 */
{
if ( (m8 == 1u) || (m8 == 2u) )
{
SysFun_KL30Monitor.FinalSts = 1u;
SysFun_KL15Monitor.FinalSts = 0u;
}
else
{
SysFun_KL30Monitor.FinalSts = m8;
}
}
/* 非高低压 */
if ( (SysFun_KL30Monitor.FinalSts != 1u) && (SysFun_KL30Monitor.FinalSts <= 7u) )
{
SysFun_KL30Monitor.FinalSts = m8;
}
}
}
else
{
/* 计时时间清除 */
SysFun_KL30Monitor.DebounceTimer = 0U;
DebpounceTimer++;
if ( DebpounceTimer >= 5u )
{
DebpounceTimer = 0u;
SysFun_KL30Monitor.ActSts = m8;
}
}
}
/*
else
{
SysFun_KL30Monitor.FinalSts = 1u;
SysFun_KL15Monitor.FinalSts = 0u;
}*/
}
monitorlib_uint8_t System_NM_KL30_Status_Get(void)
{
return SysNM_KL30Monitor.FinalSts;
}
monitorlib_uint8_t System_NM_KL15_Status_Get(void)
{
return SysNM_KL15Monitor.FinalSts;
}
monitorlib_uint8_t System_FUN_KL30_Status_Get(void)
{
return SysFun_KL30Monitor.FinalSts;
}
monitorlib_uint8_t System_FUN_KL15_Status_Get(void)
{
return SysFun_KL15Monitor.FinalSts;
}
monitorlib_uint16_t Get_Sysmonitor_Version(void)
{
return 0x0002u;
}
......@@ -37,8 +37,8 @@ static Tellib_uint16_t LED_Lateral_Strut_Judgement(void);
static void LED_Lateral_Strut_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Tire_Pressure_Judgement(void);
static void LED_Tire_Pressure_Execution(Tellib_uint16_t led_status);
static Tellib_uint16_t LED_Navigato_Judgement(void);
static void LED_Navigato_Execution(Tellib_uint16_t led_status);
//static Tellib_uint16_t LED_Navigato_Judgement(void);
//static void LED_Navigato_Execution(Tellib_uint16_t led_status);
Led_HighBeam_Count HighBeam_Timer;
......@@ -60,7 +60,7 @@ const LED_Attribute_st LED_Attribute [ LED_Max ] = {
{em_LED_Low_Batt_Vol, SelfCheck, NoExterNalCheck, LED_IGN_ON, 0u, 3000ul, LED_Low_Batt_Judgement, LED_Low_Batt_Execution},
{em_LED_Lateral_Strut, SelfCheck, NoExterNalCheck, LED_IGN_ON, 0u, 3000ul, LED_Lateral_Strut_Judgement, LED_Lateral_Strut_Execution},
{em_LED_Tire_Pressure_Alarm, SelfCheck, NoExterNalCheck, LED_IGN_ON, 0u, 3000ul, LED_Tire_Pressure_Judgement, LED_Tire_Pressure_Execution},
{em_LED_Navigator, SelfCheck, NoExterNalCheck, LED_IGN_ON, 0u, 3000ul, LED_Navigato_Judgement, LED_Navigato_Execution},
//{em_LED_Navigator, SelfCheck, NoExterNalCheck, LED_IGN_ON, 0u, 3000ul, LED_Navigato_Judgement, LED_Navigato_Execution},
};
......@@ -334,15 +334,15 @@ static void LED_Coolant_Execution(Tellib_uint16_t led_status)
}
else
{
//LED_Driver_Channel_Set(LampChannel_0, LampCh0_13_Temp_AlarmW, LED_OFF);
//LED_Driver_Channel_Set(LampChannel_0, LampCh0_11_Temp_AlarmR, LED_OFF);
//SEG_SET_LED_STS(em_SEG_Coolant, 0);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_13_Temp_AlarmW, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_11_Temp_AlarmR, LED_OFF);
SEG_SET_LED_STS(em_SEG_Coolant, 0);
}
}
static Tellib_uint16_t LED_Bluetooth_Judgement(void)
{
Tellib_uint16_t LED_STATE = 0u;
if (0)
if (BlueTooth.BLE_St)
{
LED_STATE = 1u;
}
......@@ -598,7 +598,7 @@ static Tellib_uint16_t LED_Tire_Pressure_Judgement(void)
}
else
{
LED_STATE = 0;
LED_STATE = 2;
}
return LED_STATE;
}
......@@ -610,12 +610,18 @@ static void LED_Tire_Pressure_Execution(Tellib_uint16_t led_status)
LED_Driver_Channel_Set(LampChannel_0, LampCh0_26_Tire_PressureW, LED_OFF);
SEG_SET_LED_STS(em_SEG_Tire_Pressure_Alarm, 1);
}
else
else if ( led_status == 2u )
{
LED_Driver_Channel_Set(LampChannel_0, LampCh0_26_Tire_PressureW, LED_ON);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_27_Tire_PressureY, LED_OFF);
SEG_SET_LED_STS(em_SEG_Tire_Pressure_Alarm, 1);
}
else
{
LED_Driver_Channel_Set(LampChannel_0, LampCh0_26_Tire_PressureW, LED_OFF);
LED_Driver_Channel_Set(LampChannel_0, LampCh0_27_Tire_PressureY, LED_OFF);
SEG_SET_LED_STS(em_SEG_Tire_Pressure_Alarm, 0);
}
}
static Tellib_uint16_t LED_Navigato_Judgement(void)
......
......@@ -18,7 +18,7 @@ typedef enum
em_LED_Low_Batt_Vol,
em_LED_Lateral_Strut,
em_LED_Tire_Pressure_Alarm,
em_LED_Navigator,
//em_LED_Navigator,
LED_Max ,
} LED_Idx_t;
......
......@@ -49,11 +49,11 @@
*/
static uint32_t UART_GetSysClock(void)
{
if (USE_HSE_SYSTYEM_CLOCK == SYSTYEM_CLOCK_OPEN)
{
return 64000000;
}
else
//if (USE_HSE_SYSTYEM_CLOCK == SYSTYEM_CLOCK_OPEN)
//{
// return 32000000;
//}
//else
{
return SystemCoreClock;
}
......
......@@ -12,7 +12,7 @@
#include "DeepSleep\DeepSleep.h"
#include "CLOCK_Select\RTE_CLOCK_Select.h"
#include "UART\UART_DEMO.h"
......
......@@ -9,16 +9,11 @@
* Description : *
* Function List : *
********************************************************************************/
//#include "uart_demo.h"
//#include "tim_demo.h"
//#include "dma_demo.h"
//#include "uart.h"
//#include "gpio.h"
#include "UART_DEMO.h"
//#include <stdint.h>
unsigned char UART0_RX_BUF[UART_MAX_RECV_LEN];
unsigned short UART0_RX_STA = 0;
unsigned char UART0_TX_BUF[UART_MAX_RECV_LEN];
......@@ -28,9 +23,9 @@ unsigned short UART0_RX_STA = 0;
* @param bound
* @return init status
******************************************************************************/
int8_t Uart0_Init(uint32_t bound)
int8_t Uart0_Init(uint32_t bound)//主要查看寄存器
{
int8_t ret;
int8_t ret;
GPIO_InitTypeDef GPIO_InitStruct = {0};
UART_InitTypeDef UART_InitStructure = {0};
......@@ -150,21 +145,58 @@ void uart_callback_error(uint8_t err_type)
* @param None
* @return None
*****************************************************************************/
uint8_t uart0_interrupt_receive(void)
void uart0_interrupt_receive(void)
{
uint8_t rx_data;
uint8_t err_type;
volatile uint8_t rx_data;
volatile uint8_t err_type;
INTC_ClearPendingIRQ(SR0_IRQn);
err_type = UART_GetErrStaus(UART0, UART_FLAG_FEF | UART_FLAG_PEF | UART_FLAG_OVF);
if (err_type)
{
UART_ClearFlag(UART0,UART_FLAG_FEF | UART_FLAG_PEF | UART_FLAG_OVF);
uart_callback_error(err_type);
}
rx_data = UART0_RX;
UART_Put((uint16_t)rx_data);
// if ((UART0_RX_STA & 0x8000U) == 0) //½ÓÊÕδÍê³É
// {
// if (UART0_RX_STA & 0x4000U) //½ÓÊÕµ½0x0d
// {
// if (rx_data != 0x0a)
// {
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA++;
// }
// else
// {
// UART0_RX_STA |= 0x8000;
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA ++;
// }
// }
// else //»¹Î´½ÓÊÕµ½0x0d
// {
// if (rx_data == 0x0d)
// {
// UART0_RX_STA |= 0x4000;
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA ++;
// }
// else
// {
// UART0_RX_BUF[UART0_RX_STA & 0x3fff] = rx_data;
// UART0_RX_STA ++;
// }
// }
// }
// else if ((UART0_RX_STA & 0x8000U) == 1) // receive finished
// {
// }
return rx_data;
}
......@@ -6,11 +6,12 @@
#include "uart.h"
#include "gpio.h"
#include "isr.h"
#define UART0_DMA_RCV
#define UART_MAX_RECV_LEN 64
#include "Application.h"
#define UART_MAX_RECV_LEN 256
extern unsigned char UART1_RX_BUF[UART_MAX_RECV_LEN];
extern unsigned short UART1_RX_STA ;
extern unsigned char UART0_RX_BUF[UART_MAX_RECV_LEN];
extern unsigned short UART0_RX_STA ;
extern unsigned char UART0_TX_BUF[UART_MAX_RECV_LEN];
int8_t Uart0_Init(uint32_t bound);
......@@ -19,6 +20,5 @@ char Uart0_Receive(void);
void Uart0_IntSend(uint8_t *tx_buf, uint16_t tx_num);
void uart0_interrupt_send(void *msg);
uint8_t uart0_interrupt_receive(void);
void uart0_interrupt_receive(void);
#endif
......@@ -35,12 +35,14 @@ void Sys_2ms_Tasks(void)
void Sys_5ms_Tasks(void)
{
Flash_Sync_Signal_Generation_Service();
}
}
uint8_t ljs_buf[200] = {0};
void Sys_10ms_Tasks(void)
{
Line_In_Debounce_Service(10u);
memset(ljs_buf, 0x55, 200);
Line_In_Debounce_Service(10u);
Key_Service();
Data_Mileage_Write_EEPROM();
Can_BusOff_Recover(10u);
......@@ -48,6 +50,9 @@ void Sys_10ms_Tasks(void)
Fuel_R_Cal(10u);
TYW_Check_Count();
Data_TPMS_Processing_Service();
Protocol_Service();
Protocol_Send_Service();
//Uart0_IntSend(ljs_buf, 200) ;
}
void Sys_20ms_Tasks(void)
......@@ -58,6 +63,7 @@ void Sys_20ms_Tasks(void)
Data_Engine_Speed_Processing_Service();
Data_Coolant_Temp_Processing_Service();
}
void Sys_50ms_Tasks(void)
......@@ -70,6 +76,7 @@ void Sys_50ms_Tasks(void)
}
uint8_t u8LEDDriverCheckCount = 0U;
uint16_t ljs_voltage = 0;
void Sys_100ms_Tasks(void)
{
if((PageType != Page_Time_Hour)&&(PageType != Page_Time_Minute))
......@@ -83,8 +90,9 @@ void Sys_100ms_Tasks(void)
Services_Mileage_Callback();
Data_Voltage_Processing_Service();
S3_ServerCNTT();
ECU_FaultCode_Processing_Service();
//ECU_FaultCode_Processing_Service();
Send_UUID_To_Esp32();
ljs_voltage = ADC_Conv_Single_Channel(ADC_CH_KL15_VOLTAGE);
if (u8LEDDriverCheckCount >= 10U)
{
u8LEDDriverCheckCount = 0U;
......@@ -114,4 +122,5 @@ void Sys_Exact_50us_Tasks(void)
task_1ms =0U;
eeprom_1ms_timeCount( );
}
}
......@@ -313,10 +313,10 @@
#define SWV 0x100 // 0x100 = 1.00 software version 软件版本号
#define HWV 0x100 // 0x100 = 1.00 hardware version 硬件版本号
#define BTV 0x100 // 0x100 = 1.00 bootloader version boot程序版本号
#define INTLV 0x100 // 0x100 = 1.00 internal version 内部版本号
#define INTLV 0x101 // 0x100 = 1.00 internal version 内部版本号
#define PROG_Y 0x24 // 0x24 = 2024年, program year
#define PROG_M 0x05 // 0x03 = 3月, program month
#define PROG_D 0x15 // 0x19 = 19日, program day
#define PROG_D 0x27 // 0x19 = 19日, program day
/******************************************************************************
Bootloader Variable
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
#new Option
#Wed May 15 17:36:23 CST 2024
#Mon May 27 17:27:21 CST 2024
IsSort=true
MergeFlashIsCompression=false
ChangeAppFilePath=
......@@ -56,8 +56,8 @@ IsHexDisplay=true
MergeLineInXLSPath=
MergeFlashInPutFilePath=
MergeFlashIsInternal=false
MergeOutPutFilePath=D\:\\Git\\\u5929\u9E70\\tianying_ty100\\Firmware\\utility\\\u7A0B\u5E8F\u91CA\u653E\\20240515
MergeAppFilePath=D\:\\Git\\\u5929\u9E70\\tianying_ty100\\Firmware\\utility\\\u7A0B\u5E8F\u91CA\u653E\\20240515\\TianYing.hex
MergeOutPutFilePath=D\:\\Git\\\u5929\u9E70\\tianying_ty100\\Firmware\\utility\\\u7A0B\u5E8F\u91CA\u653E
MergeAppFilePath=D\:\\Git\\\u5929\u9E70\\tianying_ty100\\Firmware\\utility\\\u7A0B\u5E8F\u91CA\u653E\\TianYing.hex
MergeTelltalesXLSPath=
FillingByte=-86
ImageVersion=0
......
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