增加硬件复位

This commit is contained in:
sunbeam 2024-12-11 10:24:37 +08:00
parent 649a686add
commit 50bf14e4f1
7 changed files with 42 additions and 24 deletions

View File

@ -77,11 +77,11 @@
</CallStackStripe>
<PlDriver>
<FirstRun>0</FirstRun>
<MemConfigValue>e:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\config\debugger\CVAChip\CVM0144.ddf</MemConfigValue>
<MemConfigValue>E:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\config\debugger\CVAChip\CVM0144.ddf</MemConfigValue>
</PlDriver>
<ArmDriver>
<EnforceMemoryConfiguration>1</EnforceMemoryConfiguration>
<EnableCache>0</EnableCache>
<EnforceMemoryConfiguration>1</EnforceMemoryConfiguration>
</ArmDriver>
<TerminalIO>
<InputSource>1</InputSource>

File diff suppressed because one or more lines are too long

View File

@ -21,6 +21,7 @@
#include <string.h>
#include "bootloader.h"
#include "SEGGER_RTT.h"
#include "uds_service11.h"
/*******************************************************************************
* the defines
@ -520,9 +521,18 @@ static void Bootloader_ExitState(void)
if(sBootloader_Cb.resetActionReady == true)
{
pSwResetFunctionPtr swResetFunction = sBootloader_Cb.pCallBackFunctionList->swResetFunction;
pSwResetFunctionPtr hwResetFunction = sBootloader_Cb.pCallBackFunctionList->hwResetFunction;
Bootloader_DeInit();
swResetFunction();
if (sBootloader_Cb.resetReqMode == UDS_RESET_HARD)
{
hwResetFunction();
}
else
{
swResetFunction();
}
}
else
{
@ -703,9 +713,10 @@ void Bootloader_EventEmergeBootRequest(bool requestEn)
*
* \return void
*/
void Bootloader_EventResetRequest(bool requestEn)
void Bootloader_EventResetRequest(bool requestEn,uint8_t resetMode)
{
sBootloader_Cb.resetReqEn = requestEn;
sBootloader_Cb.resetReqMode = resetMode;
#if BOOTLOADER_CFG_FLS_COPY_AUTO_EN == 0u
sBootloader_Cb.flsDrvInfo.flashDriverDownloaded = false;
#endif

View File

@ -151,7 +151,7 @@ typedef struct
pUds_NegativeResponsePtr udsNegativeRespFunction;
pSwResetFunctionPtr swResetFunction;
pSwResetFunctionPtr hwResetFunction;
#if BOOTLOADER_CFG_FLS_COPY_AUTO_EN != 0u
pFls_InitFunctionPtr flsInitFunction;
pFls_EraseFunctionPtr flsEraseFunction;
@ -171,6 +171,7 @@ typedef struct
bool emergeBootReqEn;
bool resetReqEn;
bool resetActionReady;
uint8_t resetReqMode;
bool bootActive;
#if BOOTLOADER_CFG_FLS_COPY_AUTO_EN == 0u
Bootloader_FlsDrvInfoType flsDrvInfo;
@ -277,7 +278,7 @@ extern void Bootloader_EventEmergeBootRequest(bool requestEn);
*
* \return void
*/
extern void Bootloader_EventResetRequest(bool requestEn);
extern void Bootloader_EventResetRequest(bool requestEn,uint8_t resetMode);
/*! \brief Set the erase information
*

View File

@ -54,6 +54,7 @@ static bool Bootloader_GetBootReq(void);
static void Bootloader_JumpToApp(void);
static void Bootloader_SetSessionMode(uint8_t sessionMode);
static void Bootloader_SwReset(void);
static void Bootloader_HwReset(void);
@ -126,10 +127,11 @@ const Bootloader_CallBackFuncListType Bootloader_CallBackFuncList = {
.getBootReqFunction = Bootloader_GetBootReq,
.jumpFunction = Bootloader_JumpToApp,
.setSessionModeFunction = Bootloader_SetSessionMode,
.udsPositiveRespFunction = BootloaderUds_PositiveResponse,
.udsNegativeRespFunction = BootloaderUds_NegativeResponse,
.swResetFunction = Bootloader_SwReset,
.hwResetFunction = Bootloader_HwReset,
#if BOOTLOADER_CFG_FLS_COPY_AUTO_EN == 1u
.flsInitFunction = Fls_Init,
@ -717,7 +719,10 @@ static void Bootloader_SwReset(void)
IrqDrv_DisableGlobalInterrupt();//关闭中断,不加会导致无法复位
ResetDrv_SoftwareResetModule(&mcu.resetDrv, RESETDRV_SWRESET_SYS);
}
static void Bootloader_HwReset(void)
{
SBC_Write_RegField(SBC_M_S_CTRL, SBC_M_S_CTRL_MODE_Msk, SBC_M_S_CTRL_MODE_Pos, SBC_MODE_RESET, NULL);
}
static void BootloaderUds_PositiveResponse(const uint8_t *data, uint16_t len)
{
Uds_PositiveResponse(&udsObj, data, len);

View File

@ -29,15 +29,7 @@
* the typedefs
******************************************************************************/
/*! \brief The Reset type definition of Uds
*/
typedef enum _UdsResetType_
{
UDS_RESET_NONE = 0,
UDS_RESET_HARD,
UDS_RESET_KEYOFFON,
UDS_RESET_SOFT
} UdsResetType;
/*******************************************************************************
* the globals
@ -73,17 +65,17 @@ void UdsService11_ResetEcu(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen
case UDS_RESET_HARD:
Uds_PositiveResponse(obj, rspBuffer, 3);
/*add hardware reset code*/
Bootloader_EventResetRequest(true);
Bootloader_EventResetRequest(true,UDS_RESET_HARD);
break;
case UDS_RESET_KEYOFFON:
Uds_PositiveResponse(obj, rspBuffer, 3);
/*add keyoffon reset code*/
Bootloader_EventResetRequest(true);
Bootloader_EventResetRequest(true,UDS_RESET_KEYOFFON);
break;
case UDS_RESET_SOFT:
Uds_PositiveResponse(obj, rspBuffer, 3);
/*add software reset code*/
Bootloader_EventResetRequest(true);
Bootloader_EventResetRequest(true,UDS_RESET_SOFT);
break;
default:
Uds_NegativeResponse(obj, 0x11, NRC_SUBFUNCTION_NOT_SUPPORTED);

View File

@ -39,6 +39,15 @@ extern "C" {
/*******************************************************************************
* the typedefs
******************************************************************************/
/*! \brief The Reset type definition of Uds
*/
typedef enum _UdsResetType_
{
UDS_RESET_NONE = 0,
UDS_RESET_HARD,
UDS_RESET_KEYOFFON,
UDS_RESET_SOFT
} UdsResetType;
/*******************************************************************************
* the globals