Skip to main content

7.5.17 MCU Watchdog

1. Introduction​

This user document provides information about the WDG driver, including features, configuration parameters, and APIs. Wherever Wdgx is mentioned in this document, x is an index with a valid range of 0, 1, and 2.

This user document provides information about the WDG driver, including features, configuration parameters, and APIs. Wherever Wdgx is mentioned in this document, x is an index with a valid range of 0, 1, 2, 3, and 4.

2. Overview​

2.1 File List​

Low-Level Interface​

These are the Watchdog low-level driver implementation and internal common interface files. General users do not need to focus on them directly:

  • McalCdd\Wdg\inc\Wdg_Lld.h
  • McalCdd\Wdg\src\Wdg_Lld.c
  • McalCdd\Wdg\inc\Wdg_Prv.h
  • McalCdd\Wdg\src\Wdg_Common.c

High-Level Interface​

These are the API implementation files for user calls. Each Wdg instance requires a separate code file:

  • McalCdd\Wdg\src\Wdg0.c
  • McalCdd\Wdg\src\Wdg1.c
  • McalCdd\Wdg\src\Wdg2.c
  • McalCdd\Wdg\inc\Wdg0.h
  • McalCdd\Wdg\inc\Wdg1.h
  • McalCdd\Wdg\inc\Wdg2.h

These are the API implementation files for user calls. Each Wdg instance requires a separate code file:

  • McalCdd\Wdg\src\Wdg0.c
  • McalCdd\Wdg\src\Wdg1.c
  • McalCdd\Wdg\src\Wdg2.c
  • McalCdd\Wdg\src\Wdg3.c
  • McalCdd\Wdg\src\Wdg4.c
  • McalCdd\Wdg\inc\Wdg0.h
  • McalCdd\Wdg\inc\Wdg1.h
  • McalCdd\Wdg\inc\Wdg2.h
  • McalCdd\Wdg\inc\Wdg3.h
  • McalCdd\Wdg\inc\Wdg4.h

2.2 Difference Between On-Chip WDG and PMIC WDG​

The on-chip WDG and PMIC WDG are complementary watchdog layers. The on-chip WDG is used for MCU internal monitoring and testing, while the PMIC WDG acts as a board-level fail-safe backup; if the MCU software cannot feed the watchdog properly, the PMIC WDG can still perform a reset or protection action after timeout.

There are two independent watchdogs on the RDK S100 MCU side:

  • On-chip WDG: Integrated inside the RDK S100. It is disabled by default; initialize and configure it through the WDG APIs when needed.
  • PMIC WDG: Located inside the external MCUPWR PMIC and fed by the MCU over I2C.
ItemOn-chip WDGPMIC WDG
LocationInside the SoCExternal MCUPWR PMIC
Default stateDisabled by defaultEnabled in MCU_RELEASE builds, disabled in non-release builds; fixed disabled on MCU1
Control methodMCU register controlMCU control through I2C
Feed methodConfigure and feed through the WDG APIsPeriodic MCU task feeds through the PMIC driver
Reset/interruptSupports normal and reset interruptsPMIC performs fail-safe/reset on timeout

Driver and Configuration Files​

  • On-chip WDG driver
    • Common low-level driver: McalCdd/Wdg/src/Wdg_Lld.c, McalCdd/Wdg/inc/Wdg_Lld.h.
    • Common high-level driver: McalCdd/Wdg/src/Wdg_Common.c, McalCdd/Wdg/inc/Wdg_Prv.h.
    • Instance interfaces: McalCdd/Wdg/src/Wdg0.c, Wdg1.c, Wdg2.c, together with McalCdd/Wdg/inc/Wdg0.h, Wdg1.h, Wdg2.h.
  • PMIC WDG driver
    • Common driver: McalCdd/Pmic/src/Wdg_Ext.c, McalCdd/Pmic/inc/Wdg_Ext.h.
    • Common low-level driver: McalCdd/Pmic/src/Pmic_Lld_Wdg.c, McalCdd/Pmic/inc/Pmic_Lld_Wdg.h.
    • RDK S100 device driver: McalCdd/Pmic/devices/src/Pmic_Lld_McuPwrWdg.c, McalCdd/Pmic/devices/inc/Pmic_Lld_McuPwrWdg.h.
  • On-chip WDG configuration
    • MCU0: Config/McalCdd/gen_s100_sip_B/Wdg/src/Wdg_Cfg.c, together with Wdg0_PBcfg.c, Wdg1_PBcfg.c, and Wdg2_PBcfg.c.
    • MCU1: Config/McalCdd/gen_s100_sip_B_mcu1/Wdg/src/Wdg_Cfg.c, together with Wdg0_PBcfg.c, Wdg1_PBcfg.c, and Wdg2_PBcfg.c.
  • PMIC WDG configuration
    • MCU0: Config/McalCdd/gen_s100_sip_B/PwrIf/src/PwrM_Cfg.c.
    • MCU1: Config/McalCdd/gen_s100_sip_B_mcu1/PwrIf/src/PwrM_Cfg.c.

