1 /** 2 * @file wdg.h 3 * @copyright Copyright (C) 2015-2021 Alibaba Group Holding Limited 4 */ 5 6 #ifndef _AOS_WDG_H 7 #define _AOS_WDG_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 #include <aos/kernel.h> 14 15 /** @addtogroup aos_wdg_device I2C 16 * aos watchdog API. 17 * 18 * @{ 19 */ 20 21 typedef uint32_t* wdg_dev_handle_t; 22 23 /** 24 * start a new watchdog 25 * 26 * @param[in] id watchdog controller's id 27 * @param[in] ms watchdog's timeout value, in unit of ms, 0xFFFFFFFF is not allowed to use 28 * 29 * @return handle of the watchdog device, used for later watchdog operations, when open operation success; 30 NULL when open operation fails 31 */ 32 extern wdg_dev_handle_t aos_wdg_open (uint32_t id, uint32_t ms); 33 34 /** 35 * close target watchdog handle 36 * 37 * @param[in] dev handle of the watchdog device to be operated, must be the return value of aos_wdg_open 38 * 39 * @return 0 if operation success 40 negative error code if operation fails 41 */ 42 extern aos_status_t aos_wdg_close (wdg_dev_handle_t dev_h); 43 44 45 /** 46 * start target watchdog 47 * 48 * @param[in] dev handle of the watchdog device to be operated, must be the return value of aos_wdg_open 49 * 50 * @return 0 if operation success 51 negative error code if operation fails 52 */ 53 extern aos_status_t aos_wdg_start (wdg_dev_handle_t dev_h); 54 55 /** 56 * stop target watchdog 57 * 58 * @param[in] dev handle of the watchdog device to be operated, must be the return value of aos_wdg_open 59 * 60 * @return 0 if operation success 61 negative error code if operation fails 62 */ 63 extern aos_status_t aos_wdg_stop (wdg_dev_handle_t dev_h); 64 65 /** 66 * set timeout value of target watchdog 67 * 68 * @param[in] dev handle of the watchdog device to be operated, must be the return value of aos_wdg_open 69 * @param[in] clk watchdog's new timeout value, in unit of ms 70 * 71 * @return 0 if operation success 72 negative error code if operation fails 73 */ 74 extern aos_status_t aos_wdg_timeout_set (wdg_dev_handle_t dev, uint32_t ms); 75 76 /** 77 * feed target watchdog 78 * 79 * @param[in] dev handle of the watchdog device to be operated, must be the return value of aos_wdg_open 80 * 81 * @return 0 if operation success 82 negative error code if operation fails 83 */ 84 extern aos_status_t aos_wdg_feed (wdg_dev_handle_t dev_h); 85 86 87 /** @} */ 88 89 #ifdef __cplusplus 90 } 91 #endif 92 93 #endif /* _AOS_WDG_H */ 94