Files
test/interface_wdt.c
2025-07-05 20:11:15 +08:00

49 lines
1.0 KiB
C

#include <sdrv_btm.h>
#include <regs_base.h>
#include <irq_num.h>
#include <debug.h>
#include <sdrv_rstgen.h>
#include "interface_config.h"
sdrv_wdt_t *wdt_type = (sdrv_wdt_t *)(uintptr_t)APB_WDT1_BASE;
static bool internal_reset_switch = true;
static bool external_reset_switch = false;
//¿´ÃŹ·³õʼ»¯
void wdt_init(uint32_t timeoutms)
{
static sdrv_wdt_config_t wdt_cfg;
int ret = 0;
//--------------------------------------------------
sdrv_wdt_get_default_config(&wdt_cfg);
if (internal_reset_switch) {
wdt_cfg.int_rst.reset_en = true;
sdrv_rstgen_wdt_reset_enable(RESET_WDT1, true);
}
if (external_reset_switch) {
/* config GPIO_H12 as WDT1_RST_N function */
wdt_cfg.ext_rst.reset_en = true;
wdt_cfg.ext_rst.reset_mode = 0; /* low level active */
}
ret = sdrv_wdt_init(wdt_type, &wdt_cfg);
ASSERT(ret == 0);
// irq_attach(wdt_irq, wdt_irq_handler, NULL);
// irq_enable(wdt_irq);
sdrv_wdt_set_timeout(wdt_type, timeoutms);
ret = sdrv_wdt_enable(wdt_type);
}