2.2 Difference Between On-Chip WDG and PMIC WDG​

The on-chip WDG and PMIC WDG are complementary watchdog layers. The on-chip WDG is used for MCU internal monitoring and testing, while the PMIC WDG acts as a board-level fail-safe backup; if the MCU software cannot feed the watchdog properly, the PMIC WDG can still perform a reset or protection action after timeout.

There are two independent watchdogs on the RDK S600 MCU side:

  • On-chip WDG: Integrated inside the RDK S600. It is disabled by default; initialize and configure it through the WDG APIs when needed. The RDK S600 supports five instances, Wdg0 through Wdg4. The current MCU0 default configuration mounts Wdg0 through Wdg2, and the MCU1 default configuration also mounts Wdg0 through Wdg2.
  • PMIC WDG: Located inside the external VR5510 PMIC and controlled/fed by the MCU over I2C. It is enabled on MCU0 by default, while the VR5510 device-level watchdog is disabled on MCU1 by default.
ItemOn-chip WDGPMIC WDG
LocationInside the SoCExternal VR5510 PMIC
Default stateDisabled by defaultEnabled on MCU0 by default; VR5510 device-level disabled on MCU1 by default
Control methodMCU register controlMCU control through I2C
Feed methodConfigure and feed through the WDG APIsPeriodic MCU task feeds through the PMIC driver
Reset/interruptSupports normal and reset interruptsPMIC performs fail-safe/reset on timeout

Driver and Configuration Files​

  • On-chip WDG driver
    • Common low-level driver: McalCdd/Wdg/src/Wdg_Lld.c, McalCdd/Wdg/inc/Wdg_Lld.h.
    • Common high-level driver: McalCdd/Wdg/src/Wdg_Common.c, McalCdd/Wdg/inc/Wdg_Prv.h.
    • Instance interfaces: McalCdd/Wdg/src/Wdg0.c, Wdg1.c, Wdg2.c, Wdg3.c, Wdg4.c, together with McalCdd/Wdg/inc/Wdg0.h, Wdg1.h, Wdg2.h, Wdg3.h, Wdg4.h.
  • PMIC WDG driver
    • Common driver: McalCdd/Pmic/src/Wdg_Ext.c, McalCdd/Pmic/inc/Wdg_Ext.h.
    • Common low-level driver: McalCdd/Pmic/src/Pmic_Lld_Wdg.c, McalCdd/Pmic/inc/Pmic_Lld_Wdg.h.
    • RDK S600 device driver: McalCdd/Pmic/devices/src/Pmic_Lld_Vr5510Wdg.c, McalCdd/Pmic/devices/inc/Pmic_Lld_Vr5510Wdg.h.
  • On-chip WDG configuration
    • MCU0: Config/McalCdd/gen_s600_md/Wdg/src/Wdg_Cfg.c, together with Wdg0_PBcfg.c, Wdg1_PBcfg.c, Wdg2_PBcfg.c, Wdg3_PBcfg.c, and Wdg4_PBcfg.c.
    • MCU1: Config/McalCdd/gen_s600_md_mcu1/Wdg/src/Wdg_Cfg.c, together with Wdg0_PBcfg.c, Wdg1_PBcfg.c, Wdg2_PBcfg.c, Wdg3_PBcfg.c, and Wdg4_PBcfg.c.
  • PMIC WDG configuration
    • MCU0: Config/McalCdd/gen_s600_md/PwrIf/src/PwrM_Cfg.c.
    • MCU1: Config/McalCdd/gen_s600_md_mcu1/PwrIf/src/PwrM_Cfg.c.

3. Application Programming Interface​

3.1 Types​

3.1.1 Imported Types​

ModuleHeader FileImported Type
Std_TypesStd_Types.hStd_ReturnType
Std_TypesStd_Types.hStd_VersionInfoType
Rte_TypeRte_Type.hDem_EventIdType
Rte_TypeRte_Type.hDem_EventStatusType
WdgIfWdgIf_Types.hWdgIf_ModeType

3.1.2 Type Definitions​

