t

Fork of mbed-dev by mbed official

Committer:
<>
Date:
Thu Feb 02 17:01:33 2017 +0000
Revision:
157:ff67d9f36b67
This updates the lib to the mbed lib v135

Who changed what in which revision?

UserRevisionLine numberNew contents of line
<> 157:ff67d9f36b67 1 /**
<> 157:ff67d9f36b67 2 * @file
<> 157:ff67d9f36b67 3 * @brief This is the high level API for the watchdog timer interface module
<> 157:ff67d9f36b67 4 */
<> 157:ff67d9f36b67 5 /* ****************************************************************************
<> 157:ff67d9f36b67 6 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
<> 157:ff67d9f36b67 7 *
<> 157:ff67d9f36b67 8 * Permission is hereby granted, free of charge, to any person obtaining a
<> 157:ff67d9f36b67 9 * copy of this software and associated documentation files (the "Software"),
<> 157:ff67d9f36b67 10 * to deal in the Software without restriction, including without limitation
<> 157:ff67d9f36b67 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
<> 157:ff67d9f36b67 12 * and/or sell copies of the Software, and to permit persons to whom the
<> 157:ff67d9f36b67 13 * Software is furnished to do so, subject to the following conditions:
<> 157:ff67d9f36b67 14 *
<> 157:ff67d9f36b67 15 * The above copyright notice and this permission notice shall be included
<> 157:ff67d9f36b67 16 * in all copies or substantial portions of the Software.
<> 157:ff67d9f36b67 17 *
<> 157:ff67d9f36b67 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
<> 157:ff67d9f36b67 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
<> 157:ff67d9f36b67 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
<> 157:ff67d9f36b67 21 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
<> 157:ff67d9f36b67 22 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
<> 157:ff67d9f36b67 23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
<> 157:ff67d9f36b67 24 * OTHER DEALINGS IN THE SOFTWARE.
<> 157:ff67d9f36b67 25 *
<> 157:ff67d9f36b67 26 * Except as contained in this notice, the name of Maxim Integrated
<> 157:ff67d9f36b67 27 * Products, Inc. shall not be used except as stated in the Maxim Integrated
<> 157:ff67d9f36b67 28 * Products, Inc. Branding Policy.
<> 157:ff67d9f36b67 29 *
<> 157:ff67d9f36b67 30 * The mere transfer of this software does not imply any licenses
<> 157:ff67d9f36b67 31 * of trade secrets, proprietary technology, copyrights, patents,
<> 157:ff67d9f36b67 32 * trademarks, maskwork rights, or any other form of intellectual
<> 157:ff67d9f36b67 33 * property whatsoever. Maxim Integrated Products, Inc. retains all
<> 157:ff67d9f36b67 34 * ownership rights.
<> 157:ff67d9f36b67 35 *
<> 157:ff67d9f36b67 36 * $Date: 2016-10-10 19:53:06 -0500 (Mon, 10 Oct 2016) $
<> 157:ff67d9f36b67 37 * $Revision: 24677 $
<> 157:ff67d9f36b67 38 *
<> 157:ff67d9f36b67 39 **************************************************************************** */
<> 157:ff67d9f36b67 40
<> 157:ff67d9f36b67 41 /* Define to prevent redundant inclusion */
<> 157:ff67d9f36b67 42 #ifndef _WDT_H
<> 157:ff67d9f36b67 43 #define _WDT_H
<> 157:ff67d9f36b67 44
<> 157:ff67d9f36b67 45 /* **** Includes **** */
<> 157:ff67d9f36b67 46 #include "mxc_config.h"
<> 157:ff67d9f36b67 47 #include "wdt_regs.h"
<> 157:ff67d9f36b67 48 #include "mxc_assert.h"
<> 157:ff67d9f36b67 49 #include "mxc_sys.h"
<> 157:ff67d9f36b67 50
<> 157:ff67d9f36b67 51 #ifdef __cplusplus
<> 157:ff67d9f36b67 52 extern "C" {
<> 157:ff67d9f36b67 53 #endif
<> 157:ff67d9f36b67 54 /**
<> 157:ff67d9f36b67 55 * @ingroup periphlibs
<> 157:ff67d9f36b67 56 * @defgroup wdttimers Watch Dog Timers
<> 157:ff67d9f36b67 57 * @brief Watch Dog Timer High Level APIs.
<> 157:ff67d9f36b67 58 */
<> 157:ff67d9f36b67 59 /**
<> 157:ff67d9f36b67 60 * @ingroup wdttimers
<> 157:ff67d9f36b67 61 * @defgroup wdt0 Watch Dog Timer 0/1
<> 157:ff67d9f36b67 62 * @brief WDT0/WDT1 configuration and control API.
<> 157:ff67d9f36b67 63 * @{
<> 157:ff67d9f36b67 64 */
<> 157:ff67d9f36b67 65
<> 157:ff67d9f36b67 66 /**
<> 157:ff67d9f36b67 67 * Definition used for clearing all of the WDT instances flags for Timeout, Pre-Window and Reset Out.
<> 157:ff67d9f36b67 68 */
<> 157:ff67d9f36b67 69 #define WDT_FLAGS_CLEAR_ALL (MXC_F_WDT_FLAGS_TIMEOUT| MXC_F_WDT_FLAGS_PRE_WIN | MXC_F_WDT_FLAGS_RESET_OUT)
<> 157:ff67d9f36b67 70 /**
<> 157:ff67d9f36b67 71 * Enumeration type to define the Watchdog Timer's Period
<> 157:ff67d9f36b67 72 */
<> 157:ff67d9f36b67 73 typedef enum {
<> 157:ff67d9f36b67 74 WDT_PERIOD_2_31_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_31_CLKS, /**< \f$ 2^{31} \f$ WDT clocks. */
<> 157:ff67d9f36b67 75 WDT_PERIOD_2_30_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_30_CLKS, /**< \f$ 2^{30} \f$ WDT clocks. */
<> 157:ff67d9f36b67 76 WDT_PERIOD_2_29_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_29_CLKS, /**< \f$ 2^{29} \f$ WDT clocks. */
<> 157:ff67d9f36b67 77 WDT_PERIOD_2_28_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_28_CLKS, /**< \f$ 2^{28} \f$ WDT clocks. */
<> 157:ff67d9f36b67 78 WDT_PERIOD_2_27_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_27_CLKS, /**< \f$ 2^{27} \f$ WDT clocks. */
<> 157:ff67d9f36b67 79 WDT_PERIOD_2_26_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_26_CLKS, /**< \f$ 2^{26} \f$ WDT clocks. */
<> 157:ff67d9f36b67 80 WDT_PERIOD_2_25_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_25_CLKS, /**< \f$ 2^{25} \f$ WDT clocks. */
<> 157:ff67d9f36b67 81 WDT_PERIOD_2_24_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_24_CLKS, /**< \f$ 2^{24} \f$ WDT clocks. */
<> 157:ff67d9f36b67 82 WDT_PERIOD_2_23_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_23_CLKS, /**< \f$ 2^{23} \f$ WDT clocks. */
<> 157:ff67d9f36b67 83 WDT_PERIOD_2_22_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_22_CLKS, /**< \f$ 2^{22} \f$ WDT clocks. */
<> 157:ff67d9f36b67 84 WDT_PERIOD_2_21_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_21_CLKS, /**< \f$ 2^{21} \f$ WDT clocks. */
<> 157:ff67d9f36b67 85 WDT_PERIOD_2_20_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_20_CLKS, /**< \f$ 2^{20} \f$ WDT clocks. */
<> 157:ff67d9f36b67 86 WDT_PERIOD_2_19_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_19_CLKS, /**< \f$ 2^{19} \f$ WDT clocks. */
<> 157:ff67d9f36b67 87 WDT_PERIOD_2_18_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_18_CLKS, /**< \f$ 2^{18} \f$ WDT clocks. */
<> 157:ff67d9f36b67 88 WDT_PERIOD_2_17_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_17_CLKS, /**< \f$ 2^{17} \f$ WDT clocks. */
<> 157:ff67d9f36b67 89 WDT_PERIOD_2_16_CLKS = MXC_V_WDT_CTRL_INT_PERIOD_2_16_CLKS, /**< \f$ 2^{16} \f$ WDT clocks. */
<> 157:ff67d9f36b67 90 WDT_PERIOD_MAX /**< Maximum Period is Max - 1 */
<> 157:ff67d9f36b67 91 } wdt_period_t;
<> 157:ff67d9f36b67 92
<> 157:ff67d9f36b67 93 /**
<> 157:ff67d9f36b67 94 * @brief Initializes system level clocks and sets watchdog in a known disabled state
<> 157:ff67d9f36b67 95 * @note The clk_scale in cfg is only used if the system clock is selected for clk.
<> 157:ff67d9f36b67 96 *
<> 157:ff67d9f36b67 97 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 98 * @param cfg Watchdog system configuration, see sys_cfg_wdt_t.
<> 157:ff67d9f36b67 99 * @param unlock_key Watchdog unlock key
<> 157:ff67d9f36b67 100 *
<> 157:ff67d9f36b67 101 * @retval #E_NO_ERROR Watchdog Timer initialized as requested
<> 157:ff67d9f36b67 102 * @retval #E_NULL_PTR NULL pointer for Watchdog Timer Instance or Configuration parameters.
<> 157:ff67d9f36b67 103 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 104 */
<> 157:ff67d9f36b67 105 int WDT_Init(mxc_wdt_regs_t *wdt, const sys_cfg_wdt_t *cfg, uint8_t unlock_key);
<> 157:ff67d9f36b67 106
<> 157:ff67d9f36b67 107 /**
<> 157:ff67d9f36b67 108 * @brief Configures and enables the interrupt timeout for the watchdog specified.
<> 157:ff67d9f36b67 109 *
<> 157:ff67d9f36b67 110 * @param wdt Watchdog module to operate on
<> 157:ff67d9f36b67 111 * @param int_period Interrupt period as defined by wdt_period_t.
<> 157:ff67d9f36b67 112 * @param unlock_key Key to unlock watchdog. See #MXC_V_WDT_UNLOCK_KEY.
<> 157:ff67d9f36b67 113 *
<> 157:ff67d9f36b67 114 * @retval #E_NO_ERROR Interrupt enabled
<> 157:ff67d9f36b67 115 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 116 */
<> 157:ff67d9f36b67 117 int WDT_EnableInt(mxc_wdt_regs_t *wdt, wdt_period_t int_period, uint8_t unlock_key);
<> 157:ff67d9f36b67 118
<> 157:ff67d9f36b67 119 /**
<> 157:ff67d9f36b67 120 * @brief Disables the interrupt timeout for the watchdog specified.
<> 157:ff67d9f36b67 121 *
<> 157:ff67d9f36b67 122 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 123 * @param unlock_key Key to unlock watchdog. See #MXC_V_WDT_UNLOCK_KEY.
<> 157:ff67d9f36b67 124 *
<> 157:ff67d9f36b67 125 * @retval #E_NO_ERROR Interrupt disabled.
<> 157:ff67d9f36b67 126 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 127 */
<> 157:ff67d9f36b67 128 int WDT_DisableInt(mxc_wdt_regs_t *wdt, uint8_t unlock_key);
<> 157:ff67d9f36b67 129
<> 157:ff67d9f36b67 130 /**
<> 157:ff67d9f36b67 131 * @brief Configures and enables the pre-window timeout for the watchdog specified.
<> 157:ff67d9f36b67 132 *
<> 157:ff67d9f36b67 133 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 134 * @param wait_period Pre-window period, see wdt_period_t for accepted values.
<> 157:ff67d9f36b67 135 * @param unlock_key Key to unlock watchdog. See #MXC_V_WDT_UNLOCK_KEY.
<> 157:ff67d9f36b67 136 *
<> 157:ff67d9f36b67 137 * @retval #E_NO_ERROR Pre-window timeout set to wait_period
<> 157:ff67d9f36b67 138 * @retval #E_BAD_STATE WDT unable to be unlocked
<> 157:ff67d9f36b67 139 * @retval #E_INVALID Requested Period is greater than the maximum supported
<> 157:ff67d9f36b67 140 */
<> 157:ff67d9f36b67 141 int WDT_EnableWait(mxc_wdt_regs_t *wdt, wdt_period_t wait_period, uint8_t unlock_key);
<> 157:ff67d9f36b67 142
<> 157:ff67d9f36b67 143 /**
<> 157:ff67d9f36b67 144 * @brief Disables the pre-window timeout for the watchdog specified.
<> 157:ff67d9f36b67 145 *
<> 157:ff67d9f36b67 146 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 147 * @param unlock_key Key to unlock watchdog. See #MXC_V_WDT_UNLOCK_KEY.
<> 157:ff67d9f36b67 148 *
<> 157:ff67d9f36b67 149 * @retval #E_NO_ERROR Wait disabled.
<> 157:ff67d9f36b67 150 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 151 */
<> 157:ff67d9f36b67 152 int WDT_DisableWait(mxc_wdt_regs_t *wdt, uint8_t unlock_key);
<> 157:ff67d9f36b67 153
<> 157:ff67d9f36b67 154 /**
<> 157:ff67d9f36b67 155 * @brief Configures and enables the reset timeout for the watchdog specified.
<> 157:ff67d9f36b67 156 *
<> 157:ff67d9f36b67 157 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 158 * @param rst_period Reset period, see wdt_period_t for accepted values.
<> 157:ff67d9f36b67 159 * @param unlock_key Key to unlock watchdog. See #MXC_V_WDT_UNLOCK_KEY.
<> 157:ff67d9f36b67 160 *
<> 157:ff67d9f36b67 161 * @retval #E_NO_ERROR Watchdog Timer Reset enabled with the rst_period time.
<> 157:ff67d9f36b67 162 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 163 * @retval #E_INVALID Requested Period is greater than the maximum supported
<> 157:ff67d9f36b67 164 */
<> 157:ff67d9f36b67 165 int WDT_EnableReset(mxc_wdt_regs_t *wdt, wdt_period_t rst_period, uint8_t unlock_key);
<> 157:ff67d9f36b67 166
<> 157:ff67d9f36b67 167 /**
<> 157:ff67d9f36b67 168 * @brief Disables the reset timeout for the watchdog specified.
<> 157:ff67d9f36b67 169 *
<> 157:ff67d9f36b67 170 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 171 * @param unlock_key Key to unlock watchdog. See #MXC_V_WDT_UNLOCK_KEY.
<> 157:ff67d9f36b67 172 *
<> 157:ff67d9f36b67 173 * @retval #E_NO_ERROR Reset disabled.
<> 157:ff67d9f36b67 174 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 175 */
<> 157:ff67d9f36b67 176 int WDT_DisableReset(mxc_wdt_regs_t *wdt, uint8_t unlock_key);
<> 157:ff67d9f36b67 177
<> 157:ff67d9f36b67 178 /**
<> 157:ff67d9f36b67 179 * @brief Gets the watchdog interrupt flags
<> 157:ff67d9f36b67 180 *
<> 157:ff67d9f36b67 181 * @param wdt Pointer to the Watchdog Timer Instance.
<> 157:ff67d9f36b67 182 *
<> 157:ff67d9f36b67 183 * @retval uint32_t Value of the Watchdog Timer Flags.
<> 157:ff67d9f36b67 184 *
<> 157:ff67d9f36b67 185 */
<> 157:ff67d9f36b67 186 __STATIC_INLINE uint32_t WDT_GetFlags(mxc_wdt_regs_t *wdt)
<> 157:ff67d9f36b67 187 {
<> 157:ff67d9f36b67 188 return (wdt->flags);
<> 157:ff67d9f36b67 189 }
<> 157:ff67d9f36b67 190
<> 157:ff67d9f36b67 191 /**
<> 157:ff67d9f36b67 192 * @brief Clears the watchdog interrupt flags based on the mask
<> 157:ff67d9f36b67 193 *
<> 157:ff67d9f36b67 194 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 195 * @param mask Watchdog Flags to clear
<> 157:ff67d9f36b67 196 *
<> 157:ff67d9f36b67 197 */
<> 157:ff67d9f36b67 198 __STATIC_INLINE void WDT_ClearFlags(mxc_wdt_regs_t *wdt, uint32_t mask)
<> 157:ff67d9f36b67 199 {
<> 157:ff67d9f36b67 200 wdt->flags = mask;
<> 157:ff67d9f36b67 201 }
<> 157:ff67d9f36b67 202
<> 157:ff67d9f36b67 203 /**
<> 157:ff67d9f36b67 204 * @brief Starts the specified Watchdog Timer instance.
<> 157:ff67d9f36b67 205 *
<> 157:ff67d9f36b67 206 * @param wdt Pointer to the Watchdog Timer instance
<> 157:ff67d9f36b67 207 * @param unlock_key Key to unlock watchdog.
<> 157:ff67d9f36b67 208 *
<> 157:ff67d9f36b67 209 * @retval #E_NO_ERROR Interrupt enabled.
<> 157:ff67d9f36b67 210 * @retval #E_BAD_STATE WDT1 Already Running
<> 157:ff67d9f36b67 211 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 212 *
<> 157:ff67d9f36b67 213 */
<> 157:ff67d9f36b67 214 int WDT_Start(mxc_wdt_regs_t *wdt, uint8_t unlock_key);
<> 157:ff67d9f36b67 215
<> 157:ff67d9f36b67 216 /**
<> 157:ff67d9f36b67 217 * @brief Feeds the watchdog specified.
<> 157:ff67d9f36b67 218 *
<> 157:ff67d9f36b67 219 * @param wdt Watchdog module to operate on
<> 157:ff67d9f36b67 220 *
<> 157:ff67d9f36b67 221 */
<> 157:ff67d9f36b67 222 void WDT_Reset(mxc_wdt_regs_t *wdt);
<> 157:ff67d9f36b67 223
<> 157:ff67d9f36b67 224 /**
<> 157:ff67d9f36b67 225 * @brief Stops the watchdog specified.
<> 157:ff67d9f36b67 226 *
<> 157:ff67d9f36b67 227 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 228 * @param unlock_key Key to unlock watchdog.
<> 157:ff67d9f36b67 229 *
<> 157:ff67d9f36b67 230 * @retval #E_NO_ERROR Interrupt enabled.
<> 157:ff67d9f36b67 231 * @retval #E_BAD_STATE Invalid unlock_key, WDT failed to unlock.
<> 157:ff67d9f36b67 232 */
<> 157:ff67d9f36b67 233 int WDT_Stop(mxc_wdt_regs_t *wdt, uint8_t unlock_key);
<> 157:ff67d9f36b67 234
<> 157:ff67d9f36b67 235 /**
<> 157:ff67d9f36b67 236 * @brief Determines if the watchdog is running
<> 157:ff67d9f36b67 237 *
<> 157:ff67d9f36b67 238 * @param wdt Pointer to the Watchdog Timer Instance
<> 157:ff67d9f36b67 239 *
<> 157:ff67d9f36b67 240 * @retval 0 Watchdog timer is Disabled.
<> 157:ff67d9f36b67 241 * @retval non-zero Watchdog timer is Active
<> 157:ff67d9f36b67 242 */
<> 157:ff67d9f36b67 243 __STATIC_INLINE int WDT_IsActive(mxc_wdt_regs_t *wdt)
<> 157:ff67d9f36b67 244 {
<> 157:ff67d9f36b67 245 return (!!(wdt->ctrl & MXC_F_WDT_CTRL_EN_TIMER));
<> 157:ff67d9f36b67 246 }
<> 157:ff67d9f36b67 247
<> 157:ff67d9f36b67 248 /**@} end of group wdt*/
<> 157:ff67d9f36b67 249
<> 157:ff67d9f36b67 250 #ifdef __cplusplus
<> 157:ff67d9f36b67 251 }
<> 157:ff67d9f36b67 252 #endif
<> 157:ff67d9f36b67 253
<> 157:ff67d9f36b67 254 #endif /* _WDT_H */