mbed library sources modified for open wear
Dependents: openwear-lifelogger-example
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_DISCO_F051R8/stm32f0xx_iwdg.c@130:1dec54e4aec3, 2014-03-21 (annotated)
- Committer:
- mbed_official
- Date:
- Fri Mar 21 11:45:09 2014 +0000
- Revision:
- 130:1dec54e4aec3
Synchronized with git revision e5c9ff6781a4e277a5a454e5a0b037f76e31739d
Full URL: https://github.com/mbedmicro/mbed/commit/e5c9ff6781a4e277a5a454e5a0b037f76e31739d/
STM32F0-Discovery (STM32F051R8) initial port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 130:1dec54e4aec3 | 1 | /** |
mbed_official | 130:1dec54e4aec3 | 2 | ****************************************************************************** |
mbed_official | 130:1dec54e4aec3 | 3 | * @file stm32f0xx_iwdg.c |
mbed_official | 130:1dec54e4aec3 | 4 | * @author MCD Application Team |
mbed_official | 130:1dec54e4aec3 | 5 | * @version V1.3.0 |
mbed_official | 130:1dec54e4aec3 | 6 | * @date 16-January-2014 |
mbed_official | 130:1dec54e4aec3 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 130:1dec54e4aec3 | 8 | * functionalities of the Independent watchdog (IWDG) peripheral: |
mbed_official | 130:1dec54e4aec3 | 9 | * + Prescaler and Counter configuration |
mbed_official | 130:1dec54e4aec3 | 10 | * + IWDG activation |
mbed_official | 130:1dec54e4aec3 | 11 | * + Flag management |
mbed_official | 130:1dec54e4aec3 | 12 | * |
mbed_official | 130:1dec54e4aec3 | 13 | * @verbatim |
mbed_official | 130:1dec54e4aec3 | 14 | * |
mbed_official | 130:1dec54e4aec3 | 15 | ============================================================================== |
mbed_official | 130:1dec54e4aec3 | 16 | ##### IWDG features ##### |
mbed_official | 130:1dec54e4aec3 | 17 | ============================================================================== |
mbed_official | 130:1dec54e4aec3 | 18 | [..] The IWDG can be started by either software or hardware (configurable |
mbed_official | 130:1dec54e4aec3 | 19 | through option byte). |
mbed_official | 130:1dec54e4aec3 | 20 | |
mbed_official | 130:1dec54e4aec3 | 21 | [..] The IWDG is clocked by its own dedicated low-speed clock (LSI) and |
mbed_official | 130:1dec54e4aec3 | 22 | thus stays active even if the main clock fails. |
mbed_official | 130:1dec54e4aec3 | 23 | Once the IWDG is started, the LSI is forced ON and cannot be disabled |
mbed_official | 130:1dec54e4aec3 | 24 | (LSI cannot be disabled too), and the counter starts counting down from |
mbed_official | 130:1dec54e4aec3 | 25 | the reset value of 0xFFF. When it reaches the end of count value (0x000) |
mbed_official | 130:1dec54e4aec3 | 26 | a system reset is generated. |
mbed_official | 130:1dec54e4aec3 | 27 | The IWDG counter should be reloaded at regular intervals to prevent |
mbed_official | 130:1dec54e4aec3 | 28 | an MCU reset. |
mbed_official | 130:1dec54e4aec3 | 29 | |
mbed_official | 130:1dec54e4aec3 | 30 | [..] The IWDG is implemented in the VDD voltage domain that is still functional |
mbed_official | 130:1dec54e4aec3 | 31 | in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). |
mbed_official | 130:1dec54e4aec3 | 32 | |
mbed_official | 130:1dec54e4aec3 | 33 | [..] IWDGRST flag in RCC_CSR register can be used to inform when a IWDG |
mbed_official | 130:1dec54e4aec3 | 34 | reset occurs. |
mbed_official | 130:1dec54e4aec3 | 35 | |
mbed_official | 130:1dec54e4aec3 | 36 | [..] Min-max timeout value @40KHz (LSI): ~0.1ms / ~28.3s |
mbed_official | 130:1dec54e4aec3 | 37 | The IWDG timeout may vary due to LSI frequency dispersion. STM32F0xx |
mbed_official | 130:1dec54e4aec3 | 38 | devices provide the capability to measure the LSI frequency (LSI clock |
mbed_official | 130:1dec54e4aec3 | 39 | should be seleted as RTC clock which is internally connected to TIM10 CH1 |
mbed_official | 130:1dec54e4aec3 | 40 | input capture). The measured value can be used to have an IWDG timeout with |
mbed_official | 130:1dec54e4aec3 | 41 | an acceptable accuracy. |
mbed_official | 130:1dec54e4aec3 | 42 | For more information, please refer to the STM32F0xx Reference manual. |
mbed_official | 130:1dec54e4aec3 | 43 | |
mbed_official | 130:1dec54e4aec3 | 44 | ##### How to use this driver ##### |
mbed_official | 130:1dec54e4aec3 | 45 | ============================================================================== |
mbed_official | 130:1dec54e4aec3 | 46 | [..] This driver allows to use IWDG peripheral with either window option enabled |
mbed_official | 130:1dec54e4aec3 | 47 | or disabled. To do so follow one of the two procedures below. |
mbed_official | 130:1dec54e4aec3 | 48 | (#) Window option is enabled: |
mbed_official | 130:1dec54e4aec3 | 49 | (++) Start the IWDG using IWDG_Enable() function, when the IWDG is used |
mbed_official | 130:1dec54e4aec3 | 50 | in software mode (no need to enable the LSI, it will be enabled |
mbed_official | 130:1dec54e4aec3 | 51 | by hardware). |
mbed_official | 130:1dec54e4aec3 | 52 | (++) Enable write access to IWDG_PR and IWDG_RLR registers using |
mbed_official | 130:1dec54e4aec3 | 53 | IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) function. |
mbed_official | 130:1dec54e4aec3 | 54 | (++) Configure the IWDG prescaler using IWDG_SetPrescaler() function. |
mbed_official | 130:1dec54e4aec3 | 55 | (++) Configure the IWDG counter value using IWDG_SetReload() function. |
mbed_official | 130:1dec54e4aec3 | 56 | This value will be loaded in the IWDG counter each time the counter |
mbed_official | 130:1dec54e4aec3 | 57 | is reloaded, then the IWDG will start counting down from this value. |
mbed_official | 130:1dec54e4aec3 | 58 | (++) Wait for the IWDG registers to be updated using IWDG_GetFlagStatus() function. |
mbed_official | 130:1dec54e4aec3 | 59 | (++) Configure the IWDG refresh window using IWDG_SetWindowValue() function. |
mbed_official | 130:1dec54e4aec3 | 60 | |
mbed_official | 130:1dec54e4aec3 | 61 | (#) Window option is disabled: |
mbed_official | 130:1dec54e4aec3 | 62 | (++) Enable write access to IWDG_PR and IWDG_RLR registers using |
mbed_official | 130:1dec54e4aec3 | 63 | IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable) function. |
mbed_official | 130:1dec54e4aec3 | 64 | (++) Configure the IWDG prescaler using IWDG_SetPrescaler() function. |
mbed_official | 130:1dec54e4aec3 | 65 | (++) Configure the IWDG counter value using IWDG_SetReload() function. |
mbed_official | 130:1dec54e4aec3 | 66 | This value will be loaded in the IWDG counter each time the counter |
mbed_official | 130:1dec54e4aec3 | 67 | is reloaded, then the IWDG will start counting down from this value. |
mbed_official | 130:1dec54e4aec3 | 68 | (++) Wait for the IWDG registers to be updated using IWDG_GetFlagStatus() function. |
mbed_official | 130:1dec54e4aec3 | 69 | (++) reload the IWDG counter at regular intervals during normal operation |
mbed_official | 130:1dec54e4aec3 | 70 | to prevent an MCU reset, using IWDG_ReloadCounter() function. |
mbed_official | 130:1dec54e4aec3 | 71 | (++) Start the IWDG using IWDG_Enable() function, when the IWDG is used |
mbed_official | 130:1dec54e4aec3 | 72 | in software mode (no need to enable the LSI, it will be enabled |
mbed_official | 130:1dec54e4aec3 | 73 | by hardware). |
mbed_official | 130:1dec54e4aec3 | 74 | |
mbed_official | 130:1dec54e4aec3 | 75 | @endverbatim |
mbed_official | 130:1dec54e4aec3 | 76 | * |
mbed_official | 130:1dec54e4aec3 | 77 | ****************************************************************************** |
mbed_official | 130:1dec54e4aec3 | 78 | * @attention |
mbed_official | 130:1dec54e4aec3 | 79 | * |
mbed_official | 130:1dec54e4aec3 | 80 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 130:1dec54e4aec3 | 81 | * |
mbed_official | 130:1dec54e4aec3 | 82 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 130:1dec54e4aec3 | 83 | * are permitted provided that the following conditions are met: |
mbed_official | 130:1dec54e4aec3 | 84 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 130:1dec54e4aec3 | 85 | * this list of conditions and the following disclaimer. |
mbed_official | 130:1dec54e4aec3 | 86 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 130:1dec54e4aec3 | 87 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 130:1dec54e4aec3 | 88 | * and/or other materials provided with the distribution. |
mbed_official | 130:1dec54e4aec3 | 89 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 130:1dec54e4aec3 | 90 | * may be used to endorse or promote products derived from this software |
mbed_official | 130:1dec54e4aec3 | 91 | * without specific prior written permission. |
mbed_official | 130:1dec54e4aec3 | 92 | * |
mbed_official | 130:1dec54e4aec3 | 93 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 130:1dec54e4aec3 | 94 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 130:1dec54e4aec3 | 95 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 130:1dec54e4aec3 | 96 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 130:1dec54e4aec3 | 97 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 130:1dec54e4aec3 | 98 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 130:1dec54e4aec3 | 99 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 130:1dec54e4aec3 | 100 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 130:1dec54e4aec3 | 101 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 130:1dec54e4aec3 | 102 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 130:1dec54e4aec3 | 103 | * |
mbed_official | 130:1dec54e4aec3 | 104 | ****************************************************************************** |
mbed_official | 130:1dec54e4aec3 | 105 | */ |
mbed_official | 130:1dec54e4aec3 | 106 | |
mbed_official | 130:1dec54e4aec3 | 107 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 108 | #include "stm32f0xx_iwdg.h" |
mbed_official | 130:1dec54e4aec3 | 109 | |
mbed_official | 130:1dec54e4aec3 | 110 | /** @addtogroup STM32F0xx_StdPeriph_Driver |
mbed_official | 130:1dec54e4aec3 | 111 | * @{ |
mbed_official | 130:1dec54e4aec3 | 112 | */ |
mbed_official | 130:1dec54e4aec3 | 113 | |
mbed_official | 130:1dec54e4aec3 | 114 | /** @defgroup IWDG |
mbed_official | 130:1dec54e4aec3 | 115 | * @brief IWDG driver modules |
mbed_official | 130:1dec54e4aec3 | 116 | * @{ |
mbed_official | 130:1dec54e4aec3 | 117 | */ |
mbed_official | 130:1dec54e4aec3 | 118 | |
mbed_official | 130:1dec54e4aec3 | 119 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 120 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 121 | /* ---------------------- IWDG registers bit mask ----------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 122 | /* KR register bit mask */ |
mbed_official | 130:1dec54e4aec3 | 123 | #define KR_KEY_RELOAD ((uint16_t)0xAAAA) |
mbed_official | 130:1dec54e4aec3 | 124 | #define KR_KEY_ENABLE ((uint16_t)0xCCCC) |
mbed_official | 130:1dec54e4aec3 | 125 | |
mbed_official | 130:1dec54e4aec3 | 126 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 127 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 128 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 129 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 130:1dec54e4aec3 | 130 | |
mbed_official | 130:1dec54e4aec3 | 131 | /** @defgroup IWDG_Private_Functions |
mbed_official | 130:1dec54e4aec3 | 132 | * @{ |
mbed_official | 130:1dec54e4aec3 | 133 | */ |
mbed_official | 130:1dec54e4aec3 | 134 | |
mbed_official | 130:1dec54e4aec3 | 135 | /** @defgroup IWDG_Group1 Prescaler and Counter configuration functions |
mbed_official | 130:1dec54e4aec3 | 136 | * @brief Prescaler and Counter configuration functions |
mbed_official | 130:1dec54e4aec3 | 137 | * |
mbed_official | 130:1dec54e4aec3 | 138 | @verbatim |
mbed_official | 130:1dec54e4aec3 | 139 | ============================================================================== |
mbed_official | 130:1dec54e4aec3 | 140 | ##### Prescaler and Counter configuration functions ##### |
mbed_official | 130:1dec54e4aec3 | 141 | ============================================================================== |
mbed_official | 130:1dec54e4aec3 | 142 | |
mbed_official | 130:1dec54e4aec3 | 143 | @endverbatim |
mbed_official | 130:1dec54e4aec3 | 144 | * @{ |
mbed_official | 130:1dec54e4aec3 | 145 | */ |
mbed_official | 130:1dec54e4aec3 | 146 | |
mbed_official | 130:1dec54e4aec3 | 147 | /** |
mbed_official | 130:1dec54e4aec3 | 148 | * @brief Enables or disables write access to IWDG_PR and IWDG_RLR registers. |
mbed_official | 130:1dec54e4aec3 | 149 | * @param IWDG_WriteAccess: new state of write access to IWDG_PR and IWDG_RLR registers. |
mbed_official | 130:1dec54e4aec3 | 150 | * This parameter can be one of the following values: |
mbed_official | 130:1dec54e4aec3 | 151 | * @arg IWDG_WriteAccess_Enable: Enable write access to IWDG_PR and IWDG_RLR registers |
mbed_official | 130:1dec54e4aec3 | 152 | * @arg IWDG_WriteAccess_Disable: Disable write access to IWDG_PR and IWDG_RLR registers |
mbed_official | 130:1dec54e4aec3 | 153 | * @retval None |
mbed_official | 130:1dec54e4aec3 | 154 | */ |
mbed_official | 130:1dec54e4aec3 | 155 | void IWDG_WriteAccessCmd(uint16_t IWDG_WriteAccess) |
mbed_official | 130:1dec54e4aec3 | 156 | { |
mbed_official | 130:1dec54e4aec3 | 157 | /* Check the parameters */ |
mbed_official | 130:1dec54e4aec3 | 158 | assert_param(IS_IWDG_WRITE_ACCESS(IWDG_WriteAccess)); |
mbed_official | 130:1dec54e4aec3 | 159 | IWDG->KR = IWDG_WriteAccess; |
mbed_official | 130:1dec54e4aec3 | 160 | } |
mbed_official | 130:1dec54e4aec3 | 161 | |
mbed_official | 130:1dec54e4aec3 | 162 | /** |
mbed_official | 130:1dec54e4aec3 | 163 | * @brief Sets IWDG Prescaler value. |
mbed_official | 130:1dec54e4aec3 | 164 | * @param IWDG_Prescaler: specifies the IWDG Prescaler value. |
mbed_official | 130:1dec54e4aec3 | 165 | * This parameter can be one of the following values: |
mbed_official | 130:1dec54e4aec3 | 166 | * @arg IWDG_Prescaler_4: IWDG prescaler set to 4 |
mbed_official | 130:1dec54e4aec3 | 167 | * @arg IWDG_Prescaler_8: IWDG prescaler set to 8 |
mbed_official | 130:1dec54e4aec3 | 168 | * @arg IWDG_Prescaler_16: IWDG prescaler set to 16 |
mbed_official | 130:1dec54e4aec3 | 169 | * @arg IWDG_Prescaler_32: IWDG prescaler set to 32 |
mbed_official | 130:1dec54e4aec3 | 170 | * @arg IWDG_Prescaler_64: IWDG prescaler set to 64 |
mbed_official | 130:1dec54e4aec3 | 171 | * @arg IWDG_Prescaler_128: IWDG prescaler set to 128 |
mbed_official | 130:1dec54e4aec3 | 172 | * @arg IWDG_Prescaler_256: IWDG prescaler set to 256 |
mbed_official | 130:1dec54e4aec3 | 173 | * @retval None |
mbed_official | 130:1dec54e4aec3 | 174 | */ |
mbed_official | 130:1dec54e4aec3 | 175 | void IWDG_SetPrescaler(uint8_t IWDG_Prescaler) |
mbed_official | 130:1dec54e4aec3 | 176 | { |
mbed_official | 130:1dec54e4aec3 | 177 | /* Check the parameters */ |
mbed_official | 130:1dec54e4aec3 | 178 | assert_param(IS_IWDG_PRESCALER(IWDG_Prescaler)); |
mbed_official | 130:1dec54e4aec3 | 179 | IWDG->PR = IWDG_Prescaler; |
mbed_official | 130:1dec54e4aec3 | 180 | } |
mbed_official | 130:1dec54e4aec3 | 181 | |
mbed_official | 130:1dec54e4aec3 | 182 | /** |
mbed_official | 130:1dec54e4aec3 | 183 | * @brief Sets IWDG Reload value. |
mbed_official | 130:1dec54e4aec3 | 184 | * @param Reload: specifies the IWDG Reload value. |
mbed_official | 130:1dec54e4aec3 | 185 | * This parameter must be a number between 0 and 0x0FFF. |
mbed_official | 130:1dec54e4aec3 | 186 | * @retval None |
mbed_official | 130:1dec54e4aec3 | 187 | */ |
mbed_official | 130:1dec54e4aec3 | 188 | void IWDG_SetReload(uint16_t Reload) |
mbed_official | 130:1dec54e4aec3 | 189 | { |
mbed_official | 130:1dec54e4aec3 | 190 | /* Check the parameters */ |
mbed_official | 130:1dec54e4aec3 | 191 | assert_param(IS_IWDG_RELOAD(Reload)); |
mbed_official | 130:1dec54e4aec3 | 192 | IWDG->RLR = Reload; |
mbed_official | 130:1dec54e4aec3 | 193 | } |
mbed_official | 130:1dec54e4aec3 | 194 | |
mbed_official | 130:1dec54e4aec3 | 195 | /** |
mbed_official | 130:1dec54e4aec3 | 196 | * @brief Reloads IWDG counter with value defined in the reload register |
mbed_official | 130:1dec54e4aec3 | 197 | * (write access to IWDG_PR and IWDG_RLR registers disabled). |
mbed_official | 130:1dec54e4aec3 | 198 | * @param None |
mbed_official | 130:1dec54e4aec3 | 199 | * @retval None |
mbed_official | 130:1dec54e4aec3 | 200 | */ |
mbed_official | 130:1dec54e4aec3 | 201 | void IWDG_ReloadCounter(void) |
mbed_official | 130:1dec54e4aec3 | 202 | { |
mbed_official | 130:1dec54e4aec3 | 203 | IWDG->KR = KR_KEY_RELOAD; |
mbed_official | 130:1dec54e4aec3 | 204 | } |
mbed_official | 130:1dec54e4aec3 | 205 | |
mbed_official | 130:1dec54e4aec3 | 206 | |
mbed_official | 130:1dec54e4aec3 | 207 | /** |
mbed_official | 130:1dec54e4aec3 | 208 | * @brief Sets the IWDG window value. |
mbed_official | 130:1dec54e4aec3 | 209 | * @param WindowValue: specifies the window value to be compared to the downcounter. |
mbed_official | 130:1dec54e4aec3 | 210 | * @retval None |
mbed_official | 130:1dec54e4aec3 | 211 | */ |
mbed_official | 130:1dec54e4aec3 | 212 | void IWDG_SetWindowValue(uint16_t WindowValue) |
mbed_official | 130:1dec54e4aec3 | 213 | { |
mbed_official | 130:1dec54e4aec3 | 214 | /* Check the parameters */ |
mbed_official | 130:1dec54e4aec3 | 215 | assert_param(IS_IWDG_WINDOW_VALUE(WindowValue)); |
mbed_official | 130:1dec54e4aec3 | 216 | IWDG->WINR = WindowValue; |
mbed_official | 130:1dec54e4aec3 | 217 | } |
mbed_official | 130:1dec54e4aec3 | 218 | |
mbed_official | 130:1dec54e4aec3 | 219 | /** |
mbed_official | 130:1dec54e4aec3 | 220 | * @} |
mbed_official | 130:1dec54e4aec3 | 221 | */ |
mbed_official | 130:1dec54e4aec3 | 222 | |
mbed_official | 130:1dec54e4aec3 | 223 | /** @defgroup IWDG_Group2 IWDG activation function |
mbed_official | 130:1dec54e4aec3 | 224 | * @brief IWDG activation function |
mbed_official | 130:1dec54e4aec3 | 225 | * |
mbed_official | 130:1dec54e4aec3 | 226 | @verbatim |
mbed_official | 130:1dec54e4aec3 | 227 | ============================================================================== |
mbed_official | 130:1dec54e4aec3 | 228 | ##### IWDG activation function ##### |
mbed_official | 130:1dec54e4aec3 | 229 | ============================================================================== |
mbed_official | 130:1dec54e4aec3 | 230 | |
mbed_official | 130:1dec54e4aec3 | 231 | @endverbatim |
mbed_official | 130:1dec54e4aec3 | 232 | * @{ |
mbed_official | 130:1dec54e4aec3 | 233 | */ |
mbed_official | 130:1dec54e4aec3 | 234 | |
mbed_official | 130:1dec54e4aec3 | 235 | /** |
mbed_official | 130:1dec54e4aec3 | 236 | * @brief Enables IWDG (write access to IWDG_PR and IWDG_RLR registers disabled). |
mbed_official | 130:1dec54e4aec3 | 237 | * @param None |
mbed_official | 130:1dec54e4aec3 | 238 | * @retval None |
mbed_official | 130:1dec54e4aec3 | 239 | */ |
mbed_official | 130:1dec54e4aec3 | 240 | void IWDG_Enable(void) |
mbed_official | 130:1dec54e4aec3 | 241 | { |
mbed_official | 130:1dec54e4aec3 | 242 | IWDG->KR = KR_KEY_ENABLE; |
mbed_official | 130:1dec54e4aec3 | 243 | } |
mbed_official | 130:1dec54e4aec3 | 244 | |
mbed_official | 130:1dec54e4aec3 | 245 | /** |
mbed_official | 130:1dec54e4aec3 | 246 | * @} |
mbed_official | 130:1dec54e4aec3 | 247 | */ |
mbed_official | 130:1dec54e4aec3 | 248 | |
mbed_official | 130:1dec54e4aec3 | 249 | /** @defgroup IWDG_Group3 Flag management function |
mbed_official | 130:1dec54e4aec3 | 250 | * @brief Flag management function |
mbed_official | 130:1dec54e4aec3 | 251 | * |
mbed_official | 130:1dec54e4aec3 | 252 | @verbatim |
mbed_official | 130:1dec54e4aec3 | 253 | =============================================================================== |
mbed_official | 130:1dec54e4aec3 | 254 | ##### Flag management function ##### |
mbed_official | 130:1dec54e4aec3 | 255 | =============================================================================== |
mbed_official | 130:1dec54e4aec3 | 256 | |
mbed_official | 130:1dec54e4aec3 | 257 | @endverbatim |
mbed_official | 130:1dec54e4aec3 | 258 | * @{ |
mbed_official | 130:1dec54e4aec3 | 259 | */ |
mbed_official | 130:1dec54e4aec3 | 260 | |
mbed_official | 130:1dec54e4aec3 | 261 | /** |
mbed_official | 130:1dec54e4aec3 | 262 | * @brief Checks whether the specified IWDG flag is set or not. |
mbed_official | 130:1dec54e4aec3 | 263 | * @param IWDG_FLAG: specifies the flag to check. |
mbed_official | 130:1dec54e4aec3 | 264 | * This parameter can be one of the following values: |
mbed_official | 130:1dec54e4aec3 | 265 | * @arg IWDG_FLAG_PVU: Prescaler Value Update on going |
mbed_official | 130:1dec54e4aec3 | 266 | * @arg IWDG_FLAG_RVU: Reload Value Update on going |
mbed_official | 130:1dec54e4aec3 | 267 | * @arg IWDG_FLAG_WVU: Counter Window Value Update on going |
mbed_official | 130:1dec54e4aec3 | 268 | * @retval The new state of IWDG_FLAG (SET or RESET). |
mbed_official | 130:1dec54e4aec3 | 269 | */ |
mbed_official | 130:1dec54e4aec3 | 270 | FlagStatus IWDG_GetFlagStatus(uint16_t IWDG_FLAG) |
mbed_official | 130:1dec54e4aec3 | 271 | { |
mbed_official | 130:1dec54e4aec3 | 272 | FlagStatus bitstatus = RESET; |
mbed_official | 130:1dec54e4aec3 | 273 | /* Check the parameters */ |
mbed_official | 130:1dec54e4aec3 | 274 | assert_param(IS_IWDG_FLAG(IWDG_FLAG)); |
mbed_official | 130:1dec54e4aec3 | 275 | if ((IWDG->SR & IWDG_FLAG) != (uint32_t)RESET) |
mbed_official | 130:1dec54e4aec3 | 276 | { |
mbed_official | 130:1dec54e4aec3 | 277 | bitstatus = SET; |
mbed_official | 130:1dec54e4aec3 | 278 | } |
mbed_official | 130:1dec54e4aec3 | 279 | else |
mbed_official | 130:1dec54e4aec3 | 280 | { |
mbed_official | 130:1dec54e4aec3 | 281 | bitstatus = RESET; |
mbed_official | 130:1dec54e4aec3 | 282 | } |
mbed_official | 130:1dec54e4aec3 | 283 | /* Return the flag status */ |
mbed_official | 130:1dec54e4aec3 | 284 | return bitstatus; |
mbed_official | 130:1dec54e4aec3 | 285 | } |
mbed_official | 130:1dec54e4aec3 | 286 | |
mbed_official | 130:1dec54e4aec3 | 287 | /** |
mbed_official | 130:1dec54e4aec3 | 288 | * @} |
mbed_official | 130:1dec54e4aec3 | 289 | */ |
mbed_official | 130:1dec54e4aec3 | 290 | |
mbed_official | 130:1dec54e4aec3 | 291 | /** |
mbed_official | 130:1dec54e4aec3 | 292 | * @} |
mbed_official | 130:1dec54e4aec3 | 293 | */ |
mbed_official | 130:1dec54e4aec3 | 294 | |
mbed_official | 130:1dec54e4aec3 | 295 | /** |
mbed_official | 130:1dec54e4aec3 | 296 | * @} |
mbed_official | 130:1dec54e4aec3 | 297 | */ |
mbed_official | 130:1dec54e4aec3 | 298 | |
mbed_official | 130:1dec54e4aec3 | 299 | /** |
mbed_official | 130:1dec54e4aec3 | 300 | * @} |
mbed_official | 130:1dec54e4aec3 | 301 | */ |
mbed_official | 130:1dec54e4aec3 | 302 | |
mbed_official | 130:1dec54e4aec3 | 303 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |