mbed(SerialHalfDuplex入り)
Fork of mbed by
TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/wdog/fsl_wdog_hal.h@82:6473597d706e, 2014-04-07 (annotated)
- Committer:
- bogdanm
- Date:
- Mon Apr 07 18:28:36 2014 +0100
- Revision:
- 82:6473597d706e
- Child:
- 90:cb3d968589d8
Release 82 of the mbed library
Main changes:
- support for K64F
- Revisited Nordic code structure
- Test infrastructure improvements
- various bug fixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 82:6473597d706e | 1 | /* |
bogdanm | 82:6473597d706e | 2 | * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc. |
bogdanm | 82:6473597d706e | 3 | * All rights reserved. |
bogdanm | 82:6473597d706e | 4 | * |
bogdanm | 82:6473597d706e | 5 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 82:6473597d706e | 6 | * are permitted provided that the following conditions are met: |
bogdanm | 82:6473597d706e | 7 | * |
bogdanm | 82:6473597d706e | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
bogdanm | 82:6473597d706e | 9 | * of conditions and the following disclaimer. |
bogdanm | 82:6473597d706e | 10 | * |
bogdanm | 82:6473597d706e | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
bogdanm | 82:6473597d706e | 12 | * list of conditions and the following disclaimer in the documentation and/or |
bogdanm | 82:6473597d706e | 13 | * other materials provided with the distribution. |
bogdanm | 82:6473597d706e | 14 | * |
bogdanm | 82:6473597d706e | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
bogdanm | 82:6473597d706e | 16 | * contributors may be used to endorse or promote products derived from this |
bogdanm | 82:6473597d706e | 17 | * software without specific prior written permission. |
bogdanm | 82:6473597d706e | 18 | * |
bogdanm | 82:6473597d706e | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
bogdanm | 82:6473597d706e | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
bogdanm | 82:6473597d706e | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 82:6473597d706e | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
bogdanm | 82:6473597d706e | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
bogdanm | 82:6473597d706e | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
bogdanm | 82:6473597d706e | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
bogdanm | 82:6473597d706e | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
bogdanm | 82:6473597d706e | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
bogdanm | 82:6473597d706e | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 82:6473597d706e | 29 | */ |
bogdanm | 82:6473597d706e | 30 | #ifndef __FSL_WDOG_HAL_H__ |
bogdanm | 82:6473597d706e | 31 | #define __FSL_WDOG_HAL_H__ |
bogdanm | 82:6473597d706e | 32 | |
bogdanm | 82:6473597d706e | 33 | #include <assert.h> |
bogdanm | 82:6473597d706e | 34 | #include <stdint.h> |
bogdanm | 82:6473597d706e | 35 | #include <stdbool.h> |
bogdanm | 82:6473597d706e | 36 | #include "fsl_wdog_features.h" |
bogdanm | 82:6473597d706e | 37 | #include "fsl_device_registers.h" |
bogdanm | 82:6473597d706e | 38 | |
bogdanm | 82:6473597d706e | 39 | /*! |
bogdanm | 82:6473597d706e | 40 | * @addtogroup wdog_hal |
bogdanm | 82:6473597d706e | 41 | * @{ |
bogdanm | 82:6473597d706e | 42 | */ |
bogdanm | 82:6473597d706e | 43 | |
bogdanm | 82:6473597d706e | 44 | /******************************************************************************* |
bogdanm | 82:6473597d706e | 45 | * Definitions |
bogdanm | 82:6473597d706e | 46 | *******************************************************************************/ |
bogdanm | 82:6473597d706e | 47 | |
bogdanm | 82:6473597d706e | 48 | /*! @brief Watchdog ISR callback function type*/ |
bogdanm | 82:6473597d706e | 49 | typedef void (*wdog_isr_callback_t)(void); |
bogdanm | 82:6473597d706e | 50 | |
bogdanm | 82:6473597d706e | 51 | /*! @brief Watchdog clock source selection.*/ |
bogdanm | 82:6473597d706e | 52 | typedef enum _wdog_clock_source { |
bogdanm | 82:6473597d706e | 53 | kWdogDedicatedClock = 0, /*!< Dedicated clock source (LPO Oscillator),1K HZ.*/ |
bogdanm | 82:6473597d706e | 54 | kWdogAlternateClock = 1 /*!< Alternate clock source, Bus clock.*/ |
bogdanm | 82:6473597d706e | 55 | } wdog_clock_source_t; |
bogdanm | 82:6473597d706e | 56 | |
bogdanm | 82:6473597d706e | 57 | /*! @brief Define the selection of the clock prescaler*/ |
bogdanm | 82:6473597d706e | 58 | typedef enum _wdog_clock_prescaler { |
bogdanm | 82:6473597d706e | 59 | kWdogClockPrescaler1 = 0, /*!< Divide 1, default*/ |
bogdanm | 82:6473597d706e | 60 | kWdogClockPrescaler2 = 1, /*!< Divide 2*/ |
bogdanm | 82:6473597d706e | 61 | kWdogClockPrescaler3 = 2, /*!< Divide 3*/ |
bogdanm | 82:6473597d706e | 62 | kWdogClockPrescaler4 = 3, /*!< Divide 4*/ |
bogdanm | 82:6473597d706e | 63 | kWdogClockPrescaler5 = 4, /*!< Divide 5*/ |
bogdanm | 82:6473597d706e | 64 | kWdogClockPrescaler6 = 5, /*!< Divide 6*/ |
bogdanm | 82:6473597d706e | 65 | kWdogClockPrescaler7 = 6, /*!< Divide 7*/ |
bogdanm | 82:6473597d706e | 66 | kWdogClockPrescaler8 = 7, /*!< Divide 8*/ |
bogdanm | 82:6473597d706e | 67 | } wdog_clock_prescaler_t; |
bogdanm | 82:6473597d706e | 68 | |
bogdanm | 82:6473597d706e | 69 | /******************************************************************************* |
bogdanm | 82:6473597d706e | 70 | * API |
bogdanm | 82:6473597d706e | 71 | *******************************************************************************/ |
bogdanm | 82:6473597d706e | 72 | |
bogdanm | 82:6473597d706e | 73 | #if defined(__cplusplus) |
bogdanm | 82:6473597d706e | 74 | extern "C" { |
bogdanm | 82:6473597d706e | 75 | #endif |
bogdanm | 82:6473597d706e | 76 | |
bogdanm | 82:6473597d706e | 77 | /*! |
bogdanm | 82:6473597d706e | 78 | * @name Watchdog HAL. |
bogdanm | 82:6473597d706e | 79 | * @{ |
bogdanm | 82:6473597d706e | 80 | */ |
bogdanm | 82:6473597d706e | 81 | |
bogdanm | 82:6473597d706e | 82 | /*! |
bogdanm | 82:6473597d706e | 83 | * @brief Enable watchdog module. |
bogdanm | 82:6473597d706e | 84 | * |
bogdanm | 82:6473597d706e | 85 | * This function is used to enable the WDOG and must be called after all |
bogdanm | 82:6473597d706e | 86 | * necessary configure have been set. |
bogdanm | 82:6473597d706e | 87 | * |
bogdanm | 82:6473597d706e | 88 | */ |
bogdanm | 82:6473597d706e | 89 | void wdog_hal_enable(void); |
bogdanm | 82:6473597d706e | 90 | |
bogdanm | 82:6473597d706e | 91 | /*! |
bogdanm | 82:6473597d706e | 92 | * @brief Disable watchdog module. |
bogdanm | 82:6473597d706e | 93 | * |
bogdanm | 82:6473597d706e | 94 | * This function is used to disable the WDOG. |
bogdanm | 82:6473597d706e | 95 | * |
bogdanm | 82:6473597d706e | 96 | */ |
bogdanm | 82:6473597d706e | 97 | void wdog_hal_disable(void); |
bogdanm | 82:6473597d706e | 98 | |
bogdanm | 82:6473597d706e | 99 | /*! |
bogdanm | 82:6473597d706e | 100 | * @brief Check whether WDOG is enabled. |
bogdanm | 82:6473597d706e | 101 | * |
bogdanm | 82:6473597d706e | 102 | * This function is used check whether WDOG is enabled. |
bogdanm | 82:6473597d706e | 103 | * |
bogdanm | 82:6473597d706e | 104 | * @return 0 means WDOG is disabled, 1 means WODG is enabled. |
bogdanm | 82:6473597d706e | 105 | * |
bogdanm | 82:6473597d706e | 106 | */ |
bogdanm | 82:6473597d706e | 107 | static inline bool wdog_hal_is_enabled(void) |
bogdanm | 82:6473597d706e | 108 | { |
bogdanm | 82:6473597d706e | 109 | return BR_WDOG_STCTRLH_WDOGEN; |
bogdanm | 82:6473597d706e | 110 | } |
bogdanm | 82:6473597d706e | 111 | |
bogdanm | 82:6473597d706e | 112 | /*! |
bogdanm | 82:6473597d706e | 113 | * @brief Enable and disable watchdog interrupt. |
bogdanm | 82:6473597d706e | 114 | * |
bogdanm | 82:6473597d706e | 115 | * This function is used to configure the WDOG interrupt. |
bogdanm | 82:6473597d706e | 116 | * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable |
bogdanm | 82:6473597d706e | 117 | * function, so this function must be called before wdog_hal_enable is called. |
bogdanm | 82:6473597d706e | 118 | * |
bogdanm | 82:6473597d706e | 119 | * @param isEnabled 0 means disable watchdog interrupt. 1 means enable watchdog interrupt. |
bogdanm | 82:6473597d706e | 120 | */ |
bogdanm | 82:6473597d706e | 121 | void wdog_hal_configure_interrupt(bool isEnabled); |
bogdanm | 82:6473597d706e | 122 | |
bogdanm | 82:6473597d706e | 123 | /*! |
bogdanm | 82:6473597d706e | 124 | * @brief Check whether WDOG interrupt is enabled. |
bogdanm | 82:6473597d706e | 125 | * |
bogdanm | 82:6473597d706e | 126 | * This function is used to check whether the WDOG interrupt is enabled. |
bogdanm | 82:6473597d706e | 127 | * |
bogdanm | 82:6473597d706e | 128 | * @return 0 means interrupt is disabled, 1 means interrupt is enabled. |
bogdanm | 82:6473597d706e | 129 | */ |
bogdanm | 82:6473597d706e | 130 | static inline bool wdog_hal_is_interrupt_enabled(void) |
bogdanm | 82:6473597d706e | 131 | { |
bogdanm | 82:6473597d706e | 132 | return BR_WDOG_STCTRLH_IRQRSTEN; |
bogdanm | 82:6473597d706e | 133 | } |
bogdanm | 82:6473597d706e | 134 | |
bogdanm | 82:6473597d706e | 135 | /*! |
bogdanm | 82:6473597d706e | 136 | * @brief set watchdog clock Source. |
bogdanm | 82:6473597d706e | 137 | * |
bogdanm | 82:6473597d706e | 138 | * This function is used to set the WDOG clock source. There are two clock sources that can be used, |
bogdanm | 82:6473597d706e | 139 | * the LPO clock and the bus clock. |
bogdanm | 82:6473597d706e | 140 | * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable |
bogdanm | 82:6473597d706e | 141 | * function, so this function must be called before wdog_hal_enable is called. |
bogdanm | 82:6473597d706e | 142 | * |
bogdanm | 82:6473597d706e | 143 | * @param clockSource watchdog clock source, see wdog_clock_source_t. |
bogdanm | 82:6473597d706e | 144 | */ |
bogdanm | 82:6473597d706e | 145 | void wdog_hal_set_clock_source(wdog_clock_source_t clockSource); |
bogdanm | 82:6473597d706e | 146 | |
bogdanm | 82:6473597d706e | 147 | /*! |
bogdanm | 82:6473597d706e | 148 | * @brief Get watchdog clock Source. |
bogdanm | 82:6473597d706e | 149 | * |
bogdanm | 82:6473597d706e | 150 | * This function is used to get the WDOG clock source. There are two clock sources that can be used, |
bogdanm | 82:6473597d706e | 151 | * the LPO clock and the bus clock. |
bogdanm | 82:6473597d706e | 152 | * |
bogdanm | 82:6473597d706e | 153 | * @return watchdog clock source, see wdog_clock_source_t. |
bogdanm | 82:6473597d706e | 154 | */ |
bogdanm | 82:6473597d706e | 155 | static inline wdog_clock_source_t wdog_hal_get_clock_source(void) |
bogdanm | 82:6473597d706e | 156 | { |
bogdanm | 82:6473597d706e | 157 | return (wdog_clock_source_t)BR_WDOG_STCTRLH_CLKSRC; |
bogdanm | 82:6473597d706e | 158 | } |
bogdanm | 82:6473597d706e | 159 | |
bogdanm | 82:6473597d706e | 160 | /*! |
bogdanm | 82:6473597d706e | 161 | * @brief Enable and disable watchdog window mode. |
bogdanm | 82:6473597d706e | 162 | * |
bogdanm | 82:6473597d706e | 163 | * This function is used to configure the WDOG window mode. |
bogdanm | 82:6473597d706e | 164 | * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable |
bogdanm | 82:6473597d706e | 165 | * function, so this function must be called before wdog_hal_enable is called. |
bogdanm | 82:6473597d706e | 166 | * |
bogdanm | 82:6473597d706e | 167 | * @param isEnabled 0 means disable watchdog window mode. 1 means enable watchdog window mode. |
bogdanm | 82:6473597d706e | 168 | */ |
bogdanm | 82:6473597d706e | 169 | void wdog_hal_configure_window_mode(bool isEnabled); |
bogdanm | 82:6473597d706e | 170 | |
bogdanm | 82:6473597d706e | 171 | /*! |
bogdanm | 82:6473597d706e | 172 | * @brief Check whether window mode is enabled. |
bogdanm | 82:6473597d706e | 173 | * |
bogdanm | 82:6473597d706e | 174 | * This function is used to check whether the WDOG window mode is enabled. |
bogdanm | 82:6473597d706e | 175 | * |
bogdanm | 82:6473597d706e | 176 | * @return 0 means window mode is disabled, 1 means window mode is enabled. |
bogdanm | 82:6473597d706e | 177 | */ |
bogdanm | 82:6473597d706e | 178 | static inline bool wdog_hal_is_window_mode_enabled(void) |
bogdanm | 82:6473597d706e | 179 | { |
bogdanm | 82:6473597d706e | 180 | return BR_WDOG_STCTRLH_WINEN; |
bogdanm | 82:6473597d706e | 181 | } |
bogdanm | 82:6473597d706e | 182 | |
bogdanm | 82:6473597d706e | 183 | /*! |
bogdanm | 82:6473597d706e | 184 | * @brief Enable and disable watchdog write-once-only register update. |
bogdanm | 82:6473597d706e | 185 | * |
bogdanm | 82:6473597d706e | 186 | * This function is used to configure the WDOG register update feature. If disabled, it means that |
bogdanm | 82:6473597d706e | 187 | * all WDOG registers will never be written again unless Power On Reset. |
bogdanm | 82:6473597d706e | 188 | * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable |
bogdanm | 82:6473597d706e | 189 | * function, so this function must be called before wdog_hal_enable is called. |
bogdanm | 82:6473597d706e | 190 | * |
bogdanm | 82:6473597d706e | 191 | * @param isEnabled 0 means disable watchdog write-once-only register update. |
bogdanm | 82:6473597d706e | 192 | * 1 means enable watchdog write-once-only register update. |
bogdanm | 82:6473597d706e | 193 | */ |
bogdanm | 82:6473597d706e | 194 | void wdog_hal_configure_register_update(bool isEnabled); |
bogdanm | 82:6473597d706e | 195 | |
bogdanm | 82:6473597d706e | 196 | /*! |
bogdanm | 82:6473597d706e | 197 | * @brief Check whether register update is enabled. |
bogdanm | 82:6473597d706e | 198 | * |
bogdanm | 82:6473597d706e | 199 | * This function is used to check whether the WDOG register update is enabled. |
bogdanm | 82:6473597d706e | 200 | * |
bogdanm | 82:6473597d706e | 201 | * @return 0 means register update is disabled, 1 means register update is enabled. |
bogdanm | 82:6473597d706e | 202 | */ |
bogdanm | 82:6473597d706e | 203 | static inline bool wdog_hal_is_register_update_enabled(void) |
bogdanm | 82:6473597d706e | 204 | { |
bogdanm | 82:6473597d706e | 205 | return BR_WDOG_STCTRLH_ALLOWUPDATE; |
bogdanm | 82:6473597d706e | 206 | } |
bogdanm | 82:6473597d706e | 207 | |
bogdanm | 82:6473597d706e | 208 | /*! |
bogdanm | 82:6473597d706e | 209 | * @brief Set whether watchdog is working while cpu is in debug mode. |
bogdanm | 82:6473597d706e | 210 | * |
bogdanm | 82:6473597d706e | 211 | * This function is used to configure whether the WDOG is enabled in CPU debug mode. |
bogdanm | 82:6473597d706e | 212 | * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable |
bogdanm | 82:6473597d706e | 213 | * function, so this function must be called before wdog_hal_enable is called. |
bogdanm | 82:6473597d706e | 214 | * |
bogdanm | 82:6473597d706e | 215 | * @param isEnabled 0 means watchdog is disabled in CPU debug mode. |
bogdanm | 82:6473597d706e | 216 | * 1 means watchdog is enabled in CPU debug mode. |
bogdanm | 82:6473597d706e | 217 | */ |
bogdanm | 82:6473597d706e | 218 | void wdog_hal_configure_enabled_in_cpu_debug_mode(bool isEnabled); |
bogdanm | 82:6473597d706e | 219 | |
bogdanm | 82:6473597d706e | 220 | /*! |
bogdanm | 82:6473597d706e | 221 | * @brief Check whether WDOG works while in CPU debug mode. |
bogdanm | 82:6473597d706e | 222 | * |
bogdanm | 82:6473597d706e | 223 | * This function is used to check whether WDOG works in CPU debug mode. |
bogdanm | 82:6473597d706e | 224 | * |
bogdanm | 82:6473597d706e | 225 | * @return 0 means not work while in cpu debug mode, 1 means works while in cpu debug mode. |
bogdanm | 82:6473597d706e | 226 | */ |
bogdanm | 82:6473597d706e | 227 | static inline bool wdog_hal_is_cpu_debug_mode_enabled(void) |
bogdanm | 82:6473597d706e | 228 | { |
bogdanm | 82:6473597d706e | 229 | return BR_WDOG_STCTRLH_DBGEN; |
bogdanm | 82:6473597d706e | 230 | } |
bogdanm | 82:6473597d706e | 231 | |
bogdanm | 82:6473597d706e | 232 | /*! |
bogdanm | 82:6473597d706e | 233 | * @brief Set whether watchdog is working while cpu is in stop mode. |
bogdanm | 82:6473597d706e | 234 | * |
bogdanm | 82:6473597d706e | 235 | * This function is used to configure whether the WDOG is enabled in CPU stop mode. |
bogdanm | 82:6473597d706e | 236 | * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable |
bogdanm | 82:6473597d706e | 237 | * function, so this function must be called before wdog_hal_enable is called. |
bogdanm | 82:6473597d706e | 238 | * |
bogdanm | 82:6473597d706e | 239 | * @param isEnabled 0 means watchdog is disabled in CPU stop mode. |
bogdanm | 82:6473597d706e | 240 | * 1 means watchdog is enabled in CPU stop mode. |
bogdanm | 82:6473597d706e | 241 | */ |
bogdanm | 82:6473597d706e | 242 | void wdog_hal_configure_enabled_in_cpu_stop_mode(bool isEnabled); |
bogdanm | 82:6473597d706e | 243 | |
bogdanm | 82:6473597d706e | 244 | /*! |
bogdanm | 82:6473597d706e | 245 | * @brief Check whether WDOG works while in CPU stop mode. |
bogdanm | 82:6473597d706e | 246 | * |
bogdanm | 82:6473597d706e | 247 | * This function is used to check whether WDOG works in CPU stop mode. |
bogdanm | 82:6473597d706e | 248 | * |
bogdanm | 82:6473597d706e | 249 | * @return 0 means not work while in CPU stop mode, 1 means works while in CPU stop mode. |
bogdanm | 82:6473597d706e | 250 | */ |
bogdanm | 82:6473597d706e | 251 | static inline bool wdog_hal_is_cpu_stop_mode_enabled(void) |
bogdanm | 82:6473597d706e | 252 | { |
bogdanm | 82:6473597d706e | 253 | return BR_WDOG_STCTRLH_STOPEN; |
bogdanm | 82:6473597d706e | 254 | } |
bogdanm | 82:6473597d706e | 255 | |
bogdanm | 82:6473597d706e | 256 | /*! |
bogdanm | 82:6473597d706e | 257 | * @brief Set whether watchdog is working while CPU is in wait mode. |
bogdanm | 82:6473597d706e | 258 | * |
bogdanm | 82:6473597d706e | 259 | * This function is used to configure whether the WDOG is enabled in CPU wait mode. |
bogdanm | 82:6473597d706e | 260 | * The configuration is saved in an internal configure buffer and written back to the register in wdog_hal_enable |
bogdanm | 82:6473597d706e | 261 | * function, so this function must be called before wdog_hal_enable is called. |
bogdanm | 82:6473597d706e | 262 | * |
bogdanm | 82:6473597d706e | 263 | * @param isEnabled 0 means watchdog is disabled in CPU wait mode. |
bogdanm | 82:6473597d706e | 264 | * 1 means watchdog is enabled in CPU wait mode. |
bogdanm | 82:6473597d706e | 265 | */ |
bogdanm | 82:6473597d706e | 266 | void wdog_hal_configure_enabled_in_cpu_wait_mode(bool isEnabled); |
bogdanm | 82:6473597d706e | 267 | |
bogdanm | 82:6473597d706e | 268 | /*! |
bogdanm | 82:6473597d706e | 269 | * @brief Check whether WDOG works while in CPU wait mode. |
bogdanm | 82:6473597d706e | 270 | * |
bogdanm | 82:6473597d706e | 271 | * This function is used to check whether WDOG works in CPU wait mode. |
bogdanm | 82:6473597d706e | 272 | * |
bogdanm | 82:6473597d706e | 273 | * @return 0 means not work while in CPU wait mode, 1 means works while in CPU wait mode. |
bogdanm | 82:6473597d706e | 274 | */ |
bogdanm | 82:6473597d706e | 275 | |
bogdanm | 82:6473597d706e | 276 | static inline bool wdog_hal_is_cpu_wait_mode_enabled(void) |
bogdanm | 82:6473597d706e | 277 | { |
bogdanm | 82:6473597d706e | 278 | return BR_WDOG_STCTRLH_WAITEN; |
bogdanm | 82:6473597d706e | 279 | } |
bogdanm | 82:6473597d706e | 280 | |
bogdanm | 82:6473597d706e | 281 | /*! |
bogdanm | 82:6473597d706e | 282 | * @brief Get watchdog interrupt status. |
bogdanm | 82:6473597d706e | 283 | * |
bogdanm | 82:6473597d706e | 284 | * This function is used to get the WDOG interrupt flag. |
bogdanm | 82:6473597d706e | 285 | * |
bogdanm | 82:6473597d706e | 286 | * @return Watchdog interrupt status, 0 means interrupt not asserted, 1 means interrupt asserted. |
bogdanm | 82:6473597d706e | 287 | */ |
bogdanm | 82:6473597d706e | 288 | static inline bool wdog_hal_is_interrupt_asserted(void) |
bogdanm | 82:6473597d706e | 289 | { |
bogdanm | 82:6473597d706e | 290 | return BR_WDOG_STCTRLL_INTFLG; |
bogdanm | 82:6473597d706e | 291 | } |
bogdanm | 82:6473597d706e | 292 | |
bogdanm | 82:6473597d706e | 293 | /*! |
bogdanm | 82:6473597d706e | 294 | * @brief Clear watchdog interrupt flag. |
bogdanm | 82:6473597d706e | 295 | * |
bogdanm | 82:6473597d706e | 296 | * This function is used to clear the WDOG interrupt flag. |
bogdanm | 82:6473597d706e | 297 | * |
bogdanm | 82:6473597d706e | 298 | */ |
bogdanm | 82:6473597d706e | 299 | static inline void wdog_hal_clear_interrupt_flag(void) |
bogdanm | 82:6473597d706e | 300 | { |
bogdanm | 82:6473597d706e | 301 | BW_WDOG_STCTRLL_INTFLG(1); |
bogdanm | 82:6473597d706e | 302 | } |
bogdanm | 82:6473597d706e | 303 | |
bogdanm | 82:6473597d706e | 304 | /*! |
bogdanm | 82:6473597d706e | 305 | * @brief set watchdog timeout value. |
bogdanm | 82:6473597d706e | 306 | * |
bogdanm | 82:6473597d706e | 307 | * This function is used to set the WDOG_TOVAL value. |
bogdanm | 82:6473597d706e | 308 | * |
bogdanm | 82:6473597d706e | 309 | * @param timeoutCount watchdog timeout value, count of watchdog clock tick. |
bogdanm | 82:6473597d706e | 310 | */ |
bogdanm | 82:6473597d706e | 311 | static inline void wdog_hal_set_timeout_value(uint32_t timeoutCount) |
bogdanm | 82:6473597d706e | 312 | { |
bogdanm | 82:6473597d706e | 313 | BW_WDOG_TOVALH_TOVALHIGH((uint16_t)((timeoutCount >> 16U) & 0xFFFFU)); |
bogdanm | 82:6473597d706e | 314 | BW_WDOG_TOVALL_TOVALLOW((uint16_t)((timeoutCount) & 0xFFFFU)); |
bogdanm | 82:6473597d706e | 315 | } |
bogdanm | 82:6473597d706e | 316 | |
bogdanm | 82:6473597d706e | 317 | /*! |
bogdanm | 82:6473597d706e | 318 | * @brief Get watchdog timeout value. |
bogdanm | 82:6473597d706e | 319 | * |
bogdanm | 82:6473597d706e | 320 | * This function is used to Get the WDOG_TOVAL value. |
bogdanm | 82:6473597d706e | 321 | * |
bogdanm | 82:6473597d706e | 322 | * @return value of register WDOG_TOVAL. |
bogdanm | 82:6473597d706e | 323 | */ |
bogdanm | 82:6473597d706e | 324 | static inline uint32_t wdog_hal_get_timeout_value(void) |
bogdanm | 82:6473597d706e | 325 | { |
bogdanm | 82:6473597d706e | 326 | return (uint32_t)((((uint32_t)(BR_WDOG_TOVALH_TOVALHIGH)) << 16U) | (BR_WDOG_TOVALL_TOVALLOW)); |
bogdanm | 82:6473597d706e | 327 | } |
bogdanm | 82:6473597d706e | 328 | |
bogdanm | 82:6473597d706e | 329 | /*! |
bogdanm | 82:6473597d706e | 330 | * @brief Get watchdog timer output. |
bogdanm | 82:6473597d706e | 331 | * |
bogdanm | 82:6473597d706e | 332 | * This function is used to get the WDOG_TMROUT value. |
bogdanm | 82:6473597d706e | 333 | * |
bogdanm | 82:6473597d706e | 334 | * @return Current value of watchdog timer counter. |
bogdanm | 82:6473597d706e | 335 | */ |
bogdanm | 82:6473597d706e | 336 | static inline uint32_t wdog_hal_get_timer_output(void) |
bogdanm | 82:6473597d706e | 337 | { |
bogdanm | 82:6473597d706e | 338 | return (uint32_t)((((uint32_t)(BR_WDOG_TMROUTH_TIMEROUTHIGH)) << 16U) | (BR_WDOG_TMROUTL_TIMEROUTLOW)); |
bogdanm | 82:6473597d706e | 339 | } |
bogdanm | 82:6473597d706e | 340 | |
bogdanm | 82:6473597d706e | 341 | /*! |
bogdanm | 82:6473597d706e | 342 | * @brief Set watchdog clock prescaler. |
bogdanm | 82:6473597d706e | 343 | * |
bogdanm | 82:6473597d706e | 344 | * This function is used to set the WDOG clock proscaler. |
bogdanm | 82:6473597d706e | 345 | * |
bogdanm | 82:6473597d706e | 346 | * @param clockPrescaler watchdog clock prescaler, see wdog_clock_prescaler_t. |
bogdanm | 82:6473597d706e | 347 | */ |
bogdanm | 82:6473597d706e | 348 | static inline void wdog_hal_set_clock_prescaler(wdog_clock_prescaler_t clockPrescaler) |
bogdanm | 82:6473597d706e | 349 | { |
bogdanm | 82:6473597d706e | 350 | BW_WDOG_PRESC_PRESCVAL(clockPrescaler); |
bogdanm | 82:6473597d706e | 351 | } |
bogdanm | 82:6473597d706e | 352 | |
bogdanm | 82:6473597d706e | 353 | /*! |
bogdanm | 82:6473597d706e | 354 | * @brief Get watchdog clock prescaler. |
bogdanm | 82:6473597d706e | 355 | * |
bogdanm | 82:6473597d706e | 356 | * This function is used to get the WDOG clock prescaler. |
bogdanm | 82:6473597d706e | 357 | * |
bogdanm | 82:6473597d706e | 358 | * @return WDOG clock prescaler. |
bogdanm | 82:6473597d706e | 359 | */ |
bogdanm | 82:6473597d706e | 360 | static inline wdog_clock_prescaler_t wdog_hal_get_clock_prescaler(void) |
bogdanm | 82:6473597d706e | 361 | { |
bogdanm | 82:6473597d706e | 362 | return (wdog_clock_prescaler_t)BR_WDOG_PRESC_PRESCVAL; |
bogdanm | 82:6473597d706e | 363 | } |
bogdanm | 82:6473597d706e | 364 | |
bogdanm | 82:6473597d706e | 365 | /*! |
bogdanm | 82:6473597d706e | 366 | * @brief Set watchdog window value. |
bogdanm | 82:6473597d706e | 367 | * |
bogdanm | 82:6473597d706e | 368 | * This function is used to set the WDOG_WIN value. |
bogdanm | 82:6473597d706e | 369 | * |
bogdanm | 82:6473597d706e | 370 | * @param windowValue watchdog window value. |
bogdanm | 82:6473597d706e | 371 | */ |
bogdanm | 82:6473597d706e | 372 | static inline void wdog_hal_set_window_value(uint32_t windowValue) |
bogdanm | 82:6473597d706e | 373 | { |
bogdanm | 82:6473597d706e | 374 | BW_WDOG_WINH_WINHIGH((uint16_t)((windowValue>>16U) & 0xFFFFU)); |
bogdanm | 82:6473597d706e | 375 | BW_WDOG_WINL_WINLOW((uint16_t)((windowValue) & 0xFFFFU)); |
bogdanm | 82:6473597d706e | 376 | } |
bogdanm | 82:6473597d706e | 377 | |
bogdanm | 82:6473597d706e | 378 | /*! |
bogdanm | 82:6473597d706e | 379 | * @brief Get watchdog window value. |
bogdanm | 82:6473597d706e | 380 | * |
bogdanm | 82:6473597d706e | 381 | * This function is used to Get the WDOG_WIN value. |
bogdanm | 82:6473597d706e | 382 | * |
bogdanm | 82:6473597d706e | 383 | * @return watchdog window value. |
bogdanm | 82:6473597d706e | 384 | */ |
bogdanm | 82:6473597d706e | 385 | static inline uint32_t wdog_hal_get_window_value(void) |
bogdanm | 82:6473597d706e | 386 | { |
bogdanm | 82:6473597d706e | 387 | return (uint32_t)((((uint32_t)(BR_WDOG_WINH_WINHIGH)) << 16U) | (BR_WDOG_WINL_WINLOW)); |
bogdanm | 82:6473597d706e | 388 | } |
bogdanm | 82:6473597d706e | 389 | |
bogdanm | 82:6473597d706e | 390 | /*! |
bogdanm | 82:6473597d706e | 391 | * @brief Unlock watchdog register written. |
bogdanm | 82:6473597d706e | 392 | * |
bogdanm | 82:6473597d706e | 393 | * This function is used to unlock the WDOG register written. |
bogdanm | 82:6473597d706e | 394 | * This function must be called before any configuration is set because watchdog register |
bogdanm | 82:6473597d706e | 395 | * will be locked automatically after a WCT(256 bus cycles). |
bogdanm | 82:6473597d706e | 396 | * |
bogdanm | 82:6473597d706e | 397 | */ |
bogdanm | 82:6473597d706e | 398 | static inline void wdog_hal_unlock(void) |
bogdanm | 82:6473597d706e | 399 | { |
bogdanm | 82:6473597d706e | 400 | BW_WDOG_UNLOCK_WDOGUNLOCK(0xC520U); |
bogdanm | 82:6473597d706e | 401 | BW_WDOG_UNLOCK_WDOGUNLOCK(0xD928U); |
bogdanm | 82:6473597d706e | 402 | } |
bogdanm | 82:6473597d706e | 403 | |
bogdanm | 82:6473597d706e | 404 | /*! |
bogdanm | 82:6473597d706e | 405 | * @brief Refresh watchdog timer. |
bogdanm | 82:6473597d706e | 406 | * |
bogdanm | 82:6473597d706e | 407 | * This function is used to feed the WDOG. |
bogdanm | 82:6473597d706e | 408 | * This function should be called before watchdog timer is in timeout, otherwise a RESET |
bogdanm | 82:6473597d706e | 409 | * will assert. |
bogdanm | 82:6473597d706e | 410 | * |
bogdanm | 82:6473597d706e | 411 | */ |
bogdanm | 82:6473597d706e | 412 | static inline void wdog_hal_refresh(void) |
bogdanm | 82:6473597d706e | 413 | { |
bogdanm | 82:6473597d706e | 414 | BW_WDOG_REFRESH_WDOGREFRESH(0xA602U); |
bogdanm | 82:6473597d706e | 415 | BW_WDOG_REFRESH_WDOGREFRESH(0xB480U); |
bogdanm | 82:6473597d706e | 416 | } |
bogdanm | 82:6473597d706e | 417 | |
bogdanm | 82:6473597d706e | 418 | /*! |
bogdanm | 82:6473597d706e | 419 | * @brief Reset chip using watchdog. |
bogdanm | 82:6473597d706e | 420 | * |
bogdanm | 82:6473597d706e | 421 | * This function is used to reset chip using WDOG. |
bogdanm | 82:6473597d706e | 422 | * |
bogdanm | 82:6473597d706e | 423 | */ |
bogdanm | 82:6473597d706e | 424 | static inline void wdog_hal_reset_chip(void) |
bogdanm | 82:6473597d706e | 425 | { |
bogdanm | 82:6473597d706e | 426 | BW_WDOG_REFRESH_WDOGREFRESH(0xA602U); |
bogdanm | 82:6473597d706e | 427 | BW_WDOG_REFRESH_WDOGREFRESH(0); |
bogdanm | 82:6473597d706e | 428 | while(1) |
bogdanm | 82:6473597d706e | 429 | { |
bogdanm | 82:6473597d706e | 430 | } |
bogdanm | 82:6473597d706e | 431 | } |
bogdanm | 82:6473597d706e | 432 | |
bogdanm | 82:6473597d706e | 433 | /*! |
bogdanm | 82:6473597d706e | 434 | * @brief Get chip reset count that was reset by watchdog. |
bogdanm | 82:6473597d706e | 435 | * |
bogdanm | 82:6473597d706e | 436 | * This function is used to get the value of WDOG_RSTCNT. |
bogdanm | 82:6473597d706e | 437 | * |
bogdanm | 82:6473597d706e | 438 | * @return Chip reset count that was reset by watchdog. |
bogdanm | 82:6473597d706e | 439 | */ |
bogdanm | 82:6473597d706e | 440 | static inline uint32_t wdog_hal_get_reset_count(void) |
bogdanm | 82:6473597d706e | 441 | { |
bogdanm | 82:6473597d706e | 442 | return BR_WDOG_RSTCNT_RSTCNT; |
bogdanm | 82:6473597d706e | 443 | } |
bogdanm | 82:6473597d706e | 444 | |
bogdanm | 82:6473597d706e | 445 | /*! |
bogdanm | 82:6473597d706e | 446 | * @brief Clear chip reset count that was reset by watchdog. |
bogdanm | 82:6473597d706e | 447 | * |
bogdanm | 82:6473597d706e | 448 | * This function is used to clear the WDOG_RSTCNT. |
bogdanm | 82:6473597d706e | 449 | * |
bogdanm | 82:6473597d706e | 450 | */ |
bogdanm | 82:6473597d706e | 451 | static inline void wdog_hal_clear_reset_count(void) |
bogdanm | 82:6473597d706e | 452 | { |
bogdanm | 82:6473597d706e | 453 | BW_WDOG_RSTCNT_RSTCNT(0xFFFFU); |
bogdanm | 82:6473597d706e | 454 | } |
bogdanm | 82:6473597d706e | 455 | /*@}*/ |
bogdanm | 82:6473597d706e | 456 | |
bogdanm | 82:6473597d706e | 457 | #if defined(__cplusplus) |
bogdanm | 82:6473597d706e | 458 | } |
bogdanm | 82:6473597d706e | 459 | #endif |
bogdanm | 82:6473597d706e | 460 | |
bogdanm | 82:6473597d706e | 461 | /*! @}*/ |
bogdanm | 82:6473597d706e | 462 | |
bogdanm | 82:6473597d706e | 463 | #endif /* __FSL_WDOG_HAL_H__*/ |
bogdanm | 82:6473597d706e | 464 | /******************************************************************************* |
bogdanm | 82:6473597d706e | 465 | * EOF |
bogdanm | 82:6473597d706e | 466 | *******************************************************************************/ |
bogdanm | 82:6473597d706e | 467 |