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 Apr 03 11:45:06 2014 +0100
Revision:
149:1fb5f62b92bd
Parent:
targets/hal/TARGET_Freescale/TARGET_KSDK_MCUS/TARGET_KSDK_CODE/hal/wdog/fsl_wdog_hal.h@146:f64d43ff0c18
Child:
324:406fd2029f23
Synchronized with git revision 220c0bb39ceee40016e1e86350c058963d01ed42

Full URL: https://github.com/mbedmicro/mbed/commit/220c0bb39ceee40016e1e86350c058963d01ed42/

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 146:f64d43ff0c18 48 /*! @brief Watchdog ISR callback function type*/
mbed_official 146:f64d43ff0c18 49 typedef void (*wdog_isr_callback_t)(void);
mbed_official 146:f64d43ff0c18 50
mbed_official 146:f64d43ff0c18 51 /*! @brief Watchdog clock source selection.*/
mbed_official 146:f64d43ff0c18 52 typedef enum _wdog_clock_source {
mbed_official 146:f64d43ff0c18 53 kWdogDedicatedClock = 0, /*!< Dedicated clock source (LPO Oscillator),1K HZ.*/
mbed_official 146:f64d43ff0c18 54 kWdogAlternateClock = 1 /*!< Alternate clock source, Bus clock.*/
mbed_official 146:f64d43ff0c18 55 } wdog_clock_source_t;
mbed_official 146:f64d43ff0c18 56
mbed_official 146:f64d43ff0c18 57 /*! @brief Define the selection of the clock prescaler*/
mbed_official 146:f64d43ff0c18 58 typedef enum _wdog_clock_prescaler {
mbed_official 146:f64d43ff0c18 59 kWdogClockPrescaler1 = 0, /*!< Divide 1, default*/
mbed_official 146:f64d43ff0c18 60 kWdogClockPrescaler2 = 1, /*!< Divide 2*/
mbed_official 146:f64d43ff0c18 61 kWdogClockPrescaler3 = 2, /*!< Divide 3*/
mbed_official 146:f64d43ff0c18 62 kWdogClockPrescaler4 = 3, /*!< Divide 4*/
mbed_official 146:f64d43ff0c18 63 kWdogClockPrescaler5 = 4, /*!< Divide 5*/
mbed_official 146:f64d43ff0c18 64 kWdogClockPrescaler6 = 5, /*!< Divide 6*/
mbed_official 146:f64d43ff0c18 65 kWdogClockPrescaler7 = 6, /*!< Divide 7*/
mbed_official 146:f64d43ff0c18 66 kWdogClockPrescaler8 = 7, /*!< Divide 8*/
mbed_official 146:f64d43ff0c18 67 } wdog_clock_prescaler_t;
mbed_official 146:f64d43ff0c18 68
mbed_official 146:f64d43ff0c18 69 /*******************************************************************************
mbed_official 146:f64d43ff0c18 70 * API
mbed_official 146:f64d43ff0c18 71 *******************************************************************************/
mbed_official 146:f64d43ff0c18 72
mbed_official 146:f64d43ff0c18 73 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 74 extern "C" {
mbed_official 146:f64d43ff0c18 75 #endif
mbed_official 146:f64d43ff0c18 76
mbed_official 146:f64d43ff0c18 77 /*!
mbed_official 146:f64d43ff0c18 78 * @name Watchdog HAL.
mbed_official 146:f64d43ff0c18 79 * @{
mbed_official 146:f64d43ff0c18 80 */
mbed_official 146:f64d43ff0c18 81
mbed_official 146:f64d43ff0c18 82 /*!
mbed_official 146:f64d43ff0c18 83 * @brief Enable watchdog module.
mbed_official 146:f64d43ff0c18 84 *
mbed_official 146:f64d43ff0c18 85 * This function is used to enable the WDOG and must be called after all
mbed_official 146:f64d43ff0c18 86 * necessary configure have been set.
mbed_official 146:f64d43ff0c18 87 *
mbed_official 146:f64d43ff0c18 88 */
mbed_official 146:f64d43ff0c18 89 void wdog_hal_enable(void);
mbed_official 146:f64d43ff0c18 90
mbed_official 146:f64d43ff0c18 91 /*!
mbed_official 146:f64d43ff0c18 92 * @brief Disable watchdog module.
mbed_official 146:f64d43ff0c18 93 *
mbed_official 146:f64d43ff0c18 94 * This function is used to disable the WDOG.
mbed_official 146:f64d43ff0c18 95 *
mbed_official 146:f64d43ff0c18 96 */
mbed_official 146:f64d43ff0c18 97 void wdog_hal_disable(void);
mbed_official 146:f64d43ff0c18 98
mbed_official 146:f64d43ff0c18 99 /*!
mbed_official 146:f64d43ff0c18 100 * @brief Check whether WDOG is enabled.
mbed_official 146:f64d43ff0c18 101 *
mbed_official 146:f64d43ff0c18 102 * This function is used check whether WDOG is enabled.
mbed_official 146:f64d43ff0c18 103 *
mbed_official 146:f64d43ff0c18 104 * @return 0 means WDOG is disabled, 1 means WODG is enabled.
mbed_official 146:f64d43ff0c18 105 *
mbed_official 146:f64d43ff0c18 106 */
mbed_official 146:f64d43ff0c18 107 static inline bool wdog_hal_is_enabled(void)
mbed_official 146:f64d43ff0c18 108 {
mbed_official 146:f64d43ff0c18 109 return BR_WDOG_STCTRLH_WDOGEN;
mbed_official 146:f64d43ff0c18 110 }
mbed_official 146:f64d43ff0c18 111
mbed_official 146:f64d43ff0c18 112 /*!
mbed_official 146:f64d43ff0c18 113 * @brief Enable and disable watchdog interrupt.
mbed_official 146:f64d43ff0c18 114 *
mbed_official 146:f64d43ff0c18 115 * This function is used to configure the WDOG interrupt.
mbed_official 146:f64d43ff0c18 116 * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable
mbed_official 146:f64d43ff0c18 117 * function, so this function must be called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 118 *
mbed_official 146:f64d43ff0c18 119 * @param isEnabled 0 means disable watchdog interrupt. 1 means enable watchdog interrupt.
mbed_official 146:f64d43ff0c18 120 */
mbed_official 146:f64d43ff0c18 121 void wdog_hal_configure_interrupt(bool isEnabled);
mbed_official 146:f64d43ff0c18 122
mbed_official 146:f64d43ff0c18 123 /*!
mbed_official 146:f64d43ff0c18 124 * @brief Check whether WDOG interrupt is enabled.
mbed_official 146:f64d43ff0c18 125 *
mbed_official 146:f64d43ff0c18 126 * This function is used to check whether the WDOG interrupt is enabled.
mbed_official 146:f64d43ff0c18 127 *
mbed_official 146:f64d43ff0c18 128 * @return 0 means interrupt is disabled, 1 means interrupt is enabled.
mbed_official 146:f64d43ff0c18 129 */
mbed_official 146:f64d43ff0c18 130 static inline bool wdog_hal_is_interrupt_enabled(void)
mbed_official 146:f64d43ff0c18 131 {
mbed_official 146:f64d43ff0c18 132 return BR_WDOG_STCTRLH_IRQRSTEN;
mbed_official 146:f64d43ff0c18 133 }
mbed_official 146:f64d43ff0c18 134
mbed_official 146:f64d43ff0c18 135 /*!
mbed_official 146:f64d43ff0c18 136 * @brief set watchdog clock Source.
mbed_official 146:f64d43ff0c18 137 *
mbed_official 146:f64d43ff0c18 138 * This function is used to set the WDOG clock source. There are two clock sources that can be used,
mbed_official 146:f64d43ff0c18 139 * the LPO clock and the bus clock.
mbed_official 146:f64d43ff0c18 140 * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable
mbed_official 146:f64d43ff0c18 141 * function, so this function must be called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 142 *
mbed_official 146:f64d43ff0c18 143 * @param clockSource watchdog clock source, see wdog_clock_source_t.
mbed_official 146:f64d43ff0c18 144 */
mbed_official 146:f64d43ff0c18 145 void wdog_hal_set_clock_source(wdog_clock_source_t clockSource);
mbed_official 146:f64d43ff0c18 146
mbed_official 146:f64d43ff0c18 147 /*!
mbed_official 146:f64d43ff0c18 148 * @brief Get watchdog clock Source.
mbed_official 146:f64d43ff0c18 149 *
mbed_official 146:f64d43ff0c18 150 * This function is used to get the WDOG clock source. There are two clock sources that can be used,
mbed_official 146:f64d43ff0c18 151 * the LPO clock and the bus clock.
mbed_official 146:f64d43ff0c18 152 *
mbed_official 146:f64d43ff0c18 153 * @return watchdog clock source, see wdog_clock_source_t.
mbed_official 146:f64d43ff0c18 154 */
mbed_official 146:f64d43ff0c18 155 static inline wdog_clock_source_t wdog_hal_get_clock_source(void)
mbed_official 146:f64d43ff0c18 156 {
mbed_official 146:f64d43ff0c18 157 return (wdog_clock_source_t)BR_WDOG_STCTRLH_CLKSRC;
mbed_official 146:f64d43ff0c18 158 }
mbed_official 146:f64d43ff0c18 159
mbed_official 146:f64d43ff0c18 160 /*!
mbed_official 146:f64d43ff0c18 161 * @brief Enable and disable watchdog window mode.
mbed_official 146:f64d43ff0c18 162 *
mbed_official 146:f64d43ff0c18 163 * This function is used to configure the WDOG window mode.
mbed_official 146:f64d43ff0c18 164 * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable
mbed_official 146:f64d43ff0c18 165 * function, so this function must be called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 166 *
mbed_official 146:f64d43ff0c18 167 * @param isEnabled 0 means disable watchdog window mode. 1 means enable watchdog window mode.
mbed_official 146:f64d43ff0c18 168 */
mbed_official 146:f64d43ff0c18 169 void wdog_hal_configure_window_mode(bool isEnabled);
mbed_official 146:f64d43ff0c18 170
mbed_official 146:f64d43ff0c18 171 /*!
mbed_official 146:f64d43ff0c18 172 * @brief Check whether window mode is enabled.
mbed_official 146:f64d43ff0c18 173 *
mbed_official 146:f64d43ff0c18 174 * This function is used to check whether the WDOG window mode is enabled.
mbed_official 146:f64d43ff0c18 175 *
mbed_official 146:f64d43ff0c18 176 * @return 0 means window mode is disabled, 1 means window mode is enabled.
mbed_official 146:f64d43ff0c18 177 */
mbed_official 146:f64d43ff0c18 178 static inline bool wdog_hal_is_window_mode_enabled(void)
mbed_official 146:f64d43ff0c18 179 {
mbed_official 146:f64d43ff0c18 180 return BR_WDOG_STCTRLH_WINEN;
mbed_official 146:f64d43ff0c18 181 }
mbed_official 146:f64d43ff0c18 182
mbed_official 146:f64d43ff0c18 183 /*!
mbed_official 146:f64d43ff0c18 184 * @brief Enable and disable watchdog write-once-only register update.
mbed_official 146:f64d43ff0c18 185 *
mbed_official 146:f64d43ff0c18 186 * This function is used to configure the WDOG register update feature. If disabled, it means that
mbed_official 146:f64d43ff0c18 187 * all WDOG registers will never be written again unless Power On Reset.
mbed_official 146:f64d43ff0c18 188 * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable
mbed_official 146:f64d43ff0c18 189 * function, so this function must be called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 190 *
mbed_official 146:f64d43ff0c18 191 * @param isEnabled 0 means disable watchdog write-once-only register update.
mbed_official 146:f64d43ff0c18 192 * 1 means enable watchdog write-once-only register update.
mbed_official 146:f64d43ff0c18 193 */
mbed_official 146:f64d43ff0c18 194 void wdog_hal_configure_register_update(bool isEnabled);
mbed_official 146:f64d43ff0c18 195
mbed_official 146:f64d43ff0c18 196 /*!
mbed_official 146:f64d43ff0c18 197 * @brief Check whether register update is enabled.
mbed_official 146:f64d43ff0c18 198 *
mbed_official 146:f64d43ff0c18 199 * This function is used to check whether the WDOG register update is enabled.
mbed_official 146:f64d43ff0c18 200 *
mbed_official 146:f64d43ff0c18 201 * @return 0 means register update is disabled, 1 means register update is enabled.
mbed_official 146:f64d43ff0c18 202 */
mbed_official 146:f64d43ff0c18 203 static inline bool wdog_hal_is_register_update_enabled(void)
mbed_official 146:f64d43ff0c18 204 {
mbed_official 146:f64d43ff0c18 205 return BR_WDOG_STCTRLH_ALLOWUPDATE;
mbed_official 146:f64d43ff0c18 206 }
mbed_official 146:f64d43ff0c18 207
mbed_official 146:f64d43ff0c18 208 /*!
mbed_official 146:f64d43ff0c18 209 * @brief Set whether watchdog is working while cpu is in debug mode.
mbed_official 146:f64d43ff0c18 210 *
mbed_official 146:f64d43ff0c18 211 * This function is used to configure whether the WDOG is enabled in CPU debug mode.
mbed_official 146:f64d43ff0c18 212 * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable
mbed_official 146:f64d43ff0c18 213 * function, so this function must be called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 214 *
mbed_official 146:f64d43ff0c18 215 * @param isEnabled 0 means watchdog is disabled in CPU debug mode.
mbed_official 146:f64d43ff0c18 216 * 1 means watchdog is enabled in CPU debug mode.
mbed_official 146:f64d43ff0c18 217 */
mbed_official 146:f64d43ff0c18 218 void wdog_hal_configure_enabled_in_cpu_debug_mode(bool isEnabled);
mbed_official 146:f64d43ff0c18 219
mbed_official 146:f64d43ff0c18 220 /*!
mbed_official 146:f64d43ff0c18 221 * @brief Check whether WDOG works while in CPU debug mode.
mbed_official 146:f64d43ff0c18 222 *
mbed_official 146:f64d43ff0c18 223 * This function is used to check whether WDOG works in CPU debug mode.
mbed_official 146:f64d43ff0c18 224 *
mbed_official 146:f64d43ff0c18 225 * @return 0 means not work while in cpu debug mode, 1 means works while in cpu debug mode.
mbed_official 146:f64d43ff0c18 226 */
mbed_official 146:f64d43ff0c18 227 static inline bool wdog_hal_is_cpu_debug_mode_enabled(void)
mbed_official 146:f64d43ff0c18 228 {
mbed_official 146:f64d43ff0c18 229 return BR_WDOG_STCTRLH_DBGEN;
mbed_official 146:f64d43ff0c18 230 }
mbed_official 146:f64d43ff0c18 231
mbed_official 146:f64d43ff0c18 232 /*!
mbed_official 146:f64d43ff0c18 233 * @brief Set whether watchdog is working while cpu is in stop mode.
mbed_official 146:f64d43ff0c18 234 *
mbed_official 146:f64d43ff0c18 235 * This function is used to configure whether the WDOG is enabled in CPU stop mode.
mbed_official 146:f64d43ff0c18 236 * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable
mbed_official 146:f64d43ff0c18 237 * function, so this function must be called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 238 *
mbed_official 146:f64d43ff0c18 239 * @param isEnabled 0 means watchdog is disabled in CPU stop mode.
mbed_official 146:f64d43ff0c18 240 * 1 means watchdog is enabled in CPU stop mode.
mbed_official 146:f64d43ff0c18 241 */
mbed_official 146:f64d43ff0c18 242 void wdog_hal_configure_enabled_in_cpu_stop_mode(bool isEnabled);
mbed_official 146:f64d43ff0c18 243
mbed_official 146:f64d43ff0c18 244 /*!
mbed_official 146:f64d43ff0c18 245 * @brief Check whether WDOG works while in CPU stop mode.
mbed_official 146:f64d43ff0c18 246 *
mbed_official 146:f64d43ff0c18 247 * This function is used to check whether WDOG works in CPU stop mode.
mbed_official 146:f64d43ff0c18 248 *
mbed_official 146:f64d43ff0c18 249 * @return 0 means not work while in CPU stop mode, 1 means works while in CPU stop mode.
mbed_official 146:f64d43ff0c18 250 */
mbed_official 146:f64d43ff0c18 251 static inline bool wdog_hal_is_cpu_stop_mode_enabled(void)
mbed_official 146:f64d43ff0c18 252 {
mbed_official 146:f64d43ff0c18 253 return BR_WDOG_STCTRLH_STOPEN;
mbed_official 146:f64d43ff0c18 254 }
mbed_official 146:f64d43ff0c18 255
mbed_official 146:f64d43ff0c18 256 /*!
mbed_official 146:f64d43ff0c18 257 * @brief Set whether watchdog is working while CPU is in wait mode.
mbed_official 146:f64d43ff0c18 258 *
mbed_official 146:f64d43ff0c18 259 * This function is used to configure whether the WDOG is enabled in CPU wait mode.
mbed_official 146:f64d43ff0c18 260 * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable
mbed_official 146:f64d43ff0c18 261 * function, so this function must be called before wdog_hal_enable is called.
mbed_official 146:f64d43ff0c18 262 *
mbed_official 146:f64d43ff0c18 263 * @param isEnabled 0 means watchdog is disabled in CPU wait mode.
mbed_official 146:f64d43ff0c18 264 * 1 means watchdog is enabled in CPU wait mode.
mbed_official 146:f64d43ff0c18 265 */
mbed_official 146:f64d43ff0c18 266 void wdog_hal_configure_enabled_in_cpu_wait_mode(bool isEnabled);
mbed_official 146:f64d43ff0c18 267
mbed_official 146:f64d43ff0c18 268 /*!
mbed_official 146:f64d43ff0c18 269 * @brief Check whether WDOG works while in CPU wait mode.
mbed_official 146:f64d43ff0c18 270 *
mbed_official 146:f64d43ff0c18 271 * This function is used to check whether WDOG works in CPU wait mode.
mbed_official 146:f64d43ff0c18 272 *
mbed_official 146:f64d43ff0c18 273 * @return 0 means not work while in CPU wait mode, 1 means works while in CPU wait mode.
mbed_official 146:f64d43ff0c18 274 */
mbed_official 146:f64d43ff0c18 275
mbed_official 146:f64d43ff0c18 276 static inline bool wdog_hal_is_cpu_wait_mode_enabled(void)
mbed_official 146:f64d43ff0c18 277 {
mbed_official 146:f64d43ff0c18 278 return BR_WDOG_STCTRLH_WAITEN;
mbed_official 146:f64d43ff0c18 279 }
mbed_official 146:f64d43ff0c18 280
mbed_official 146:f64d43ff0c18 281 /*!
mbed_official 146:f64d43ff0c18 282 * @brief Get watchdog interrupt status.
mbed_official 146:f64d43ff0c18 283 *
mbed_official 146:f64d43ff0c18 284 * This function is used to get the WDOG interrupt flag.
mbed_official 146:f64d43ff0c18 285 *
mbed_official 146:f64d43ff0c18 286 * @return Watchdog interrupt status, 0 means interrupt not asserted, 1 means interrupt asserted.
mbed_official 146:f64d43ff0c18 287 */
mbed_official 146:f64d43ff0c18 288 static inline bool wdog_hal_is_interrupt_asserted(void)
mbed_official 146:f64d43ff0c18 289 {
mbed_official 146:f64d43ff0c18 290 return BR_WDOG_STCTRLL_INTFLG;
mbed_official 146:f64d43ff0c18 291 }
mbed_official 146:f64d43ff0c18 292
mbed_official 146:f64d43ff0c18 293 /*!
mbed_official 146:f64d43ff0c18 294 * @brief Clear watchdog interrupt flag.
mbed_official 146:f64d43ff0c18 295 *
mbed_official 146:f64d43ff0c18 296 * This function is used to clear the WDOG interrupt flag.
mbed_official 146:f64d43ff0c18 297 *
mbed_official 146:f64d43ff0c18 298 */
mbed_official 146:f64d43ff0c18 299 static inline void wdog_hal_clear_interrupt_flag(void)
mbed_official 146:f64d43ff0c18 300 {
mbed_official 146:f64d43ff0c18 301 BW_WDOG_STCTRLL_INTFLG(1);
mbed_official 146:f64d43ff0c18 302 }
mbed_official 146:f64d43ff0c18 303
mbed_official 146:f64d43ff0c18 304 /*!
mbed_official 146:f64d43ff0c18 305 * @brief set watchdog timeout value.
mbed_official 146:f64d43ff0c18 306 *
mbed_official 146:f64d43ff0c18 307 * This function is used to set the WDOG_TOVAL value.
mbed_official 146:f64d43ff0c18 308 *
mbed_official 146:f64d43ff0c18 309 * @param timeoutCount watchdog timeout value, count of watchdog clock tick.
mbed_official 146:f64d43ff0c18 310 */
mbed_official 146:f64d43ff0c18 311 static inline void wdog_hal_set_timeout_value(uint32_t timeoutCount)
mbed_official 146:f64d43ff0c18 312 {
mbed_official 146:f64d43ff0c18 313 BW_WDOG_TOVALH_TOVALHIGH((uint16_t)((timeoutCount >> 16U) & 0xFFFFU));
mbed_official 146:f64d43ff0c18 314 BW_WDOG_TOVALL_TOVALLOW((uint16_t)((timeoutCount) & 0xFFFFU));
mbed_official 146:f64d43ff0c18 315 }
mbed_official 146:f64d43ff0c18 316
mbed_official 146:f64d43ff0c18 317 /*!
mbed_official 146:f64d43ff0c18 318 * @brief Get watchdog timeout value.
mbed_official 146:f64d43ff0c18 319 *
mbed_official 146:f64d43ff0c18 320 * This function is used to Get the WDOG_TOVAL value.
mbed_official 146:f64d43ff0c18 321 *
mbed_official 146:f64d43ff0c18 322 * @return value of register WDOG_TOVAL.
mbed_official 146:f64d43ff0c18 323 */
mbed_official 146:f64d43ff0c18 324 static inline uint32_t wdog_hal_get_timeout_value(void)
mbed_official 146:f64d43ff0c18 325 {
mbed_official 146:f64d43ff0c18 326 return (uint32_t)((((uint32_t)(BR_WDOG_TOVALH_TOVALHIGH)) << 16U) | (BR_WDOG_TOVALL_TOVALLOW));
mbed_official 146:f64d43ff0c18 327 }
mbed_official 146:f64d43ff0c18 328
mbed_official 146:f64d43ff0c18 329 /*!
mbed_official 146:f64d43ff0c18 330 * @brief Get watchdog timer output.
mbed_official 146:f64d43ff0c18 331 *
mbed_official 146:f64d43ff0c18 332 * This function is used to get the WDOG_TMROUT value.
mbed_official 146:f64d43ff0c18 333 *
mbed_official 146:f64d43ff0c18 334 * @return Current value of watchdog timer counter.
mbed_official 146:f64d43ff0c18 335 */
mbed_official 146:f64d43ff0c18 336 static inline uint32_t wdog_hal_get_timer_output(void)
mbed_official 146:f64d43ff0c18 337 {
mbed_official 146:f64d43ff0c18 338 return (uint32_t)((((uint32_t)(BR_WDOG_TMROUTH_TIMEROUTHIGH)) << 16U) | (BR_WDOG_TMROUTL_TIMEROUTLOW));
mbed_official 146:f64d43ff0c18 339 }
mbed_official 146:f64d43ff0c18 340
mbed_official 146:f64d43ff0c18 341 /*!
mbed_official 146:f64d43ff0c18 342 * @brief Set watchdog clock prescaler.
mbed_official 146:f64d43ff0c18 343 *
mbed_official 146:f64d43ff0c18 344 * This function is used to set the WDOG clock proscaler.
mbed_official 146:f64d43ff0c18 345 *
mbed_official 146:f64d43ff0c18 346 * @param clockPrescaler watchdog clock prescaler, see wdog_clock_prescaler_t.
mbed_official 146:f64d43ff0c18 347 */
mbed_official 146:f64d43ff0c18 348 static inline void wdog_hal_set_clock_prescaler(wdog_clock_prescaler_t clockPrescaler)
mbed_official 146:f64d43ff0c18 349 {
mbed_official 146:f64d43ff0c18 350 BW_WDOG_PRESC_PRESCVAL(clockPrescaler);
mbed_official 146:f64d43ff0c18 351 }
mbed_official 146:f64d43ff0c18 352
mbed_official 146:f64d43ff0c18 353 /*!
mbed_official 146:f64d43ff0c18 354 * @brief Get watchdog clock prescaler.
mbed_official 146:f64d43ff0c18 355 *
mbed_official 146:f64d43ff0c18 356 * This function is used to get the WDOG clock prescaler.
mbed_official 146:f64d43ff0c18 357 *
mbed_official 146:f64d43ff0c18 358 * @return WDOG clock prescaler.
mbed_official 146:f64d43ff0c18 359 */
mbed_official 146:f64d43ff0c18 360 static inline wdog_clock_prescaler_t wdog_hal_get_clock_prescaler(void)
mbed_official 146:f64d43ff0c18 361 {
mbed_official 146:f64d43ff0c18 362 return (wdog_clock_prescaler_t)BR_WDOG_PRESC_PRESCVAL;
mbed_official 146:f64d43ff0c18 363 }
mbed_official 146:f64d43ff0c18 364
mbed_official 146:f64d43ff0c18 365 /*!
mbed_official 146:f64d43ff0c18 366 * @brief Set watchdog window value.
mbed_official 146:f64d43ff0c18 367 *
mbed_official 146:f64d43ff0c18 368 * This function is used to set the WDOG_WIN value.
mbed_official 146:f64d43ff0c18 369 *
mbed_official 146:f64d43ff0c18 370 * @param windowValue watchdog window value.
mbed_official 146:f64d43ff0c18 371 */
mbed_official 146:f64d43ff0c18 372 static inline void wdog_hal_set_window_value(uint32_t windowValue)
mbed_official 146:f64d43ff0c18 373 {
mbed_official 146:f64d43ff0c18 374 BW_WDOG_WINH_WINHIGH((uint16_t)((windowValue>>16U) & 0xFFFFU));
mbed_official 146:f64d43ff0c18 375 BW_WDOG_WINL_WINLOW((uint16_t)((windowValue) & 0xFFFFU));
mbed_official 146:f64d43ff0c18 376 }
mbed_official 146:f64d43ff0c18 377
mbed_official 146:f64d43ff0c18 378 /*!
mbed_official 146:f64d43ff0c18 379 * @brief Get watchdog window value.
mbed_official 146:f64d43ff0c18 380 *
mbed_official 146:f64d43ff0c18 381 * This function is used to Get the WDOG_WIN value.
mbed_official 146:f64d43ff0c18 382 *
mbed_official 146:f64d43ff0c18 383 * @return watchdog window value.
mbed_official 146:f64d43ff0c18 384 */
mbed_official 146:f64d43ff0c18 385 static inline uint32_t wdog_hal_get_window_value(void)
mbed_official 146:f64d43ff0c18 386 {
mbed_official 146:f64d43ff0c18 387 return (uint32_t)((((uint32_t)(BR_WDOG_WINH_WINHIGH)) << 16U) | (BR_WDOG_WINL_WINLOW));
mbed_official 146:f64d43ff0c18 388 }
mbed_official 146:f64d43ff0c18 389
mbed_official 146:f64d43ff0c18 390 /*!
mbed_official 146:f64d43ff0c18 391 * @brief Unlock watchdog register written.
mbed_official 146:f64d43ff0c18 392 *
mbed_official 146:f64d43ff0c18 393 * This function is used to unlock the WDOG register written.
mbed_official 146:f64d43ff0c18 394 * This function must be called before any configuration is set because watchdog register
mbed_official 146:f64d43ff0c18 395 * will be locked automatically after a WCT(256 bus cycles).
mbed_official 146:f64d43ff0c18 396 *
mbed_official 146:f64d43ff0c18 397 */
mbed_official 146:f64d43ff0c18 398 static inline void wdog_hal_unlock(void)
mbed_official 146:f64d43ff0c18 399 {
mbed_official 146:f64d43ff0c18 400 BW_WDOG_UNLOCK_WDOGUNLOCK(0xC520U);
mbed_official 146:f64d43ff0c18 401 BW_WDOG_UNLOCK_WDOGUNLOCK(0xD928U);
mbed_official 146:f64d43ff0c18 402 }
mbed_official 146:f64d43ff0c18 403
mbed_official 146:f64d43ff0c18 404 /*!
mbed_official 146:f64d43ff0c18 405 * @brief Refresh watchdog timer.
mbed_official 146:f64d43ff0c18 406 *
mbed_official 146:f64d43ff0c18 407 * This function is used to feed the WDOG.
mbed_official 146:f64d43ff0c18 408 * This function should be called before watchdog timer is in timeout, otherwise a RESET
mbed_official 146:f64d43ff0c18 409 * will assert.
mbed_official 146:f64d43ff0c18 410 *
mbed_official 146:f64d43ff0c18 411 */
mbed_official 146:f64d43ff0c18 412 static inline void wdog_hal_refresh(void)
mbed_official 146:f64d43ff0c18 413 {
mbed_official 146:f64d43ff0c18 414 BW_WDOG_REFRESH_WDOGREFRESH(0xA602U);
mbed_official 146:f64d43ff0c18 415 BW_WDOG_REFRESH_WDOGREFRESH(0xB480U);
mbed_official 146:f64d43ff0c18 416 }
mbed_official 146:f64d43ff0c18 417
mbed_official 146:f64d43ff0c18 418 /*!
mbed_official 146:f64d43ff0c18 419 * @brief Reset chip using watchdog.
mbed_official 146:f64d43ff0c18 420 *
mbed_official 146:f64d43ff0c18 421 * This function is used to reset chip using WDOG.
mbed_official 146:f64d43ff0c18 422 *
mbed_official 146:f64d43ff0c18 423 */
mbed_official 146:f64d43ff0c18 424 static inline void wdog_hal_reset_chip(void)
mbed_official 146:f64d43ff0c18 425 {
mbed_official 146:f64d43ff0c18 426 BW_WDOG_REFRESH_WDOGREFRESH(0xA602U);
mbed_official 146:f64d43ff0c18 427 BW_WDOG_REFRESH_WDOGREFRESH(0);
mbed_official 146:f64d43ff0c18 428 while(1)
mbed_official 146:f64d43ff0c18 429 {
mbed_official 146:f64d43ff0c18 430 }
mbed_official 146:f64d43ff0c18 431 }
mbed_official 146:f64d43ff0c18 432
mbed_official 146:f64d43ff0c18 433 /*!
mbed_official 146:f64d43ff0c18 434 * @brief Get chip reset count that was reset by watchdog.
mbed_official 146:f64d43ff0c18 435 *
mbed_official 146:f64d43ff0c18 436 * This function is used to get the value of WDOG_RSTCNT.
mbed_official 146:f64d43ff0c18 437 *
mbed_official 146:f64d43ff0c18 438 * @return Chip reset count that was reset by watchdog.
mbed_official 146:f64d43ff0c18 439 */
mbed_official 146:f64d43ff0c18 440 static inline uint32_t wdog_hal_get_reset_count(void)
mbed_official 146:f64d43ff0c18 441 {
mbed_official 146:f64d43ff0c18 442 return BR_WDOG_RSTCNT_RSTCNT;
mbed_official 146:f64d43ff0c18 443 }
mbed_official 146:f64d43ff0c18 444
mbed_official 146:f64d43ff0c18 445 /*!
mbed_official 146:f64d43ff0c18 446 * @brief Clear chip reset count that was reset by watchdog.
mbed_official 146:f64d43ff0c18 447 *
mbed_official 146:f64d43ff0c18 448 * This function is used to clear the WDOG_RSTCNT.
mbed_official 146:f64d43ff0c18 449 *
mbed_official 146:f64d43ff0c18 450 */
mbed_official 146:f64d43ff0c18 451 static inline void wdog_hal_clear_reset_count(void)
mbed_official 146:f64d43ff0c18 452 {
mbed_official 146:f64d43ff0c18 453 BW_WDOG_RSTCNT_RSTCNT(0xFFFFU);
mbed_official 146:f64d43ff0c18 454 }
mbed_official 146:f64d43ff0c18 455 /*@}*/
mbed_official 146:f64d43ff0c18 456
mbed_official 146:f64d43ff0c18 457 #if defined(__cplusplus)
mbed_official 146:f64d43ff0c18 458 }
mbed_official 146:f64d43ff0c18 459 #endif
mbed_official 146:f64d43ff0c18 460
mbed_official 146:f64d43ff0c18 461 /*! @}*/
mbed_official 146:f64d43ff0c18 462
mbed_official 146:f64d43ff0c18 463 #endif /* __FSL_WDOG_HAL_H__*/
mbed_official 146:f64d43ff0c18 464 /*******************************************************************************
mbed_official 146:f64d43ff0c18 465 * EOF
mbed_official 146:f64d43ff0c18 466 *******************************************************************************/
mbed_official 146:f64d43ff0c18 467