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