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