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.

Committer:
AnnaBridge
Date:
Wed Feb 20 20:53:29 2019 +0000
Revision:
172:65be27845400
Parent:
171:3a7713b1edbc
mbed library release version 165

Who changed what in which revision?

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