mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Sep 18 14:00:17 2014 +0100
Revision:
324:406fd2029f23
Parent:
149:1fb5f62b92bd
Synchronized with git revision a73f28e6fbca9559fbed2726410eeb4c0534a4a5

Full URL: https://github.com/mbedmicro/mbed/commit/a73f28e6fbca9559fbed2726410eeb4c0534a4a5/

Extended #476, which does not break ethernet for K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 146:f64d43ff0c18 1 /*
mbed_official 146:f64d43ff0c18 2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
mbed_official 146:f64d43ff0c18 3 * All rights reserved.
mbed_official 146:f64d43ff0c18 4 *
mbed_official 146:f64d43ff0c18 5 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 146:f64d43ff0c18 6 * are permitted provided that the following conditions are met:
mbed_official 146:f64d43ff0c18 7 *
mbed_official 146:f64d43ff0c18 8 * o Redistributions of source code must retain the above copyright notice, this list
mbed_official 146:f64d43ff0c18 9 * of conditions and the following disclaimer.
mbed_official 146:f64d43ff0c18 10 *
mbed_official 146:f64d43ff0c18 11 * o Redistributions in binary form must reproduce the above copyright notice, this
mbed_official 146:f64d43ff0c18 12 * list of conditions and the following disclaimer in the documentation and/or
mbed_official 146:f64d43ff0c18 13 * other materials provided with the distribution.
mbed_official 146:f64d43ff0c18 14 *
mbed_official 146:f64d43ff0c18 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
mbed_official 146:f64d43ff0c18 16 * contributors may be used to endorse or promote products derived from this
mbed_official 146:f64d43ff0c18 17 * software without specific prior written permission.
mbed_official 146:f64d43ff0c18 18 *
mbed_official 146:f64d43ff0c18 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
mbed_official 146:f64d43ff0c18 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
mbed_official 146:f64d43ff0c18 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 146:f64d43ff0c18 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
mbed_official 146:f64d43ff0c18 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
mbed_official 146:f64d43ff0c18 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
mbed_official 146:f64d43ff0c18 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
mbed_official 146:f64d43ff0c18 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
mbed_official 146:f64d43ff0c18 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
mbed_official 146:f64d43ff0c18 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 146:f64d43ff0c18 29 */
mbed_official 146:f64d43ff0c18 30 #ifndef __FSL_WDOG_HAL_H__
mbed_official 146:f64d43ff0c18 31 #define __FSL_WDOG_HAL_H__
mbed_official 146:f64d43ff0c18 32
mbed_official 146:f64d43ff0c18 33 #include <assert.h>
mbed_official 146:f64d43ff0c18 34 #include <stdint.h>
mbed_official 146:f64d43ff0c18 35 #include <stdbool.h>
mbed_official 146:f64d43ff0c18 36 #include "fsl_wdog_features.h"
mbed_official 146:f64d43ff0c18 37 #include "fsl_device_registers.h"
mbed_official 146:f64d43ff0c18 38
mbed_official 146:f64d43ff0c18 39 /*!
mbed_official 146:f64d43ff0c18 40 * @addtogroup wdog_hal
mbed_official 146:f64d43ff0c18 41 * @{
mbed_official 146:f64d43ff0c18 42 */
mbed_official 146:f64d43ff0c18 43
mbed_official 146:f64d43ff0c18 44 /*******************************************************************************
mbed_official 146:f64d43ff0c18 45 * Definitions
mbed_official 146:f64d43ff0c18 46 *******************************************************************************/
mbed_official 146:f64d43ff0c18 47
mbed_official 324:406fd2029f23 48 #define WDOG_UNLOCK_VALUE_HIGH (0xC520U)
mbed_official 324:406fd2029f23 49 #define WDOG_UNLOCK_VALUE_LOW (0xD928U)
mbed_official 324:406fd2029f23 50
mbed_official 324:406fd2029f23 51 #define WDOG_REFRESH_VALUE_HIGH (0xA602U)
mbed_official 324:406fd2029f23 52 #define WDOG_REFRESH_VALUE_LOW (0xB480U)
mbed_official 146:f64d43ff0c18 53
mbed_official 146:f64d43ff0c18 54 /*! @brief Watchdog clock source selection.*/
mbed_official 146:f64d43ff0c18 55 typedef enum _wdog_clock_source {
mbed_official 324:406fd2029f23 56 kWdogClockSourceLpoClock = 0x0U, /*!< Clock source is LPO clock */
mbed_official 324:406fd2029f23 57 kWdogClockSourceBusClock = 0x1U /*!< Clock source is Bus clock */
mbed_official 146:f64d43ff0c18 58 } wdog_clock_source_t;
mbed_official 146:f64d43ff0c18 59
mbed_official 146:f64d43ff0c18 60 /*! @brief Define the selection of the clock prescaler*/
mbed_official 324:406fd2029f23 61 typedef enum _wdog_clock_prescaler_value {
mbed_official 324:406fd2029f23 62 kWdogClockPrescalerValueDevide1 = 0x0U, /*!< Divided by 1 */
mbed_official 324:406fd2029f23 63 kWdogClockPrescalerValueDevide2 = 0x1U, /*!< Divided by 2 */
mbed_official 324:406fd2029f23 64 kWdogClockPrescalerValueDevide3 = 0x2U, /*!< Divided by 3 */
mbed_official 324:406fd2029f23 65 kWdogClockPrescalerValueDevide4 = 0x3U, /*!< Divided by 4 */
mbed_official 324:406fd2029f23 66 kWdogClockPrescalerValueDevide5 = 0x4U, /*!< Divided by 5 */
mbed_official 324:406fd2029f23 67 kWdogClockPrescalerValueDevide6 = 0x5U, /*!< Divided by 6 */
mbed_official 324:406fd2029f23 68 kWdogClockPrescalerValueDevide7 = 0x6U, /*!< Divided by 7 */
mbed_official 324:406fd2029f23 69 kWdogClockPrescalerValueDevide8 = 0x7U /*!< Divided by 8 */
mbed_official 324:406fd2029f23 70 } wdog_clock_prescaler_value_t;
mbed_official 324:406fd2029f23 71
mbed_official 324:406fd2029f23 72 /*! @brief Define the common configure */
mbed_official 324:406fd2029f23 73 typedef union _wdog_common_config {
mbed_official 324:406fd2029f23 74 uint32_t U;
mbed_official 324:406fd2029f23 75 struct CommonConfig {
mbed_official 324:406fd2029f23 76 uint32_t wdogEnable:1; /*!< Enable configure, 1 means enable WDOG */
mbed_official 324:406fd2029f23 77 uint32_t clockSource:1; /*!< Clock source */
mbed_official 324:406fd2029f23 78 uint32_t interruptEnable:1; /*!< WDOG interrupt configure, 1 means enable interrupt */
mbed_official 324:406fd2029f23 79 uint32_t windowModeEnable:1; /*!< Window mode configure, 1 means enable window mode */
mbed_official 324:406fd2029f23 80 uint32_t updateRegisterEnable:1; /*!< 1 means WDOG register can reconfigure by unlock */
mbed_official 324:406fd2029f23 81 uint32_t workInDebugModeEnable:1; /*!< 1 means WDOG works while CPU in Debug mode */
mbed_official 324:406fd2029f23 82 uint32_t workInStopModeEnable:1; /*!< 1 means WDOG works while CPU in Debug mode */
mbed_official 324:406fd2029f23 83 uint32_t workInWaitModeEnable:1; /*!< 1 means WDOG works while CPU in Debug mode */
mbed_official 324:406fd2029f23 84 uint32_t reserved0:1; /*!< Reserved */
mbed_official 324:406fd2029f23 85 uint32_t reserved1:1; /*!< Reserved */
mbed_official 324:406fd2029f23 86 uint32_t testWdog:1; /*!< WDOG enable configure */
mbed_official 324:406fd2029f23 87 uint32_t testSelect:1; /*!< 0 means quick test, 1 means byte test */
mbed_official 324:406fd2029f23 88 uint32_t byteSelect:2; /*!< Test byte select */
mbed_official 324:406fd2029f23 89 uint32_t disableTestWdog:1; /*!< 1 means WDOG test mode is disabled */
mbed_official 324:406fd2029f23 90 uint32_t reserved2:1; /*!< Reserved */
mbed_official 324:406fd2029f23 91 uint32_t reserved3:16; /*!< Reserved */
mbed_official 324:406fd2029f23 92 } commonConfig;
mbed_official 324:406fd2029f23 93 } wdog_common_config;
mbed_official 324:406fd2029f23 94
mbed_official 146:f64d43ff0c18 95
mbed_official 146:f64d43ff0c18 96 /*******************************************************************************
mbed_official 146:f64d43ff0c18 97 * API
mbed_official 146:f64d43ff0c18 98 *******************************************************************************/
mbed_official 146:f64d43ff0c18 99
mbed_official 146:f64d43ff0c18 100 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 101 extern "C" {
mbed_official 146:f64d43ff0c18 102 #endif
mbed_official 146:f64d43ff0c18 103
mbed_official 146:f64d43ff0c18 104 /*!
mbed_official 146:f64d43ff0c18 105 * @name Watchdog HAL.
mbed_official 146:f64d43ff0c18 106 * @{
mbed_official 146:f64d43ff0c18 107 */
mbed_official 146:f64d43ff0c18 108
mbed_official 146:f64d43ff0c18 109 /*!
mbed_official 324:406fd2029f23 110 * @brief Sets the WDOG common configure.
mbed_official 146:f64d43ff0c18 111 *
mbed_official 324:406fd2029f23 112 * This function is used to set the WDOG common configure.
mbed_official 324:406fd2029f23 113 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock, the WCT window is still open and
mbed_official 324:406fd2029f23 114 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 115 * Make sure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which means that the register update is enabled.
mbed_official 324:406fd2029f23 116 * The common configuration is controlled by the WDOG_STCTRLH. This is a write-once register and this interface
mbed_official 324:406fd2029f23 117 * is used to set all field of the WDOG_STCTRLH registers at the same time.
mbed_official 324:406fd2029f23 118 * If only one field needs to be set, the API can be used. These API write to the WDOG_STCTRLH register:
mbed_official 324:406fd2029f23 119 * #WDOG_HAL_Enable,#WDOG_HAL_Disable,#WDOG_HAL_SetIntCmd,#WDOG_HAL_SetClockSourceMode,#WDOG_HAL_SetWindowModeCmd,
mbed_official 324:406fd2029f23 120 * #WDOG_HAL_SetRegisterUpdateCmd,#WDOG_HAL_SetWorkInDebugModeCmd,#WDOG_HAL_SetWorkInStopModeCmd,
mbed_official 324:406fd2029f23 121 * #WDOG_HAL_SetWorkInWaitModeCmd
mbed_official 146:f64d43ff0c18 122 *
mbed_official 324:406fd2029f23 123 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 124 * @param commonConfig The common configure of the WDOG
mbed_official 146:f64d43ff0c18 125 */
mbed_official 324:406fd2029f23 126 static inline void WDOG_HAL_SetCommonConfig(uint32_t baseAddr, wdog_common_config commonConfig)
mbed_official 324:406fd2029f23 127 {
mbed_official 324:406fd2029f23 128 HW_WDOG_STCTRLH_WR(baseAddr,(uint16_t)commonConfig.U);
mbed_official 324:406fd2029f23 129 }
mbed_official 146:f64d43ff0c18 130
mbed_official 146:f64d43ff0c18 131 /*!
mbed_official 324:406fd2029f23 132 * @brief Enables the Watchdog module.
mbed_official 146:f64d43ff0c18 133 *
mbed_official 324:406fd2029f23 134 * This function enables the WDOG.
mbed_official 324:406fd2029f23 135 * Make sure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 136 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 137 *
mbed_official 324:406fd2029f23 138 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 139 */
mbed_official 324:406fd2029f23 140 static inline void WDOG_HAL_Enable(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 141 {
mbed_official 324:406fd2029f23 142 BW_WDOG_STCTRLH_WDOGEN(baseAddr, (uint8_t)true);
mbed_official 146:f64d43ff0c18 143 }
mbed_official 146:f64d43ff0c18 144
mbed_official 146:f64d43ff0c18 145 /*!
mbed_official 324:406fd2029f23 146 * @brief Disables the Watchdog module.
mbed_official 324:406fd2029f23 147 *
mbed_official 324:406fd2029f23 148 * This function disables the WDOG.
mbed_official 324:406fd2029f23 149 * Make sure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 150 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 146:f64d43ff0c18 151 *
mbed_official 324:406fd2029f23 152 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 153 */
mbed_official 324:406fd2029f23 154 static inline void WDOG_HAL_Disable(uint32_t baseAddr)
mbed_official 324:406fd2029f23 155 {
mbed_official 324:406fd2029f23 156 BW_WDOG_STCTRLH_WDOGEN(baseAddr, (uint8_t)false);
mbed_official 324:406fd2029f23 157 }
mbed_official 146:f64d43ff0c18 158
mbed_official 146:f64d43ff0c18 159 /*!
mbed_official 324:406fd2029f23 160 * @brief Checks whether the WDOG is enabled.
mbed_official 324:406fd2029f23 161 *
mbed_official 324:406fd2029f23 162 * This function checks whether the WDOG is enabled.
mbed_official 324:406fd2029f23 163 *
mbed_official 324:406fd2029f23 164 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 165 * @return false means WDOG is disabled, true means WODG is enabled.
mbed_official 146:f64d43ff0c18 166 *
mbed_official 324:406fd2029f23 167 */
mbed_official 324:406fd2029f23 168 static inline bool WDOG_HAL_IsEnabled(uint32_t baseAddr)
mbed_official 324:406fd2029f23 169 {
mbed_official 324:406fd2029f23 170 return (bool)BR_WDOG_STCTRLH_WDOGEN(baseAddr);
mbed_official 324:406fd2029f23 171 }
mbed_official 324:406fd2029f23 172
mbed_official 324:406fd2029f23 173 /*!
mbed_official 324:406fd2029f23 174 * @brief Enables and disables the Watchdog interrupt.
mbed_official 146:f64d43ff0c18 175 *
mbed_official 324:406fd2029f23 176 * This function enables or disables the WDOG interrupt.
mbed_official 324:406fd2029f23 177 * Make sure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 178 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 179 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 324:406fd2029f23 180 *
mbed_official 324:406fd2029f23 181 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 182 * @param enable false means disable watchdog interrupt and true means enable watchdog interrupt.
mbed_official 146:f64d43ff0c18 183 */
mbed_official 324:406fd2029f23 184 static inline void WDOG_HAL_SetIntCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 185 {
mbed_official 324:406fd2029f23 186 BW_WDOG_STCTRLH_IRQRSTEN(baseAddr, (uint8_t)enable);
mbed_official 324:406fd2029f23 187 }
mbed_official 324:406fd2029f23 188
mbed_official 324:406fd2029f23 189 /*!
mbed_official 324:406fd2029f23 190 * @brief Checks whether the WDOG interrupt is enabled.
mbed_official 324:406fd2029f23 191 *
mbed_official 324:406fd2029f23 192 * This function checks whether the WDOG interrupt is enabled.
mbed_official 324:406fd2029f23 193 *
mbed_official 324:406fd2029f23 194 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 195 * @return false means interrupt is disabled, true means interrupt is enabled.
mbed_official 324:406fd2029f23 196 */
mbed_official 324:406fd2029f23 197 static inline bool WDOG_HAL_GetIntCmd(uint32_t baseAddr)
mbed_official 324:406fd2029f23 198 {
mbed_official 324:406fd2029f23 199 return (bool)BR_WDOG_STCTRLH_IRQRSTEN(baseAddr);
mbed_official 146:f64d43ff0c18 200 }
mbed_official 146:f64d43ff0c18 201
mbed_official 146:f64d43ff0c18 202 /*!
mbed_official 324:406fd2029f23 203 * @brief Sets the Watchdog clock Source.
mbed_official 146:f64d43ff0c18 204 *
mbed_official 324:406fd2029f23 205 * This function sets the WDOG clock source. There are two clock sources that can be used:
mbed_official 146:f64d43ff0c18 206 * the LPO clock and the bus clock.
mbed_official 324:406fd2029f23 207 * Make sure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 208 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 209 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 210 *
mbed_official 324:406fd2029f23 211 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 212 * @param clockSource watchdog clock source, see #wdog_clock_source_t.
mbed_official 146:f64d43ff0c18 213 */
mbed_official 324:406fd2029f23 214 static inline void WDOG_HAL_SetClockSourceMode(uint32_t baseAddr, wdog_clock_source_t clockSource)
mbed_official 324:406fd2029f23 215 {
mbed_official 324:406fd2029f23 216 BW_WDOG_STCTRLH_CLKSRC(baseAddr, (uint8_t)clockSource);
mbed_official 324:406fd2029f23 217 }
mbed_official 146:f64d43ff0c18 218
mbed_official 146:f64d43ff0c18 219 /*!
mbed_official 324:406fd2029f23 220 * @brief Gets the Watchdog clock Source.
mbed_official 146:f64d43ff0c18 221 *
mbed_official 324:406fd2029f23 222 * This function gets the WDOG clock source. There are two clock sources that can be used:
mbed_official 146:f64d43ff0c18 223 * the LPO clock and the bus clock.
mbed_official 324:406fd2029f23 224 * A Clock Switching Delay time is about 2 clock A cycles plus 2
mbed_official 324:406fd2029f23 225 * clock B, where clock A and B are the two input clocks to the clock mux.
mbed_official 146:f64d43ff0c18 226 *
mbed_official 324:406fd2029f23 227 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 228 * @return watchdog clock source, see #wdog_clock_source_t.
mbed_official 146:f64d43ff0c18 229 */
mbed_official 324:406fd2029f23 230 static inline wdog_clock_source_t WDOG_HAL_GetClockSourceMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 231 {
mbed_official 324:406fd2029f23 232 return (wdog_clock_source_t)BR_WDOG_STCTRLH_CLKSRC(baseAddr);
mbed_official 324:406fd2029f23 233 }
mbed_official 324:406fd2029f23 234
mbed_official 324:406fd2029f23 235 /*!
mbed_official 324:406fd2029f23 236 * @brief Enables and disables the Watchdog window mode.
mbed_official 324:406fd2029f23 237 *
mbed_official 324:406fd2029f23 238 * This function configures the WDOG window mode.
mbed_official 324:406fd2029f23 239 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 240 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 241 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 324:406fd2029f23 242 *
mbed_official 324:406fd2029f23 243 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 244 * @param enable false means disable watchdog window mode. true means enable watchdog window mode.
mbed_official 324:406fd2029f23 245 */
mbed_official 324:406fd2029f23 246 static inline void WDOG_HAL_SetWindowModeCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 247 {
mbed_official 324:406fd2029f23 248 BW_WDOG_STCTRLH_WINEN(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 249 }
mbed_official 146:f64d43ff0c18 250
mbed_official 146:f64d43ff0c18 251 /*!
mbed_official 324:406fd2029f23 252 * @brief Checks whether the window mode is enabled.
mbed_official 324:406fd2029f23 253 *
mbed_official 324:406fd2029f23 254 * This function checks whether the WDOG window mode is enabled.
mbed_official 146:f64d43ff0c18 255 *
mbed_official 324:406fd2029f23 256 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 257 * @return false means window mode is disabled, true means window mode is enabled.
mbed_official 146:f64d43ff0c18 258 */
mbed_official 324:406fd2029f23 259 static inline bool WDOG_HAL_GetWindowModeCmd(uint32_t baseAddr)
mbed_official 324:406fd2029f23 260 {
mbed_official 324:406fd2029f23 261 return (bool)BR_WDOG_STCTRLH_WINEN(baseAddr);
mbed_official 324:406fd2029f23 262 }
mbed_official 146:f64d43ff0c18 263
mbed_official 146:f64d43ff0c18 264 /*!
mbed_official 324:406fd2029f23 265 * @brief Enables and disables the Watchdog write-once-only register update.
mbed_official 146:f64d43ff0c18 266 *
mbed_official 324:406fd2029f23 267 * This function configures the WDOG register update feature. If disabled, it means that
mbed_official 324:406fd2029f23 268 * all WDOG registers is never written again unless Power On Reset.
mbed_official 324:406fd2029f23 269 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 270 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 271 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 272 *
mbed_official 324:406fd2029f23 273 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 274 * @param enable false means disable watchdog write-once-only register update.
mbed_official 324:406fd2029f23 275 * true means enable watchdog write-once-only register update.
mbed_official 146:f64d43ff0c18 276 */
mbed_official 324:406fd2029f23 277 static inline void WDOG_HAL_SetRegisterUpdateCmd(uint32_t baseAddr, bool enable)
mbed_official 146:f64d43ff0c18 278 {
mbed_official 324:406fd2029f23 279 BW_WDOG_STCTRLH_ALLOWUPDATE(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 280 }
mbed_official 146:f64d43ff0c18 281
mbed_official 146:f64d43ff0c18 282 /*!
mbed_official 324:406fd2029f23 283 * @brief Checks whether the register update is enabled.
mbed_official 146:f64d43ff0c18 284 *
mbed_official 324:406fd2029f23 285 * This function checks whether the WDOG register update is enabled.
mbed_official 146:f64d43ff0c18 286 *
mbed_official 324:406fd2029f23 287 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 288 * @return false means register update is disabled, true means register update is enabled.
mbed_official 146:f64d43ff0c18 289 */
mbed_official 324:406fd2029f23 290 static inline bool WDOG_HAL_GetRegisterUpdateCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 291 {
mbed_official 324:406fd2029f23 292 return (bool)BR_WDOG_STCTRLH_ALLOWUPDATE(baseAddr);
mbed_official 146:f64d43ff0c18 293 }
mbed_official 146:f64d43ff0c18 294
mbed_official 146:f64d43ff0c18 295 /*!
mbed_official 324:406fd2029f23 296 * @brief Sets whether Watchdog is working while the CPU is in debug mode.
mbed_official 324:406fd2029f23 297 *
mbed_official 324:406fd2029f23 298 * This function configures whether the WDOG is enabled in the CPU debug mode.
mbed_official 324:406fd2029f23 299 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 300 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 301 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 302 *
mbed_official 324:406fd2029f23 303 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 304 * @param enable false means watchdog is disabled in CPU debug mode.
mbed_official 324:406fd2029f23 305 * true means watchdog is enabled in CPU debug mode.
mbed_official 146:f64d43ff0c18 306 */
mbed_official 324:406fd2029f23 307 static inline void WDOG_HAL_SetWorkInDebugModeCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 308 {
mbed_official 324:406fd2029f23 309 BW_WDOG_STCTRLH_DBGEN(baseAddr, (uint8_t)enable);
mbed_official 324:406fd2029f23 310 }
mbed_official 146:f64d43ff0c18 311
mbed_official 146:f64d43ff0c18 312 /*!
mbed_official 324:406fd2029f23 313 * @brief Checks whether the WDOG works while in the CPU debug mode.
mbed_official 146:f64d43ff0c18 314 *
mbed_official 324:406fd2029f23 315 * This function checks whether the WDOG works in the CPU debug mode.
mbed_official 146:f64d43ff0c18 316 *
mbed_official 324:406fd2029f23 317 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 318 * @return false means not work while in CPU debug mode, true means works while in CPU debug mode.
mbed_official 146:f64d43ff0c18 319 */
mbed_official 324:406fd2029f23 320 static inline bool WDOG_HAL_GetWorkInDebugModeCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 321 {
mbed_official 324:406fd2029f23 322 return (bool)BR_WDOG_STCTRLH_DBGEN(baseAddr);
mbed_official 146:f64d43ff0c18 323 }
mbed_official 146:f64d43ff0c18 324
mbed_official 146:f64d43ff0c18 325 /*!
mbed_official 324:406fd2029f23 326 * @brief Sets whether the Watchdog is working while the CPU is in stop mode.
mbed_official 324:406fd2029f23 327 *
mbed_official 324:406fd2029f23 328 * This function configures whether the WDOG is enabled in the CPU stop mode.
mbed_official 324:406fd2029f23 329 * Make sure that the WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 330 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 331 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 332 *
mbed_official 324:406fd2029f23 333 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 334 * @param enable false means watchdog is disabled in CPU stop mode.
mbed_official 324:406fd2029f23 335 * true means watchdog is enabled in CPU stop mode.
mbed_official 146:f64d43ff0c18 336 */
mbed_official 324:406fd2029f23 337 static inline void WDOG_HAL_SetWorkInStopModeCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 338 {
mbed_official 324:406fd2029f23 339 BW_WDOG_STCTRLH_STOPEN(baseAddr, (uint8_t)enable);
mbed_official 324:406fd2029f23 340 }
mbed_official 146:f64d43ff0c18 341
mbed_official 146:f64d43ff0c18 342 /*!
mbed_official 324:406fd2029f23 343 * @brief Checks whether the WDOG works while in CPU stop mode.
mbed_official 146:f64d43ff0c18 344 *
mbed_official 324:406fd2029f23 345 * This function checks whether the WDOG works in the CPU stop mode.
mbed_official 324:406fd2029f23 346 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 347 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 348 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 349 *
mbed_official 324:406fd2029f23 350 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 351 * @return false means not work while in CPU stop mode, true means works while in CPU stop mode.
mbed_official 146:f64d43ff0c18 352 */
mbed_official 324:406fd2029f23 353 static inline bool WDOG_HAL_GetWorkInStopModeCmd(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 354 {
mbed_official 324:406fd2029f23 355 return (bool)BR_WDOG_STCTRLH_STOPEN(baseAddr);
mbed_official 324:406fd2029f23 356 }
mbed_official 324:406fd2029f23 357
mbed_official 324:406fd2029f23 358 /*!
mbed_official 324:406fd2029f23 359 * @brief Sets whether the Watchdog is working while the CPU is in wait mode.
mbed_official 324:406fd2029f23 360 *
mbed_official 324:406fd2029f23 361 * This function configures whether the WDOG is enabled in the CPU wait mode.
mbed_official 324:406fd2029f23 362 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock, that the WCT window is still open and that
mbed_official 324:406fd2029f23 363 * the WDOG_STCTRLH register has not been written in this WCT while this function is called.
mbed_official 324:406fd2029f23 364 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 324:406fd2029f23 365 *
mbed_official 324:406fd2029f23 366 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 367 * @param enable false means watchdog is disabled in CPU wait mode.
mbed_official 324:406fd2029f23 368 * true means watchdog is enabled in CPU wait mode.
mbed_official 324:406fd2029f23 369 */
mbed_official 324:406fd2029f23 370 static inline void WDOG_HAL_SetWorkInWaitModeCmd(uint32_t baseAddr, bool enable)
mbed_official 324:406fd2029f23 371 {
mbed_official 324:406fd2029f23 372 BW_WDOG_STCTRLH_WAITEN(baseAddr, (uint8_t)enable);
mbed_official 146:f64d43ff0c18 373 }
mbed_official 146:f64d43ff0c18 374
mbed_official 146:f64d43ff0c18 375 /*!
mbed_official 324:406fd2029f23 376 * @brief Checks whether the WDOG works while in the CPU wait mode.
mbed_official 324:406fd2029f23 377 *
mbed_official 324:406fd2029f23 378 * This function checks whether the WDOG works in the CPU wait mode.
mbed_official 146:f64d43ff0c18 379 *
mbed_official 324:406fd2029f23 380 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 381 * @return false means not work while in CPU wait mode, true means works while in CPU wait mode.
mbed_official 146:f64d43ff0c18 382 */
mbed_official 324:406fd2029f23 383
mbed_official 324:406fd2029f23 384 static inline bool WDOG_HAL_GetWorkInWaitModeCmd(uint32_t baseAddr)
mbed_official 324:406fd2029f23 385 {
mbed_official 324:406fd2029f23 386 return (bool)BR_WDOG_STCTRLH_WAITEN(baseAddr);
mbed_official 324:406fd2029f23 387 }
mbed_official 146:f64d43ff0c18 388
mbed_official 146:f64d43ff0c18 389 /*!
mbed_official 324:406fd2029f23 390 * @brief Gets the Watchdog interrupt status.
mbed_official 146:f64d43ff0c18 391 *
mbed_official 324:406fd2029f23 392 * This function gets the WDOG interrupt flag.
mbed_official 146:f64d43ff0c18 393 *
mbed_official 324:406fd2029f23 394 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 395 * @return Watchdog interrupt status, false means interrupt not asserted, true means interrupt asserted.
mbed_official 146:f64d43ff0c18 396 */
mbed_official 324:406fd2029f23 397 static inline bool WDOG_HAL_IsIntPending(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 398 {
mbed_official 324:406fd2029f23 399 return (bool)BR_WDOG_STCTRLL_INTFLG(baseAddr);
mbed_official 146:f64d43ff0c18 400 }
mbed_official 146:f64d43ff0c18 401
mbed_official 146:f64d43ff0c18 402 /*!
mbed_official 324:406fd2029f23 403 * @brief Clears the Watchdog interrupt flag.
mbed_official 146:f64d43ff0c18 404 *
mbed_official 324:406fd2029f23 405 * This function clears the WDOG interrupt flag.
mbed_official 146:f64d43ff0c18 406 *
mbed_official 324:406fd2029f23 407 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 408 */
mbed_official 324:406fd2029f23 409 static inline void WDOG_HAL_ClearIntFlag(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 410 {
mbed_official 324:406fd2029f23 411 BW_WDOG_STCTRLL_INTFLG(baseAddr, true);
mbed_official 146:f64d43ff0c18 412 }
mbed_official 146:f64d43ff0c18 413
mbed_official 146:f64d43ff0c18 414 /*!
mbed_official 324:406fd2029f23 415 * @brief Set the Watchdog timeout value.
mbed_official 146:f64d43ff0c18 416 *
mbed_official 324:406fd2029f23 417 * This function sets the WDOG_TOVAL value.
mbed_official 324:406fd2029f23 418 * It should be ensured that the time-out value for the Watchdog is always greater than
mbed_official 324:406fd2029f23 419 * 2xWCT time + 20 bus clock cycles.
mbed_official 324:406fd2029f23 420 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock , that the WCT window is still open and that
mbed_official 324:406fd2029f23 421 * this API has not been called in this WCT while this function is called.
mbed_official 324:406fd2029f23 422 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 423 *
mbed_official 324:406fd2029f23 424 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 425 * @param timeoutCount watchdog timeout value, count of watchdog clock tick.
mbed_official 146:f64d43ff0c18 426 */
mbed_official 324:406fd2029f23 427 static inline void WDOG_HAL_SetTimeoutValue(uint32_t baseAddr, uint32_t timeoutCount)
mbed_official 146:f64d43ff0c18 428 {
mbed_official 324:406fd2029f23 429 HW_WDOG_TOVALH_WR(baseAddr, (uint16_t)((timeoutCount >> 16U) & 0xFFFFU));
mbed_official 324:406fd2029f23 430 HW_WDOG_TOVALL_WR(baseAddr, (uint16_t)((timeoutCount) & 0xFFFFU));
mbed_official 146:f64d43ff0c18 431 }
mbed_official 146:f64d43ff0c18 432
mbed_official 146:f64d43ff0c18 433 /*!
mbed_official 324:406fd2029f23 434 * @brief Gets the Watchdog timeout value.
mbed_official 324:406fd2029f23 435 *
mbed_official 324:406fd2029f23 436 * This function gets the WDOG_TOVAL value.
mbed_official 146:f64d43ff0c18 437 *
mbed_official 324:406fd2029f23 438 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 439 * @return value of register WDOG_TOVAL.
mbed_official 324:406fd2029f23 440 */
mbed_official 324:406fd2029f23 441 static inline uint32_t WDOG_HAL_GetTimeoutValue(uint32_t baseAddr)
mbed_official 324:406fd2029f23 442 {
mbed_official 324:406fd2029f23 443 return (uint32_t)((((uint32_t)(HW_WDOG_TOVALH_RD(baseAddr))) << 16U) | (HW_WDOG_TOVALL_RD(baseAddr)));
mbed_official 324:406fd2029f23 444 }
mbed_official 324:406fd2029f23 445
mbed_official 324:406fd2029f23 446 /*!
mbed_official 324:406fd2029f23 447 * @brief Gets the Watchdog timer output.
mbed_official 146:f64d43ff0c18 448 *
mbed_official 324:406fd2029f23 449 * This function gets the WDOG_TMROUT value.
mbed_official 324:406fd2029f23 450 *
mbed_official 324:406fd2029f23 451 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 452 * @return Current value of watchdog timer counter.
mbed_official 146:f64d43ff0c18 453 */
mbed_official 324:406fd2029f23 454 static inline uint32_t WDOG_HAL_GetTimerOutputValue(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 455 {
mbed_official 324:406fd2029f23 456 return (uint32_t)((((uint32_t)(HW_WDOG_TMROUTH_RD(baseAddr))) << 16U) | (HW_WDOG_TMROUTL_RD(baseAddr)));
mbed_official 146:f64d43ff0c18 457 }
mbed_official 146:f64d43ff0c18 458
mbed_official 146:f64d43ff0c18 459 /*!
mbed_official 324:406fd2029f23 460 * @brief Sets the Watchdog clock prescaler.
mbed_official 146:f64d43ff0c18 461 *
mbed_official 324:406fd2029f23 462 * This function sets the WDOG clock prescaler.
mbed_official 324:406fd2029f23 463 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock , that the WCT window is still open and that
mbed_official 324:406fd2029f23 464 * this API has not been called in this WCT while this function is called.
mbed_official 324:406fd2029f23 465 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 466 *
mbed_official 324:406fd2029f23 467 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 468 * @param clockPrescaler watchdog clock prescaler, see #wdog_clock_prescaler_value_t.
mbed_official 146:f64d43ff0c18 469 */
mbed_official 324:406fd2029f23 470 static inline void WDOG_HAL_SetClockPrescalerValueMode(uint32_t baseAddr, wdog_clock_prescaler_value_t clockPrescaler)
mbed_official 146:f64d43ff0c18 471 {
mbed_official 324:406fd2029f23 472 BW_WDOG_PRESC_PRESCVAL(baseAddr, (uint8_t)clockPrescaler);
mbed_official 146:f64d43ff0c18 473 }
mbed_official 146:f64d43ff0c18 474
mbed_official 146:f64d43ff0c18 475 /*!
mbed_official 324:406fd2029f23 476 * @brief Gets the Watchdog clock prescaler.
mbed_official 146:f64d43ff0c18 477 *
mbed_official 324:406fd2029f23 478 * This function gets the WDOG clock prescaler.
mbed_official 146:f64d43ff0c18 479 *
mbed_official 324:406fd2029f23 480 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 481 * @return WDOG clock prescaler, see #wdog_clock_prescaler_value_t.
mbed_official 146:f64d43ff0c18 482 */
mbed_official 324:406fd2029f23 483 static inline wdog_clock_prescaler_value_t WDOG_HAL_GetClockPrescalerValueMode(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 484 {
mbed_official 324:406fd2029f23 485 return (wdog_clock_prescaler_value_t)BR_WDOG_PRESC_PRESCVAL(baseAddr);
mbed_official 146:f64d43ff0c18 486 }
mbed_official 146:f64d43ff0c18 487
mbed_official 146:f64d43ff0c18 488 /*!
mbed_official 324:406fd2029f23 489 * @brief Sets the Watchdog window value.
mbed_official 146:f64d43ff0c18 490 *
mbed_official 324:406fd2029f23 491 * This function sets the WDOG_WIN value.
mbed_official 324:406fd2029f23 492 * Make sure WDOG registers are unlocked by the WDOG_HAL_Unlock , that the WCT window is still open and that
mbed_official 324:406fd2029f23 493 * this API has not been called in this WCT while this function is called.
mbed_official 324:406fd2029f23 494 * Make sure WDOG_STCTRLH.ALLOWUPDATE is 1 which means register update is enabled.
mbed_official 146:f64d43ff0c18 495 *
mbed_official 324:406fd2029f23 496 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 497 * @param windowValue watchdog window value.
mbed_official 146:f64d43ff0c18 498 */
mbed_official 324:406fd2029f23 499 static inline void WDOG_HAL_SetWindowValue(uint32_t baseAddr, uint32_t windowValue)
mbed_official 146:f64d43ff0c18 500 {
mbed_official 324:406fd2029f23 501 HW_WDOG_WINH_WR(baseAddr, (uint16_t)((windowValue>>16U) & 0xFFFFU));
mbed_official 324:406fd2029f23 502 HW_WDOG_WINL_WR(baseAddr, (uint16_t)((windowValue) & 0xFFFFU));
mbed_official 146:f64d43ff0c18 503 }
mbed_official 146:f64d43ff0c18 504
mbed_official 146:f64d43ff0c18 505 /*!
mbed_official 324:406fd2029f23 506 * @brief Gets the Watchdog window value.
mbed_official 324:406fd2029f23 507 *
mbed_official 324:406fd2029f23 508 * This function gets the WDOG_WIN value.
mbed_official 324:406fd2029f23 509 *
mbed_official 324:406fd2029f23 510 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 511 * @return watchdog window value.
mbed_official 324:406fd2029f23 512 */
mbed_official 324:406fd2029f23 513 static inline uint32_t WDOG_HAL_GetWindowValue(uint32_t baseAddr)
mbed_official 324:406fd2029f23 514 {
mbed_official 324:406fd2029f23 515 return (uint32_t)((((uint32_t)(HW_WDOG_WINH_RD(baseAddr))) << 16U) | (HW_WDOG_WINL_RD(baseAddr)));
mbed_official 324:406fd2029f23 516 }
mbed_official 324:406fd2029f23 517
mbed_official 324:406fd2029f23 518 /*!
mbed_official 324:406fd2029f23 519 * @brief Unlocks the Watchdog register written.
mbed_official 146:f64d43ff0c18 520 *
mbed_official 324:406fd2029f23 521 * This function unlocks the WDOG register written.
mbed_official 146:f64d43ff0c18 522 * This function must be called before any configuration is set because watchdog register
mbed_official 146:f64d43ff0c18 523 * will be locked automatically after a WCT(256 bus cycles).
mbed_official 146:f64d43ff0c18 524 *
mbed_official 324:406fd2029f23 525 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 526 */
mbed_official 324:406fd2029f23 527 static inline void WDOG_HAL_Unlock(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 528 {
mbed_official 324:406fd2029f23 529 HW_WDOG_UNLOCK_WR(baseAddr, WDOG_UNLOCK_VALUE_HIGH);
mbed_official 324:406fd2029f23 530 HW_WDOG_UNLOCK_WR(baseAddr, WDOG_UNLOCK_VALUE_LOW);
mbed_official 146:f64d43ff0c18 531 }
mbed_official 146:f64d43ff0c18 532
mbed_official 146:f64d43ff0c18 533 /*!
mbed_official 324:406fd2029f23 534 * @brief Refreshes the Watchdog timer.
mbed_official 146:f64d43ff0c18 535 *
mbed_official 324:406fd2029f23 536 * This function feeds the WDOG.
mbed_official 324:406fd2029f23 537 * This function should be called before watchdog timer is in timeout. Otherwise, a reset is asserted.
mbed_official 146:f64d43ff0c18 538 *
mbed_official 324:406fd2029f23 539 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 540 */
mbed_official 324:406fd2029f23 541 static inline void WDOG_HAL_Refresh(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 542 {
mbed_official 324:406fd2029f23 543 HW_WDOG_REFRESH_WR(baseAddr, WDOG_REFRESH_VALUE_HIGH);
mbed_official 324:406fd2029f23 544 HW_WDOG_REFRESH_WR(baseAddr, WDOG_REFRESH_VALUE_LOW);
mbed_official 146:f64d43ff0c18 545 }
mbed_official 146:f64d43ff0c18 546
mbed_official 146:f64d43ff0c18 547 /*!
mbed_official 324:406fd2029f23 548 * @brief Resets the chip using the Watchdog.
mbed_official 146:f64d43ff0c18 549 *
mbed_official 324:406fd2029f23 550 * This function resets the chip using WDOG.
mbed_official 146:f64d43ff0c18 551 *
mbed_official 324:406fd2029f23 552 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 553 */
mbed_official 324:406fd2029f23 554 static inline void WDOG_HAL_ResetSystem(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 555 {
mbed_official 324:406fd2029f23 556 HW_WDOG_REFRESH_WR(baseAddr, WDOG_REFRESH_VALUE_HIGH);
mbed_official 324:406fd2029f23 557 HW_WDOG_REFRESH_WR(baseAddr, 0);
mbed_official 146:f64d43ff0c18 558 while(1)
mbed_official 146:f64d43ff0c18 559 {
mbed_official 146:f64d43ff0c18 560 }
mbed_official 146:f64d43ff0c18 561 }
mbed_official 146:f64d43ff0c18 562
mbed_official 146:f64d43ff0c18 563 /*!
mbed_official 324:406fd2029f23 564 * @brief Gets the chip reset count that was reset by Watchdog.
mbed_official 146:f64d43ff0c18 565 *
mbed_official 324:406fd2029f23 566 * This function gets the value of the WDOG_RSTCNT.
mbed_official 146:f64d43ff0c18 567 *
mbed_official 324:406fd2029f23 568 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 569 * @return Chip reset count that was reset by Watchdog.
mbed_official 146:f64d43ff0c18 570 */
mbed_official 324:406fd2029f23 571 static inline uint32_t WDOG_HAL_GetResetCount(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 572 {
mbed_official 324:406fd2029f23 573 return HW_WDOG_RSTCNT_RD(baseAddr);
mbed_official 146:f64d43ff0c18 574 }
mbed_official 146:f64d43ff0c18 575
mbed_official 146:f64d43ff0c18 576 /*!
mbed_official 324:406fd2029f23 577 * @brief Clears the chip reset count that was reset by Watchdog.
mbed_official 146:f64d43ff0c18 578 *
mbed_official 324:406fd2029f23 579 * This function clears the WDOG_RSTCNT.
mbed_official 146:f64d43ff0c18 580 *
mbed_official 324:406fd2029f23 581 * @param baseAddr The WDOG peripheral base address
mbed_official 146:f64d43ff0c18 582 */
mbed_official 324:406fd2029f23 583 static inline void WDOG_HAL_ClearResetCount(uint32_t baseAddr)
mbed_official 146:f64d43ff0c18 584 {
mbed_official 324:406fd2029f23 585 HW_WDOG_RSTCNT_WR(baseAddr, 0xFFFFU);
mbed_official 146:f64d43ff0c18 586 }
mbed_official 324:406fd2029f23 587
mbed_official 324:406fd2029f23 588 /*!
mbed_official 324:406fd2029f23 589 * @brief Restores the WDOG module to reset value.
mbed_official 324:406fd2029f23 590 *
mbed_official 324:406fd2029f23 591 * This function restores the WDOG module to reset value.
mbed_official 324:406fd2029f23 592 *
mbed_official 324:406fd2029f23 593 * @param baseAddr The WDOG peripheral base address
mbed_official 324:406fd2029f23 594 */
mbed_official 324:406fd2029f23 595 void WDOG_HAL_Init(uint32_t baseAddr);
mbed_official 324:406fd2029f23 596
mbed_official 146:f64d43ff0c18 597 /*@}*/
mbed_official 146:f64d43ff0c18 598
mbed_official 146:f64d43ff0c18 599 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 600 }
mbed_official 146:f64d43ff0c18 601 #endif
mbed_official 146:f64d43ff0c18 602
mbed_official 146:f64d43ff0c18 603 /*! @}*/
mbed_official 146:f64d43ff0c18 604
mbed_official 146:f64d43ff0c18 605 #endif /* __FSL_WDOG_HAL_H__*/
mbed_official 146:f64d43ff0c18 606 /*******************************************************************************
mbed_official 146:f64d43ff0c18 607 * EOF
mbed_official 146:f64d43ff0c18 608 *******************************************************************************/
mbed_official 146:f64d43ff0c18 609