Document API IEC60730 Library
sl_iec60730_watchdog.h
Go to the documentation of this file.
1 /***************************************************************************/
18 #ifndef SL_IEC60730_WATCHDOG_H
19 #define SL_IEC60730_WATCHDOG_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif /* __cplusplus */
24 
25 #include <stdint.h>
26 #include "em_wdog.h"
27 #include "sl_iec60730.h"
28 
29 /**************************************************************************/
117 typedef struct {
119  WDOG_TypeDef *const SL_WDOG;
120  uint32_t rst;
122 
124 typedef enum {
129 
130 #ifdef DOXYGEN
131 #define SL_IEC60730_WDOGINST_NUMB 1
133 #else // DOXYGEN
134 #if ((SL_IEC60730_WDOG0_ENABLE == 1) && (SL_IEC60730_WDOG1_ENABLE == 1))
135 #define SL_IEC60730_WDOGINST_NUMB 2
136 #elif ((SL_IEC60730_WDOG0_ENABLE == 0) && (SL_IEC60730_WDOG1_ENABLE == 0))
137 #warning No watchdogs have been selected for testing!
138 #define SL_IEC60730_WDOGINST_NUMB 0
139 #else
140 #define SL_IEC60730_WDOGINST_NUMB 1
141 #endif
142 #endif // DOXYGEN
143 
145 #ifndef SL_IEC60730_WDOG_WAIT_TIMEOUT
146 #define SL_IEC60730_WDOG_WAIT_TIMEOUT (uint32_t) 0x0000FFFFUL
147 #endif
148 
149 #ifdef DOXYGEN
150 #define SL_IEC60730_WDOG_INST(n) WDOG##n
152 
154 #define SL_IEC60730_RST RMU
155 
157 #define SL_IEC60730_RSTCAUSE_POR RMU_RSTCAUSE_PORST
158 
160 #define SL_IEC60730_RSTCAUSE_EM4 RMU_RSTCAUSE_EM4RST
161 
163 #define SL_IEC60730_RSTCAUSE_WDOG0 RMU_RSTCAUSE_WDOGRST
164 
166 #define SL_IEC60730_RSTCAUSE_WDOG1 RMU_RSTCAUSE_WDOGRST
167 
169 #define SL_IEC60730_RSTCAUSES_CLEAR()
170 
172 #define SL_IEC60730_RSTCAUSE (SL_IEC60730_RST->RSTCAUSE)
173 
174 #else // DOXYGEN
175 #ifndef SL_IEC60730_WDOG_INST
176 #if (_SILICON_LABS_32B_SERIES == 2)
177 #if ((defined SL_IEC60730_NON_SECURE_ENABLE) && (!defined(SL_TRUSTZONE_SECURE)))
178 #define SL_IEC60730_WDOG_INST(n) WDOG##n##_NS
179 #else
180 #define SL_IEC60730_WDOG_INST(n) WDOG##n
181 #endif
182 #else // Series 1 devices
183 #define SL_IEC60730_WDOG_INST(n) WDOG##n
184 #endif //(_SILICON_LABS_32B_SERIES == 2)
185 #endif
186 
187 #if (_SILICON_LABS_32B_SERIES < 2)
188 #ifndef SL_IEC60730_RST
189 #define SL_IEC60730_RST RMU
190 #endif
191 
192 #define SL_IEC60730_RSTCAUSE_POR RMU_RSTCAUSE_PORST
193 #define SL_IEC60730_RSTCAUSE_EM4 RMU_RSTCAUSE_EM4RST
194 #define SL_IEC60730_RSTCAUSE_WDOG0 RMU_RSTCAUSE_WDOGRST
195 #define SL_IEC60730_RSTCAUSE_WDOG1 RMU_RSTCAUSE_WDOGRST
196 
197 #ifndef UNIT_TEST_IEC60730_WATCHDOG_ENABLE
198 #define SL_IEC60730_RSTCAUSES_CLEAR() \
199  do { \
200  SL_IEC60730_RST->CMD |= RMU_CMD_RCCLR; \
201  } while (0)
202 #else
203 #define SL_IEC60730_RSTCAUSES_CLEAR() unit_test_iec60730_watchdog_mock_rstcause_clear()
204 #endif // UNIT_TEST_IEC60730_WATCHDOG_ENABLE
205 #else // Series 2 devices
206 #ifndef SL_IEC60730_RST
207 #if ((defined SL_IEC60730_NON_SECURE_ENABLE) && (!defined(SL_TRUSTZONE_SECURE)))
208 #define SL_IEC60730_RST EMU_NS
209 #else
210 #define SL_IEC60730_RST EMU
211 #endif
212 #endif
213 
214 #define SL_IEC60730_RSTCAUSE_POR EMU_RSTCAUSE_POR
215 #define SL_IEC60730_RSTCAUSE_EM4 EMU_RSTCAUSE_EM4
216 #define SL_IEC60730_RSTCAUSE_WDOG0 EMU_RSTCAUSE_WDOG0
217 #define SL_IEC60730_RSTCAUSE_WDOG1 EMU_RSTCAUSE_WDOG1
218 
219 #ifndef UNIT_TEST_IEC60730_WATCHDOG_ENABLE
220 #ifdef WDOG_HAS_SET_CLEAR
221 #define SL_IEC60730_RSTCAUSES_CLEAR() \
222  do { \
223  SL_IEC60730_RST->CMD_SET = EMU_CMD_RSTCAUSECLR; \
224  } while (0)
225 #else
226 #define SL_IEC60730_RSTCAUSES_CLEAR() \
227  do { \
228  SL_IEC60730_RST->CMD |= EMU_CMD_RSTCAUSECLR; \
229  } while (0)
230 #endif // WDOG_HAS_SET_CLEAR
231 #else
232 #define SL_IEC60730_RSTCAUSES_CLEAR() unit_test_iec60730_watchdog_mock_rstcause_clear()
233 #endif // UNIT_TEST_IEC60730_WATCHDOG_ENABLE
234 #endif // (_SILICON_LABS_32B_SERIES < 2)
235 #endif // DOXYGEN
236 
237 #ifndef UNIT_TEST_IEC60730_WATCHDOG_ENABLE
238 #define SL_IEC60730_RSTCAUSE (SL_IEC60730_RST->RSTCAUSE)
239 #else
240 #define SL_IEC60730_RSTCAUSE unit_test_iec60730_watchdog_mock_rstcause()
241 #endif // UNIT_TEST_IEC60730_WATCHDOG_ENABLE
242 
243 #ifndef UNIT_TEST_IEC60730_WATCHDOG_ENABLE
244 #define SL_IEC60730_RST_POR (SL_IEC60730_RSTCAUSE & SL_IEC60730_RSTCAUSE_POR)
245 #define SL_IEC60730_RST_EM4 (SL_IEC60730_RSTCAUSE & SL_IEC60730_RSTCAUSE_EM4)
246 #else
247 #define SL_IEC60730_RST_POR unit_test_iec60730_watchdog_mock_rst_por()
248 #define SL_IEC60730_RST_EM4 unit_test_iec60730_watchdog_mock_rst_em4()
249 #endif // UNIT_TEST_IEC60730_WATCHDOG_ENABLE
250 
251 #ifdef DOXYGEN
252 
253 #define SL_IEC60730_RST_WDOG0 (SL_IEC60730_RSTCAUSE & SL_IEC60730_RSTCAUSE_WDOG0)
254 #define SL_IEC60730_RST_WDOG1 (SL_IEC60730_RSTCAUSE & SL_IEC60730_RSTCAUSE_WDOG1)
255 
256 #else // DOXYGEN
257 #ifndef UNIT_TEST_IEC60730_WATCHDOG_ENABLE
258 #if (SL_IEC60730_WDOG0_ENABLE == 1)
259 #define SL_IEC60730_RST_WDOG0 (SL_IEC60730_RSTCAUSE & SL_IEC60730_RSTCAUSE_WDOG0)
260 #else
261 #define SL_IEC60730_RST_WDOG0 0
262 #endif // (SL_IEC60730_WDOG0_ENABLE == 1)
263 #if (SL_IEC60730_WDOG1_ENABLE == 1)
264 #define SL_IEC60730_RST_WDOG1 (SL_IEC60730_RSTCAUSE & SL_IEC60730_RSTCAUSE_WDOG1)
265 #else
266 #define SL_IEC60730_RST_WDOG1 0
267 #endif // (SL_IEC60730_WDOG1_ENABLE == 1)
268 #else
269 #if (SL_IEC60730_WDOG0_ENABLE == 1)
270 #define SL_IEC60730_RST_WDOG0 unit_test_iec60730_watchdog_mock_rst_wdog0()
271 #else
272 #define SL_IEC60730_RST_WDOG0 0
273 #endif // (SL_IEC60730_WDOG0_ENABLE == 1)
274 #if (SL_IEC60730_WDOG1_ENABLE == 1)
275 #define SL_IEC60730_RST_WDOG1 unit_test_iec60730_watchdog_mock_rst_wdog1()
276 #else
277 #define SL_IEC60730_RST_WDOG1 0
278 #endif // (SL_IEC60730_WDOG1_ENABLE == 1)
279 #endif // UNIT_TEST_IEC60730_WATCHDOG_ENABLE
280 #endif // DOXYGEN
281 
282 #define SL_IEC60730_RST_WDOGS (SL_IEC60730_RST_WDOG0 || SL_IEC60730_RST_WDOG1)
283 
284 #ifndef SL_IEC60730_BURAM
285 #if (_SILICON_LABS_32B_SERIES == 2)
286 #if ((defined SL_IEC60730_NON_SECURE_ENABLE) && (!defined(SL_TRUSTZONE_SECURE)))
287 #define SL_IEC60730_BURAM BURAM_NS
288 #else
289 #define SL_IEC60730_BURAM BURAM
290 #endif
291 #endif // (_SILICON_LABS_32B_SERIES == 2)
292 #endif
293 
295 #ifndef SL_IEC60730_BURAM_IDX
296 #define SL_IEC60730_BURAM_IDX 0UL
297 #endif
298 
299 #ifdef DOXYGEN
304 #else
306 #endif // DOXYGEN
307 
308 #ifdef UNIT_TEST_IEC60730_WATCHDOG_ENABLE
309 /**************************************************************************/
315 void sl_iec60730_watchdog_count_reset(void);
316 
317 /**************************************************************************/
323 void sl_iec60730_watchdog_count_set(uint8_t count);
324 
325 #endif // UNIT_TEST_IEC60730_WATCHDOG_ENABLE
326 
327 /**************************************************************************/
345 
349 #ifdef __cplusplus
350 }
351 #endif /* __cplusplus */
352 
353 #endif /* SL_IEC60730_WATCHDOG_H */
sl_iec60730.h
Library definitions.
SL_IEC60730_WATCHDOG_INVALID
@ SL_IEC60730_WATCHDOG_INVALID
Watchdog POST test not done.
Definition: sl_iec60730_watchdog.h:125
sl_iec60730_test_watchdog_t
sl_iec60730_test_watchdog_t
State of watchdog testing.
Definition: sl_iec60730_watchdog.h:124
sl_iec60730_watchdog_t
Watchdog component configuration structure.
Definition: sl_iec60730_watchdog.h:118
sl_iec60730_watchdog_t::SL_WDOG
WDOG_TypeDef *const SL_WDOG
Pointer to Watchdog instance.
Definition: sl_iec60730_watchdog.h:119
SL_IEC60730_WATCHDOG_TESTING
@ SL_IEC60730_WATCHDOG_TESTING
Watchdog POST testing in progress.
Definition: sl_iec60730_watchdog.h:126
sl_iec60730_watchdog_post
sl_iec60730_test_result_t sl_iec60730_watchdog_post(void)
sl_iec60730_watchdog_t::rst
uint32_t rst
Watchdog reset cause value.
Definition: sl_iec60730_watchdog.h:120
sl_iec60730_test_result_t
sl_iec60730_test_result_t
The result of a test.
Definition: sl_iec60730.h:72
SL_IEC60730_WATCHDOG_VALID
@ SL_IEC60730_WATCHDOG_VALID
Watchdog POST test complete, watchdog valid.
Definition: sl_iec60730_watchdog.h:127
iec60730_watchdog_state
volatile sl_iec60730_test_watchdog_t iec60730_watchdog_state
IEC60730_DATA_NO_CLEAR
#define IEC60730_DATA_NO_CLEAR
No clear at startup.
Definition: sl_iec60730_toolchain.h:67