The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_K64F/TOOLCHAIN_IAR/fsl_wdog.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 145:64910690c574 | 1 | /* |
AnnaBridge | 145:64910690c574 | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
AnnaBridge | 145:64910690c574 | 3 | * All rights reserved. |
AnnaBridge | 145:64910690c574 | 4 | * |
AnnaBridge | 145:64910690c574 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 145:64910690c574 | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 145:64910690c574 | 7 | * |
AnnaBridge | 145:64910690c574 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 145:64910690c574 | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 145:64910690c574 | 10 | * |
AnnaBridge | 145:64910690c574 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 145:64910690c574 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 145:64910690c574 | 13 | * other materials provided with the distribution. |
AnnaBridge | 145:64910690c574 | 14 | * |
AnnaBridge | 145:64910690c574 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 145:64910690c574 | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 145:64910690c574 | 17 | * software without specific prior written permission. |
AnnaBridge | 145:64910690c574 | 18 | * |
AnnaBridge | 145:64910690c574 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 145:64910690c574 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 145:64910690c574 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 145:64910690c574 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 145:64910690c574 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 145:64910690c574 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 145:64910690c574 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 145:64910690c574 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 145:64910690c574 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 145:64910690c574 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 145:64910690c574 | 29 | */ |
AnnaBridge | 145:64910690c574 | 30 | #ifndef _FSL_WDOG_H_ |
AnnaBridge | 145:64910690c574 | 31 | #define _FSL_WDOG_H_ |
AnnaBridge | 145:64910690c574 | 32 | |
AnnaBridge | 145:64910690c574 | 33 | #include "fsl_common.h" |
AnnaBridge | 145:64910690c574 | 34 | |
AnnaBridge | 145:64910690c574 | 35 | /*! |
AnnaBridge | 145:64910690c574 | 36 | * @addtogroup wdog |
AnnaBridge | 145:64910690c574 | 37 | * @{ |
AnnaBridge | 145:64910690c574 | 38 | */ |
AnnaBridge | 145:64910690c574 | 39 | |
AnnaBridge | 145:64910690c574 | 40 | |
AnnaBridge | 145:64910690c574 | 41 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 42 | * Definitions |
AnnaBridge | 145:64910690c574 | 43 | *******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 44 | |
AnnaBridge | 145:64910690c574 | 45 | /*! @name Driver version */ |
AnnaBridge | 145:64910690c574 | 46 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 47 | /*! @brief Defines WDOG driver version 2.0.0. */ |
AnnaBridge | 145:64910690c574 | 48 | #define FSL_WDOG_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
AnnaBridge | 145:64910690c574 | 49 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 50 | |
AnnaBridge | 145:64910690c574 | 51 | /*! @name Unlock sequence */ |
AnnaBridge | 145:64910690c574 | 52 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 53 | #define WDOG_FIRST_WORD_OF_UNLOCK (0xC520U) /*!< First word of unlock sequence */ |
AnnaBridge | 145:64910690c574 | 54 | #define WDOG_SECOND_WORD_OF_UNLOCK (0xD928U) /*!< Second word of unlock sequence */ |
AnnaBridge | 145:64910690c574 | 55 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 56 | |
AnnaBridge | 145:64910690c574 | 57 | /*! @name Refresh sequence */ |
AnnaBridge | 145:64910690c574 | 58 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 59 | #define WDOG_FIRST_WORD_OF_REFRESH (0xA602U) /*!< First word of refresh sequence */ |
AnnaBridge | 145:64910690c574 | 60 | #define WDOG_SECOND_WORD_OF_REFRESH (0xB480U) /*!< Second word of refresh sequence */ |
AnnaBridge | 145:64910690c574 | 61 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 62 | |
AnnaBridge | 145:64910690c574 | 63 | /*! @brief Describes WDOG clock source. */ |
AnnaBridge | 145:64910690c574 | 64 | typedef enum _wdog_clock_source |
AnnaBridge | 145:64910690c574 | 65 | { |
AnnaBridge | 145:64910690c574 | 66 | kWDOG_LpoClockSource = 0U, /*!< WDOG clock sourced from LPO*/ |
AnnaBridge | 145:64910690c574 | 67 | kWDOG_AlternateClockSource = 1U, /*!< WDOG clock sourced from alternate clock source*/ |
AnnaBridge | 145:64910690c574 | 68 | } wdog_clock_source_t; |
AnnaBridge | 145:64910690c574 | 69 | |
AnnaBridge | 145:64910690c574 | 70 | /*! @brief Defines WDOG work mode. */ |
AnnaBridge | 145:64910690c574 | 71 | typedef struct _wdog_work_mode |
AnnaBridge | 145:64910690c574 | 72 | { |
AnnaBridge | 145:64910690c574 | 73 | #if defined(FSL_FEATURE_WDOG_HAS_WAITEN) && FSL_FEATURE_WDOG_HAS_WAITEN |
AnnaBridge | 145:64910690c574 | 74 | bool enableWait; /*!< Enables or disables WDOG in wait mode */ |
AnnaBridge | 145:64910690c574 | 75 | #endif /* FSL_FEATURE_WDOG_HAS_WAITEN */ |
AnnaBridge | 145:64910690c574 | 76 | bool enableStop; /*!< Enables or disables WDOG in stop mode */ |
AnnaBridge | 145:64910690c574 | 77 | bool enableDebug; /*!< Enables or disables WDOG in debug mode */ |
AnnaBridge | 145:64910690c574 | 78 | } wdog_work_mode_t; |
AnnaBridge | 145:64910690c574 | 79 | |
AnnaBridge | 145:64910690c574 | 80 | /*! @brief Describes the selection of the clock prescaler. */ |
AnnaBridge | 145:64910690c574 | 81 | typedef enum _wdog_clock_prescaler |
AnnaBridge | 145:64910690c574 | 82 | { |
AnnaBridge | 145:64910690c574 | 83 | kWDOG_ClockPrescalerDivide1 = 0x0U, /*!< Divided by 1 */ |
AnnaBridge | 145:64910690c574 | 84 | kWDOG_ClockPrescalerDivide2 = 0x1U, /*!< Divided by 2 */ |
AnnaBridge | 145:64910690c574 | 85 | kWDOG_ClockPrescalerDivide3 = 0x2U, /*!< Divided by 3 */ |
AnnaBridge | 145:64910690c574 | 86 | kWDOG_ClockPrescalerDivide4 = 0x3U, /*!< Divided by 4 */ |
AnnaBridge | 145:64910690c574 | 87 | kWDOG_ClockPrescalerDivide5 = 0x4U, /*!< Divided by 5 */ |
AnnaBridge | 145:64910690c574 | 88 | kWDOG_ClockPrescalerDivide6 = 0x5U, /*!< Divided by 6 */ |
AnnaBridge | 145:64910690c574 | 89 | kWDOG_ClockPrescalerDivide7 = 0x6U, /*!< Divided by 7 */ |
AnnaBridge | 145:64910690c574 | 90 | kWDOG_ClockPrescalerDivide8 = 0x7U, /*!< Divided by 8 */ |
AnnaBridge | 145:64910690c574 | 91 | } wdog_clock_prescaler_t; |
AnnaBridge | 145:64910690c574 | 92 | |
AnnaBridge | 145:64910690c574 | 93 | /*! @brief Describes WDOG configuration structure. */ |
AnnaBridge | 145:64910690c574 | 94 | typedef struct _wdog_config |
AnnaBridge | 145:64910690c574 | 95 | { |
AnnaBridge | 145:64910690c574 | 96 | bool enableWdog; /*!< Enables or disables WDOG */ |
AnnaBridge | 145:64910690c574 | 97 | wdog_clock_source_t clockSource; /*!< Clock source select */ |
AnnaBridge | 145:64910690c574 | 98 | wdog_clock_prescaler_t prescaler; /*!< Clock prescaler value */ |
AnnaBridge | 145:64910690c574 | 99 | wdog_work_mode_t workMode; /*!< Configures WDOG work mode in debug stop and wait mode */ |
AnnaBridge | 145:64910690c574 | 100 | bool enableUpdate; /*!< Update write-once register enable */ |
AnnaBridge | 145:64910690c574 | 101 | bool enableInterrupt; /*!< Enables or disables WDOG interrupt */ |
AnnaBridge | 145:64910690c574 | 102 | bool enableWindowMode; /*!< Enables or disables WDOG window mode */ |
AnnaBridge | 145:64910690c574 | 103 | uint32_t windowValue; /*!< Window value */ |
AnnaBridge | 145:64910690c574 | 104 | uint32_t timeoutValue; /*!< Timeout value */ |
AnnaBridge | 145:64910690c574 | 105 | } wdog_config_t; |
AnnaBridge | 145:64910690c574 | 106 | |
AnnaBridge | 145:64910690c574 | 107 | /*! @brief Describes WDOG test mode. */ |
AnnaBridge | 145:64910690c574 | 108 | typedef enum _wdog_test_mode |
AnnaBridge | 145:64910690c574 | 109 | { |
AnnaBridge | 145:64910690c574 | 110 | kWDOG_QuickTest = 0U, /*!< Selects quick test */ |
AnnaBridge | 145:64910690c574 | 111 | kWDOG_ByteTest = 1U, /*!< Selects byte test */ |
AnnaBridge | 145:64910690c574 | 112 | } wdog_test_mode_t; |
AnnaBridge | 145:64910690c574 | 113 | |
AnnaBridge | 145:64910690c574 | 114 | /*! @brief Describes WDOG tested byte selection in byte test mode. */ |
AnnaBridge | 145:64910690c574 | 115 | typedef enum _wdog_tested_byte |
AnnaBridge | 145:64910690c574 | 116 | { |
AnnaBridge | 145:64910690c574 | 117 | kWDOG_TestByte0 = 0U, /*!< Byte 0 selected in byte test mode */ |
AnnaBridge | 145:64910690c574 | 118 | kWDOG_TestByte1 = 1U, /*!< Byte 1 selected in byte test mode */ |
AnnaBridge | 145:64910690c574 | 119 | kWDOG_TestByte2 = 2U, /*!< Byte 2 selected in byte test mode */ |
AnnaBridge | 145:64910690c574 | 120 | kWDOG_TestByte3 = 3U, /*!< Byte 3 selected in byte test mode */ |
AnnaBridge | 145:64910690c574 | 121 | } wdog_tested_byte_t; |
AnnaBridge | 145:64910690c574 | 122 | |
AnnaBridge | 145:64910690c574 | 123 | /*! @brief Describes WDOG test mode configuration structure. */ |
AnnaBridge | 145:64910690c574 | 124 | typedef struct _wdog_test_config |
AnnaBridge | 145:64910690c574 | 125 | { |
AnnaBridge | 145:64910690c574 | 126 | wdog_test_mode_t testMode; /*!< Selects test mode */ |
AnnaBridge | 145:64910690c574 | 127 | wdog_tested_byte_t testedByte; /*!< Selects tested byte in byte test mode */ |
AnnaBridge | 145:64910690c574 | 128 | uint32_t timeoutValue; /*!< Timeout value */ |
AnnaBridge | 145:64910690c574 | 129 | } wdog_test_config_t; |
AnnaBridge | 145:64910690c574 | 130 | |
AnnaBridge | 145:64910690c574 | 131 | /*! |
AnnaBridge | 145:64910690c574 | 132 | * @brief WDOG interrupt configuration structure, default settings all disabled. |
AnnaBridge | 145:64910690c574 | 133 | * |
AnnaBridge | 145:64910690c574 | 134 | * This structure contains the settings for all of the WDOG interrupt configurations. |
AnnaBridge | 145:64910690c574 | 135 | */ |
AnnaBridge | 145:64910690c574 | 136 | enum _wdog_interrupt_enable_t |
AnnaBridge | 145:64910690c574 | 137 | { |
AnnaBridge | 145:64910690c574 | 138 | kWDOG_InterruptEnable = WDOG_STCTRLH_IRQRSTEN_MASK, /*!< WDOG timeout generates an interrupt before reset*/ |
AnnaBridge | 145:64910690c574 | 139 | }; |
AnnaBridge | 145:64910690c574 | 140 | |
AnnaBridge | 145:64910690c574 | 141 | /*! |
AnnaBridge | 145:64910690c574 | 142 | * @brief WDOG status flags. |
AnnaBridge | 145:64910690c574 | 143 | * |
AnnaBridge | 145:64910690c574 | 144 | * This structure contains the WDOG status flags for use in the WDOG functions. |
AnnaBridge | 145:64910690c574 | 145 | */ |
AnnaBridge | 145:64910690c574 | 146 | enum _wdog_status_flags_t |
AnnaBridge | 145:64910690c574 | 147 | { |
AnnaBridge | 145:64910690c574 | 148 | kWDOG_RunningFlag = WDOG_STCTRLH_WDOGEN_MASK, /*!< Running flag, set when WDOG is enabled*/ |
AnnaBridge | 145:64910690c574 | 149 | kWDOG_TimeoutFlag = WDOG_STCTRLL_INTFLG_MASK, /*!< Interrupt flag, set when an exception occurs*/ |
AnnaBridge | 145:64910690c574 | 150 | }; |
AnnaBridge | 145:64910690c574 | 151 | |
AnnaBridge | 145:64910690c574 | 152 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 153 | * API |
AnnaBridge | 145:64910690c574 | 154 | *******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 155 | |
AnnaBridge | 145:64910690c574 | 156 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 157 | extern "C" { |
AnnaBridge | 145:64910690c574 | 158 | #endif /* __cplusplus */ |
AnnaBridge | 145:64910690c574 | 159 | |
AnnaBridge | 145:64910690c574 | 160 | /*! |
AnnaBridge | 145:64910690c574 | 161 | * @name WDOG Initialization and De-initialization |
AnnaBridge | 145:64910690c574 | 162 | * @{ |
AnnaBridge | 145:64910690c574 | 163 | */ |
AnnaBridge | 145:64910690c574 | 164 | |
AnnaBridge | 145:64910690c574 | 165 | /*! |
AnnaBridge | 145:64910690c574 | 166 | * @brief Initializes the WDOG configuration sturcture. |
AnnaBridge | 145:64910690c574 | 167 | * |
AnnaBridge | 145:64910690c574 | 168 | * This function initializes the WDOG configuration structure to default values. The default |
AnnaBridge | 145:64910690c574 | 169 | * values are as follows. |
AnnaBridge | 145:64910690c574 | 170 | * @code |
AnnaBridge | 145:64910690c574 | 171 | * wdogConfig->enableWdog = true; |
AnnaBridge | 145:64910690c574 | 172 | * wdogConfig->clockSource = kWDOG_LpoClockSource; |
AnnaBridge | 145:64910690c574 | 173 | * wdogConfig->prescaler = kWDOG_ClockPrescalerDivide1; |
AnnaBridge | 145:64910690c574 | 174 | * wdogConfig->workMode.enableWait = true; |
AnnaBridge | 145:64910690c574 | 175 | * wdogConfig->workMode.enableStop = false; |
AnnaBridge | 145:64910690c574 | 176 | * wdogConfig->workMode.enableDebug = false; |
AnnaBridge | 145:64910690c574 | 177 | * wdogConfig->enableUpdate = true; |
AnnaBridge | 145:64910690c574 | 178 | * wdogConfig->enableInterrupt = false; |
AnnaBridge | 145:64910690c574 | 179 | * wdogConfig->enableWindowMode = false; |
AnnaBridge | 145:64910690c574 | 180 | * wdogConfig->windowValue = 0; |
AnnaBridge | 145:64910690c574 | 181 | * wdogConfig->timeoutValue = 0xFFFFU; |
AnnaBridge | 145:64910690c574 | 182 | * @endcode |
AnnaBridge | 145:64910690c574 | 183 | * |
AnnaBridge | 145:64910690c574 | 184 | * @param config Pointer to the WDOG configuration structure. |
AnnaBridge | 145:64910690c574 | 185 | * @see wdog_config_t |
AnnaBridge | 145:64910690c574 | 186 | */ |
AnnaBridge | 145:64910690c574 | 187 | void WDOG_GetDefaultConfig(wdog_config_t *config); |
AnnaBridge | 145:64910690c574 | 188 | |
AnnaBridge | 145:64910690c574 | 189 | /*! |
AnnaBridge | 145:64910690c574 | 190 | * @brief Initializes the WDOG. |
AnnaBridge | 145:64910690c574 | 191 | * |
AnnaBridge | 145:64910690c574 | 192 | * This function initializes the WDOG. When called, the WDOG runs according to the configuration. |
AnnaBridge | 145:64910690c574 | 193 | * To reconfigure WDOG without forcing a reset first, enableUpdate must be set to true |
AnnaBridge | 145:64910690c574 | 194 | * in the configuration. |
AnnaBridge | 145:64910690c574 | 195 | * |
AnnaBridge | 145:64910690c574 | 196 | * This is an example. |
AnnaBridge | 145:64910690c574 | 197 | * @code |
AnnaBridge | 145:64910690c574 | 198 | * wdog_config_t config; |
AnnaBridge | 145:64910690c574 | 199 | * WDOG_GetDefaultConfig(&config); |
AnnaBridge | 145:64910690c574 | 200 | * config.timeoutValue = 0x7ffU; |
AnnaBridge | 145:64910690c574 | 201 | * config.enableUpdate = true; |
AnnaBridge | 145:64910690c574 | 202 | * WDOG_Init(wdog_base,&config); |
AnnaBridge | 145:64910690c574 | 203 | * @endcode |
AnnaBridge | 145:64910690c574 | 204 | * |
AnnaBridge | 145:64910690c574 | 205 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 206 | * @param config The configuration of WDOG |
AnnaBridge | 145:64910690c574 | 207 | */ |
AnnaBridge | 145:64910690c574 | 208 | void WDOG_Init(WDOG_Type *base, const wdog_config_t *config); |
AnnaBridge | 145:64910690c574 | 209 | |
AnnaBridge | 145:64910690c574 | 210 | /*! |
AnnaBridge | 145:64910690c574 | 211 | * @brief Shuts down the WDOG. |
AnnaBridge | 145:64910690c574 | 212 | * |
AnnaBridge | 145:64910690c574 | 213 | * This function shuts down the WDOG. |
AnnaBridge | 145:64910690c574 | 214 | * Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which indicates that the register update is enabled. |
AnnaBridge | 145:64910690c574 | 215 | */ |
AnnaBridge | 145:64910690c574 | 216 | void WDOG_Deinit(WDOG_Type *base); |
AnnaBridge | 145:64910690c574 | 217 | |
AnnaBridge | 145:64910690c574 | 218 | /*! |
AnnaBridge | 145:64910690c574 | 219 | * @brief Configures the WDOG functional test. |
AnnaBridge | 145:64910690c574 | 220 | * |
AnnaBridge | 145:64910690c574 | 221 | * This function is used to configure the WDOG functional test. When called, the WDOG goes into test mode |
AnnaBridge | 145:64910690c574 | 222 | * and runs according to the configuration. |
AnnaBridge | 145:64910690c574 | 223 | * Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which means that the register update is enabled. |
AnnaBridge | 145:64910690c574 | 224 | * |
AnnaBridge | 145:64910690c574 | 225 | * This is an example. |
AnnaBridge | 145:64910690c574 | 226 | * @code |
AnnaBridge | 145:64910690c574 | 227 | * wdog_test_config_t test_config; |
AnnaBridge | 145:64910690c574 | 228 | * test_config.testMode = kWDOG_QuickTest; |
AnnaBridge | 145:64910690c574 | 229 | * test_config.timeoutValue = 0xfffffu; |
AnnaBridge | 145:64910690c574 | 230 | * WDOG_SetTestModeConfig(wdog_base, &test_config); |
AnnaBridge | 145:64910690c574 | 231 | * @endcode |
AnnaBridge | 145:64910690c574 | 232 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 233 | * @param config The functional test configuration of WDOG |
AnnaBridge | 145:64910690c574 | 234 | */ |
AnnaBridge | 145:64910690c574 | 235 | void WDOG_SetTestModeConfig(WDOG_Type *base, wdog_test_config_t *config); |
AnnaBridge | 145:64910690c574 | 236 | |
AnnaBridge | 145:64910690c574 | 237 | /* @} */ |
AnnaBridge | 145:64910690c574 | 238 | |
AnnaBridge | 145:64910690c574 | 239 | /*! |
AnnaBridge | 145:64910690c574 | 240 | * @name WDOG Functional Operation |
AnnaBridge | 145:64910690c574 | 241 | * @{ |
AnnaBridge | 145:64910690c574 | 242 | */ |
AnnaBridge | 145:64910690c574 | 243 | |
AnnaBridge | 145:64910690c574 | 244 | /*! |
AnnaBridge | 145:64910690c574 | 245 | * @brief Enables the WDOG module. |
AnnaBridge | 145:64910690c574 | 246 | * |
AnnaBridge | 145:64910690c574 | 247 | * This function write value into WDOG_STCTRLH register to enable the WDOG, it is a write-once register, |
AnnaBridge | 145:64910690c574 | 248 | * make sure that the WCT window is still open and this register has not been written in this WCT |
AnnaBridge | 145:64910690c574 | 249 | * while this function is called. |
AnnaBridge | 145:64910690c574 | 250 | * |
AnnaBridge | 145:64910690c574 | 251 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 252 | */ |
AnnaBridge | 145:64910690c574 | 253 | static inline void WDOG_Enable(WDOG_Type *base) |
AnnaBridge | 145:64910690c574 | 254 | { |
AnnaBridge | 145:64910690c574 | 255 | base->STCTRLH |= WDOG_STCTRLH_WDOGEN_MASK; |
AnnaBridge | 145:64910690c574 | 256 | } |
AnnaBridge | 145:64910690c574 | 257 | |
AnnaBridge | 145:64910690c574 | 258 | /*! |
AnnaBridge | 145:64910690c574 | 259 | * @brief Disables the WDOG module. |
AnnaBridge | 145:64910690c574 | 260 | * |
AnnaBridge | 145:64910690c574 | 261 | * This function writes a value into the WDOG_STCTRLH register to disable the WDOG. It is a write-once register. |
AnnaBridge | 145:64910690c574 | 262 | * Ensure that the WCT window is still open and that register has not been written to in this WCT |
AnnaBridge | 145:64910690c574 | 263 | * while the function is called. |
AnnaBridge | 145:64910690c574 | 264 | * |
AnnaBridge | 145:64910690c574 | 265 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 266 | */ |
AnnaBridge | 145:64910690c574 | 267 | static inline void WDOG_Disable(WDOG_Type *base) |
AnnaBridge | 145:64910690c574 | 268 | { |
AnnaBridge | 145:64910690c574 | 269 | base->STCTRLH &= ~WDOG_STCTRLH_WDOGEN_MASK; |
AnnaBridge | 145:64910690c574 | 270 | } |
AnnaBridge | 145:64910690c574 | 271 | |
AnnaBridge | 145:64910690c574 | 272 | /*! |
AnnaBridge | 145:64910690c574 | 273 | * @brief Enables the WDOG interrupt. |
AnnaBridge | 145:64910690c574 | 274 | * |
AnnaBridge | 145:64910690c574 | 275 | * This function writes a value into the WDOG_STCTRLH register to enable the WDOG interrupt. It is a write-once register. |
AnnaBridge | 145:64910690c574 | 276 | * Ensure that the WCT window is still open and the register has not been written to in this WCT |
AnnaBridge | 145:64910690c574 | 277 | * while the function is called. |
AnnaBridge | 145:64910690c574 | 278 | * |
AnnaBridge | 145:64910690c574 | 279 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 280 | * @param mask The interrupts to enable |
AnnaBridge | 145:64910690c574 | 281 | * The parameter can be combination of the following source if defined. |
AnnaBridge | 145:64910690c574 | 282 | * @arg kWDOG_InterruptEnable |
AnnaBridge | 145:64910690c574 | 283 | */ |
AnnaBridge | 145:64910690c574 | 284 | static inline void WDOG_EnableInterrupts(WDOG_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 285 | { |
AnnaBridge | 145:64910690c574 | 286 | base->STCTRLH |= mask; |
AnnaBridge | 145:64910690c574 | 287 | } |
AnnaBridge | 145:64910690c574 | 288 | |
AnnaBridge | 145:64910690c574 | 289 | /*! |
AnnaBridge | 145:64910690c574 | 290 | * @brief Disables the WDOG interrupt. |
AnnaBridge | 145:64910690c574 | 291 | * |
AnnaBridge | 145:64910690c574 | 292 | * This function writes a value into the WDOG_STCTRLH register to disable the WDOG interrupt. It is a write-once register. |
AnnaBridge | 145:64910690c574 | 293 | * Ensure that the WCT window is still open and the register has not been written to in this WCT |
AnnaBridge | 145:64910690c574 | 294 | * while the function is called. |
AnnaBridge | 145:64910690c574 | 295 | * |
AnnaBridge | 145:64910690c574 | 296 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 297 | * @param mask The interrupts to disable |
AnnaBridge | 145:64910690c574 | 298 | * The parameter can be combination of the following source if defined. |
AnnaBridge | 145:64910690c574 | 299 | * @arg kWDOG_InterruptEnable |
AnnaBridge | 145:64910690c574 | 300 | */ |
AnnaBridge | 145:64910690c574 | 301 | static inline void WDOG_DisableInterrupts(WDOG_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 302 | { |
AnnaBridge | 145:64910690c574 | 303 | base->STCTRLH &= ~mask; |
AnnaBridge | 145:64910690c574 | 304 | } |
AnnaBridge | 145:64910690c574 | 305 | |
AnnaBridge | 145:64910690c574 | 306 | /*! |
AnnaBridge | 145:64910690c574 | 307 | * @brief Gets the WDOG all status flags. |
AnnaBridge | 145:64910690c574 | 308 | * |
AnnaBridge | 145:64910690c574 | 309 | * This function gets all status flags. |
AnnaBridge | 145:64910690c574 | 310 | * |
AnnaBridge | 145:64910690c574 | 311 | * This is an example for getting the Running Flag. |
AnnaBridge | 145:64910690c574 | 312 | * @code |
AnnaBridge | 145:64910690c574 | 313 | * uint32_t status; |
AnnaBridge | 145:64910690c574 | 314 | * status = WDOG_GetStatusFlags (wdog_base) & kWDOG_RunningFlag; |
AnnaBridge | 145:64910690c574 | 315 | * @endcode |
AnnaBridge | 145:64910690c574 | 316 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 317 | * @return State of the status flag: asserted (true) or not-asserted (false).@see _wdog_status_flags_t |
AnnaBridge | 145:64910690c574 | 318 | * - true: a related status flag has been set. |
AnnaBridge | 145:64910690c574 | 319 | * - false: a related status flag is not set. |
AnnaBridge | 145:64910690c574 | 320 | */ |
AnnaBridge | 145:64910690c574 | 321 | uint32_t WDOG_GetStatusFlags(WDOG_Type *base); |
AnnaBridge | 145:64910690c574 | 322 | |
AnnaBridge | 145:64910690c574 | 323 | /*! |
AnnaBridge | 145:64910690c574 | 324 | * @brief Clears the WDOG flag. |
AnnaBridge | 145:64910690c574 | 325 | * |
AnnaBridge | 145:64910690c574 | 326 | * This function clears the WDOG status flag. |
AnnaBridge | 145:64910690c574 | 327 | * |
AnnaBridge | 145:64910690c574 | 328 | * This is an example for clearing the timeout (interrupt) flag. |
AnnaBridge | 145:64910690c574 | 329 | * @code |
AnnaBridge | 145:64910690c574 | 330 | * WDOG_ClearStatusFlags(wdog_base,kWDOG_TimeoutFlag); |
AnnaBridge | 145:64910690c574 | 331 | * @endcode |
AnnaBridge | 145:64910690c574 | 332 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 333 | * @param mask The status flags to clear. |
AnnaBridge | 145:64910690c574 | 334 | * The parameter could be any combination of the following values. |
AnnaBridge | 145:64910690c574 | 335 | * kWDOG_TimeoutFlag |
AnnaBridge | 145:64910690c574 | 336 | */ |
AnnaBridge | 145:64910690c574 | 337 | void WDOG_ClearStatusFlags(WDOG_Type *base, uint32_t mask); |
AnnaBridge | 145:64910690c574 | 338 | |
AnnaBridge | 145:64910690c574 | 339 | /*! |
AnnaBridge | 145:64910690c574 | 340 | * @brief Sets the WDOG timeout value. |
AnnaBridge | 145:64910690c574 | 341 | * |
AnnaBridge | 145:64910690c574 | 342 | * This function sets the timeout value. |
AnnaBridge | 145:64910690c574 | 343 | * It should be ensured that the time-out value for the WDOG is always greater than |
AnnaBridge | 145:64910690c574 | 344 | * 2xWCT time + 20 bus clock cycles. |
AnnaBridge | 145:64910690c574 | 345 | * This function writes a value into WDOG_TOVALH and WDOG_TOVALL registers which are wirte-once. |
AnnaBridge | 145:64910690c574 | 346 | * Ensure the WCT window is still open and the two registers have not been written to in this WCT |
AnnaBridge | 145:64910690c574 | 347 | * while the function is called. |
AnnaBridge | 145:64910690c574 | 348 | * |
AnnaBridge | 145:64910690c574 | 349 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 350 | * @param timeoutCount WDOG timeout value; count of WDOG clock tick. |
AnnaBridge | 145:64910690c574 | 351 | */ |
AnnaBridge | 145:64910690c574 | 352 | static inline void WDOG_SetTimeoutValue(WDOG_Type *base, uint32_t timeoutCount) |
AnnaBridge | 145:64910690c574 | 353 | { |
AnnaBridge | 145:64910690c574 | 354 | base->TOVALH = (uint16_t)((timeoutCount >> 16U) & 0xFFFFU); |
AnnaBridge | 145:64910690c574 | 355 | base->TOVALL = (uint16_t)((timeoutCount)&0xFFFFU); |
AnnaBridge | 145:64910690c574 | 356 | } |
AnnaBridge | 145:64910690c574 | 357 | |
AnnaBridge | 145:64910690c574 | 358 | /*! |
AnnaBridge | 145:64910690c574 | 359 | * @brief Sets the WDOG window value. |
AnnaBridge | 145:64910690c574 | 360 | * |
AnnaBridge | 145:64910690c574 | 361 | * This function sets the WDOG window value. |
AnnaBridge | 145:64910690c574 | 362 | * This function writes a value into WDOG_WINH and WDOG_WINL registers which are wirte-once. |
AnnaBridge | 145:64910690c574 | 363 | * Ensure the WCT window is still open and the two registers have not been written to in this WCT |
AnnaBridge | 145:64910690c574 | 364 | * while the function is called. |
AnnaBridge | 145:64910690c574 | 365 | * |
AnnaBridge | 145:64910690c574 | 366 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 367 | * @param windowValue WDOG window value. |
AnnaBridge | 145:64910690c574 | 368 | */ |
AnnaBridge | 145:64910690c574 | 369 | static inline void WDOG_SetWindowValue(WDOG_Type *base, uint32_t windowValue) |
AnnaBridge | 145:64910690c574 | 370 | { |
AnnaBridge | 145:64910690c574 | 371 | base->WINH = (uint16_t)((windowValue >> 16U) & 0xFFFFU); |
AnnaBridge | 145:64910690c574 | 372 | base->WINL = (uint16_t)((windowValue)&0xFFFFU); |
AnnaBridge | 145:64910690c574 | 373 | } |
AnnaBridge | 145:64910690c574 | 374 | |
AnnaBridge | 145:64910690c574 | 375 | /*! |
AnnaBridge | 145:64910690c574 | 376 | * @brief Unlocks the WDOG register written. |
AnnaBridge | 145:64910690c574 | 377 | * |
AnnaBridge | 145:64910690c574 | 378 | * This function unlocks the WDOG register written. |
AnnaBridge | 145:64910690c574 | 379 | * Before starting the unlock sequence and following congfiguration, disable the global interrupts. |
AnnaBridge | 145:64910690c574 | 380 | * Otherwise, an interrupt may invalidate the unlocking sequence and the WCT may expire. |
AnnaBridge | 145:64910690c574 | 381 | * After the configuration finishes, re-enable the global interrupts. |
AnnaBridge | 145:64910690c574 | 382 | * |
AnnaBridge | 145:64910690c574 | 383 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 384 | */ |
AnnaBridge | 145:64910690c574 | 385 | static inline void WDOG_Unlock(WDOG_Type *base) |
AnnaBridge | 145:64910690c574 | 386 | { |
AnnaBridge | 145:64910690c574 | 387 | base->UNLOCK = WDOG_FIRST_WORD_OF_UNLOCK; |
AnnaBridge | 145:64910690c574 | 388 | base->UNLOCK = WDOG_SECOND_WORD_OF_UNLOCK; |
AnnaBridge | 145:64910690c574 | 389 | } |
AnnaBridge | 145:64910690c574 | 390 | |
AnnaBridge | 145:64910690c574 | 391 | /*! |
AnnaBridge | 145:64910690c574 | 392 | * @brief Refreshes the WDOG timer. |
AnnaBridge | 145:64910690c574 | 393 | * |
AnnaBridge | 145:64910690c574 | 394 | * This function feeds the WDOG. |
AnnaBridge | 145:64910690c574 | 395 | * This function should be called before the WDOG timer is in timeout. Otherwise, a reset is asserted. |
AnnaBridge | 145:64910690c574 | 396 | * |
AnnaBridge | 145:64910690c574 | 397 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 398 | */ |
AnnaBridge | 145:64910690c574 | 399 | void WDOG_Refresh(WDOG_Type *base); |
AnnaBridge | 145:64910690c574 | 400 | |
AnnaBridge | 145:64910690c574 | 401 | /*! |
AnnaBridge | 145:64910690c574 | 402 | * @brief Gets the WDOG reset count. |
AnnaBridge | 145:64910690c574 | 403 | * |
AnnaBridge | 145:64910690c574 | 404 | * This function gets the WDOG reset count value. |
AnnaBridge | 145:64910690c574 | 405 | * |
AnnaBridge | 145:64910690c574 | 406 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 407 | * @return WDOG reset count value. |
AnnaBridge | 145:64910690c574 | 408 | */ |
AnnaBridge | 145:64910690c574 | 409 | static inline uint16_t WDOG_GetResetCount(WDOG_Type *base) |
AnnaBridge | 145:64910690c574 | 410 | { |
AnnaBridge | 145:64910690c574 | 411 | return base->RSTCNT; |
AnnaBridge | 145:64910690c574 | 412 | } |
AnnaBridge | 145:64910690c574 | 413 | /*! |
AnnaBridge | 145:64910690c574 | 414 | * @brief Clears the WDOG reset count. |
AnnaBridge | 145:64910690c574 | 415 | * |
AnnaBridge | 145:64910690c574 | 416 | * This function clears the WDOG reset count value. |
AnnaBridge | 145:64910690c574 | 417 | * |
AnnaBridge | 145:64910690c574 | 418 | * @param base WDOG peripheral base address |
AnnaBridge | 145:64910690c574 | 419 | */ |
AnnaBridge | 145:64910690c574 | 420 | static inline void WDOG_ClearResetCount(WDOG_Type *base) |
AnnaBridge | 145:64910690c574 | 421 | { |
AnnaBridge | 145:64910690c574 | 422 | base->RSTCNT |= UINT16_MAX; |
AnnaBridge | 145:64910690c574 | 423 | } |
AnnaBridge | 145:64910690c574 | 424 | |
AnnaBridge | 145:64910690c574 | 425 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 426 | |
AnnaBridge | 145:64910690c574 | 427 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 428 | } |
AnnaBridge | 145:64910690c574 | 429 | #endif /* __cplusplus */ |
AnnaBridge | 145:64910690c574 | 430 | |
AnnaBridge | 145:64910690c574 | 431 | /*! @}*/ |
AnnaBridge | 145:64910690c574 | 432 | |
AnnaBridge | 145:64910690c574 | 433 | #endif /* _FSL_WDOG_H_ */ |