1 /**
2  * @file wdg_core.h
3  * @copyright Copyright (C) 2015-2021 Alibaba Group Holding Limited
4  */
5 
6 #ifndef _WDG_CORE_H
7 #define _WDG_CORE_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 #include "aos/driver/wdg.h"
13 #include <aos/list.h>
14 #include <aos/kernel.h>
15 
16 #define AOS_WDG_MAGIC 0x3D63D63D
17 
18 /* This struct define watchdog main handle */
19 typedef struct {
20     uint8_t             id;                /**< watchdog controller's id */
21     uint32_t            timeout;            /**< watchdog's timeout value, in unit of ms */
22     aos_mutex_t         lock;             /**< lock for watchdog device's operations */
23     uint32_t            wdg_dev_handle;    /**< use &wdg_dev_handle as watchdog device's handle */
24     dlist_t             node;              /**<  node in watchdog controller's device list */
25     void                *controller;       /**<  pointer to watchdog controller's struct */
26     bool                started;           /**< whether watchdog user is started or not >*/
27 } wdg_dev_t;
28 
29 /**
30  * watchdog controller's settings
31  * all watdhdog users connected to the same watchdog controller are connected to the list named with user
32 */
33 typedef struct wdg_controller_dev {
34     uint32_t    id;          /**< watchdog controller's id */
35     uint32_t    tmo;         /**< current watdhdog's timeout value setting, in unit of ms */
36     aos_mutex_t lock;        /**< used to lock all operations on current watchdog controller */
37     dlist_t     user;       /**< node in watchdog controller's user list */
38     csi_wdt_t   csi_dev;     /**< CSI watchdog device */
39     bool        init;        /**< whether watchdog controller is initialized or not >*/
40     bool        started;     /**< whether watchdog controller is started or not >*/
41 } wdg_controller_t;
42 
43 
44 #ifdef __cplusplus
45 }
46 #endif
47 
48 #endif /* _WDG_CORE_H */