340 lines
12 KiB
C
340 lines
12 KiB
C
|
|
|||
|
#include "uds_config.h"
|
|||
|
#include "uds_nvm.h"
|
|||
|
#include "24cxx.h"
|
|||
|
#include "can.h"
|
|||
|
#include "sys.h"
|
|||
|
#include "dc300.h"
|
|||
|
#include "adc.h"
|
|||
|
#include "app_pwr_manage.h"
|
|||
|
|
|||
|
static uint32_t bootSwAddr;
|
|||
|
|
|||
|
extern DIDs gDIDCache;
|
|||
|
extern void DTC_SignalInit(void);
|
|||
|
extern void DID_SignalInit(void);
|
|||
|
extern int8_t can_write2( CanTxMsg *TxMessage);
|
|||
|
|
|||
|
/* udsǿ<73><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӳ<EFBFBD><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DTC<54><43><EFBFBD>ع<EFBFBD><D8B9>ϱ<EFBFBD>־λ */
|
|||
|
void UdsApi_HardwareFault_ForceClear(void)
|
|||
|
{
|
|||
|
//Ӳ<><D3B2>ǿ<EFBFBD><C7BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>DTC<54><43><EFBFBD>ع<EFBFBD><D8B9><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
}
|
|||
|
|
|||
|
#ifdef CS_TEMP_MODIFY
|
|||
|
//extern bus_off_recovery_t* can_bus_off_recovery_info(uint8_t ch);
|
|||
|
extern qiruibat_info_t QiruiBatteryInfo;
|
|||
|
#endif
|
|||
|
/* Ӳ<><D3B2><EFBFBD><EFBFBD>UDS<44><53><EFBFBD>³<EFBFBD><C2B3><EFBFBD><EFBFBD>ź<EFBFBD> */
|
|||
|
void UdsApi_VehicleInfo2UdsProc(void)
|
|||
|
{
|
|||
|
vehicleInfo2uds.IgnSts = 1;
|
|||
|
#ifdef CS_TEMP_MODIFY
|
|||
|
vehicleInfo2uds.IgnSts = ChkInputIGN1();
|
|||
|
|
|||
|
if(battery_volt_state < NORM_VOLT)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>
|
|||
|
vehicleInfo2uds.BattLow = 1;
|
|||
|
else
|
|||
|
vehicleInfo2uds.BattLow = 0;
|
|||
|
|
|||
|
if(battery_volt_state > NORM_VOLT)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>
|
|||
|
vehicleInfo2uds.BattHigh = 1;
|
|||
|
else
|
|||
|
vehicleInfo2uds.BattHigh = 0;
|
|||
|
|
|||
|
|
|||
|
vehicleInfo2uds.InOverVoltFault = mExistFdcFault( fault_grid_volt_over); // DCB<43>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
vehicleInfo2uds.InUnderVoltFault =mExistFdcFault( fault_grid_volt_under); //DCB<43>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿѹ<C7B7><D1B9><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
vehicleInfo2uds.OutOverVoltFault =mExistFdcFault( fault_Bat_OverVolt); //DCB<43>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
vehicleInfo2uds.OutUnderVoltFault =mExistFdcFault( fault_Bat_UnderVolt); //DCB<43>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿѹ<C7B7><D1B9><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
vehicleInfo2uds.InOverCurFault =mExistFdcFault( fault_grid_curr_over); //DCB<43>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
|
|||
|
vehicleInfo2uds.OutOverCurFault = 0; //DCB<43>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
// vehicleInfo2uds.OutOverCurFault =mExistFdcFault( fault_grid_volt_over); //DCB<43>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
|
|||
|
vehicleInfo2uds.OverTemperture =mExistFdcFault( fault_temp_over); //FCDC<44><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
vehicleInfo2uds.InputShort =mExistFdcFault( fault_grid_input_reverse); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
vehicleInfo2uds.OutputShort =mExistFdcFault( fault_grid_output_reverse); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
|
|||
|
// vehicleInfo2uds.PrechargeFault =0; //Ԥ<><D4A4>ʧ<EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD> 0:false 1:true
|
|||
|
// vehicleInfo2uds.FCDC_HardFault =0; //FCDCӲ<43><D3B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
// vehicleInfo2uds.ChargeOverTemp =0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¹<EFBFBD><C2B9><EFBFBD> 0:false 1:true
|
|||
|
// vehicleInfo2uds.FCDC_FanFault =0; //FCDC<44><43><EFBFBD>ȹ<EFBFBD><C8B9><EFBFBD> 0:false 1:true
|
|||
|
// vehicleInfo2uds.FCDC_CC1Fault =0; //FCDC<44><43><EFBFBD><EFBFBD>CC1<43><31>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
vehicleInfo2uds.FCDC_InAstVoltFault =mExistFdcFault( fault_power24_err); //FCDC<44><43><EFBFBD>븨<EFBFBD><EBB8A8><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4>ѹ<EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
// vehicleInfo2uds.FCDCIGBT_OverTempFault =0; //FCDCIGBT<42><54><EFBFBD>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0:false 1:true
|
|||
|
|
|||
|
|
|||
|
|
|||
|
// busoff<66><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>busoff<66><66>ÿ<EFBFBD>ָ<EFBFBD>һ<EFBFBD>ξ<EFBFBD><CEBE>ۼ<EFBFBD>1<EFBFBD><31>CAN<41><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>busoff<66><66><EFBFBD><EFBFBD><EFBFBD>㡣
|
|||
|
vehicleInfo2uds.BusoffCnt = can_bus_off_recovery_times(1); // busoff<66><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>busoff<66><66>ÿ<EFBFBD>ָ<EFBFBD>һ<EFBFBD>ξ<EFBFBD><CEBE>ۼ<EFBFBD>1<EFBFBD><31>CAN<41><4E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>busoff<66><66><EFBFBD><EFBFBD><EFBFBD>㡣
|
|||
|
|
|||
|
vehicleInfo2uds.Snapshot.PowerMode = QiruiBatteryInfo.BCM_1.bits.KeySts ;//ECU<43><55><EFBFBD><EFBFBD>ģʽ(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
|
|||
|
|
|||
|
vehicleInfo2uds.Snapshot.TolOdometerH = (QiruiBatteryInfo.ICM_1.bits.TotalOdometer_km >>16)&0xff; // <09><><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD>byte
|
|||
|
vehicleInfo2uds.Snapshot.TolOdometerM = (QiruiBatteryInfo.ICM_1.bits.TotalOdometer_km >>8)&0xff; // <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>byte
|
|||
|
vehicleInfo2uds.Snapshot.TolOdometerL = (QiruiBatteryInfo.ICM_1.bits.TotalOdometer_km)&0xff; // <09><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD>byte(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
|
|||
|
|
|||
|
// vehicleInfo2uds.Snapshot.DateSec ʱ<><CAB1> <20><>(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
// vehicleInfo2uds.Snapshot.DateMin ʱ<><CAB1> <20><>(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
// vehicleInfo2uds.Snapshot.DateHour ʱ<><CAB1> Сʱ(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
// vehicleInfo2uds.Snapshot.DateDay ʱ<><CAB1> <20><>(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
// vehicleInfo2uds.Snapshot.DateMonth ʱ<><CAB1> <20><>(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
// vehicleInfo2uds.Snapshot.DateYear ʱ<><CAB1> <20><>(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
// vehicleInfo2uds.Snapshot.VehSpeedH <09><><EFBFBD>ٸ<EFBFBD>byte
|
|||
|
// vehicleInfo2uds.Snapshot.VehSpeedL <09><><EFBFBD>ٵ<EFBFBD>byte(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
|
|||
|
vehicleInfo2uds.Snapshot.DateSec = QiruiBatteryInfo.TBOX_2.bits.second;
|
|||
|
vehicleInfo2uds.Snapshot.DateMin = QiruiBatteryInfo.TBOX_2.bits.minute;
|
|||
|
vehicleInfo2uds.Snapshot.DateHour = QiruiBatteryInfo.TBOX_2.bits.hour;
|
|||
|
vehicleInfo2uds.Snapshot.DateDay = QiruiBatteryInfo.TBOX_2.bits.day;
|
|||
|
vehicleInfo2uds.Snapshot.DateMonth = QiruiBatteryInfo.TBOX_2.bits.month;
|
|||
|
vehicleInfo2uds.Snapshot.DateYear = QiruiBatteryInfo.TBOX_2.bits.year;
|
|||
|
vehicleInfo2uds.Snapshot.VehSpeedH = (uint8_t)(QiruiBatteryInfo.MCU_1.bits.MCU_SpeedVechile>>8);
|
|||
|
vehicleInfo2uds.Snapshot.VehSpeedL = (uint8_t)(QiruiBatteryInfo.MCU_1.bits.MCU_SpeedVechile);
|
|||
|
|
|||
|
vehicleInfo2uds.Snapshot.BatVolt = (uint8_t)(Sample_DataS.VIN_Input_Voltage*10);// <09><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD>ѹ(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
vehicleInfo2uds.Snapshot.SOCH = (uint8_t)((QiruiBatteryInfo.soc/5)>>8);// SOC(<28><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD> 3_2_Snapshot&Extended Data List һ<><D2BB>)
|
|||
|
vehicleInfo2uds.Snapshot.SOCL = (uint8_t)((QiruiBatteryInfo.soc/5)>>0);
|
|||
|
/* <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
vehicleInfo2uds.IgnSts = ;
|
|||
|
vehicleInfo2uds.BattLow = ;
|
|||
|
vehicleInfo2uds.BattHigh = ;
|
|||
|
vehicleInfo2uds.InOverVoltFault = ;
|
|||
|
vehicleInfo2uds.InUnderVoltFault = ;
|
|||
|
vehicleInfo2uds.OutOverVoltFault = ;
|
|||
|
vehicleInfo2uds.OutUnderVoltFault = ;
|
|||
|
vehicleInfo2uds.InOverCurFault = ;
|
|||
|
vehicleInfo2uds.OutOverCurFault = ;
|
|||
|
vehicleInfo2uds.OverTemperture = ;
|
|||
|
vehicleInfo2uds.InputShort = ;
|
|||
|
vehicleInfo2uds.OutputShort = ;
|
|||
|
vehicleInfo2uds.PrechargeFault = ;
|
|||
|
vehicleInfo2uds.FCDC_HardFault = ;
|
|||
|
vehicleInfo2uds.ChargeOverTemp = ;
|
|||
|
vehicleInfo2uds.FCDC_FanFault = ;
|
|||
|
vehicleInfo2uds.FCDC_CC1Fault = ;
|
|||
|
vehicleInfo2uds.FCDC_InAstVoltFault = ;
|
|||
|
vehicleInfo2uds.FCDCIGBT_OverTempFault = ;
|
|||
|
|
|||
|
vehicleInfo2uds.BusoffCnt = ;
|
|||
|
|
|||
|
vehicleInfo2uds.Snapshot.PowerMode = ;
|
|||
|
vehicleInfo2uds.Snapshot.TolOdometerH = ;
|
|||
|
vehicleInfo2uds.Snapshot.TolOdometerM = ;
|
|||
|
vehicleInfo2uds.Snapshot.TolOdometerL = ;
|
|||
|
vehicleInfo2uds.Snapshot.DateSec = ;
|
|||
|
vehicleInfo2uds.Snapshot.DateMin = ;
|
|||
|
vehicleInfo2uds.Snapshot.DateHour = ;
|
|||
|
vehicleInfo2uds.Snapshot.DateDay = ;
|
|||
|
vehicleInfo2uds.Snapshot.DateMonth = ;
|
|||
|
vehicleInfo2uds.Snapshot.DateYear = ;
|
|||
|
vehicleInfo2uds.Snapshot.VehSpeedH = ;
|
|||
|
vehicleInfo2uds.Snapshot.VehSpeedL = ;
|
|||
|
vehicleInfo2uds.Snapshot.BatVolt = ;
|
|||
|
vehicleInfo2uds.Snapshot.SOC = ;
|
|||
|
*/
|
|||
|
#endif
|
|||
|
}
|
|||
|
|
|||
|
/* uds parameter init*/
|
|||
|
void UdsApi_ParaInit(void)
|
|||
|
{
|
|||
|
#if BOOTLOADER_CODE_FLAG
|
|||
|
memcpy(gDIDCache.DID_BootSoftware, BOOTLOADER_SOFTWARE_VERSION, DIDSize[BootSoftware]);
|
|||
|
#else
|
|||
|
memcpy(gDIDCache.DID_BootSoftwareNumber, (uint8_t *)bootSwAddr, DIDSize[BootSoftwareNumber]);
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ,<2C><><EFBFBD>Ȳ<EFBFBD><C8B2><EFBFBD><EFBFBD>ÿո<C3BF><D5B8><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
memcpy(gDIDCache.DID_ECUManufacturerSparePartNumber, "2109140-SZ01", DIDSize[ECUManufacturerSparePartNumber]);
|
|||
|
memcpy(gDIDCache.DID_SystemSupplierIdentifierData, " ", DIDSize[SystemSupplierIdentifierData]);
|
|||
|
memcpy(gDIDCache.DID_SystemName, "DCU ", DIDSize[SystemName]);
|
|||
|
memcpy(gDIDCache.DID_VehicleManufacturerECUHardwareNumber, "HW:A.1.0", DIDSize[VehicleManufacturerECUHardwareNumber]);
|
|||
|
memcpy(gDIDCache.DID_VehicleManufacturerECUSoftwareNumber, "SW:DCU.1.34.01 ", DIDSize[VehicleManufacturerECUSoftwareNumber]);
|
|||
|
memcpy(gDIDCache.DID_SystemSupplierECUHardwareNumber, " ", DIDSize[SystemSupplierECUHardwareNumber]);
|
|||
|
memcpy(gDIDCache.DID_SystemSupplierECUSoftwareNumber, " ", DIDSize[SystemSupplierECUSoftwareNumber]);
|
|||
|
|
|||
|
// memcpy(gDIDCache.DID_ECUSerialNumber, "123456789012", DIDSize[ECUSerialNumber]);
|
|||
|
#ifdef CS_TEMP_MODIFY
|
|||
|
memcpy(gDIDCache.DID_BootSoftware, (uint8_t*)GetBootloaderSwVersionAddress(), DIDSize[BootSoftware]);
|
|||
|
memset(gDIDCache.DID_ProgrammingDate, 0x00, DIDSize[ProgrammingDate]);
|
|||
|
memset(gDIDCache.DID_TesterSerialNumber, 0x00, DIDSize[TesterSerialNumber]);
|
|||
|
memset(gDIDCache.DID_VehicleIdentificationNumber, 0x00, DIDSize[VehicleIdentificationNumber]);
|
|||
|
gDIDCache.DID_ActiveDiagnosticSession[0] = _UDS_DEFAULT_SESSION;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
gDIDCache.DID_InputOvervoltageValue[0] = MSB(350);
|
|||
|
gDIDCache.DID_InputOvervoltageValue[1] = LSB(350);
|
|||
|
gDIDCache.DID_InputUndervoltageValue[0] = MSB(200);
|
|||
|
gDIDCache.DID_InputUndervoltageValue[1] = LSB(200);
|
|||
|
gDIDCache.DID_OutputOvervoltageValue[0] = MSB(130);
|
|||
|
gDIDCache.DID_OutputOvervoltageValue[1] = LSB(130);
|
|||
|
gDIDCache.DID_OutputUndervoltageValue[0] = MSB(60);
|
|||
|
gDIDCache.DID_OutputUndervoltageValue[1] = LSB(60);
|
|||
|
gDIDCache.DID_OutputOvercurrentFaultValue[0] = 120;
|
|||
|
gDIDCache.DID_InputOvercurrentFaultValue[0] = 40;
|
|||
|
gDIDCache.DID_OverTempertureProtectValue[0] = 85+40;
|
|||
|
gDIDCache.DID_IGBTOverTempertureProtectValue[0] = 95+40;
|
|||
|
gDIDCache.DID_ChargeOverTemperture[0] = 100+40;
|
|||
|
#endif
|
|||
|
#endif
|
|||
|
}
|
|||
|
|
|||
|
/* uds 1ms task */
|
|||
|
void UdsApi_1ms_task(void)
|
|||
|
{
|
|||
|
UdsProcTask();
|
|||
|
}
|
|||
|
|
|||
|
/* uds 10ms task */
|
|||
|
void UdsApi_10ms_task(void)
|
|||
|
{
|
|||
|
UdsApi_VehicleInfo2UdsProc();
|
|||
|
}
|
|||
|
|
|||
|
/* uds can receive msg in */
|
|||
|
void UdsApi_MsgQueueIn(CanRxMsg msg)
|
|||
|
{
|
|||
|
can_msg_t uds_msg;
|
|||
|
|
|||
|
uds_msg.id = msg.StdId;
|
|||
|
uds_msg.dlc = msg.DLC;
|
|||
|
memcpy(uds_msg.data, msg.Data, uds_msg.dlc);
|
|||
|
UdsQueueCanIn(uds_msg);
|
|||
|
}
|
|||
|
|
|||
|
/* uds transmit diag msg */
|
|||
|
void UdsApi_MsgQueueOut(can_msg_t uds_msg)
|
|||
|
{
|
|||
|
CanTxMsg msg;
|
|||
|
|
|||
|
msg.IDE = CAN_Id_Standard;
|
|||
|
msg.StdId = uds_msg.id;
|
|||
|
msg.DLC = uds_msg.dlc;
|
|||
|
msg.RTR = CAN_RTR_Data;
|
|||
|
memcpy(msg.Data, uds_msg.data, msg.DLC);
|
|||
|
// Can2_Send_Message(msg);
|
|||
|
can_write2(&msg);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/* uds <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
uint32_t UdsApi_GetRandom(void)
|
|||
|
{
|
|||
|
static uint32_t Seed=0;
|
|||
|
uint32_t Random;
|
|||
|
|
|||
|
if(Seed == 0)
|
|||
|
{
|
|||
|
Seed = SysTick->VAL;
|
|||
|
Seed *= 91939597;
|
|||
|
}
|
|||
|
Random = Seed+SysTick->VAL;
|
|||
|
Seed += 13957;
|
|||
|
Random = (u32)( (u32)Random<<16)>>16;
|
|||
|
Random |= ((Seed*5)<<16);
|
|||
|
|
|||
|
return Random;
|
|||
|
}
|
|||
|
|
|||
|
/* eeprom write*/
|
|||
|
uint8_t UdsApi_EE_WriteBytes(uint8_t *_pWriteBuf, uint16_t _usAddress, uint16_t _usSize)
|
|||
|
{
|
|||
|
return ee_WriteBytes(_pWriteBuf, _usAddress, _usSize);
|
|||
|
}
|
|||
|
|
|||
|
/* eeprom read*/
|
|||
|
uint8_t UdsApi_EE_ReadBytes(uint8_t *_pReadBuf, uint16_t _usAddress, uint16_t _usSize)
|
|||
|
{
|
|||
|
return ee_ReadBytes(_pReadBuf, _usAddress, _usSize);
|
|||
|
}
|
|||
|
|
|||
|
/* NVM <20><>ʼ<EFBFBD><CABC>*/
|
|||
|
void UdsApi_NVM_Init(void)
|
|||
|
{
|
|||
|
static uint8_t enter_flag = 0;
|
|||
|
// Delay_MS(50);//<2F>ȴ<EFBFBD><C8B4><EFBFBD>Դ<EFBFBD>ȶ<EFBFBD>
|
|||
|
if (!enter_flag) {
|
|||
|
enter_flag = 1;
|
|||
|
NVM_Init();
|
|||
|
DID_SignalInit();
|
|||
|
DTC_SignalInit();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/* <20><>ѯUDS<44>Ƿ<EFBFBD>ʹ<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>ͨ<EFBFBD>ű<EFBFBD><C5B1>ķ<EFBFBD><C4B7><EFBFBD> */
|
|||
|
bool UdsApi_Is_UdsEnableNCMTx(void)
|
|||
|
{
|
|||
|
bool bRst=false;
|
|||
|
|
|||
|
if (udsInfo2Vehicle.NcmTxEnable) {
|
|||
|
bRst = true;
|
|||
|
}
|
|||
|
return bRst;
|
|||
|
}
|
|||
|
|
|||
|
/* <20><>ѯUDS<44>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD> */
|
|||
|
bool UdsApi_Is_UdsEnableNWMCMTx(void)
|
|||
|
{
|
|||
|
bool bRst=false;
|
|||
|
|
|||
|
if (udsInfo2Vehicle.NmcmTxEnable) {
|
|||
|
bRst = true;
|
|||
|
}
|
|||
|
return bRst;
|
|||
|
}
|
|||
|
|
|||
|
/* <20><>ѯUDS<44>Ƿ<EFBFBD>ʹ<EFBFBD>ܳ<EFBFBD><DCB3><EFBFBD>ͨ<EFBFBD>ű<EFBFBD><C5B1>Ľ<EFBFBD><C4BD><EFBFBD> */
|
|||
|
bool UdsApi_Is_UdsEnableNCMRx(void)
|
|||
|
{
|
|||
|
bool bRst=false;
|
|||
|
|
|||
|
if (udsInfo2Vehicle.NcmRxEnable) {
|
|||
|
bRst = true;
|
|||
|
}
|
|||
|
return bRst;
|
|||
|
}
|
|||
|
|
|||
|
/* <20><>ѯUDS<44>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD> */
|
|||
|
bool UdsApi_Is_UdsEnableNWMCMRx(void)
|
|||
|
{
|
|||
|
bool bRst=false;
|
|||
|
|
|||
|
if (udsInfo2Vehicle.NmcmRxEnable) {
|
|||
|
bRst = true;
|
|||
|
}
|
|||
|
return bRst;
|
|||
|
}
|
|||
|
|
|||
|
/* <20><>ѯUDS<44>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD> */
|
|||
|
bool UdsApi_Is_UdsOnline(void)
|
|||
|
{
|
|||
|
bool bRst=false;
|
|||
|
|
|||
|
if (!udsInfo2Vehicle.UdsOffLine) {
|
|||
|
bRst = true;
|
|||
|
}
|
|||
|
return bRst;
|
|||
|
}
|
|||
|
|
|||
|
/* <20><>ѯ<EFBFBD>Ƿ<EFBFBD>ΪUDS<44><53>Ӧ<EFBFBD><D3A6>Ϣ */
|
|||
|
bool UdsApi_Is_UdsResponeMsg(uint16_t msg_id)
|
|||
|
{
|
|||
|
bool bRst=false;
|
|||
|
|
|||
|
if (msg_id == UDS_PHY_RX_ID) {
|
|||
|
bRst = true;
|
|||
|
}
|
|||
|
return bRst;
|
|||
|
}
|
|||
|
|
|||
|
/* ȡBootLoader<65><72><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>ַ */
|
|||
|
void UdsApi_BootSwAddr_Get(void)
|
|||
|
{
|
|||
|
bootSwAddr = BKP->DR42;
|
|||
|
bootSwAddr = (bootSwAddr << 16) | BKP->DR41;
|
|||
|
}
|
|||
|
|