Wdg_ApiIdType​
NameWdg_ApiIdTypeAnalysis
TypeEnumeration
Element0x00 WDG_INIT_API_IDAPI Id of Wdg_Init
0x01 WDG_SETMODE_API_IDAPI Id of Wdg_SetMode
0x02 WDG_SETTRIGGERCONDITION_API_IDAPI Id of Wdg_SetTriggerCondition
0x03 WDG_GETVERSION_API_IDAPI Id of Wdg_GetVersionInfo
DescriptionWDG ApiId Enumeration
Available viaWdg_Prv.h
Wdg_ErrIdType​
NameWdg_ErrIdTypeAnalysis
TypeEnumeration
Element0x10 WDG_E_DRIVER_STATEError ID of wrong driver state
0x11 WDG_E_PARAM_MODEError ID of wrong mode
0x12 WDG_E_PARAM_CONFIGError ID of wrong config
0x13 WDG_E_PARAM_TIMEOUTError ID of wrong timeout
0x14 WDG_E_PARAM_POINTERError ID of wrong pointer
0x15 WDG_E_INIT_FAILEDError ID of init failed
DescriptionWDG ErrId Enumeration
Available viaWdg_Prv.h
Wdg_StateType​
NameWdg_StateType
TypeEnumeration
Element0x01 WDG_UNINIT(The wdg’s state is uninitialized)
0x02 WDG_IDLE(The wdg’s state is idle)
0x03 WDG_BUSY(The wdg’s state is busy)
DescriptionWDG State Enumeration
Available viaWdg_Prv.h
Wdg_ModeType​
NameWdg_ModeTypeAnalysis
TypeStructure
Elementuint32 Wdg_GptPeriodTimeout period of GPT used by WDG
const Wdg_Lld_ConfigType * Wdg_Lld_ConfigPtrPointer to WDG Low-Level Driver Config
DescriptionWDG Mode Structure
Available viaWdg_Prv.h
Wdg_ConfigType​
NameWdg_ConfigTypeAnalysis
TypeStructure
ElementWdg_Lld_InstanceType Wdg_InstanceIdWDG’s instance id
WdgIf_ModeType Wdg_DefaultModeSettingWDG’s default mode setting
const Wdg_ModeType Wdg_ModeSettingsWDG Specific mode settings
Gpt_ChannelType Wdg_GptChannelChannel of GPT used by WDG
uint32 Wdg_GptFreqFrequency of GPT used by WDG
DescriptionWDG Configuration Structure
Available viaWdg_Prv.h

3.2 Function Definitions​

3.2.1 Wdgx_Init​

Service NameWdgx_Init
Syntaxvoid Wdgx_Init(const Wdg_ConfigType *ConfigPtr)
Sync/AsyncSynchronous
ReentrancyNon Reentrant
Parameters (in)ConfigPtr:Pointer to configuration set
Parameters (inout)None
Parameters (out)None
Return valueNone
DescriptionInitializes the module
Available viaWdgx.h

3.2.2 Wdgx_SetMode​

Service NameWdgx_SetMode
SyntaxStd_ReturnType Wdgx_SetMode(WdgIf_ModeType Mode)
Sync/AsyncSynchronous
ReentrancyNon Reentrant
Parameters (in)Mode:WDGIF_OFF_MODE/WDGIF_SLOW_MODE/WDGIF_FAST_MODE
Parameters (inout)None
Parameters (out)None
Return valueStd_ReturnType
DescriptionSwitches the Watchdog into the mode Mode.
Available viaWdgx.h

3.2.3 Wdgx_SetTriggerCondition​

Service NameWdgx_SetTriggerCondition
Syntaxvoid Wdgx_SetTriggerCondition(uint16 timeout)
Sync/AsyncSynchronous
ReentrancyNon Reentrant
Parameters (in)Timeout:Timeout value (milliseconds) for setting the trigger counter.
Parameters (inout)None
Parameters (out)None
Return valueNone
DescriptionSets the timeout value for the trigger counter.
Available viaWdgx.h

3.2.4 Wdgx_GetVersionInfo​

Service NameWdgx_GetVersionInfo
Syntaxvoid Wdgx_GetVersionInfo(Std_VersionInfoType *VersionInfoPtr)
Sync/AsyncSynchronous
ReentrancyReentrant
Parameters (in)None
Parameters (inout)None
Parameters (out)VersionInfoPtr:Pointer to where to store the version information of this module.
Return valueNone
DescriptionReturns the version information of the module.
Available viaWdgx.h

3.2.5 Wdg_Lld_SetRstCallback​

Service NameWdg_Lld_SetRstCallback
SyntaxStd_ReturnType Wdg_Lld_SetRstCallback(const Wdg_Lld_InstanceType Instance, Wdg_CallbackPtrType Callback)
Sync/AsyncSynchronous
ReentrancyNon Reentrant
Parameters (in)Instance:watchdog instance index; Callback:Reset interrupt callback, NULL_PTR can be used to clear
Parameters (inout)None
Parameters (out)None
Return valueStd_ReturnType
DescriptionRegisters or clears the reset interrupt callback of the specified watchdog instance.
Available viaWdg_Lld.h

3.2.6 Wdg_Lld_RstIrqHandler​

Service NameWdg_Lld_RstIrqHandler
Syntaxvoid Wdg_Lld_RstIrqHandler(uint32 Instance)
Sync/AsyncSynchronous
ReentrancyNon Reentrant
Parameters (in)Instance:watchdog instance index
Parameters (inout)None
Parameters (out)None
Return valueNone
DescriptionHandles the watchdog reset interrupt and invokes the callback registered by Wdg_Lld_SetRstCallback.
Available viaWdg_Lld.h

3.2.5 Wdg_Lld_SetRstCallback​

Service NameWdg_Lld_SetRstCallback
SyntaxStd_ReturnType Wdg_Lld_SetRstCallback(const Wdg_Lld_InstanceType Instance, Wdg_CallbackPtrType Callback)
Sync/AsyncSynchronous
ReentrancyNon Reentrant
Parameters (in)Instance:watchdog instance index; Callback:Reset interrupt callback, NULL_PTR can be used to clear
Parameters (inout)None
Parameters (out)None
Return valueStd_ReturnType
DescriptionRegisters or clears the reset interrupt callback of the specified watchdog instance.
Available viaWdg_Lld.h

3.2.6 Wdg_Lld_RstIrqHandler​

Service NameWdg_Lld_RstIrqHandler
Syntaxvoid Wdg_Lld_RstIrqHandler(uint32 Instance)
Sync/AsyncSynchronous
ReentrancyNon Reentrant
Parameters (in)Instance:watchdog instance index
Parameters (inout)None
Parameters (out)None
Return valueNone
DescriptionHandles the watchdog reset interrupt and invokes the callback registered by Wdg_Lld_SetRstCallback.
Available viaWdg_Lld.h

3.3 Interrupt Handling​

ISR NameHardware Interrupt Vector
Wdg_Ins0IntIsr71
Wdg_Ins0RstIsr72
Wdg_Ins1IntIsr73
Wdg_Ins1RstIsr74
Wdg_Ins2IntIsr75
Wdg_Ins2RstIsr76
ISR NameHardware Interrupt Vector
Wdg_Ins0IntIsr93
Wdg_Ins0RstIsr94
Wdg_Ins1IntIsr95
Wdg_Ins1RstIsr96
Wdg_Ins2IntIsr97
Wdg_Ins2RstIsr98
Wdg_Ins3IntIsr99
Wdg_Ins3RstIsr100
Wdg_Ins4IntIsr101
Wdg_Ins4RstIsr102

The handling paths for normal WDG interrupts and reset interrupts are as follows:

ISRHandlerDescription
Wdg_InsXIntIsrWdgX_IrqHandlerNormal WDG interrupt; finally calls Wdg_Lld_IrqHandler
Wdg_InsXRstIsrWdg_Lld_RstIrqHandlerWDG reset interrupt; finally calls the callback registered by Wdg_Lld_SetRstCallback
note

WdgX_RstIrqHandler() wraps Wdg_Lld_RstIrqHandler(X) in the Target project and is equivalent to it; Wdg0 through Wdg2 all provide an instance-level entry.

The handling paths for normal WDG interrupts and reset interrupts are as follows:

ISRHandlerDescription
Wdg_InsXIntIsrWdgX_IrqHandlerNormal WDG interrupt; finally calls Wdg_Lld_IrqHandler
Wdg_InsXRstIsrWdg_Lld_RstIrqHandlerWDG reset interrupt; finally calls the callback registered by Wdg_Lld_SetRstCallback
note

WdgX_RstIrqHandler() wraps Wdg_Lld_RstIrqHandler(X) in the Target project and is equivalent to it; Wdg0 through Wdg2 all provide an instance-level entry, while Wdg3/Wdg4 have none and call Wdg_Lld_RstIrqHandler(3U)/Wdg_Lld_RstIrqHandler(4U) directly.

3.4 Critical Sections​

Use SchM_Enter_Wdg_ExclusiveZone_XX and SchM_Exit_Wdg_ExclusiveZone_XX to define operations for entering and exiting critical sections. The WDG driver requires users to handle critical sections according to their actual application deployment. These functions are already called in the driver.

Protects Wdg_LastMode:

  • SchM_Enter_Wdg_ExclusiveZone_00
  • SchM_Exit_Wdg_ExclusiveZone_00

Protects Wdg_CurrMode:

  • SchM_Enter_Wdg_ExclusiveZone_01
  • SchM_Exit_Wdg_ExclusiveZone_01

Protects Wdg_State:

  • SchM_Enter_Wdg_ExclusiveZone_02
  • SchM_Exit_Wdg_ExclusiveZone_02

Protects Wdg_GptPeriod:

  • SchM_Enter_Wdg_ExclusiveZone_03
  • SchM_Exit_Wdg_ExclusiveZone_03

Protects Wdg_Timeout:

  • SchM_Enter_Wdg_ExclusiveZone_04
  • SchM_Exit_Wdg_ExclusiveZone_04

Protects Wdg_PausePtr:

  • SchM_Enter_Wdg_ExclusiveZone_05
  • SchM_Exit_Wdg_ExclusiveZone_05

Protects Wdg_Lld_Rst:

  • SchM_Enter_Wdg_ExclusiveZone_06
  • SchM_Exit_Wdg_ExclusiveZone_06

4. A-Core Watchdog Timeout MCU Handling Flow​

4.1 Reset Configuration Enable​

Call Wdg_Enable_RstConfig() in Target's main.c (implementation in Wdg_Common.c, declaration in Wdg_Prv.h) to complete the low-level enablement related to the watchdog-side and MCU reset/notification link.

NameDescription
Wdg_Enable_RstConfigReset configuration

4.2 MCU-Side Handling Flow​

When the A-core watchdog times out, an interrupt is sent to MCU0. MCU0 then initiates a reset after a delay so that the A-core can print stack and other information.

The flow is: interrupt sets flag → dedicated task delays → trigger long reset. The responsibility for executing the long reset lies with the OS task.

NameLocationDescription
Interrupt (entry)Target...\HorizonISR.c: ISR(Wdt_CfIntIsr)Set g_need_reset = 1 (g_need_reset is in McalCdd\Wdg\src\Wdg_Common.c), Os_Disable_Wdt_CfIntIsr(); bound to IntRouter and ConfigInterrupts.h
OS task (delay + long reset)Target...\HorizonTask.c: TASK(OsTask_SysCore_WDG_RST)When g_need_reset is true: log → vTaskDelay(MS_TO_TICK(5000)) (approx. 5s) → Rfchm_TriggerSocLongReset() executes SoC long reset

4. A-Core Watchdog Timeout MCU Handling Flow​

4.1 Reset Configuration Enable​

Call Wdg_Enable_RstConfig() in Target's main.c (implementation in Wdg_Common.c, declaration in Wdg_Prv.h) to complete the low-level enablement related to the watchdog-side and MCU reset/notification link.

NameDescription
Wdg_Enable_RstConfigReset configuration

4.2 MCU-Side Handling Flow​

When the A-core watchdog times out, an interrupt is sent to MCU0. MCU0 then initiates a reset after a delay so that the A-core can print stack and other information.

The flow is: interrupt sets flag → dedicated task delays → trigger long reset. The responsibility for executing the long reset lies with the OS task.

NameLocationDescription
Interrupt (entry)Target...\HorizonISR.c: ISR(Wdt_CfIntIsr)Set g_need_reset = 1 (g_need_reset is in McalCdd\Wdg\src\Wdg_Common.c), Os_Disable_Wdt_CfIntIsr(); bound to IntRouter and ConfigInterrupts.h
OS task (delay + long reset)Target...\HorizonTask.c: TASK(OsTask_SysCore_WDG_RST)When g_need_reset is true: log → vTaskDelay(MS_TO_TICK(5000)) (approx. 5s) → Rfchm_TriggerSocLongReset() executes SoC long reset

5. WDG Reset Interrupt Test Environment Configuration​

This section describes the test environment configuration required to verify the WDG reset interrupt callback path after a timeout. The driver already provides the reset interrupt callback interface; see 3.2.5 and 3.2.6 for the related APIs and 3.3 for the interrupt handling path.

5.1 Test Environment Configuration​

The following configuration is used to allow the core running the test code to control the WDG and receive reset interrupts.

5.1.1 Reset Interrupt Handler​

  • File: Target/Target_S100/Target-hobot-lite-freertos/target/HorizonISR.c
  • Location: Wdg_Ins0RstIsr, Wdg_Ins1RstIsr, Wdg_Ins2RstIsr.
  • Default behavior: The reset interrupt entries call WdgX_IrqHandler(), so the driver reset interrupt callback path is not entered.
  • Test configuration: Change the three reset interrupt entries to call WdgX_RstIrqHandler() so that the driver reset interrupt callback path is entered.
ISR(Wdg_Ins0RstIsr){
LogSync("Enter Wdg_Ins0RstIsr\\r\\n");
Wdg0_RstIrqHandler();
}
ISR(Wdg_Ins1RstIsr){
LogSync("Enter Wdg_Ins1RstIsr\\r\\n");
Wdg1_RstIrqHandler();
}
ISR(Wdg_Ins2RstIsr){
LogSync("Enter Wdg_Ins2RstIsr\\r\\n");
Wdg2_RstIrqHandler();
}

5.1.2 WDG Core Binding​

  • File: Config/McalCdd/gen_s100_sip_B/Wdg/src/Wdg_Cfg.c
  • Location: Wdg_CoreIdConfig array.
  • Configuration: Bind the WDG instances to be tested to the core where the test code runs.
const uint16 Wdg_CoreIdConfig[WDG_NUM] =
{
0U,
0U,
0U,
};

