1 /***************************************************************************//**
\r
3 * @brief Watchdog (WDOG) peripheral API
\r
5 *******************************************************************************
\r
7 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
\r
8 *******************************************************************************
\r
10 * Permission is granted to anyone to use this software for any purpose,
\r
11 * including commercial applications, and to alter it and redistribute it
\r
12 * freely, subject to the following restrictions:
\r
14 * 1. The origin of this software must not be misrepresented; you must not
\r
15 * claim that you wrote the original software.
\r
16 * 2. Altered source versions must be plainly marked as such, and must not be
\r
17 * misrepresented as being the original software.
\r
18 * 3. This notice may not be removed or altered from any source distribution.
\r
20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
\r
21 * obligation to support this Software. Silicon Labs is providing the
\r
22 * Software "AS IS", with no express or implied warranties of any kind,
\r
23 * including, but not limited to, any implied warranties of merchantability
\r
24 * or fitness for any particular purpose or warranties against infringement
\r
25 * of any proprietary rights of a third party.
\r
27 * Silicon Labs will not be liable for any consequential, incidental, or
\r
28 * special damages, or any other relief, or for any claim by any third party,
\r
29 * arising from your use of this Software.
\r
31 ******************************************************************************/
\r
34 #ifndef __SILICON_LABS_EM_WDOG_H__
\r
35 #define __SILICON_LABS_EM_WDOG_H__
\r
37 #include "em_device.h"
\r
38 #if defined(WDOG_COUNT) && (WDOG_COUNT > 0)
\r
40 #include <stdbool.h>
\r
46 /***************************************************************************//**
\r
47 * @addtogroup EM_Library
\r
49 ******************************************************************************/
\r
51 /***************************************************************************//**
\r
54 ******************************************************************************/
\r
56 /*******************************************************************************
\r
57 ******************************** ENUMS ************************************
\r
58 ******************************************************************************/
\r
60 /** Watchdog clock selection. */
\r
63 wdogClkSelULFRCO = _WDOG_CTRL_CLKSEL_ULFRCO, /**< Ultra low frequency (1 kHz) clock */
\r
64 wdogClkSelLFRCO = _WDOG_CTRL_CLKSEL_LFRCO, /**< Low frequency RC oscillator */
\r
65 wdogClkSelLFXO = _WDOG_CTRL_CLKSEL_LFXO /**< Low frequency crystal oscillator */
\r
66 } WDOG_ClkSel_TypeDef;
\r
68 /** Watchdog period selection. */
\r
71 wdogPeriod_9 = 0x0, /**< 9 clock periods */
\r
72 wdogPeriod_17 = 0x1, /**< 17 clock periods */
\r
73 wdogPeriod_33 = 0x2, /**< 33 clock periods */
\r
74 wdogPeriod_65 = 0x3, /**< 65 clock periods */
\r
75 wdogPeriod_129 = 0x4, /**< 129 clock periods */
\r
76 wdogPeriod_257 = 0x5, /**< 257 clock periods */
\r
77 wdogPeriod_513 = 0x6, /**< 513 clock periods */
\r
78 wdogPeriod_1k = 0x7, /**< 1025 clock periods */
\r
79 wdogPeriod_2k = 0x8, /**< 2049 clock periods */
\r
80 wdogPeriod_4k = 0x9, /**< 4097 clock periods */
\r
81 wdogPeriod_8k = 0xA, /**< 8193 clock periods */
\r
82 wdogPeriod_16k = 0xB, /**< 16385 clock periods */
\r
83 wdogPeriod_32k = 0xC, /**< 32769 clock periods */
\r
84 wdogPeriod_64k = 0xD, /**< 65537 clock periods */
\r
85 wdogPeriod_128k = 0xE, /**< 131073 clock periods */
\r
86 wdogPeriod_256k = 0xF /**< 262145 clock periods */
\r
87 } WDOG_PeriodSel_TypeDef;
\r
89 /*******************************************************************************
\r
90 ******************************* STRUCTS ***********************************
\r
91 ******************************************************************************/
\r
93 /** Watchdog initialization structure. */
\r
96 /** Enable watchdog when init completed. */
\r
99 /** Counter shall keep running during debug halt. */
\r
102 /** Counter shall keep running when in EM2. */
\r
105 /** Counter shall keep running when in EM3. */
\r
108 /** Block EMU from entering EM4. */
\r
111 /** Block SW from disabling LFRCO/LFXO oscillators. */
\r
114 /** Block SW from modifying the configuration (a reset is needed to reconfigure). */
\r
117 /** Clock source to use for watchdog. */
\r
118 WDOG_ClkSel_TypeDef clkSel;
\r
120 /** Watchdog timeout period. */
\r
121 WDOG_PeriodSel_TypeDef perSel;
\r
122 } WDOG_Init_TypeDef;
\r
124 /** Suggested default config for WDOG init structure. */
\r
125 #define WDOG_INIT_DEFAULT \
\r
127 true, /* Start watchdog when init done */ \
\r
128 false, /* WDOG not counting during debug halt */ \
\r
129 false, /* WDOG not counting when in EM2 */ \
\r
130 false, /* WDOG not counting when in EM3 */ \
\r
131 false, /* EM4 can be entered */ \
\r
132 false, /* Do not block disabling LFRCO/LFXO in CMU */ \
\r
133 false, /* Do not lock WDOG configuration (if locked, reset needed to unlock) */ \
\r
134 wdogClkSelULFRCO, /* Select 1kHZ WDOG oscillator */ \
\r
135 wdogPeriod_256k /* Set longest possible timeout period */ \
\r
139 /*******************************************************************************
\r
140 ***************************** PROTOTYPES **********************************
\r
141 ******************************************************************************/
\r
143 void WDOG_Enable(bool enable);
\r
144 void WDOG_Feed(void);
\r
145 void WDOG_Init(const WDOG_Init_TypeDef *init);
\r
146 void WDOG_Lock(void);
\r
148 /** @} (end addtogroup WDOG) */
\r
149 /** @} (end addtogroup EM_Library) */
\r
155 #endif /* defined(WDOG_COUNT) && (WDOG_COUNT > 0) */
\r
156 #endif /* __SILICON_LABS_EM_WDOG_H__ */
\r