Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions os/arch/arm/src/amebasmart/amebasmart_watchdog_lowerhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,19 @@ static int amebasmart_wdg_ioctl(FAR struct watchdog_lowerhalf_s *lower, int cmd,
}
return OK;
}

/****************************************************************************
* Name: wdog_irq_handler
*
* Description:
* early interrupt handler
*
****************************************************************************/
static void wdog_irq_handler(void *id)
{
(void)id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one question.
What is id value means?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id parameter is a user-defined context pointer passed to the watchdog interrupt handler.
we pass the watchdog lower-half private structure (priv) as id, which allows the handler to access per-device state if needed.
Currently, the early watchdog interrupt does not require any context, so the handler explicitly marks id as unused.

watchdog_clear_irq();
lldbg("===Watchdog Early Interrupt===\n");
}
/****************************************************************************
* Name: amebasmart_wdg_initialize
*
Expand All @@ -442,12 +454,12 @@ int amebasmart_wdg_initialize(const char *devpath, uint32_t timeout_ms)

/* Set the priv to default */
priv->ops = &g_wdgops;
priv->handler = NULL;
priv->handler = (xcpt_t)wdog_irq_handler;

/* Initializes the watchdog, include time setting, mode register */
watchdog_init(timeout_ms);
priv->wdt_status = WDT_STOP;
priv->int_mode = false;
priv->int_mode = true;

/* Register the watchdog driver as /dev/wdgX. */
if (!watchdog_register(devpath, (FAR struct watchdog_lowerhalf_s *)priv)) {
Expand Down
6 changes: 6 additions & 0 deletions os/board/rtl8730e/src/component/mbed/hal_ext/wdt_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ void watchdog_stop(void);
*/
void watchdog_refresh(void);

/**
* @brief Clear the watchdog early interrupt to prevent multiple trigger.
* @param none
* @retval none
*/
void watchdog_clear_irq(void);
/**
* @brief Switch the watchdog timer to interrupt mode and
* register a watchdog timer timeout interrupt handler.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ void watchdog_refresh(void)
WDG_Refresh(WDGDev);
}

/**
* @brief Clear the watchdog early interrupt to prevent multiple trigger.
* @param none
* @retval none
*/
void watchdog_clear_irq(void)
{
WDG_ClearINT(WDGDev, WDG_BIT_EIC);
WDG_INTConfig(WDGDev, WDG_BIT_EIE, DISABLE);
}
/**
* @brief Enable eraly interrupt and register a watchdog timer timeout interrupt handler.
* The interrupt handler will be called at a programmable time prior to watchdog timeout, for users to prepare for reset
Expand Down