mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_STM32F4/stm32f4xx_hal_iwdg.c@613:bc40b8d2aec4, 2015-08-20 (annotated)
- Committer:
- mbed_official
- Date:
- Thu Aug 20 10:45:13 2015 +0100
- Revision:
- 613:bc40b8d2aec4
- Parent:
- 532:fe11edbda85c
Synchronized with git revision 92ca8c7b60a283b6bb60eb65b183dac1599f0ade
Full URL: https://github.com/mbedmicro/mbed/commit/92ca8c7b60a283b6bb60eb65b183dac1599f0ade/
Nordic: update application start address in GCC linker script
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 87:085cde657901 | 1 | /** |
mbed_official | 87:085cde657901 | 2 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 3 | * @file stm32f4xx_hal_iwdg.c |
mbed_official | 87:085cde657901 | 4 | * @author MCD Application Team |
mbed_official | 613:bc40b8d2aec4 | 5 | * @version V1.3.2 |
mbed_official | 613:bc40b8d2aec4 | 6 | * @date 26-June-2015 |
mbed_official | 87:085cde657901 | 7 | * @brief IWDG HAL module driver. |
mbed_official | 87:085cde657901 | 8 | * This file provides firmware functions to manage the following |
mbed_official | 87:085cde657901 | 9 | * functionalities of the Independent Watchdog (IWDG) peripheral: |
mbed_official | 532:fe11edbda85c | 10 | * + Initialization and Configuration functions |
mbed_official | 87:085cde657901 | 11 | * + IO operation functions |
mbed_official | 87:085cde657901 | 12 | * + Peripheral State functions |
mbed_official | 87:085cde657901 | 13 | * |
mbed_official | 87:085cde657901 | 14 | @verbatim |
mbed_official | 87:085cde657901 | 15 | ============================================================================== |
mbed_official | 532:fe11edbda85c | 16 | ##### IWDG Specific features ##### |
mbed_official | 87:085cde657901 | 17 | ============================================================================== |
mbed_official | 87:085cde657901 | 18 | [..] |
mbed_official | 87:085cde657901 | 19 | (+) The IWDG can be started by either software or hardware (configurable |
mbed_official | 87:085cde657901 | 20 | through option byte). |
mbed_official | 87:085cde657901 | 21 | |
mbed_official | 87:085cde657901 | 22 | (+) The IWDG is clocked by its own dedicated Low-Speed clock (LSI) and |
mbed_official | 87:085cde657901 | 23 | thus stays active even if the main clock fails. |
mbed_official | 87:085cde657901 | 24 | Once the IWDG is started, the LSI is forced ON and cannot be disabled |
mbed_official | 87:085cde657901 | 25 | (LSI cannot be disabled too), and the counter starts counting down from |
mbed_official | 87:085cde657901 | 26 | the reset value of 0xFFF. When it reaches the end of count value (0x000) |
mbed_official | 87:085cde657901 | 27 | a system reset is generated. |
mbed_official | 87:085cde657901 | 28 | |
mbed_official | 87:085cde657901 | 29 | (+) The IWDG counter should be refreshed at regular intervals, otherwise the |
mbed_official | 87:085cde657901 | 30 | watchdog generates an MCU reset when the counter reaches 0. |
mbed_official | 87:085cde657901 | 31 | |
mbed_official | 87:085cde657901 | 32 | (+) The IWDG is implemented in the VDD voltage domain that is still functional |
mbed_official | 87:085cde657901 | 33 | in STOP and STANDBY mode (IWDG reset can wake-up from STANDBY). |
mbed_official | 87:085cde657901 | 34 | IWDGRST flag in RCC_CSR register can be used to inform when an IWDG |
mbed_official | 87:085cde657901 | 35 | reset occurs. |
mbed_official | 87:085cde657901 | 36 | |
mbed_official | 87:085cde657901 | 37 | (+) Min-max timeout value @32KHz (LSI): ~125us / ~32.7s |
mbed_official | 87:085cde657901 | 38 | The IWDG timeout may vary due to LSI frequency dispersion. STM32F4xx |
mbed_official | 87:085cde657901 | 39 | devices provide the capability to measure the LSI frequency (LSI clock |
mbed_official | 87:085cde657901 | 40 | connected internally to TIM5 CH4 input capture). The measured value |
mbed_official | 87:085cde657901 | 41 | can be used to have an IWDG timeout with an acceptable accuracy. |
mbed_official | 87:085cde657901 | 42 | |
mbed_official | 87:085cde657901 | 43 | |
mbed_official | 87:085cde657901 | 44 | ##### How to use this driver ##### |
mbed_official | 87:085cde657901 | 45 | ============================================================================== |
mbed_official | 87:085cde657901 | 46 | [..] |
mbed_official | 369:2e96f1b71984 | 47 | If Window option is disabled |
mbed_official | 369:2e96f1b71984 | 48 | (+) Use IWDG using HAL_IWDG_Init() function to : |
mbed_official | 369:2e96f1b71984 | 49 | (++) Enable write access to IWDG_PR, IWDG_RLR. |
mbed_official | 369:2e96f1b71984 | 50 | (++) Configure the IWDG prescaler, counter reload value. |
mbed_official | 369:2e96f1b71984 | 51 | This reload value will be loaded in the IWDG counter each time the counter |
mbed_official | 369:2e96f1b71984 | 52 | is reloaded, then the IWDG will start counting down from this value. |
mbed_official | 369:2e96f1b71984 | 53 | [..] |
mbed_official | 87:085cde657901 | 54 | (+) Use IWDG using HAL_IWDG_Start() function to: |
mbed_official | 87:085cde657901 | 55 | (++) Reload IWDG counter with value defined in the IWDG_RLR register. |
mbed_official | 87:085cde657901 | 56 | (++) Start the IWDG, when the IWDG is used in software mode (no need |
mbed_official | 87:085cde657901 | 57 | to enable the LSI, it will be enabled by hardware). |
mbed_official | 87:085cde657901 | 58 | (+) Then the application program must refresh the IWDG counter at regular |
mbed_official | 87:085cde657901 | 59 | intervals during normal operation to prevent an MCU reset, using |
mbed_official | 369:2e96f1b71984 | 60 | HAL_IWDG_Refresh() function. |
mbed_official | 369:2e96f1b71984 | 61 | [..] |
mbed_official | 369:2e96f1b71984 | 62 | if Window option is enabled: |
mbed_official | 369:2e96f1b71984 | 63 | |
mbed_official | 369:2e96f1b71984 | 64 | (+) Use IWDG using HAL_IWDG_Start() function to enable IWDG downcounter |
mbed_official | 369:2e96f1b71984 | 65 | (+) Use IWDG using HAL_IWDG_Init() function to : |
mbed_official | 369:2e96f1b71984 | 66 | (++) Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. |
mbed_official | 369:2e96f1b71984 | 67 | (++) Configure the IWDG prescaler, reload value and window value. |
mbed_official | 369:2e96f1b71984 | 68 | (+) Then the application program must refresh the IWDG counter at regular |
mbed_official | 369:2e96f1b71984 | 69 | intervals during normal operation to prevent an MCU reset, using |
mbed_official | 87:085cde657901 | 70 | HAL_IWDG_Refresh() function. |
mbed_official | 87:085cde657901 | 71 | |
mbed_official | 87:085cde657901 | 72 | *** IWDG HAL driver macros list *** |
mbed_official | 87:085cde657901 | 73 | ==================================== |
mbed_official | 87:085cde657901 | 74 | [..] |
mbed_official | 87:085cde657901 | 75 | Below the list of most used macros in IWDG HAL driver. |
mbed_official | 87:085cde657901 | 76 | |
mbed_official | 87:085cde657901 | 77 | (+) __HAL_IWDG_START: Enable the IWDG peripheral |
mbed_official | 87:085cde657901 | 78 | (+) __HAL_IWDG_RELOAD_COUNTER: Reloads IWDG counter with value defined in the reload register |
mbed_official | 87:085cde657901 | 79 | (+) __HAL_IWDG_GET_FLAG: Get the selected IWDG's flag status |
mbed_official | 369:2e96f1b71984 | 80 | |
mbed_official | 87:085cde657901 | 81 | @endverbatim |
mbed_official | 87:085cde657901 | 82 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 83 | * @attention |
mbed_official | 87:085cde657901 | 84 | * |
mbed_official | 532:fe11edbda85c | 85 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
mbed_official | 87:085cde657901 | 86 | * |
mbed_official | 87:085cde657901 | 87 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 87:085cde657901 | 88 | * are permitted provided that the following conditions are met: |
mbed_official | 87:085cde657901 | 89 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 87:085cde657901 | 90 | * this list of conditions and the following disclaimer. |
mbed_official | 87:085cde657901 | 91 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 87:085cde657901 | 92 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 87:085cde657901 | 93 | * and/or other materials provided with the distribution. |
mbed_official | 87:085cde657901 | 94 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 87:085cde657901 | 95 | * may be used to endorse or promote products derived from this software |
mbed_official | 87:085cde657901 | 96 | * without specific prior written permission. |
mbed_official | 87:085cde657901 | 97 | * |
mbed_official | 87:085cde657901 | 98 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 87:085cde657901 | 99 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 87:085cde657901 | 100 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 87:085cde657901 | 101 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 87:085cde657901 | 102 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 87:085cde657901 | 103 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 87:085cde657901 | 104 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 87:085cde657901 | 105 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 87:085cde657901 | 106 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 87:085cde657901 | 107 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 87:085cde657901 | 108 | * |
mbed_official | 87:085cde657901 | 109 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 110 | */ |
mbed_official | 87:085cde657901 | 111 | |
mbed_official | 87:085cde657901 | 112 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 113 | #include "stm32f4xx_hal.h" |
mbed_official | 87:085cde657901 | 114 | |
mbed_official | 87:085cde657901 | 115 | /** @addtogroup STM32F4xx_HAL_Driver |
mbed_official | 87:085cde657901 | 116 | * @{ |
mbed_official | 87:085cde657901 | 117 | */ |
mbed_official | 87:085cde657901 | 118 | |
mbed_official | 532:fe11edbda85c | 119 | /** @defgroup IWDG IWDG |
mbed_official | 87:085cde657901 | 120 | * @brief IWDG HAL module driver. |
mbed_official | 87:085cde657901 | 121 | * @{ |
mbed_official | 87:085cde657901 | 122 | */ |
mbed_official | 87:085cde657901 | 123 | |
mbed_official | 87:085cde657901 | 124 | #ifdef HAL_IWDG_MODULE_ENABLED |
mbed_official | 87:085cde657901 | 125 | |
mbed_official | 87:085cde657901 | 126 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 127 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 532:fe11edbda85c | 128 | /** @addtogroup IWDG_Private_Constants |
mbed_official | 532:fe11edbda85c | 129 | * @{ |
mbed_official | 532:fe11edbda85c | 130 | */ |
mbed_official | 369:2e96f1b71984 | 131 | #define IWDG_TIMEOUT_FLAG ((uint32_t)1000) /* 1 s */ |
mbed_official | 532:fe11edbda85c | 132 | /** |
mbed_official | 532:fe11edbda85c | 133 | * @} |
mbed_official | 532:fe11edbda85c | 134 | */ |
mbed_official | 87:085cde657901 | 135 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 136 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 137 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 87:085cde657901 | 138 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 532:fe11edbda85c | 139 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 532:fe11edbda85c | 140 | /** @defgroup IWDG_Exported_Functions IWDG Exported Functions |
mbed_official | 87:085cde657901 | 141 | * @{ |
mbed_official | 87:085cde657901 | 142 | */ |
mbed_official | 87:085cde657901 | 143 | |
mbed_official | 532:fe11edbda85c | 144 | /** @defgroup IWDG_Exported_Functions_Group1 Initialization and de-initialization functions |
mbed_official | 87:085cde657901 | 145 | * @brief Initialization and Configuration functions. |
mbed_official | 87:085cde657901 | 146 | * |
mbed_official | 87:085cde657901 | 147 | @verbatim |
mbed_official | 87:085cde657901 | 148 | =============================================================================== |
mbed_official | 87:085cde657901 | 149 | ##### Initialization and de-initialization functions ##### |
mbed_official | 87:085cde657901 | 150 | =============================================================================== |
mbed_official | 87:085cde657901 | 151 | [..] This section provides functions allowing to: |
mbed_official | 87:085cde657901 | 152 | (+) Initialize the IWDG according to the specified parameters |
mbed_official | 87:085cde657901 | 153 | in the IWDG_InitTypeDef and create the associated handle |
mbed_official | 87:085cde657901 | 154 | (+) Initialize the IWDG MSP |
mbed_official | 87:085cde657901 | 155 | (+) DeInitialize IWDG MSP |
mbed_official | 87:085cde657901 | 156 | |
mbed_official | 87:085cde657901 | 157 | @endverbatim |
mbed_official | 87:085cde657901 | 158 | * @{ |
mbed_official | 87:085cde657901 | 159 | */ |
mbed_official | 87:085cde657901 | 160 | |
mbed_official | 87:085cde657901 | 161 | /** |
mbed_official | 87:085cde657901 | 162 | * @brief Initializes the IWDG according to the specified |
mbed_official | 87:085cde657901 | 163 | * parameters in the IWDG_InitTypeDef and creates the associated handle. |
mbed_official | 226:b062af740e40 | 164 | * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 165 | * the configuration information for the specified IWDG module. |
mbed_official | 87:085cde657901 | 166 | * @retval HAL status |
mbed_official | 87:085cde657901 | 167 | */ |
mbed_official | 87:085cde657901 | 168 | HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg) |
mbed_official | 87:085cde657901 | 169 | { |
mbed_official | 87:085cde657901 | 170 | /* Check the IWDG handle allocation */ |
mbed_official | 613:bc40b8d2aec4 | 171 | if(hiwdg == NULL) |
mbed_official | 87:085cde657901 | 172 | { |
mbed_official | 87:085cde657901 | 173 | return HAL_ERROR; |
mbed_official | 87:085cde657901 | 174 | } |
mbed_official | 87:085cde657901 | 175 | |
mbed_official | 87:085cde657901 | 176 | /* Check the parameters */ |
mbed_official | 369:2e96f1b71984 | 177 | assert_param(IS_IWDG_ALL_INSTANCE(hiwdg->Instance)); |
mbed_official | 87:085cde657901 | 178 | assert_param(IS_IWDG_PRESCALER(hiwdg->Init.Prescaler)); |
mbed_official | 87:085cde657901 | 179 | assert_param(IS_IWDG_RELOAD(hiwdg->Init.Reload)); |
mbed_official | 87:085cde657901 | 180 | |
mbed_official | 87:085cde657901 | 181 | if(hiwdg->State == HAL_IWDG_STATE_RESET) |
mbed_official | 87:085cde657901 | 182 | { |
mbed_official | 532:fe11edbda85c | 183 | /* Allocate lock resource and initialize it */ |
mbed_official | 532:fe11edbda85c | 184 | hiwdg->Lock = HAL_UNLOCKED; |
mbed_official | 87:085cde657901 | 185 | /* Init the low level hardware */ |
mbed_official | 87:085cde657901 | 186 | HAL_IWDG_MspInit(hiwdg); |
mbed_official | 87:085cde657901 | 187 | } |
mbed_official | 87:085cde657901 | 188 | |
mbed_official | 87:085cde657901 | 189 | /* Change IWDG peripheral state */ |
mbed_official | 87:085cde657901 | 190 | hiwdg->State = HAL_IWDG_STATE_BUSY; |
mbed_official | 87:085cde657901 | 191 | |
mbed_official | 87:085cde657901 | 192 | /* Enable write access to IWDG_PR and IWDG_RLR registers */ |
mbed_official | 532:fe11edbda85c | 193 | IWDG_ENABLE_WRITE_ACCESS(hiwdg); |
mbed_official | 87:085cde657901 | 194 | |
mbed_official | 369:2e96f1b71984 | 195 | /* Write to IWDG registers the IWDG_Prescaler & IWDG_Reload values to work with */ |
mbed_official | 369:2e96f1b71984 | 196 | MODIFY_REG(hiwdg->Instance->PR, IWDG_PR_PR, hiwdg->Init.Prescaler); |
mbed_official | 369:2e96f1b71984 | 197 | MODIFY_REG(hiwdg->Instance->RLR, IWDG_RLR_RL, hiwdg->Init.Reload); |
mbed_official | 87:085cde657901 | 198 | |
mbed_official | 87:085cde657901 | 199 | /* Change IWDG peripheral state */ |
mbed_official | 87:085cde657901 | 200 | hiwdg->State = HAL_IWDG_STATE_READY; |
mbed_official | 87:085cde657901 | 201 | |
mbed_official | 87:085cde657901 | 202 | /* Return function status */ |
mbed_official | 87:085cde657901 | 203 | return HAL_OK; |
mbed_official | 87:085cde657901 | 204 | } |
mbed_official | 87:085cde657901 | 205 | |
mbed_official | 87:085cde657901 | 206 | /** |
mbed_official | 87:085cde657901 | 207 | * @brief Initializes the IWDG MSP. |
mbed_official | 226:b062af740e40 | 208 | * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 209 | * the configuration information for the specified IWDG module. |
mbed_official | 87:085cde657901 | 210 | * @retval None |
mbed_official | 87:085cde657901 | 211 | */ |
mbed_official | 87:085cde657901 | 212 | __weak void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg) |
mbed_official | 87:085cde657901 | 213 | { |
mbed_official | 87:085cde657901 | 214 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 87:085cde657901 | 215 | the HAL_IWDG_MspInit could be implemented in the user file |
mbed_official | 87:085cde657901 | 216 | */ |
mbed_official | 87:085cde657901 | 217 | } |
mbed_official | 87:085cde657901 | 218 | |
mbed_official | 87:085cde657901 | 219 | /** |
mbed_official | 87:085cde657901 | 220 | * @} |
mbed_official | 87:085cde657901 | 221 | */ |
mbed_official | 87:085cde657901 | 222 | |
mbed_official | 532:fe11edbda85c | 223 | /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions |
mbed_official | 87:085cde657901 | 224 | * @brief IO operation functions |
mbed_official | 87:085cde657901 | 225 | * |
mbed_official | 87:085cde657901 | 226 | @verbatim |
mbed_official | 87:085cde657901 | 227 | =============================================================================== |
mbed_official | 87:085cde657901 | 228 | ##### IO operation functions ##### |
mbed_official | 87:085cde657901 | 229 | =============================================================================== |
mbed_official | 87:085cde657901 | 230 | [..] This section provides functions allowing to: |
mbed_official | 87:085cde657901 | 231 | (+) Start the IWDG. |
mbed_official | 87:085cde657901 | 232 | (+) Refresh the IWDG. |
mbed_official | 87:085cde657901 | 233 | |
mbed_official | 87:085cde657901 | 234 | @endverbatim |
mbed_official | 87:085cde657901 | 235 | * @{ |
mbed_official | 87:085cde657901 | 236 | */ |
mbed_official | 87:085cde657901 | 237 | |
mbed_official | 87:085cde657901 | 238 | /** |
mbed_official | 87:085cde657901 | 239 | * @brief Starts the IWDG. |
mbed_official | 226:b062af740e40 | 240 | * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 241 | * the configuration information for the specified IWDG module. |
mbed_official | 87:085cde657901 | 242 | * @retval HAL status |
mbed_official | 87:085cde657901 | 243 | */ |
mbed_official | 87:085cde657901 | 244 | HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg) |
mbed_official | 87:085cde657901 | 245 | { |
mbed_official | 87:085cde657901 | 246 | /* Process Locked */ |
mbed_official | 87:085cde657901 | 247 | __HAL_LOCK(hiwdg); |
mbed_official | 87:085cde657901 | 248 | |
mbed_official | 87:085cde657901 | 249 | /* Change IWDG peripheral state */ |
mbed_official | 87:085cde657901 | 250 | hiwdg->State = HAL_IWDG_STATE_BUSY; |
mbed_official | 87:085cde657901 | 251 | |
mbed_official | 87:085cde657901 | 252 | /* Start the IWDG peripheral */ |
mbed_official | 87:085cde657901 | 253 | __HAL_IWDG_START(hiwdg); |
mbed_official | 87:085cde657901 | 254 | |
mbed_official | 87:085cde657901 | 255 | /* Reload IWDG counter with value defined in the RLR register */ |
mbed_official | 87:085cde657901 | 256 | __HAL_IWDG_RELOAD_COUNTER(hiwdg); |
mbed_official | 87:085cde657901 | 257 | |
mbed_official | 87:085cde657901 | 258 | /* Change IWDG peripheral state */ |
mbed_official | 87:085cde657901 | 259 | hiwdg->State = HAL_IWDG_STATE_READY; |
mbed_official | 87:085cde657901 | 260 | |
mbed_official | 87:085cde657901 | 261 | /* Process Unlocked */ |
mbed_official | 87:085cde657901 | 262 | __HAL_UNLOCK(hiwdg); |
mbed_official | 87:085cde657901 | 263 | |
mbed_official | 87:085cde657901 | 264 | /* Return function status */ |
mbed_official | 87:085cde657901 | 265 | return HAL_OK; |
mbed_official | 87:085cde657901 | 266 | } |
mbed_official | 87:085cde657901 | 267 | |
mbed_official | 87:085cde657901 | 268 | /** |
mbed_official | 87:085cde657901 | 269 | * @brief Refreshes the IWDG. |
mbed_official | 226:b062af740e40 | 270 | * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 271 | * the configuration information for the specified IWDG module. |
mbed_official | 87:085cde657901 | 272 | * @retval HAL status |
mbed_official | 87:085cde657901 | 273 | */ |
mbed_official | 87:085cde657901 | 274 | HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg) |
mbed_official | 87:085cde657901 | 275 | { |
mbed_official | 369:2e96f1b71984 | 276 | uint32_t tickstart = 0; |
mbed_official | 369:2e96f1b71984 | 277 | |
mbed_official | 87:085cde657901 | 278 | /* Process Locked */ |
mbed_official | 369:2e96f1b71984 | 279 | __HAL_LOCK(hiwdg); |
mbed_official | 369:2e96f1b71984 | 280 | |
mbed_official | 87:085cde657901 | 281 | /* Change IWDG peripheral state */ |
mbed_official | 87:085cde657901 | 282 | hiwdg->State = HAL_IWDG_STATE_BUSY; |
mbed_official | 369:2e96f1b71984 | 283 | |
mbed_official | 369:2e96f1b71984 | 284 | tickstart = HAL_GetTick(); |
mbed_official | 369:2e96f1b71984 | 285 | |
mbed_official | 369:2e96f1b71984 | 286 | /* Wait until RVU flag is RESET */ |
mbed_official | 369:2e96f1b71984 | 287 | while(__HAL_IWDG_GET_FLAG(hiwdg, IWDG_FLAG_RVU) != RESET) |
mbed_official | 369:2e96f1b71984 | 288 | { |
mbed_official | 369:2e96f1b71984 | 289 | if((HAL_GetTick() - tickstart ) > IWDG_TIMEOUT_FLAG) |
mbed_official | 369:2e96f1b71984 | 290 | { |
mbed_official | 369:2e96f1b71984 | 291 | /* Set IWDG state */ |
mbed_official | 369:2e96f1b71984 | 292 | hiwdg->State = HAL_IWDG_STATE_TIMEOUT; |
mbed_official | 369:2e96f1b71984 | 293 | |
mbed_official | 369:2e96f1b71984 | 294 | /* Process unlocked */ |
mbed_official | 369:2e96f1b71984 | 295 | __HAL_UNLOCK(hiwdg); |
mbed_official | 369:2e96f1b71984 | 296 | |
mbed_official | 369:2e96f1b71984 | 297 | return HAL_TIMEOUT; |
mbed_official | 369:2e96f1b71984 | 298 | } |
mbed_official | 369:2e96f1b71984 | 299 | } |
mbed_official | 87:085cde657901 | 300 | |
mbed_official | 87:085cde657901 | 301 | /* Reload IWDG counter with value defined in the reload register */ |
mbed_official | 87:085cde657901 | 302 | __HAL_IWDG_RELOAD_COUNTER(hiwdg); |
mbed_official | 87:085cde657901 | 303 | |
mbed_official | 87:085cde657901 | 304 | /* Change IWDG peripheral state */ |
mbed_official | 87:085cde657901 | 305 | hiwdg->State = HAL_IWDG_STATE_READY; |
mbed_official | 87:085cde657901 | 306 | |
mbed_official | 87:085cde657901 | 307 | /* Process Unlocked */ |
mbed_official | 87:085cde657901 | 308 | __HAL_UNLOCK(hiwdg); |
mbed_official | 87:085cde657901 | 309 | |
mbed_official | 87:085cde657901 | 310 | /* Return function status */ |
mbed_official | 87:085cde657901 | 311 | return HAL_OK; |
mbed_official | 87:085cde657901 | 312 | } |
mbed_official | 87:085cde657901 | 313 | |
mbed_official | 87:085cde657901 | 314 | /** |
mbed_official | 87:085cde657901 | 315 | * @} |
mbed_official | 87:085cde657901 | 316 | */ |
mbed_official | 87:085cde657901 | 317 | |
mbed_official | 532:fe11edbda85c | 318 | /** @defgroup IWDG_Exported_Functions_Group3 Peripheral State functions |
mbed_official | 87:085cde657901 | 319 | * @brief Peripheral State functions. |
mbed_official | 87:085cde657901 | 320 | * |
mbed_official | 87:085cde657901 | 321 | @verbatim |
mbed_official | 87:085cde657901 | 322 | =============================================================================== |
mbed_official | 87:085cde657901 | 323 | ##### Peripheral State functions ##### |
mbed_official | 87:085cde657901 | 324 | =============================================================================== |
mbed_official | 87:085cde657901 | 325 | [..] |
mbed_official | 87:085cde657901 | 326 | This subsection permits to get in run-time the status of the peripheral |
mbed_official | 87:085cde657901 | 327 | and the data flow. |
mbed_official | 87:085cde657901 | 328 | |
mbed_official | 87:085cde657901 | 329 | @endverbatim |
mbed_official | 87:085cde657901 | 330 | * @{ |
mbed_official | 87:085cde657901 | 331 | */ |
mbed_official | 87:085cde657901 | 332 | |
mbed_official | 87:085cde657901 | 333 | /** |
mbed_official | 87:085cde657901 | 334 | * @brief Returns the IWDG state. |
mbed_official | 226:b062af740e40 | 335 | * @param hiwdg: pointer to a IWDG_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 336 | * the configuration information for the specified IWDG module. |
mbed_official | 87:085cde657901 | 337 | * @retval HAL state |
mbed_official | 87:085cde657901 | 338 | */ |
mbed_official | 87:085cde657901 | 339 | HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg) |
mbed_official | 87:085cde657901 | 340 | { |
mbed_official | 87:085cde657901 | 341 | return hiwdg->State; |
mbed_official | 87:085cde657901 | 342 | } |
mbed_official | 87:085cde657901 | 343 | |
mbed_official | 87:085cde657901 | 344 | /** |
mbed_official | 87:085cde657901 | 345 | * @} |
mbed_official | 87:085cde657901 | 346 | */ |
mbed_official | 87:085cde657901 | 347 | |
mbed_official | 87:085cde657901 | 348 | /** |
mbed_official | 87:085cde657901 | 349 | * @} |
mbed_official | 87:085cde657901 | 350 | */ |
mbed_official | 87:085cde657901 | 351 | |
mbed_official | 87:085cde657901 | 352 | #endif /* HAL_IWDG_MODULE_ENABLED */ |
mbed_official | 87:085cde657901 | 353 | /** |
mbed_official | 87:085cde657901 | 354 | * @} |
mbed_official | 87:085cde657901 | 355 | */ |
mbed_official | 87:085cde657901 | 356 | |
mbed_official | 87:085cde657901 | 357 | /** |
mbed_official | 87:085cde657901 | 358 | * @} |
mbed_official | 87:085cde657901 | 359 | */ |
mbed_official | 87:085cde657901 | 360 | |
mbed_official | 87:085cde657901 | 361 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |