Intel® Quark™ Microcontroller Software Interface 1.4.0 Intel® Quark™ Microcontroller BSP

- Main Page
- Modules
- Data Structures
- Files

- File List

qm_wdt.h
1 /*
2 * {% copyright %}
3 */
4
5 #ifndef __QM_WDT_H__
6 #define __QM_WDT_H__
7
8 #include "qm_common.h"
9 #include "qm_soc_regs.h"
10
11 /**
12 * Watchdog timer.
13 *
14 * @defgroup groupWDT WDT
15 * @{
16 */
17
18 /**
19 * WDT Mode type.
20 */
21 typedef enum {
22 /** Watchdog Reset Response Mode.
23 *
24 * The watchdog will request a SoC Warm Reset on a timeout.
25 */
26 QM_WDT_MODE_RESET = 0,
27 /** Watchdog Interrupt Reset Response Mode.
28 *
29 * The watchdog will generate an interrupt on first timeout.
30 * If interrupt has not been cleared by the second timeout
31 * the watchdog will then request a SoC Warm Reset.
32 */
33 QM_WDT_MODE_INTERRUPT_RESET
34 } qm_wdt_mode_t;
35
36 /**
37 * QM WDT configuration type.
38 */
39 typedef struct {
40 /**
41 * Index for the WDT timeout table.
42 * For each instantiation of WDT there are multiple timeout
43 * values pre-programmed in hardware.
44 * Reference the SoC datasheet or register file for the table
45 * associated to the WDT being configured.
46 */
47 uint32_t timeout;
48 qm_wdt_mode_t mode; /**< Watchdog response mode. */
49 #if (HAS_WDT_PAUSE)
50 /**
51 * Pause enable in LMT power state C2 and C2 Plus.
52 *
53 * When equal to 1, the WDT is paused when LMT enters the C2
54 * state. When equal to 0, the WDT is not paused when LMT
55 * enters the C2 state.
56 *
57 * This field applies only to Watchdogs on AON power island.
58 *
59 */
60 bool pause_en;
61 #endif /* HAS_WDT_PAUSE */
62
63 /**
64 * User callback.
65 *
66 * param[in] data Callback user data.
67 */
68 void (*callback)(void *data);
69 void *callback_data; /**< Callback user data. */
70 } qm_wdt_config_t;
71
72 /**
73 * Start WDT.
74 *
75 * Once started, WDT can only be stopped by a SoC reset.
76 *
77 * @param[in] wdt WDT index.
78 *
79 * @return Standard errno return type for QMSI.
80 * @retval 0 on success.
81 * @retval Negative @ref errno for possible error codes.
82 */
83 int qm_wdt_start(const qm_wdt_t wdt);
84
85 /**
86 * Set configuration of WDT module.
87 *
88 * This includes the timeout period in PCLK cycles, the WDT mode of operation.
89 * It also registers an ISR to the user defined callback.
90 *
91 * @param[in] wdt WDT index.
92 * @param[in] cfg New configuration for WDT.
93 * This must not be NULL.
94 *
95 * @return Standard errno return type for QMSI.
96 * @retval 0 on success.
97 * @retval Negative @ref errno for possible error codes.
98 */
99 int qm_wdt_set_config(const qm_wdt_t wdt, const qm_wdt_config_t *const cfg);
100
101 /**
102 * Reload the WDT counter.
103 *
104 * Reload the WDT counter with safety value, i.e. service the watchdog.
105 *
106 * @param[in] wdt WDT index.
107 *
108 * @return Standard errno return type for QMSI.
109 * @retval 0 on success.
110 * @retval Negative @ref errno for possible error codes.
111 */
112 int qm_wdt_reload(const qm_wdt_t wdt);
113
114 /**
115 * Save watchdog context.
116 *
117 * Save the configuration of the watchdog before entering sleep.
118 *
119 * @param[in] wdt WDT index.
120 * @param[out] ctx WDT context structure. This must not be NULL.
121 *
122 * @return Standard errno return type for QMSI.
123 * @retval 0 on success.
124 * @retval Negative @ref errno for possible error codes.
125 */
126 int qm_wdt_save_context(const qm_wdt_t wdt, qm_wdt_context_t *const ctx);
127
128 /**
129 * Restore watchdog context.
130 *
131 * Restore the configuration of the watchdog after exiting sleep.
132 *
133 * @param[in] wdt WDT index.
134 * @param[in] ctx WDT context structure. This must not be NULL.
135 *
136 * @return Standard errno return type for QMSI.
137 * @retval 0 on success.
138 * @retval Negative @ref errno for possible error codes.
139 */
140 int qm_wdt_restore_context(const qm_wdt_t wdt,
141 const qm_wdt_context_t *const ctx);
142
143 /**
144 * @}
145 */
146
147 #endif /* __QM_WDT_H__ */
QM_WDT_MODE_INTERRUPT_RESET
Watchdog Interrupt Reset Response Mode.
Definition: qm_wdt.h:33
qm_wdt_config_t::mode
qm_wdt_mode_t mode
Watchdog response mode.
Definition: qm_wdt.h:48
qm_wdt_config_t::pause_en
bool pause_en
Pause enable in LMT power state C2 and C2 Plus.
Definition: qm_wdt.h:60
QM_WDT_MODE_RESET
Watchdog Reset Response Mode.
Definition: qm_wdt.h:26
qm_wdt_config_t
QM WDT configuration type.
Definition: qm_wdt.h:39
qm_wdt_config_t::timeout
uint32_t timeout
Index for the WDT timeout table.
Definition: qm_wdt.h:47
qm_wdt_restore_context
int qm_wdt_restore_context(const qm_wdt_t wdt, const qm_wdt_context_t *const ctx)
Restore watchdog context.
Definition: qm_wdt.c:152
qm_wdt_reload
int qm_wdt_reload(const qm_wdt_t wdt)
Reload the WDT counter.
Definition: qm_wdt.c:98
qm_wdt_save_context
int qm_wdt_save_context(const qm_wdt_t wdt, qm_wdt_context_t *const ctx)
Save watchdog context.
Definition: qm_wdt.c:144
qm_wdt_set_config
int qm_wdt_set_config(const qm_wdt_t wdt, const qm_wdt_config_t *const cfg)
Set configuration of WDT module.
Definition: qm_wdt.c:60
qm_wdt_t
qm_wdt_t
Number of WDT controllers.
Definition: qm_soc_regs.h:467
qm_wdt_start
int qm_wdt_start(const qm_wdt_t wdt)
Start WDT.
Definition: qm_wdt.c:44
qm_wdt_config_t::callback_data
void * callback_data
Callback user data.
Definition: qm_wdt.h:69
qm_wdt_mode_t
qm_wdt_mode_t
WDT Mode type.
Definition: qm_wdt.h:21