1 /* 2 * Copyright (c) 2006-2021, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2021-07-28 songchao first version 9 */ 10 11 #ifndef __WATCHDOG_H__ 12 #define __WATCHDOG_H__ 13 14 #include <rtthread.h> 15 #include "fsl_wdog.h" 16 17 #define RT_DEVICE_CTRL_WDT_GET_TIMEOUT (1) /* get timeout(in seconds) */ 18 #define RT_DEVICE_CTRL_WDT_SET_TIMEOUT (2) /* set timeout(in seconds) */ 19 #define RT_DEVICE_CTRL_WDT_GET_TIMELEFT (3) /* get the left time before reboot(in seconds) */ 20 #define RT_DEVICE_CTRL_WDT_KEEPALIVE (4) /* refresh watchdog */ 21 #define RT_DEVICE_CTRL_WDT_START (5) /* start watchdog */ 22 #define RT_DEVICE_CTRL_WDT_STOP (6) /* stop watchdog */ 23 24 struct rt_watchdog_ops; 25 struct rt_watchdog_device 26 { 27 struct rt_device parent; 28 const struct rt_watchdog_ops *ops; 29 const char *name; 30 rt_uint32_t paddr; 31 rt_uint32_t vaddr; 32 rt_uint32_t irqno; 33 wdog_config_t *config; 34 }; 35 typedef struct rt_watchdog_device rt_watchdog_t; 36 37 struct rt_watchdog_ops 38 { 39 rt_err_t (*init)(rt_watchdog_t *wdt); 40 rt_err_t (*control)(rt_watchdog_t *wdt, int cmd, void *arg); 41 }; 42 43 rt_err_t rt_hw_watchdog_register(rt_watchdog_t *wdt, 44 const char *name, 45 rt_uint32_t flag, 46 void *data); 47 48 #endif /* __WATCHDOG_H__ */ 49