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