5.1.3 Interrupt Routing​

  • File: Target/Target_S100/Target-hobot-lite-freertos/target/main.c
  • Location: After FreeRtos_Irq_Init();.
  • Configuration: Route the WDG interrupts and reset interrupts to the core where the test code runs.
OS_R52_GICD_IROUTER[MCUSYS_WWDT0_SYS_RST_INTR] = WDG_IRQ_AFFINITY_NS | 0U;
OS_R52_GICD_IROUTER[MCUSYS_WWDT0_INTR] = WDG_IRQ_AFFINITY_NS | 0U;
OS_R52_GICD_IROUTER[MCUSYS_WWDT1_SYS_RST_INTR] = WDG_IRQ_AFFINITY_NS | 0U;
OS_R52_GICD_IROUTER[MCUSYS_WWDT1_INTR] = WDG_IRQ_AFFINITY_NS | 0U;
OS_R52_GICD_IROUTER[MCUSYS_WWDT2_SYS_RST_INTR] = WDG_IRQ_AFFINITY_NS | 0U;
OS_R52_GICD_IROUTER[MCUSYS_WWDT2_INTR] = WDG_IRQ_AFFINITY_NS | 0U;

5.1.4 Enable Shell​

  • File: Target/Target_S100/Target-hobot-lite-freertos/target/Target.h
  • Location: SHELL_ENABLE macro definition.
  • Configuration: Enable the Shell if test commands are executed through the Shell.
#define SHELL_ENABLE TRUE

5. WDG Reset Interrupt Test Environment Configuration​

This section describes the test environment configuration required to verify the WDG reset interrupt callback path after a timeout. The driver already provides the reset interrupt callback interface; see 3.2.5 and 3.2.6 for the related APIs and 3.3 for the interrupt handling path.

The current RDK S600 MCU0 Target project has wired up the Wdg_InsXIntIsr/Wdg_InsXRstIsr reset interrupt test path. When testing from an unmodified source tree, apply the following test environment configuration before testing.

5.1 Test Environment Configuration​

The following configuration is used to verify the reset interrupt callback path for Wdg0 through Wdg4 from the Shell on Core0 of RDK S600 MCU0. The driver already supports the Wdg0 through Wdg4 reset interrupt interfaces.

5.1.1 WDG Configuration Expansion​

The RDK S600 MCU0 test configuration expands the WDG instance count from three to five, adds the Wdg3/4 timeout, mode, and state entries, and binds all five instances to MCU0 Core0 so that the core running the test code can receive the corresponding interrupts.

Wdg_Cfg_Defines.h​
  • File: Config/McalCdd/gen_s600_md/Wdg/inc/Wdg_Cfg_Defines.h
  • Change WDG_NUM from 3U to 5U.
#define WDG_NUM            (5U)
  • Add the WDG3/4 timeout parameters:
#define WDG3_INITIAL_TIMEOUT ((uint16)5000)
#define WDG3_MAX_TIMEOUT ((uint16)65535)
#define WDG4_INITIAL_TIMEOUT ((uint16)5000)
#define WDG4_MAX_TIMEOUT ((uint16)65535)
  • Add two entries to WDG_TIMEOUT_VALUE_ARRAY, WDG_INIT_LAST_MODE_ARRAY, and WDG_INIT_STATE_ARRAY for Wdg3 and Wdg4, increasing the array length from 3 to 5:
#define WDG_TIMEOUT_VALUE_ARRAY { \
{(uint32)0,(uint32)200, (uint32)100}, \
{(uint32)0,(uint32)200, (uint32)100}, \
{(uint32)0,(uint32)200, (uint32)100}, \
{(uint32)0,(uint32)200, (uint32)100}, \
{(uint32)0,(uint32)200, (uint32)100}, \
}

#define WDG_INIT_LAST_MODE_ARRAY { \
WDGIF_OFF_MODE, \
WDGIF_OFF_MODE, \
WDGIF_OFF_MODE, \
WDGIF_OFF_MODE, \
WDGIF_OFF_MODE, \
}

#define WDG_INIT_STATE_ARRAY { \
WDG_UNINIT, \
WDG_UNINIT, \
WDG_UNINIT, \
WDG_UNINIT, \
WDG_UNINIT, \
}
Wdg_Cfg.c​
  • File: Config/McalCdd/gen_s600_md/Wdg/src/Wdg_Cfg.c
  • Add &Wdg_Config_3 and &Wdg_Config_4 to Wdg_Config[].
  • Add the WDG3/4 timeout macros to Wdg_CfgInitialTimeout[] and Wdg_CfgMaxTimeout[].
const Wdg_ConfigType * const Wdg_Config[WDG_NUM] =
{
&Wdg_Config_0,
&Wdg_Config_1,
&Wdg_Config_2,
&Wdg_Config_3,
&Wdg_Config_4,
};

