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