增加硬件复位

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> </CallStackStripe>
<PlDriver> <PlDriver>
<FirstRun>0</FirstRun> <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> </PlDriver>
<ArmDriver> <ArmDriver>
<EnforceMemoryConfiguration>1</EnforceMemoryConfiguration>
<EnableCache>0</EnableCache> <EnableCache>0</EnableCache>
<EnforceMemoryConfiguration>1</EnforceMemoryConfiguration>
</ArmDriver> </ArmDriver>
<TerminalIO> <TerminalIO>
<InputSource>1</InputSource> <InputSource>1</InputSource>

File diff suppressed because one or more lines are too long

View File

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

View File

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

View File

@ -54,6 +54,7 @@ static bool Bootloader_GetBootReq(void);
static void Bootloader_JumpToApp(void); static void Bootloader_JumpToApp(void);
static void Bootloader_SetSessionMode(uint8_t sessionMode); static void Bootloader_SetSessionMode(uint8_t sessionMode);
static void Bootloader_SwReset(void); static void Bootloader_SwReset(void);
static void Bootloader_HwReset(void);
@ -130,6 +131,7 @@ const Bootloader_CallBackFuncListType Bootloader_CallBackFuncList = {
.udsPositiveRespFunction = BootloaderUds_PositiveResponse, .udsPositiveRespFunction = BootloaderUds_PositiveResponse,
.udsNegativeRespFunction = BootloaderUds_NegativeResponse, .udsNegativeRespFunction = BootloaderUds_NegativeResponse,
.swResetFunction = Bootloader_SwReset, .swResetFunction = Bootloader_SwReset,
.hwResetFunction = Bootloader_HwReset,
#if BOOTLOADER_CFG_FLS_COPY_AUTO_EN == 1u #if BOOTLOADER_CFG_FLS_COPY_AUTO_EN == 1u
.flsInitFunction = Fls_Init, .flsInitFunction = Fls_Init,
@ -717,7 +719,10 @@ static void Bootloader_SwReset(void)
IrqDrv_DisableGlobalInterrupt();//关闭中断,不加会导致无法复位 IrqDrv_DisableGlobalInterrupt();//关闭中断,不加会导致无法复位
ResetDrv_SoftwareResetModule(&mcu.resetDrv, RESETDRV_SWRESET_SYS); 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) static void BootloaderUds_PositiveResponse(const uint8_t *data, uint16_t len)
{ {
Uds_PositiveResponse(&udsObj, data, len); Uds_PositiveResponse(&udsObj, data, len);

View File

@ -29,15 +29,7 @@
* the typedefs * 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 * the globals
@ -73,17 +65,17 @@ void UdsService11_ResetEcu(UdsType *obj, const uint8_t msgBuf[], uint16_t msgLen
case UDS_RESET_HARD: case UDS_RESET_HARD:
Uds_PositiveResponse(obj, rspBuffer, 3); Uds_PositiveResponse(obj, rspBuffer, 3);
/*add hardware reset code*/ /*add hardware reset code*/
Bootloader_EventResetRequest(true); Bootloader_EventResetRequest(true,UDS_RESET_HARD);
break; break;
case UDS_RESET_KEYOFFON: case UDS_RESET_KEYOFFON:
Uds_PositiveResponse(obj, rspBuffer, 3); Uds_PositiveResponse(obj, rspBuffer, 3);
/*add keyoffon reset code*/ /*add keyoffon reset code*/
Bootloader_EventResetRequest(true); Bootloader_EventResetRequest(true,UDS_RESET_KEYOFFON);
break; break;
case UDS_RESET_SOFT: case UDS_RESET_SOFT:
Uds_PositiveResponse(obj, rspBuffer, 3); Uds_PositiveResponse(obj, rspBuffer, 3);
/*add software reset code*/ /*add software reset code*/
Bootloader_EventResetRequest(true); Bootloader_EventResetRequest(true,UDS_RESET_SOFT);
break; break;
default: default:
Uds_NegativeResponse(obj, 0x11, NRC_SUBFUNCTION_NOT_SUPPORTED); Uds_NegativeResponse(obj, 0x11, NRC_SUBFUNCTION_NOT_SUPPORTED);

View File

@ -39,6 +39,15 @@ extern "C" {
/******************************************************************************* /*******************************************************************************
* the typedefs * 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 * the globals