raspiezo / mbed-dev

Dependents:   Nucleo_L432KC_Quadrature_Decoder_with_ADC_and_DAC

Fork of mbed-dev by mbed official

Committer:
tonnyleonard
Date:
Sat May 27 01:26:18 2017 +0000
Revision:
161:bd0311f1ad86
Parent:
154:37f96f9d4de2
Testing ADC with shunt

Who changed what in which revision?

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