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