const uint16 Wdg_CfgInitialTimeout[WDG_NUM] =
{
WDG0_INITIAL_TIMEOUT,
WDG1_INITIAL_TIMEOUT,
WDG2_INITIAL_TIMEOUT,
WDG3_INITIAL_TIMEOUT,
WDG4_INITIAL_TIMEOUT,
};

const uint16 Wdg_CfgMaxTimeout[WDG_NUM] =
{
WDG0_MAX_TIMEOUT,
WDG1_MAX_TIMEOUT,
WDG2_MAX_TIMEOUT,
WDG3_MAX_TIMEOUT,
WDG4_MAX_TIMEOUT,
};
  • Expand Wdg_CoreIdConfig[] to five entries. When testing on MCU0 Core0, set all entries to 0U so that all five WDGs are bound to Core0:
const uint16 Wdg_CoreIdConfig[WDG_NUM] =
{
0U,
0U,
0U,
0U,
0U,
};

5.1.2 Reset Interrupt Handlers​

  • File: Target/Target_S600/Target-hobot-lite-freertos/target/HorizonISR.c
  • Configuration: Add Wdg_Ins0RstIsr through Wdg_Ins4RstIsr. The reset interrupt entries call Wdg_Lld_RstIrqHandler(0U) through Wdg_Lld_RstIrqHandler(4U). Wdg0 through Wdg2 also provide WdgX_RstIrqHandler(); Wdg3/Wdg4 call Wdg_Lld_RstIrqHandler(3U)/(4U) directly. If normal WDG interrupts are also required, add Wdg_InsXIntIsr entries that call Wdg_Lld_IrqHandler(0U) through Wdg_Lld_IrqHandler(4U).
ISR(Wdg_Ins0RstIsr) {
LogSync("Enter Wdg_Ins0RstIsr\\r\\n");
Wdg_Lld_RstIrqHandler(0U);
}
ISR(Wdg_Ins1RstIsr) {
LogSync("Enter Wdg_Ins1RstIsr\\r\\n");
Wdg_Lld_RstIrqHandler(1U);
}
ISR(Wdg_Ins2RstIsr) {
LogSync("Enter Wdg_Ins2RstIsr\\r\\n");
Wdg_Lld_RstIrqHandler(2U);
}
ISR(Wdg_Ins3RstIsr) {
LogSync("Enter Wdg_Ins3RstIsr\\r\\n");
Wdg_Lld_RstIrqHandler(3U);
}
ISR(Wdg_Ins4RstIsr) {
LogSync("Enter Wdg_Ins4RstIsr\\r\\n");
Wdg_Lld_RstIrqHandler(4U);
}

5.1.3 Interrupt Declaration, Registration, and Enablement​

The reset interrupt handlers are defined in HorizonISR.c, but the interrupts cannot reach those handlers until the following four files are wired up in this order: function declaration, interrupt-number mapping, priority mask, and interrupt-table registration. After registration, FreeRtos_Irq_Init() installs and enables these interrupts and routes the SPI to the current Core0, so no additional IROUTER entries are needed in main.c.

Os.h​
  • File: Target/Target_S600/Target-hobot-lite-freertos/target/FreeRtosOsHal/Os.h
  • Add function declarations for Wdg_Ins0IntIsr/RstIsr through Wdg_Ins4IntIsr/RstIsr:
extern void Os_Isr_Wdg_Ins0IntIsr(void);
extern void Os_Isr_Wdg_Ins0RstIsr(void);
extern void Os_Isr_Wdg_Ins1IntIsr(void);
extern void Os_Isr_Wdg_Ins1RstIsr(void);
extern void Os_Isr_Wdg_Ins2IntIsr(void);
extern void Os_Isr_Wdg_Ins2RstIsr(void);
extern void Os_Isr_Wdg_Ins3IntIsr(void);
extern void Os_Isr_Wdg_Ins3RstIsr(void);
extern void Os_Isr_Wdg_Ins4IntIsr(void);
extern void Os_Isr_Wdg_Ins4RstIsr(void);
ConfigInterrupts.h​
  • File: Target/Target_S600/Target-hobot-lite-freertos/target/FreeRtosOsHal/ConfigInterrupts.h
  • Define the interrupt-channel macros that map Os_IntChannel_Wdg_InsX* to the RDK S600 normal interrupt vectors MCUSYS_WWDT0..4_INTR and reset interrupt vectors MCUSYS_WWDT0..4_SYS_RST_INTR:
