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


