The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_EFM32GG_STK3700/TOOLCHAIN_ARM_MICRO/em_wdog.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_EFM32GG_STK3700/TARGET_Silicon_Labs/TARGET_EFM32/emlib/inc/em_wdog.h@160:5571c4ff569f
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 156:ff21514d8981 | 1 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 2 | * @file em_wdog.h |
AnnaBridge | 156:ff21514d8981 | 3 | * @brief Watchdog (WDOG) peripheral API |
Anna Bridge |
160:5571c4ff569f | 4 | * @version 5.3.3 |
AnnaBridge | 156:ff21514d8981 | 5 | ******************************************************************************* |
Anna Bridge |
160:5571c4ff569f | 6 | * # License |
AnnaBridge | 156:ff21514d8981 | 7 | * <b>Copyright 2016 Silicon Laboratories, Inc. http://www.silabs.com</b> |
AnnaBridge | 156:ff21514d8981 | 8 | ******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 9 | * |
AnnaBridge | 156:ff21514d8981 | 10 | * Permission is granted to anyone to use this software for any purpose, |
AnnaBridge | 156:ff21514d8981 | 11 | * including commercial applications, and to alter it and redistribute it |
AnnaBridge | 156:ff21514d8981 | 12 | * freely, subject to the following restrictions: |
AnnaBridge | 156:ff21514d8981 | 13 | * |
AnnaBridge | 156:ff21514d8981 | 14 | * 1. The origin of this software must not be misrepresented; you must not |
AnnaBridge | 156:ff21514d8981 | 15 | * claim that you wrote the original software. |
AnnaBridge | 156:ff21514d8981 | 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
AnnaBridge | 156:ff21514d8981 | 17 | * misrepresented as being the original software. |
AnnaBridge | 156:ff21514d8981 | 18 | * 3. This notice may not be removed or altered from any source distribution. |
AnnaBridge | 156:ff21514d8981 | 19 | * |
AnnaBridge | 156:ff21514d8981 | 20 | * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no |
AnnaBridge | 156:ff21514d8981 | 21 | * obligation to support this Software. Silicon Labs is providing the |
AnnaBridge | 156:ff21514d8981 | 22 | * Software "AS IS", with no express or implied warranties of any kind, |
AnnaBridge | 156:ff21514d8981 | 23 | * including, but not limited to, any implied warranties of merchantability |
AnnaBridge | 156:ff21514d8981 | 24 | * or fitness for any particular purpose or warranties against infringement |
AnnaBridge | 156:ff21514d8981 | 25 | * of any proprietary rights of a third party. |
AnnaBridge | 156:ff21514d8981 | 26 | * |
AnnaBridge | 156:ff21514d8981 | 27 | * Silicon Labs will not be liable for any consequential, incidental, or |
AnnaBridge | 156:ff21514d8981 | 28 | * special damages, or any other relief, or for any claim by any third party, |
AnnaBridge | 156:ff21514d8981 | 29 | * arising from your use of this Software. |
AnnaBridge | 156:ff21514d8981 | 30 | * |
AnnaBridge | 156:ff21514d8981 | 31 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 32 | |
AnnaBridge | 156:ff21514d8981 | 33 | #ifndef EM_WDOG_H |
AnnaBridge | 156:ff21514d8981 | 34 | #define EM_WDOG_H |
AnnaBridge | 156:ff21514d8981 | 35 | |
AnnaBridge | 156:ff21514d8981 | 36 | #include "em_device.h" |
AnnaBridge | 156:ff21514d8981 | 37 | #if defined(WDOG_COUNT) && (WDOG_COUNT > 0) |
AnnaBridge | 156:ff21514d8981 | 38 | |
AnnaBridge | 156:ff21514d8981 | 39 | #include <stdbool.h> |
AnnaBridge | 156:ff21514d8981 | 40 | |
AnnaBridge | 156:ff21514d8981 | 41 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 42 | extern "C" { |
AnnaBridge | 156:ff21514d8981 | 43 | #endif |
AnnaBridge | 156:ff21514d8981 | 44 | |
AnnaBridge | 156:ff21514d8981 | 45 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 46 | * @addtogroup emlib |
AnnaBridge | 156:ff21514d8981 | 47 | * @{ |
AnnaBridge | 156:ff21514d8981 | 48 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 49 | |
AnnaBridge | 156:ff21514d8981 | 50 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 51 | * @addtogroup WDOG |
AnnaBridge | 156:ff21514d8981 | 52 | * @{ |
AnnaBridge | 156:ff21514d8981 | 53 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 54 | |
AnnaBridge | 156:ff21514d8981 | 55 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 56 | ******************************** ENUMS ************************************ |
AnnaBridge | 156:ff21514d8981 | 57 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 58 | |
AnnaBridge | 156:ff21514d8981 | 59 | /** Watchdog clock selection. */ |
Anna Bridge |
160:5571c4ff569f | 60 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 61 | wdogClkSelULFRCO = _WDOG_CTRL_CLKSEL_ULFRCO, /**< Ultra low frequency (1 kHz) clock */ |
AnnaBridge | 156:ff21514d8981 | 62 | wdogClkSelLFRCO = _WDOG_CTRL_CLKSEL_LFRCO, /**< Low frequency RC oscillator */ |
AnnaBridge | 156:ff21514d8981 | 63 | wdogClkSelLFXO = _WDOG_CTRL_CLKSEL_LFXO /**< Low frequency crystal oscillator */ |
AnnaBridge | 156:ff21514d8981 | 64 | } WDOG_ClkSel_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 65 | |
AnnaBridge | 156:ff21514d8981 | 66 | /** Watchdog period selection. */ |
Anna Bridge |
160:5571c4ff569f | 67 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 68 | wdogPeriod_9 = 0x0, /**< 9 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 69 | wdogPeriod_17 = 0x1, /**< 17 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 70 | wdogPeriod_33 = 0x2, /**< 33 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 71 | wdogPeriod_65 = 0x3, /**< 65 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 72 | wdogPeriod_129 = 0x4, /**< 129 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 73 | wdogPeriod_257 = 0x5, /**< 257 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 74 | wdogPeriod_513 = 0x6, /**< 513 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 75 | wdogPeriod_1k = 0x7, /**< 1025 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 76 | wdogPeriod_2k = 0x8, /**< 2049 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 77 | wdogPeriod_4k = 0x9, /**< 4097 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 78 | wdogPeriod_8k = 0xA, /**< 8193 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 79 | wdogPeriod_16k = 0xB, /**< 16385 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 80 | wdogPeriod_32k = 0xC, /**< 32769 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 81 | wdogPeriod_64k = 0xD, /**< 65537 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 82 | wdogPeriod_128k = 0xE, /**< 131073 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 83 | wdogPeriod_256k = 0xF /**< 262145 clock periods */ |
AnnaBridge | 156:ff21514d8981 | 84 | } WDOG_PeriodSel_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 85 | |
Anna Bridge |
160:5571c4ff569f | 86 | #if defined(_WDOG_CTRL_WARNSEL_MASK) |
AnnaBridge | 156:ff21514d8981 | 87 | /** Select watchdog warning timeout period as percentage of timeout. */ |
Anna Bridge |
160:5571c4ff569f | 88 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 89 | wdogWarnDisable = 0, |
AnnaBridge | 156:ff21514d8981 | 90 | wdogWarnTime25pct = 1, |
AnnaBridge | 156:ff21514d8981 | 91 | wdogWarnTime50pct = 2, |
AnnaBridge | 156:ff21514d8981 | 92 | wdogWarnTime75pct = 3, |
AnnaBridge | 156:ff21514d8981 | 93 | } WDOG_WarnSel_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 94 | #endif |
AnnaBridge | 156:ff21514d8981 | 95 | |
Anna Bridge |
160:5571c4ff569f | 96 | #if defined(_WDOG_CTRL_WINSEL_MASK) |
AnnaBridge | 156:ff21514d8981 | 97 | /** Select watchdog illegal window limit. */ |
Anna Bridge |
160:5571c4ff569f | 98 | typedef enum { |
AnnaBridge | 156:ff21514d8981 | 99 | wdogIllegalWindowDisable = 0, |
AnnaBridge | 156:ff21514d8981 | 100 | wdogIllegalWindowTime12_5pct = 1, |
AnnaBridge | 156:ff21514d8981 | 101 | wdogIllegalWindowTime25_0pct = 2, |
AnnaBridge | 156:ff21514d8981 | 102 | wdogIllegalWindowTime37_5pct = 3, |
AnnaBridge | 156:ff21514d8981 | 103 | wdogIllegalWindowTime50_0pct = 4, |
AnnaBridge | 156:ff21514d8981 | 104 | wdogIllegalWindowTime62_5pct = 5, |
AnnaBridge | 156:ff21514d8981 | 105 | wdogIllegalWindowTime75_0pct = 6, |
AnnaBridge | 156:ff21514d8981 | 106 | wdogIllegalWindowTime87_5pct = 7, |
AnnaBridge | 156:ff21514d8981 | 107 | } WDOG_WinSel_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 108 | #endif |
AnnaBridge | 156:ff21514d8981 | 109 | |
AnnaBridge | 156:ff21514d8981 | 110 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 111 | ******************************* STRUCTS *********************************** |
AnnaBridge | 156:ff21514d8981 | 112 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 113 | |
AnnaBridge | 156:ff21514d8981 | 114 | /** Watchdog initialization structure. */ |
Anna Bridge |
160:5571c4ff569f | 115 | typedef struct { |
AnnaBridge | 156:ff21514d8981 | 116 | /** Enable watchdog when init completed. */ |
AnnaBridge | 156:ff21514d8981 | 117 | bool enable; |
AnnaBridge | 156:ff21514d8981 | 118 | |
AnnaBridge | 156:ff21514d8981 | 119 | /** Counter shall keep running during debug halt. */ |
AnnaBridge | 156:ff21514d8981 | 120 | bool debugRun; |
AnnaBridge | 156:ff21514d8981 | 121 | |
AnnaBridge | 156:ff21514d8981 | 122 | /** Counter shall keep running when in EM2. */ |
AnnaBridge | 156:ff21514d8981 | 123 | bool em2Run; |
AnnaBridge | 156:ff21514d8981 | 124 | |
AnnaBridge | 156:ff21514d8981 | 125 | /** Counter shall keep running when in EM3. */ |
AnnaBridge | 156:ff21514d8981 | 126 | bool em3Run; |
AnnaBridge | 156:ff21514d8981 | 127 | |
AnnaBridge | 156:ff21514d8981 | 128 | /** Block EMU from entering EM4. */ |
AnnaBridge | 156:ff21514d8981 | 129 | bool em4Block; |
AnnaBridge | 156:ff21514d8981 | 130 | |
AnnaBridge | 156:ff21514d8981 | 131 | /** Block SW from disabling LFRCO/LFXO oscillators. */ |
AnnaBridge | 156:ff21514d8981 | 132 | bool swoscBlock; |
AnnaBridge | 156:ff21514d8981 | 133 | |
AnnaBridge | 156:ff21514d8981 | 134 | /** Block SW from modifying the configuration (a reset is needed to reconfigure). */ |
AnnaBridge | 156:ff21514d8981 | 135 | bool lock; |
AnnaBridge | 156:ff21514d8981 | 136 | |
AnnaBridge | 156:ff21514d8981 | 137 | /** Clock source to use for watchdog. */ |
AnnaBridge | 156:ff21514d8981 | 138 | WDOG_ClkSel_TypeDef clkSel; |
AnnaBridge | 156:ff21514d8981 | 139 | |
AnnaBridge | 156:ff21514d8981 | 140 | /** Watchdog timeout period. */ |
AnnaBridge | 156:ff21514d8981 | 141 | WDOG_PeriodSel_TypeDef perSel; |
AnnaBridge | 156:ff21514d8981 | 142 | |
Anna Bridge |
160:5571c4ff569f | 143 | #if defined(_WDOG_CTRL_WARNSEL_MASK) |
AnnaBridge | 156:ff21514d8981 | 144 | /** Select warning time as % of the watchdog timeout */ |
AnnaBridge | 156:ff21514d8981 | 145 | WDOG_WarnSel_TypeDef warnSel; |
AnnaBridge | 156:ff21514d8981 | 146 | #endif |
AnnaBridge | 156:ff21514d8981 | 147 | |
Anna Bridge |
160:5571c4ff569f | 148 | #if defined(_WDOG_CTRL_WINSEL_MASK) |
AnnaBridge | 156:ff21514d8981 | 149 | /** Select illegal window time as % of the watchdog timeout */ |
AnnaBridge | 156:ff21514d8981 | 150 | WDOG_WinSel_TypeDef winSel; |
AnnaBridge | 156:ff21514d8981 | 151 | #endif |
AnnaBridge | 156:ff21514d8981 | 152 | |
Anna Bridge |
160:5571c4ff569f | 153 | #if defined(_WDOG_CTRL_WDOGRSTDIS_MASK) |
AnnaBridge | 156:ff21514d8981 | 154 | /** Disable watchdog reset output if true */ |
AnnaBridge | 156:ff21514d8981 | 155 | bool resetDisable; |
AnnaBridge | 156:ff21514d8981 | 156 | #endif |
AnnaBridge | 156:ff21514d8981 | 157 | } WDOG_Init_TypeDef; |
AnnaBridge | 156:ff21514d8981 | 158 | |
AnnaBridge | 156:ff21514d8981 | 159 | /** Suggested default config for WDOG init structure. */ |
Anna Bridge |
160:5571c4ff569f | 160 | #if defined(_WDOG_CTRL_WARNSEL_MASK) \ |
Anna Bridge |
160:5571c4ff569f | 161 | && defined(_WDOG_CTRL_WDOGRSTDIS_MASK) \ |
Anna Bridge |
160:5571c4ff569f | 162 | && defined(_WDOG_CTRL_WINSEL_MASK) |
Anna Bridge |
160:5571c4ff569f | 163 | #define WDOG_INIT_DEFAULT \ |
Anna Bridge |
160:5571c4ff569f | 164 | { \ |
Anna Bridge |
160:5571c4ff569f | 165 | true, /* Start watchdog when init done */ \ |
Anna Bridge |
160:5571c4ff569f | 166 | false, /* WDOG not counting during debug halt */ \ |
Anna Bridge |
160:5571c4ff569f | 167 | false, /* WDOG not counting when in EM2 */ \ |
Anna Bridge |
160:5571c4ff569f | 168 | false, /* WDOG not counting when in EM3 */ \ |
Anna Bridge |
160:5571c4ff569f | 169 | false, /* EM4 can be entered */ \ |
Anna Bridge |
160:5571c4ff569f | 170 | false, /* Do not block disabling LFRCO/LFXO in CMU */ \ |
Anna Bridge |
160:5571c4ff569f | 171 | false, /* Do not lock WDOG configuration (if locked, |
Anna Bridge |
160:5571c4ff569f | 172 | reset needed to unlock) */ \ |
Anna Bridge |
160:5571c4ff569f | 173 | wdogClkSelULFRCO, /* Select 1kHZ WDOG oscillator */ \ |
Anna Bridge |
160:5571c4ff569f | 174 | wdogPeriod_256k, /* Set longest possible timeout period */ \ |
Anna Bridge |
160:5571c4ff569f | 175 | wdogWarnDisable, /* Disable warning interrupt */ \ |
Anna Bridge |
160:5571c4ff569f | 176 | wdogIllegalWindowDisable, /* Disable illegal window interrupt */ \ |
Anna Bridge |
160:5571c4ff569f | 177 | false /* Do not disable reset */ \ |
Anna Bridge |
160:5571c4ff569f | 178 | } |
AnnaBridge | 156:ff21514d8981 | 179 | #else |
Anna Bridge |
160:5571c4ff569f | 180 | #define WDOG_INIT_DEFAULT \ |
Anna Bridge |
160:5571c4ff569f | 181 | { \ |
Anna Bridge |
160:5571c4ff569f | 182 | true, /* Start watchdog when init done */ \ |
Anna Bridge |
160:5571c4ff569f | 183 | false, /* WDOG not counting during debug halt */ \ |
Anna Bridge |
160:5571c4ff569f | 184 | false, /* WDOG not counting when in EM2 */ \ |
Anna Bridge |
160:5571c4ff569f | 185 | false, /* WDOG not counting when in EM3 */ \ |
Anna Bridge |
160:5571c4ff569f | 186 | false, /* EM4 can be entered */ \ |
Anna Bridge |
160:5571c4ff569f | 187 | false, /* Do not block disabling LFRCO/LFXO in CMU */ \ |
Anna Bridge |
160:5571c4ff569f | 188 | false, /* Do not lock WDOG configuration (if locked, |
Anna Bridge |
160:5571c4ff569f | 189 | reset needed to unlock) */ \ |
Anna Bridge |
160:5571c4ff569f | 190 | wdogClkSelULFRCO, /* Select 1kHZ WDOG oscillator */ \ |
Anna Bridge |
160:5571c4ff569f | 191 | wdogPeriod_256k /* Set longest possible timeout period */ \ |
Anna Bridge |
160:5571c4ff569f | 192 | } |
AnnaBridge | 156:ff21514d8981 | 193 | #endif |
AnnaBridge | 156:ff21514d8981 | 194 | |
AnnaBridge | 156:ff21514d8981 | 195 | /******************************************************************************* |
AnnaBridge | 156:ff21514d8981 | 196 | ***************************** PROTOTYPES ********************************** |
AnnaBridge | 156:ff21514d8981 | 197 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 198 | |
AnnaBridge | 156:ff21514d8981 | 199 | void WDOGn_Enable(WDOG_TypeDef *wdog, bool enable); |
AnnaBridge | 156:ff21514d8981 | 200 | void WDOGn_Feed(WDOG_TypeDef *wdog); |
AnnaBridge | 156:ff21514d8981 | 201 | void WDOGn_Init(WDOG_TypeDef *wdog, const WDOG_Init_TypeDef *init); |
AnnaBridge | 156:ff21514d8981 | 202 | void WDOGn_Lock(WDOG_TypeDef *wdog); |
AnnaBridge | 156:ff21514d8981 | 203 | |
Anna Bridge |
160:5571c4ff569f | 204 | #if defined(_WDOG_IF_MASK) |
AnnaBridge | 156:ff21514d8981 | 205 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 206 | * @brief |
AnnaBridge | 156:ff21514d8981 | 207 | * Clear one or more pending WDOG interrupts. |
AnnaBridge | 156:ff21514d8981 | 208 | * |
AnnaBridge | 156:ff21514d8981 | 209 | * @param[in] wdog |
AnnaBridge | 156:ff21514d8981 | 210 | * Pointer to WDOG peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 211 | * |
AnnaBridge | 156:ff21514d8981 | 212 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 213 | * WDOG interrupt sources to clear. Use a set of interrupt flags OR-ed |
AnnaBridge | 156:ff21514d8981 | 214 | * together to clear multiple interrupt sources. |
AnnaBridge | 156:ff21514d8981 | 215 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 216 | __STATIC_INLINE void WDOGn_IntClear(WDOG_TypeDef *wdog, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 217 | { |
AnnaBridge | 156:ff21514d8981 | 218 | wdog->IFC = flags; |
AnnaBridge | 156:ff21514d8981 | 219 | } |
AnnaBridge | 156:ff21514d8981 | 220 | |
AnnaBridge | 156:ff21514d8981 | 221 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 222 | * @brief |
AnnaBridge | 156:ff21514d8981 | 223 | * Disable one or more WDOG interrupts. |
AnnaBridge | 156:ff21514d8981 | 224 | * |
AnnaBridge | 156:ff21514d8981 | 225 | * @param[in] wdog |
AnnaBridge | 156:ff21514d8981 | 226 | * Pointer to WDOG peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 227 | * |
AnnaBridge | 156:ff21514d8981 | 228 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 229 | * WDOG interrupt sources to disable. Use a set of interrupt flags OR-ed |
AnnaBridge | 156:ff21514d8981 | 230 | * together to disable multiple interrupt. |
AnnaBridge | 156:ff21514d8981 | 231 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 232 | __STATIC_INLINE void WDOGn_IntDisable(WDOG_TypeDef *wdog, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 233 | { |
AnnaBridge | 156:ff21514d8981 | 234 | wdog->IEN &= ~flags; |
AnnaBridge | 156:ff21514d8981 | 235 | } |
AnnaBridge | 156:ff21514d8981 | 236 | |
AnnaBridge | 156:ff21514d8981 | 237 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 238 | * @brief |
AnnaBridge | 156:ff21514d8981 | 239 | * Enable one or more WDOG interrupts. |
AnnaBridge | 156:ff21514d8981 | 240 | * |
AnnaBridge | 156:ff21514d8981 | 241 | * @note |
AnnaBridge | 156:ff21514d8981 | 242 | * Depending on the use, a pending interrupt may already be set prior to |
AnnaBridge | 156:ff21514d8981 | 243 | * enabling the interrupt. Consider using WDOG_IntClear() prior to enabling |
AnnaBridge | 156:ff21514d8981 | 244 | * if such a pending interrupt should be ignored. |
AnnaBridge | 156:ff21514d8981 | 245 | * |
AnnaBridge | 156:ff21514d8981 | 246 | * @param[in] wdog |
AnnaBridge | 156:ff21514d8981 | 247 | * Pointer to WDOG peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 248 | * |
AnnaBridge | 156:ff21514d8981 | 249 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 250 | * WDOG interrupt sources to enable. Use a set of interrupt flags OR-ed |
AnnaBridge | 156:ff21514d8981 | 251 | * together to set multiple interrupt. |
AnnaBridge | 156:ff21514d8981 | 252 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 253 | __STATIC_INLINE void WDOGn_IntEnable(WDOG_TypeDef *wdog, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 254 | { |
AnnaBridge | 156:ff21514d8981 | 255 | wdog->IEN |= flags; |
AnnaBridge | 156:ff21514d8981 | 256 | } |
AnnaBridge | 156:ff21514d8981 | 257 | |
AnnaBridge | 156:ff21514d8981 | 258 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 259 | * @brief |
AnnaBridge | 156:ff21514d8981 | 260 | * Get pending WDOG interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 261 | * |
AnnaBridge | 156:ff21514d8981 | 262 | * @note |
AnnaBridge | 156:ff21514d8981 | 263 | * The event bits are not cleared by the use of this function. |
AnnaBridge | 156:ff21514d8981 | 264 | * |
AnnaBridge | 156:ff21514d8981 | 265 | * @param[in] wdog |
AnnaBridge | 156:ff21514d8981 | 266 | * Pointer to WDOG peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 267 | * |
AnnaBridge | 156:ff21514d8981 | 268 | * @return |
AnnaBridge | 156:ff21514d8981 | 269 | * Pending WDOG interrupt sources. Returns a set of interrupt flags OR-ed |
AnnaBridge | 156:ff21514d8981 | 270 | * together for the interrupt sources set. |
AnnaBridge | 156:ff21514d8981 | 271 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 272 | __STATIC_INLINE uint32_t WDOGn_IntGet(WDOG_TypeDef *wdog) |
AnnaBridge | 156:ff21514d8981 | 273 | { |
AnnaBridge | 156:ff21514d8981 | 274 | return wdog->IF; |
AnnaBridge | 156:ff21514d8981 | 275 | } |
AnnaBridge | 156:ff21514d8981 | 276 | |
AnnaBridge | 156:ff21514d8981 | 277 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 278 | * @brief |
AnnaBridge | 156:ff21514d8981 | 279 | * Get enabled and pending WDOG interrupt flags. |
AnnaBridge | 156:ff21514d8981 | 280 | * |
AnnaBridge | 156:ff21514d8981 | 281 | * @details |
AnnaBridge | 156:ff21514d8981 | 282 | * Useful for handling more interrupt sources in the same interrupt handler. |
AnnaBridge | 156:ff21514d8981 | 283 | * |
AnnaBridge | 156:ff21514d8981 | 284 | * @param[in] wdog |
AnnaBridge | 156:ff21514d8981 | 285 | * Pointer to WDOG peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 286 | * |
AnnaBridge | 156:ff21514d8981 | 287 | * @return |
AnnaBridge | 156:ff21514d8981 | 288 | * Pending and enabled WDOG interrupt sources. Returns a set of interrupt |
AnnaBridge | 156:ff21514d8981 | 289 | * flags OR-ed together for the interrupt sources set. |
AnnaBridge | 156:ff21514d8981 | 290 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 291 | __STATIC_INLINE uint32_t WDOGn_IntGetEnabled(WDOG_TypeDef *wdog) |
AnnaBridge | 156:ff21514d8981 | 292 | { |
AnnaBridge | 156:ff21514d8981 | 293 | uint32_t tmp; |
AnnaBridge | 156:ff21514d8981 | 294 | |
AnnaBridge | 156:ff21514d8981 | 295 | tmp = wdog->IEN; |
AnnaBridge | 156:ff21514d8981 | 296 | |
AnnaBridge | 156:ff21514d8981 | 297 | /* Bitwise AND of pending and enabled interrupt flags. */ |
AnnaBridge | 156:ff21514d8981 | 298 | return wdog->IF & tmp; |
AnnaBridge | 156:ff21514d8981 | 299 | } |
AnnaBridge | 156:ff21514d8981 | 300 | |
AnnaBridge | 156:ff21514d8981 | 301 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 302 | * @brief |
AnnaBridge | 156:ff21514d8981 | 303 | * Set one or more pending WDOG interrupts from SW. |
AnnaBridge | 156:ff21514d8981 | 304 | * |
AnnaBridge | 156:ff21514d8981 | 305 | * @param[in] wdog |
AnnaBridge | 156:ff21514d8981 | 306 | * Pointer to WDOG peripheral register block. |
AnnaBridge | 156:ff21514d8981 | 307 | * |
AnnaBridge | 156:ff21514d8981 | 308 | * @param[in] flags |
AnnaBridge | 156:ff21514d8981 | 309 | * WDOG interrupt sources to set to pending. Use a set of interrupt flags |
AnnaBridge | 156:ff21514d8981 | 310 | * (WDOG_IFS_nnn). |
AnnaBridge | 156:ff21514d8981 | 311 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 312 | __STATIC_INLINE void WDOGn_IntSet(WDOG_TypeDef *wdog, uint32_t flags) |
AnnaBridge | 156:ff21514d8981 | 313 | { |
AnnaBridge | 156:ff21514d8981 | 314 | wdog->IFS = flags; |
AnnaBridge | 156:ff21514d8981 | 315 | } |
AnnaBridge | 156:ff21514d8981 | 316 | #endif |
AnnaBridge | 156:ff21514d8981 | 317 | |
AnnaBridge | 156:ff21514d8981 | 318 | /** Default WDOG instance for deprecated functions. */ |
AnnaBridge | 156:ff21514d8981 | 319 | #if !defined(DEFAULT_WDOG) |
AnnaBridge | 156:ff21514d8981 | 320 | #if defined(WDOG) |
AnnaBridge | 156:ff21514d8981 | 321 | #define DEFAULT_WDOG WDOG |
AnnaBridge | 156:ff21514d8981 | 322 | #elif defined(WDOG0) |
AnnaBridge | 156:ff21514d8981 | 323 | #define DEFAULT_WDOG WDOG0 |
AnnaBridge | 156:ff21514d8981 | 324 | #endif |
AnnaBridge | 156:ff21514d8981 | 325 | #endif |
AnnaBridge | 156:ff21514d8981 | 326 | |
AnnaBridge | 156:ff21514d8981 | 327 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 328 | * @brief |
AnnaBridge | 156:ff21514d8981 | 329 | * Enable/disable the watchdog timer. |
AnnaBridge | 156:ff21514d8981 | 330 | * |
AnnaBridge | 156:ff21514d8981 | 331 | * @deprecated |
AnnaBridge | 156:ff21514d8981 | 332 | * Deprecated function. New code should use @ref WDOGn_Enable(). |
AnnaBridge | 156:ff21514d8981 | 333 | * This function uses @ref DEFAULT_WDOG. |
AnnaBridge | 156:ff21514d8981 | 334 | * |
AnnaBridge | 156:ff21514d8981 | 335 | * @param[in] enable |
AnnaBridge | 156:ff21514d8981 | 336 | * true to enable watchdog, false to disable. Watchdog cannot be disabled if |
AnnaBridge | 156:ff21514d8981 | 337 | * watchdog has been locked. |
AnnaBridge | 156:ff21514d8981 | 338 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 339 | __STATIC_INLINE void WDOG_Enable(bool enable) |
AnnaBridge | 156:ff21514d8981 | 340 | { |
AnnaBridge | 156:ff21514d8981 | 341 | WDOGn_Enable(DEFAULT_WDOG, enable); |
AnnaBridge | 156:ff21514d8981 | 342 | } |
AnnaBridge | 156:ff21514d8981 | 343 | |
AnnaBridge | 156:ff21514d8981 | 344 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 345 | * @brief |
AnnaBridge | 156:ff21514d8981 | 346 | * Feed the watchdog. |
AnnaBridge | 156:ff21514d8981 | 347 | * |
AnnaBridge | 156:ff21514d8981 | 348 | * @deprecated |
AnnaBridge | 156:ff21514d8981 | 349 | * Deprecated function. New code should use @ref WDOGn_Feed(). |
AnnaBridge | 156:ff21514d8981 | 350 | * This function uses @ref DEFAULT_WDOG. |
AnnaBridge | 156:ff21514d8981 | 351 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 352 | __STATIC_INLINE void WDOG_Feed(void) |
AnnaBridge | 156:ff21514d8981 | 353 | { |
AnnaBridge | 156:ff21514d8981 | 354 | WDOGn_Feed(DEFAULT_WDOG); |
AnnaBridge | 156:ff21514d8981 | 355 | } |
AnnaBridge | 156:ff21514d8981 | 356 | |
AnnaBridge | 156:ff21514d8981 | 357 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 358 | * @brief |
AnnaBridge | 156:ff21514d8981 | 359 | * Initialize watchdog (assuming the watchdog configuration has not been |
AnnaBridge | 156:ff21514d8981 | 360 | * locked). |
AnnaBridge | 156:ff21514d8981 | 361 | * |
AnnaBridge | 156:ff21514d8981 | 362 | * @deprecated |
AnnaBridge | 156:ff21514d8981 | 363 | * Deprecated function. New code should use Use @ref WDOGn_Init(). |
AnnaBridge | 156:ff21514d8981 | 364 | * This function uses @ref DEFAULT_WDOG. |
AnnaBridge | 156:ff21514d8981 | 365 | * |
AnnaBridge | 156:ff21514d8981 | 366 | * @param[in] init |
AnnaBridge | 156:ff21514d8981 | 367 | * Structure holding watchdog configuration. A default setting |
AnnaBridge | 156:ff21514d8981 | 368 | * #WDOG_INIT_DEFAULT is available for init. |
AnnaBridge | 156:ff21514d8981 | 369 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 370 | __STATIC_INLINE void WDOG_Init(const WDOG_Init_TypeDef *init) |
AnnaBridge | 156:ff21514d8981 | 371 | { |
AnnaBridge | 156:ff21514d8981 | 372 | WDOGn_Init(DEFAULT_WDOG, init); |
AnnaBridge | 156:ff21514d8981 | 373 | } |
AnnaBridge | 156:ff21514d8981 | 374 | |
AnnaBridge | 156:ff21514d8981 | 375 | /***************************************************************************//** |
AnnaBridge | 156:ff21514d8981 | 376 | * @brief |
AnnaBridge | 156:ff21514d8981 | 377 | * Lock the watchdog configuration. |
AnnaBridge | 156:ff21514d8981 | 378 | * |
AnnaBridge | 156:ff21514d8981 | 379 | * @deprecated |
AnnaBridge | 156:ff21514d8981 | 380 | * Deprecated function. New code should use @ref WDOGn_Lock(). |
AnnaBridge | 156:ff21514d8981 | 381 | * This function uses @ref DEFAULT_WDOG. |
AnnaBridge | 156:ff21514d8981 | 382 | ******************************************************************************/ |
AnnaBridge | 156:ff21514d8981 | 383 | __STATIC_INLINE void WDOG_Lock(void) |
AnnaBridge | 156:ff21514d8981 | 384 | { |
AnnaBridge | 156:ff21514d8981 | 385 | WDOGn_Lock(DEFAULT_WDOG); |
AnnaBridge | 156:ff21514d8981 | 386 | } |
AnnaBridge | 156:ff21514d8981 | 387 | |
AnnaBridge | 156:ff21514d8981 | 388 | /** @} (end addtogroup WDOG) */ |
AnnaBridge | 156:ff21514d8981 | 389 | /** @} (end addtogroup emlib) */ |
AnnaBridge | 156:ff21514d8981 | 390 | |
AnnaBridge | 156:ff21514d8981 | 391 | #ifdef __cplusplus |
AnnaBridge | 156:ff21514d8981 | 392 | } |
AnnaBridge | 156:ff21514d8981 | 393 | #endif |
AnnaBridge | 156:ff21514d8981 | 394 | |
AnnaBridge | 156:ff21514d8981 | 395 | #endif /* defined(WDOG_COUNT) && (WDOG_COUNT > 0) */ |
AnnaBridge | 156:ff21514d8981 | 396 | #endif /* EM_WDOG_H */ |