2025-04-11 10:46:09 +08:00

106 lines
3.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*******************************************************************************
* the includes
******************************************************************************/
#include "extern.h"
#include "TLE94x1.h"
#include <string.h>
#include "drivers/reset/reset_drv.h"
#include "mcu.h"
/*******************************************************************************
* the defines
******************************************************************************/
#define ASW_HEAD_MASK (0xAABBCCDDul)
/*******************************************************************************
* the typedefs
******************************************************************************/
typedef struct
{
uint8_t HWVersion[4];
uint8_t BLVersion[8];
uint8_t bootBuildTime[12];
uint8_t bootBuildDate[16];
uint8_t ECUName[8];
uint8_t Reverse[16];
} Bootloade_CfgInfoType;//64 byte
typedef struct
{
uint32_t sAswHeader;
uint8_t appBuildTime[12];
uint8_t appBuildDate[16];
uint8_t appSW_VERSION[16];
uint8_t appSW_Debug;
uint8_t reverse[15];
} app_CfgInfoType;//64 byte
/*******************************************************************************
* the globals
******************************************************************************/
extern McuType mcu;
/*******************************************************************************
* the constants
******************************************************************************/
#pragma location = ".asw_header"
__root const app_CfgInfoType app_info = {
.sAswHeader = ASW_HEAD_MASK,//0x00010400
.appBuildTime = __TIME__,//0x00010404
.appBuildDate = __DATE__,//0x00010410
.appSW_VERSION = "SW0101_20250401",
.appSW_Debug = 0xff,//0x55为量产模式其它为debug模式
};
/*******************************************************************************
* the functions
******************************************************************************/
void getSW_VERSION(unsigned char *pdata)
{
memcpy(pdata, &(app_info.appSW_VERSION), sizeof(app_info.appSW_VERSION));
}
void getHW_VERSION(unsigned char *pdata)
{
Bootloade_CfgInfoType * PBootInfo;
PBootInfo = (Bootloade_CfgInfoType *)0x0000400;
memcpy(pdata, &(PBootInfo->HWVersion), sizeof(PBootInfo->HWVersion));
//memcpy(pdata, HW_VERSION, );
}
void getBuildTime(unsigned char *pdata)
{
memcpy(pdata, (unsigned char *)0x00010410, 12);
memcpy(pdata + 12, (unsigned char *)0x00010404, 8);
pdata[11] = ' ';
}
void getBL_VERSION(unsigned char *pdata)
{
Bootloade_CfgInfoType * PBootInfo;
PBootInfo = (Bootloade_CfgInfoType *)0x0000400;
memcpy(pdata, &(PBootInfo->BLVersion), sizeof(PBootInfo->BLVersion));
}
void getEcuName(unsigned char *pdata)
{
Bootloade_CfgInfoType * PBootInfo;
PBootInfo = (Bootloade_CfgInfoType *)0x0000400;
memcpy(pdata, &(PBootInfo->ECUName), sizeof(PBootInfo->ECUName));
}
void extHardwareReset(void)
{
SBC_Write_RegField(SBC_M_S_CTRL, SBC_M_S_CTRL_MODE_Msk, SBC_M_S_CTRL_MODE_Pos, SBC_MODE_RESET, NULL);
}
void extSortwareReset(void)
{
ResetDrv_SoftwareResetModule(&mcu.resetDrv,RESETDRV_SWRESET_SYS);
}