#define Os_IntChannel_Wdg_Ins0IntIsr (MCUSYS_WWDT0_INTR)
#define Os_IntChannel_Wdg_Ins0RstIsr (MCUSYS_WWDT0_SYS_RST_INTR)
#define Os_IntChannel_Wdg_Ins1IntIsr (MCUSYS_WWDT1_INTR)
#define Os_IntChannel_Wdg_Ins1RstIsr (MCUSYS_WWDT1_SYS_RST_INTR)
#define Os_IntChannel_Wdg_Ins2IntIsr (MCUSYS_WWDT2_INTR)
#define Os_IntChannel_Wdg_Ins2RstIsr (MCUSYS_WWDT2_SYS_RST_INTR)
#define Os_IntChannel_Wdg_Ins3IntIsr (MCUSYS_WWDT3_INTR)
#define Os_IntChannel_Wdg_Ins3RstIsr (MCUSYS_WWDT3_SYS_RST_INTR)
#define Os_IntChannel_Wdg_Ins4IntIsr (MCUSYS_WWDT4_INTR)
#define Os_IntChannel_Wdg_Ins4RstIsr (MCUSYS_WWDT4_SYS_RST_INTR)
Isr_cfg.h​
  • File: Target/Target_S600/Target-hobot-lite-freertos/target/FreeRtosOsHal/Isr_cfg.h
  • Add the OS_IMASK_FOR_Wdg_InsX* priority-mask macros:
#define OS_IMASK_FOR_Wdg_Ins0IntIsr (8)
#define OS_IMASK_FOR_Wdg_Ins0RstIsr (8)
#define OS_IMASK_FOR_Wdg_Ins1IntIsr (8)
#define OS_IMASK_FOR_Wdg_Ins1RstIsr (8)
#define OS_IMASK_FOR_Wdg_Ins2IntIsr (8)
#define OS_IMASK_FOR_Wdg_Ins2RstIsr (8)
#define OS_IMASK_FOR_Wdg_Ins3IntIsr (8)
#define OS_IMASK_FOR_Wdg_Ins3RstIsr (8)
#define OS_IMASK_FOR_Wdg_Ins4IntIsr (8)
#define OS_IMASK_FOR_Wdg_Ins4RstIsr (8)
Isr_Hal.c​
  • File: Target/Target_S600/Target-hobot-lite-freertos/target/FreeRtosOsHal/Isr_Hal.c
  • Register Wdg_InsXIntIsr/RstIsr in Interrupt_McuConfigs[] using the tuple {interrupt number, handler, priority, enable flag} and set them to ENABLE:
{Os_IntChannel_Wdg_Ins0IntIsr, Os_Isr_Wdg_Ins0IntIsr, OS_IMASK_FOR_Wdg_Ins0IntIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins0RstIsr, Os_Isr_Wdg_Ins0RstIsr, OS_IMASK_FOR_Wdg_Ins0RstIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins1IntIsr, Os_Isr_Wdg_Ins1IntIsr, OS_IMASK_FOR_Wdg_Ins1IntIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins1RstIsr, Os_Isr_Wdg_Ins1RstIsr, OS_IMASK_FOR_Wdg_Ins1RstIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins2IntIsr, Os_Isr_Wdg_Ins2IntIsr, OS_IMASK_FOR_Wdg_Ins2IntIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins2RstIsr, Os_Isr_Wdg_Ins2RstIsr, OS_IMASK_FOR_Wdg_Ins2RstIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins3IntIsr, Os_Isr_Wdg_Ins3IntIsr, OS_IMASK_FOR_Wdg_Ins3IntIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins3RstIsr, Os_Isr_Wdg_Ins3RstIsr, OS_IMASK_FOR_Wdg_Ins3RstIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins4IntIsr, Os_Isr_Wdg_Ins4IntIsr, OS_IMASK_FOR_Wdg_Ins4IntIsr/8, ENABLE},
{Os_IntChannel_Wdg_Ins4RstIsr, Os_Isr_Wdg_Ins4RstIsr, OS_IMASK_FOR_Wdg_Ins4RstIsr/8, ENABLE},

5.1.4 Enable Shell​

  • File: Target/Target_S600/Target-hobot-lite-freertos/target/Target.h
  • Configuration: MCU0 defaults to SHELL_ENABLE FALSE; change it to TRUE for Shell-based testing.
#define SHELL_ENABLE TRUE

5.1.5 Enable Shell UART Input​

  • File: Target/Target_S600/Target-hobot-lite-freertos/target/FreeRtosOsHal/Isr_Hal.c
  • Configuration: Register Uart0_Isr in Interrupt_McuConfigs[] with ENABLE; otherwise the MCU0 Shell can only print output and cannot receive UART input.
{Os_IntChannel_Uart0_Isr, Os_Isr_Uart0_Isr, OS_IMASK_FOR_Uart0_Isr / 8, ENABLE},
note

On RDK S600, Uart8 is the shared debug console for MCU0/MCU1. If MCU1 also registers and owns Uart0_Isr, input will be contended. When testing the MCU0 serial Shell, ensure only MCU0 owns this UART, or disable the MCU1 Shell/UART0 receive path.