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_SDT32625B/TOOLCHAIN_IAR/wdt2.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
- Parent:
- TARGET_MAX32625PICO_NO_BOOT/TARGET_Maxim/TARGET_MAX32625/mxc/wdt2.h@169:a7c7b631e539
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Anna Bridge |
169:a7c7b631e539 | 1 | /******************************************************************************* |
Anna Bridge |
169:a7c7b631e539 | 2 | * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. |
Anna Bridge |
169:a7c7b631e539 | 3 | * |
Anna Bridge |
169:a7c7b631e539 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a |
Anna Bridge |
169:a7c7b631e539 | 5 | * copy of this software and associated documentation files (the "Software"), |
Anna Bridge |
169:a7c7b631e539 | 6 | * to deal in the Software without restriction, including without limitation |
Anna Bridge |
169:a7c7b631e539 | 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
Anna Bridge |
169:a7c7b631e539 | 8 | * and/or sell copies of the Software, and to permit persons to whom the |
Anna Bridge |
169:a7c7b631e539 | 9 | * Software is furnished to do so, subject to the following conditions: |
Anna Bridge |
169:a7c7b631e539 | 10 | * |
Anna Bridge |
169:a7c7b631e539 | 11 | * The above copyright notice and this permission notice shall be included |
Anna Bridge |
169:a7c7b631e539 | 12 | * in all copies or substantial portions of the Software. |
Anna Bridge |
169:a7c7b631e539 | 13 | * |
Anna Bridge |
169:a7c7b631e539 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
Anna Bridge |
169:a7c7b631e539 | 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
Anna Bridge |
169:a7c7b631e539 | 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
Anna Bridge |
169:a7c7b631e539 | 17 | * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
Anna Bridge |
169:a7c7b631e539 | 18 | * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
Anna Bridge |
169:a7c7b631e539 | 19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
Anna Bridge |
169:a7c7b631e539 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
Anna Bridge |
169:a7c7b631e539 | 21 | * |
Anna Bridge |
169:a7c7b631e539 | 22 | * Except as contained in this notice, the name of Maxim Integrated |
Anna Bridge |
169:a7c7b631e539 | 23 | * Products, Inc. shall not be used except as stated in the Maxim Integrated |
Anna Bridge |
169:a7c7b631e539 | 24 | * Products, Inc. Branding Policy. |
Anna Bridge |
169:a7c7b631e539 | 25 | * |
Anna Bridge |
169:a7c7b631e539 | 26 | * The mere transfer of this software does not imply any licenses |
Anna Bridge |
169:a7c7b631e539 | 27 | * of trade secrets, proprietary technology, copyrights, patents, |
Anna Bridge |
169:a7c7b631e539 | 28 | * trademarks, maskwork rights, or any other form of intellectual |
Anna Bridge |
169:a7c7b631e539 | 29 | * property whatsoever. Maxim Integrated Products, Inc. retains all |
Anna Bridge |
169:a7c7b631e539 | 30 | * ownership rights. |
Anna Bridge |
169:a7c7b631e539 | 31 | * |
Anna Bridge |
169:a7c7b631e539 | 32 | * $Date: 2016-03-21 15:44:11 -0500 (Mon, 21 Mar 2016) $ |
Anna Bridge |
169:a7c7b631e539 | 33 | * $Revision: 22024 $ |
Anna Bridge |
169:a7c7b631e539 | 34 | * |
Anna Bridge |
169:a7c7b631e539 | 35 | ******************************************************************************/ |
Anna Bridge |
169:a7c7b631e539 | 36 | |
Anna Bridge |
169:a7c7b631e539 | 37 | /** |
Anna Bridge |
169:a7c7b631e539 | 38 | * @file wdt2.h |
Anna Bridge |
169:a7c7b631e539 | 39 | * @addtogroup wdt WDT |
Anna Bridge |
169:a7c7b631e539 | 40 | * @{ |
Anna Bridge |
169:a7c7b631e539 | 41 | * @brief This is the high level API for the watchdog timer interface module |
Anna Bridge |
169:a7c7b631e539 | 42 | * |
Anna Bridge |
169:a7c7b631e539 | 43 | */ |
Anna Bridge |
169:a7c7b631e539 | 44 | |
Anna Bridge |
169:a7c7b631e539 | 45 | #ifndef _WDT2_H |
Anna Bridge |
169:a7c7b631e539 | 46 | #define _WDT2_H |
Anna Bridge |
169:a7c7b631e539 | 47 | |
Anna Bridge |
169:a7c7b631e539 | 48 | #include "mxc_config.h" |
Anna Bridge |
169:a7c7b631e539 | 49 | #include "wdt2_regs.h" |
Anna Bridge |
169:a7c7b631e539 | 50 | #include "mxc_assert.h" |
Anna Bridge |
169:a7c7b631e539 | 51 | |
Anna Bridge |
169:a7c7b631e539 | 52 | #ifdef __cplusplus |
Anna Bridge |
169:a7c7b631e539 | 53 | extern "C" { |
Anna Bridge |
169:a7c7b631e539 | 54 | #endif |
Anna Bridge |
169:a7c7b631e539 | 55 | |
Anna Bridge |
169:a7c7b631e539 | 56 | #define WDT2_FLAGS_CLEAR_ALL (MXC_F_WDT2_FLAGS_TIMEOUT| \ |
Anna Bridge |
169:a7c7b631e539 | 57 | MXC_F_WDT2_FLAGS_RESET_OUT) |
Anna Bridge |
169:a7c7b631e539 | 58 | /** |
Anna Bridge |
169:a7c7b631e539 | 59 | * @enum wdt2_period_t |
Anna Bridge |
169:a7c7b631e539 | 60 | * @brief WatchDog Timer 2 Period Settings |
Anna Bridge |
169:a7c7b631e539 | 61 | */ |
Anna Bridge |
169:a7c7b631e539 | 62 | typedef enum { |
Anna Bridge |
169:a7c7b631e539 | 63 | WDT2_PERIOD_2_25_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_25_NANO_CLKS, /**< 2^25 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 64 | WDT2_PERIOD_2_24_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_24_NANO_CLKS, /**< 2^24 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 65 | WDT2_PERIOD_2_23_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_23_NANO_CLKS, /**< 2^23 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 66 | WDT2_PERIOD_2_22_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_22_NANO_CLKS, /**< 2^22 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 67 | WDT2_PERIOD_2_21_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_21_NANO_CLKS, /**< 2^21 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 68 | WDT2_PERIOD_2_20_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_20_NANO_CLKS, /**< 2^20 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 69 | WDT2_PERIOD_2_19_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_19_NANO_CLKS, /**< 2^19 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 70 | WDT2_PERIOD_2_18_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_18_NANO_CLKS, /**< 2^18 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 71 | WDT2_PERIOD_2_17_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_17_NANO_CLKS, /**< 2^17 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 72 | WDT2_PERIOD_2_16_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_16_NANO_CLKS, /**< 2^16 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 73 | WDT2_PERIOD_2_15_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_15_NANO_CLKS, /**< 2^15 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 74 | WDT2_PERIOD_2_14_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_14_NANO_CLKS, /**< 2^14 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 75 | WDT2_PERIOD_2_13_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_13_NANO_CLKS, /**< 2^13 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 76 | WDT2_PERIOD_2_12_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_12_NANO_CLKS, /**< 2^12 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 77 | WDT2_PERIOD_2_11_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_11_NANO_CLKS, /**< 2^11 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 78 | WDT2_PERIOD_2_10_CLKS = MXC_V_WDT2_CTRL_INT_PERIOD_2_10_NANO_CLKS, /**< 2^10 WDT clocks. */ |
Anna Bridge |
169:a7c7b631e539 | 79 | WDT2_PERIOD_MAX /**< Maximum Period is Max - 1 */ |
Anna Bridge |
169:a7c7b631e539 | 80 | } wdt2_period_t; |
Anna Bridge |
169:a7c7b631e539 | 81 | |
Anna Bridge |
169:a7c7b631e539 | 82 | |
Anna Bridge |
169:a7c7b631e539 | 83 | |
Anna Bridge |
169:a7c7b631e539 | 84 | /** |
Anna Bridge |
169:a7c7b631e539 | 85 | * @brief Initializes the NanoRing for the watchdog clock and sets watchdog in a known disabled state |
Anna Bridge |
169:a7c7b631e539 | 86 | * @param runInSleep If non-zero, the WDT2 operates in Sleep Modes for the device, |
Anna Bridge |
169:a7c7b631e539 | 87 | * 0 disables the WDT2 during Sleep Modes. |
Anna Bridge |
169:a7c7b631e539 | 88 | * @param unlock_key The WDT2 unlock key value, use MXC_V_WDT2_UNLOCK_KEY |
Anna Bridge |
169:a7c7b631e539 | 89 | * |
Anna Bridge |
169:a7c7b631e539 | 90 | * @retval E_NO_ERROR Watchdog Timer initialized as requested |
Anna Bridge |
169:a7c7b631e539 | 91 | * @retval E_BAD_STATE Invalid unlock_key, WDT failed to unlock. |
Anna Bridge |
169:a7c7b631e539 | 92 | |
Anna Bridge |
169:a7c7b631e539 | 93 | */ |
Anna Bridge |
169:a7c7b631e539 | 94 | int WDT2_Init(uint8_t runInSleep, uint8_t unlock_key); |
Anna Bridge |
169:a7c7b631e539 | 95 | |
Anna Bridge |
169:a7c7b631e539 | 96 | /** |
Anna Bridge |
169:a7c7b631e539 | 97 | * @brief Configures and enables the wake-up timeout for the watchdog specified. |
Anna Bridge |
169:a7c7b631e539 | 98 | * |
Anna Bridge |
169:a7c7b631e539 | 99 | * @param int_period Interrupt period. |
Anna Bridge |
169:a7c7b631e539 | 100 | * @param unlock_key Key to unlock watchdog. |
Anna Bridge |
169:a7c7b631e539 | 101 | * |
Anna Bridge |
169:a7c7b631e539 | 102 | * @retval E_NO_ERROR WDT2 Interrupt period enabled with the int_period time. |
Anna Bridge |
169:a7c7b631e539 | 103 | * @retval E_INVALID Requested Period is greater than the maximum supported |
Anna Bridge |
169:a7c7b631e539 | 104 | * @retval E_BAD_STATE Invalid unlock_key, WDT failed to unlock. |
Anna Bridge |
169:a7c7b631e539 | 105 | * |
Anna Bridge |
169:a7c7b631e539 | 106 | */ |
Anna Bridge |
169:a7c7b631e539 | 107 | int WDT2_EnableWakeUp(wdt2_period_t int_period, uint8_t unlock_key); |
Anna Bridge |
169:a7c7b631e539 | 108 | |
Anna Bridge |
169:a7c7b631e539 | 109 | /** |
Anna Bridge |
169:a7c7b631e539 | 110 | * @brief Disables the interrupt timeout for the watchdog specified. |
Anna Bridge |
169:a7c7b631e539 | 111 | * |
Anna Bridge |
169:a7c7b631e539 | 112 | * @param unlock_key Key to unlock watchdog. |
Anna Bridge |
169:a7c7b631e539 | 113 | * |
Anna Bridge |
169:a7c7b631e539 | 114 | * @retval E_NO_ERROR Wakeup disabled. |
Anna Bridge |
169:a7c7b631e539 | 115 | * @retval E_BAD_STATE Invalid unlock_key, WDT failed to unlock. |
Anna Bridge |
169:a7c7b631e539 | 116 | */ |
Anna Bridge |
169:a7c7b631e539 | 117 | int WDT2_DisableWakeUp(uint8_t unlock_key); |
Anna Bridge |
169:a7c7b631e539 | 118 | |
Anna Bridge |
169:a7c7b631e539 | 119 | /** |
Anna Bridge |
169:a7c7b631e539 | 120 | * @brief Configures and enables the reset timeout for the watchdog specified. |
Anna Bridge |
169:a7c7b631e539 | 121 | * |
Anna Bridge |
169:a7c7b631e539 | 122 | * @param rst_period Reset period. |
Anna Bridge |
169:a7c7b631e539 | 123 | * @param unlock_key Key to unlock watchdog. |
Anna Bridge |
169:a7c7b631e539 | 124 | * |
Anna Bridge |
169:a7c7b631e539 | 125 | * @retval E_NO_ERROR Reset timeout enabled with the rst_period time. |
Anna Bridge |
169:a7c7b631e539 | 126 | * @retval E_INVALID Requested Period is greater than the maximum supported |
Anna Bridge |
169:a7c7b631e539 | 127 | * @retval E_BAD_STATE Invalid unlock_key, WDT failed to unlock. |
Anna Bridge |
169:a7c7b631e539 | 128 | */ |
Anna Bridge |
169:a7c7b631e539 | 129 | int WDT2_EnableReset(wdt2_period_t rst_period, uint8_t unlock_key); |
Anna Bridge |
169:a7c7b631e539 | 130 | |
Anna Bridge |
169:a7c7b631e539 | 131 | /** |
Anna Bridge |
169:a7c7b631e539 | 132 | * @brief Disables the reset timeout for the watchdog specified. |
Anna Bridge |
169:a7c7b631e539 | 133 | * |
Anna Bridge |
169:a7c7b631e539 | 134 | * @param unlock_key Key to unlock watchdog. |
Anna Bridge |
169:a7c7b631e539 | 135 | * |
Anna Bridge |
169:a7c7b631e539 | 136 | * @retval E_NO_ERROR Reset disabled. |
Anna Bridge |
169:a7c7b631e539 | 137 | * @retval E_BAD_STATE Invalid unlock_key, WDT failed to unlock. |
Anna Bridge |
169:a7c7b631e539 | 138 | */ |
Anna Bridge |
169:a7c7b631e539 | 139 | int WDT2_DisableReset(uint8_t unlock_key); |
Anna Bridge |
169:a7c7b631e539 | 140 | |
Anna Bridge |
169:a7c7b631e539 | 141 | /** |
Anna Bridge |
169:a7c7b631e539 | 142 | * @brief Gets the watchdog interrupt flags |
Anna Bridge |
169:a7c7b631e539 | 143 | * |
Anna Bridge |
169:a7c7b631e539 | 144 | * @retval 0 = flags not set, non-zero = flag is set |
Anna Bridge |
169:a7c7b631e539 | 145 | */ |
Anna Bridge |
169:a7c7b631e539 | 146 | __STATIC_INLINE uint32_t WDT2_GetFlags(void) |
Anna Bridge |
169:a7c7b631e539 | 147 | { |
Anna Bridge |
169:a7c7b631e539 | 148 | return (MXC_WDT2->flags); |
Anna Bridge |
169:a7c7b631e539 | 149 | } |
Anna Bridge |
169:a7c7b631e539 | 150 | |
Anna Bridge |
169:a7c7b631e539 | 151 | /** |
Anna Bridge |
169:a7c7b631e539 | 152 | * @brief Clears the watchdog interrupt flags based on the mask |
Anna Bridge |
169:a7c7b631e539 | 153 | * |
Anna Bridge |
169:a7c7b631e539 | 154 | * @param mask bits to clear |
Anna Bridge |
169:a7c7b631e539 | 155 | * |
Anna Bridge |
169:a7c7b631e539 | 156 | */ |
Anna Bridge |
169:a7c7b631e539 | 157 | __STATIC_INLINE void WDT2_ClearFlags(uint32_t mask) |
Anna Bridge |
169:a7c7b631e539 | 158 | { |
Anna Bridge |
169:a7c7b631e539 | 159 | MXC_WDT2->flags = mask; |
Anna Bridge |
169:a7c7b631e539 | 160 | } |
Anna Bridge |
169:a7c7b631e539 | 161 | |
Anna Bridge |
169:a7c7b631e539 | 162 | /** |
Anna Bridge |
169:a7c7b631e539 | 163 | * @brief Starts the watchdog specified. |
Anna Bridge |
169:a7c7b631e539 | 164 | * |
Anna Bridge |
169:a7c7b631e539 | 165 | * @param unlock_key Key to unlock watchdog. |
Anna Bridge |
169:a7c7b631e539 | 166 | * |
Anna Bridge |
169:a7c7b631e539 | 167 | * @retval E_NO_ERROR if everything is successful, error if unsuccessful. |
Anna Bridge |
169:a7c7b631e539 | 168 | * @retval E_BAD_STATE Invalid unlock_key, WDT failed to unlock. |
Anna Bridge |
169:a7c7b631e539 | 169 | */ |
Anna Bridge |
169:a7c7b631e539 | 170 | int WDT2_Start(uint8_t unlock_key); |
Anna Bridge |
169:a7c7b631e539 | 171 | |
Anna Bridge |
169:a7c7b631e539 | 172 | /** |
Anna Bridge |
169:a7c7b631e539 | 173 | * @brief Feeds the watchdog specified. |
Anna Bridge |
169:a7c7b631e539 | 174 | * |
Anna Bridge |
169:a7c7b631e539 | 175 | * @retval E_NO_ERROR if everything is successful, error if unsuccessful. |
Anna Bridge |
169:a7c7b631e539 | 176 | */ |
Anna Bridge |
169:a7c7b631e539 | 177 | void WDT2_Reset(void); |
Anna Bridge |
169:a7c7b631e539 | 178 | |
Anna Bridge |
169:a7c7b631e539 | 179 | /** |
Anna Bridge |
169:a7c7b631e539 | 180 | * @brief Stops the WatchDog Timer 2. |
Anna Bridge |
169:a7c7b631e539 | 181 | * |
Anna Bridge |
169:a7c7b631e539 | 182 | * @param unlock_key Key to unlock watchdog. |
Anna Bridge |
169:a7c7b631e539 | 183 | * |
Anna Bridge |
169:a7c7b631e539 | 184 | * @retval E_NO_ERROR if everything is successful, error if unsuccessful. |
Anna Bridge |
169:a7c7b631e539 | 185 | * @retval E_BAD_STATE Invalid unlock_key, WDT failed to unlock. |
Anna Bridge |
169:a7c7b631e539 | 186 | */ |
Anna Bridge |
169:a7c7b631e539 | 187 | int WDT2_Stop(uint8_t unlock_key); |
Anna Bridge |
169:a7c7b631e539 | 188 | |
Anna Bridge |
169:a7c7b631e539 | 189 | /** |
Anna Bridge |
169:a7c7b631e539 | 190 | * @brief Determines if the watchdog is running |
Anna Bridge |
169:a7c7b631e539 | 191 | * |
Anna Bridge |
169:a7c7b631e539 | 192 | * @retval 0 = watchdog timer is off, non-zero = watchdog timer is on |
Anna Bridge |
169:a7c7b631e539 | 193 | */ |
Anna Bridge |
169:a7c7b631e539 | 194 | __STATIC_INLINE int WDT2_IsActive(void) |
Anna Bridge |
169:a7c7b631e539 | 195 | { |
Anna Bridge |
169:a7c7b631e539 | 196 | return (!!(MXC_WDT2->ctrl & MXC_F_WDT2_CTRL_EN_TIMER)); |
Anna Bridge |
169:a7c7b631e539 | 197 | } |
Anna Bridge |
169:a7c7b631e539 | 198 | |
Anna Bridge |
169:a7c7b631e539 | 199 | /** |
Anna Bridge |
169:a7c7b631e539 | 200 | * @} |
Anna Bridge |
169:a7c7b631e539 | 201 | */ |
Anna Bridge |
169:a7c7b631e539 | 202 | |
Anna Bridge |
169:a7c7b631e539 | 203 | #ifdef __cplusplus |
Anna Bridge |
169:a7c7b631e539 | 204 | } |
Anna Bridge |
169:a7c7b631e539 | 205 | #endif |
Anna Bridge |
169:a7c7b631e539 | 206 | |
Anna Bridge |
169:a7c7b631e539 | 207 | #endif /* _WDT_H */ |