mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_iwdg.h@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 226:b062af740e40
test with CLOCK_SETUP = 0
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.h |
mbed_official | 87:085cde657901 | 4 | * @author MCD Application Team |
mbed_official | 226:b062af740e40 | 5 | * @version V1.1.0RC2 |
mbed_official | 226:b062af740e40 | 6 | * @date 14-May-2014 |
mbed_official | 87:085cde657901 | 7 | * @brief Header file of IWDG HAL module. |
mbed_official | 87:085cde657901 | 8 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 9 | * @attention |
mbed_official | 87:085cde657901 | 10 | * |
mbed_official | 87:085cde657901 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 87:085cde657901 | 12 | * |
mbed_official | 87:085cde657901 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 87:085cde657901 | 14 | * are permitted provided that the following conditions are met: |
mbed_official | 87:085cde657901 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 87:085cde657901 | 16 | * this list of conditions and the following disclaimer. |
mbed_official | 87:085cde657901 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 87:085cde657901 | 18 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 87:085cde657901 | 19 | * and/or other materials provided with the distribution. |
mbed_official | 87:085cde657901 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 87:085cde657901 | 21 | * may be used to endorse or promote products derived from this software |
mbed_official | 87:085cde657901 | 22 | * without specific prior written permission. |
mbed_official | 87:085cde657901 | 23 | * |
mbed_official | 87:085cde657901 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 87:085cde657901 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 87:085cde657901 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 87:085cde657901 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 87:085cde657901 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 87:085cde657901 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 87:085cde657901 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 87:085cde657901 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 87:085cde657901 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 87:085cde657901 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 87:085cde657901 | 34 | * |
mbed_official | 87:085cde657901 | 35 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 36 | */ |
mbed_official | 87:085cde657901 | 37 | |
mbed_official | 87:085cde657901 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
mbed_official | 87:085cde657901 | 39 | #ifndef __STM32F4xx_HAL_IWDG_H |
mbed_official | 87:085cde657901 | 40 | #define __STM32F4xx_HAL_IWDG_H |
mbed_official | 87:085cde657901 | 41 | |
mbed_official | 87:085cde657901 | 42 | #ifdef __cplusplus |
mbed_official | 87:085cde657901 | 43 | extern "C" { |
mbed_official | 87:085cde657901 | 44 | #endif |
mbed_official | 87:085cde657901 | 45 | |
mbed_official | 87:085cde657901 | 46 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 47 | #include "stm32f4xx_hal_def.h" |
mbed_official | 87:085cde657901 | 48 | |
mbed_official | 87:085cde657901 | 49 | /** @addtogroup STM32F4xx_HAL_Driver |
mbed_official | 87:085cde657901 | 50 | * @{ |
mbed_official | 87:085cde657901 | 51 | */ |
mbed_official | 87:085cde657901 | 52 | |
mbed_official | 87:085cde657901 | 53 | /** @addtogroup IWDG |
mbed_official | 87:085cde657901 | 54 | * @{ |
mbed_official | 87:085cde657901 | 55 | */ |
mbed_official | 87:085cde657901 | 56 | |
mbed_official | 106:ced8cbb51063 | 57 | /* Exported types ------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 58 | |
mbed_official | 87:085cde657901 | 59 | /** |
mbed_official | 87:085cde657901 | 60 | * @brief IWDG HAL State Structure definition |
mbed_official | 87:085cde657901 | 61 | */ |
mbed_official | 87:085cde657901 | 62 | typedef enum |
mbed_official | 87:085cde657901 | 63 | { |
mbed_official | 87:085cde657901 | 64 | HAL_IWDG_STATE_RESET = 0x00, /*!< IWDG not yet initialized or disabled */ |
mbed_official | 87:085cde657901 | 65 | HAL_IWDG_STATE_READY = 0x01, /*!< IWDG initialized and ready for use */ |
mbed_official | 106:ced8cbb51063 | 66 | HAL_IWDG_STATE_BUSY = 0x02, /*!< IWDG internal process is ongoing */ |
mbed_official | 87:085cde657901 | 67 | HAL_IWDG_STATE_TIMEOUT = 0x03, /*!< IWDG timeout state */ |
mbed_official | 87:085cde657901 | 68 | HAL_IWDG_STATE_ERROR = 0x04 /*!< IWDG error state */ |
mbed_official | 87:085cde657901 | 69 | |
mbed_official | 87:085cde657901 | 70 | }HAL_IWDG_StateTypeDef; |
mbed_official | 87:085cde657901 | 71 | |
mbed_official | 87:085cde657901 | 72 | /** |
mbed_official | 87:085cde657901 | 73 | * @brief IWDG Init structure definition |
mbed_official | 87:085cde657901 | 74 | */ |
mbed_official | 87:085cde657901 | 75 | typedef struct |
mbed_official | 87:085cde657901 | 76 | { |
mbed_official | 87:085cde657901 | 77 | uint32_t Prescaler; /*!< Select the prescaler of the IWDG. |
mbed_official | 87:085cde657901 | 78 | This parameter can be a value of @ref IWDG_Prescaler */ |
mbed_official | 87:085cde657901 | 79 | |
mbed_official | 87:085cde657901 | 80 | uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. |
mbed_official | 106:ced8cbb51063 | 81 | This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ |
mbed_official | 87:085cde657901 | 82 | |
mbed_official | 87:085cde657901 | 83 | }IWDG_InitTypeDef; |
mbed_official | 87:085cde657901 | 84 | |
mbed_official | 87:085cde657901 | 85 | /** |
mbed_official | 87:085cde657901 | 86 | * @brief IWDG handle Structure definition |
mbed_official | 87:085cde657901 | 87 | */ |
mbed_official | 87:085cde657901 | 88 | typedef struct |
mbed_official | 87:085cde657901 | 89 | { |
mbed_official | 87:085cde657901 | 90 | IWDG_TypeDef *Instance; /*!< Register base address */ |
mbed_official | 87:085cde657901 | 91 | |
mbed_official | 87:085cde657901 | 92 | IWDG_InitTypeDef Init; /*!< IWDG required parameters */ |
mbed_official | 87:085cde657901 | 93 | |
mbed_official | 87:085cde657901 | 94 | HAL_LockTypeDef Lock; /*!< IWDG locking object */ |
mbed_official | 87:085cde657901 | 95 | |
mbed_official | 87:085cde657901 | 96 | __IO HAL_IWDG_StateTypeDef State; /*!< IWDG communication state */ |
mbed_official | 87:085cde657901 | 97 | |
mbed_official | 87:085cde657901 | 98 | }IWDG_HandleTypeDef; |
mbed_official | 87:085cde657901 | 99 | |
mbed_official | 87:085cde657901 | 100 | /* Exported constants --------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 101 | /** @defgroup IWDG_Exported_Constants |
mbed_official | 87:085cde657901 | 102 | * @{ |
mbed_official | 87:085cde657901 | 103 | */ |
mbed_official | 87:085cde657901 | 104 | |
mbed_official | 87:085cde657901 | 105 | /** @defgroup IWDG_Registers_BitMask |
mbed_official | 87:085cde657901 | 106 | * @{ |
mbed_official | 87:085cde657901 | 107 | */ |
mbed_official | 87:085cde657901 | 108 | /* --- KR Register ---*/ |
mbed_official | 87:085cde657901 | 109 | /* KR register bit mask */ |
mbed_official | 87:085cde657901 | 110 | #define KR_KEY_RELOAD ((uint32_t)0xAAAA) /*!< IWDG reload counter enable */ |
mbed_official | 87:085cde657901 | 111 | #define KR_KEY_ENABLE ((uint32_t)0xCCCC) /*!< IWDG peripheral enable */ |
mbed_official | 87:085cde657901 | 112 | #define KR_KEY_EWA ((uint32_t)0x5555) /*!< IWDG KR write Access enable */ |
mbed_official | 87:085cde657901 | 113 | #define KR_KEY_DWA ((uint32_t)0x0000) /*!< IWDG KR write Access disable */ |
mbed_official | 87:085cde657901 | 114 | |
mbed_official | 87:085cde657901 | 115 | /** |
mbed_official | 87:085cde657901 | 116 | * @} |
mbed_official | 87:085cde657901 | 117 | */ |
mbed_official | 87:085cde657901 | 118 | |
mbed_official | 87:085cde657901 | 119 | /** @defgroup IWDG_Flag_definition |
mbed_official | 87:085cde657901 | 120 | * @{ |
mbed_official | 87:085cde657901 | 121 | */ |
mbed_official | 87:085cde657901 | 122 | #define IWDG_FLAG_PVU ((uint32_t)0x0001) /*!< Watchdog counter prescaler value update flag */ |
mbed_official | 87:085cde657901 | 123 | #define IWDG_FLAG_RVU ((uint32_t)0x0002) /*!< Watchdog counter reload value update flag */ |
mbed_official | 87:085cde657901 | 124 | |
mbed_official | 87:085cde657901 | 125 | #define IS_IWDG_FLAG(FLAG) (((FLAG) == IWDG_FLAG_PVU) || \ |
mbed_official | 87:085cde657901 | 126 | ((FLAG) == IWDG_FLAG_RVU)) |
mbed_official | 87:085cde657901 | 127 | |
mbed_official | 87:085cde657901 | 128 | /** |
mbed_official | 87:085cde657901 | 129 | * @} |
mbed_official | 87:085cde657901 | 130 | */ |
mbed_official | 87:085cde657901 | 131 | |
mbed_official | 87:085cde657901 | 132 | /** @defgroup IWDG_Prescaler |
mbed_official | 87:085cde657901 | 133 | * @{ |
mbed_official | 87:085cde657901 | 134 | */ |
mbed_official | 87:085cde657901 | 135 | #define IWDG_PRESCALER_4 ((uint8_t)0x00) /*!< IWDG prescaler set to 4 */ |
mbed_official | 87:085cde657901 | 136 | #define IWDG_PRESCALER_8 ((uint8_t)0x01) /*!< IWDG prescaler set to 8 */ |
mbed_official | 87:085cde657901 | 137 | #define IWDG_PRESCALER_16 ((uint8_t)0x02) /*!< IWDG prescaler set to 16 */ |
mbed_official | 87:085cde657901 | 138 | #define IWDG_PRESCALER_32 ((uint8_t)0x03) /*!< IWDG prescaler set to 32 */ |
mbed_official | 87:085cde657901 | 139 | #define IWDG_PRESCALER_64 ((uint8_t)0x04) /*!< IWDG prescaler set to 64 */ |
mbed_official | 87:085cde657901 | 140 | #define IWDG_PRESCALER_128 ((uint8_t)0x05) /*!< IWDG prescaler set to 128 */ |
mbed_official | 87:085cde657901 | 141 | #define IWDG_PRESCALER_256 ((uint8_t)0x06) /*!< IWDG prescaler set to 256 */ |
mbed_official | 87:085cde657901 | 142 | |
mbed_official | 87:085cde657901 | 143 | #define IS_IWDG_PRESCALER(PRESCALER) (((PRESCALER) == IWDG_PRESCALER_4) || \ |
mbed_official | 87:085cde657901 | 144 | ((PRESCALER) == IWDG_PRESCALER_8) || \ |
mbed_official | 87:085cde657901 | 145 | ((PRESCALER) == IWDG_PRESCALER_16) || \ |
mbed_official | 87:085cde657901 | 146 | ((PRESCALER) == IWDG_PRESCALER_32) || \ |
mbed_official | 87:085cde657901 | 147 | ((PRESCALER) == IWDG_PRESCALER_64) || \ |
mbed_official | 87:085cde657901 | 148 | ((PRESCALER) == IWDG_PRESCALER_128)|| \ |
mbed_official | 87:085cde657901 | 149 | ((PRESCALER) == IWDG_PRESCALER_256)) |
mbed_official | 87:085cde657901 | 150 | |
mbed_official | 87:085cde657901 | 151 | /** |
mbed_official | 87:085cde657901 | 152 | * @} |
mbed_official | 87:085cde657901 | 153 | */ |
mbed_official | 87:085cde657901 | 154 | |
mbed_official | 87:085cde657901 | 155 | /** @defgroup IWDG_Reload_Value |
mbed_official | 87:085cde657901 | 156 | * @{ |
mbed_official | 87:085cde657901 | 157 | */ |
mbed_official | 87:085cde657901 | 158 | #define IS_IWDG_RELOAD(RELOAD) ((RELOAD) <= 0xFFF) |
mbed_official | 87:085cde657901 | 159 | |
mbed_official | 87:085cde657901 | 160 | /** |
mbed_official | 87:085cde657901 | 161 | * @} |
mbed_official | 87:085cde657901 | 162 | */ |
mbed_official | 87:085cde657901 | 163 | |
mbed_official | 87:085cde657901 | 164 | /** |
mbed_official | 87:085cde657901 | 165 | * @} |
mbed_official | 87:085cde657901 | 166 | */ |
mbed_official | 87:085cde657901 | 167 | |
mbed_official | 87:085cde657901 | 168 | /* Exported macro ------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 169 | |
mbed_official | 226:b062af740e40 | 170 | /** @brief Reset IWDG handle state |
mbed_official | 226:b062af740e40 | 171 | * @param __HANDLE__: IWDG handle |
mbed_official | 226:b062af740e40 | 172 | * @retval None |
mbed_official | 226:b062af740e40 | 173 | */ |
mbed_official | 226:b062af740e40 | 174 | #define __HAL_IWDG_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_IWDG_STATE_RESET) |
mbed_official | 226:b062af740e40 | 175 | |
mbed_official | 87:085cde657901 | 176 | /** |
mbed_official | 87:085cde657901 | 177 | * @brief Enables the IWDG peripheral. |
mbed_official | 87:085cde657901 | 178 | * @param __HANDLE__: IWDG handle |
mbed_official | 87:085cde657901 | 179 | * @retval None |
mbed_official | 87:085cde657901 | 180 | */ |
mbed_official | 87:085cde657901 | 181 | #define __HAL_IWDG_START(__HANDLE__) ((__HANDLE__)->Instance->KR |= KR_KEY_ENABLE) |
mbed_official | 87:085cde657901 | 182 | |
mbed_official | 87:085cde657901 | 183 | /** |
mbed_official | 87:085cde657901 | 184 | * @brief Reloads IWDG counter with value defined in the reload register |
mbed_official | 87:085cde657901 | 185 | * (write access to IWDG_PR and IWDG_RLR registers disabled). |
mbed_official | 87:085cde657901 | 186 | * @param __HANDLE__: IWDG handle |
mbed_official | 87:085cde657901 | 187 | * @retval None |
mbed_official | 87:085cde657901 | 188 | */ |
mbed_official | 87:085cde657901 | 189 | #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) (((__HANDLE__)->Instance->KR) |= KR_KEY_RELOAD) |
mbed_official | 87:085cde657901 | 190 | |
mbed_official | 87:085cde657901 | 191 | /** |
mbed_official | 87:085cde657901 | 192 | * @brief Enables write access to IWDG_PR and IWDG_RLR registers. |
mbed_official | 87:085cde657901 | 193 | * @param __HANDLE__: IWDG handle |
mbed_official | 87:085cde657901 | 194 | * @retval None |
mbed_official | 87:085cde657901 | 195 | */ |
mbed_official | 87:085cde657901 | 196 | #define __HAL_IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) (((__HANDLE__)->Instance->KR) |= KR_KEY_EWA) |
mbed_official | 87:085cde657901 | 197 | |
mbed_official | 87:085cde657901 | 198 | /** |
mbed_official | 87:085cde657901 | 199 | * @brief Disables write access to IWDG_PR and IWDG_RLR registers. |
mbed_official | 87:085cde657901 | 200 | * @param __HANDLE__: IWDG handle |
mbed_official | 87:085cde657901 | 201 | * @retval None |
mbed_official | 87:085cde657901 | 202 | */ |
mbed_official | 87:085cde657901 | 203 | #define __HAL_IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) (((__HANDLE__)->Instance->KR) |= KR_KEY_DWA) |
mbed_official | 87:085cde657901 | 204 | |
mbed_official | 87:085cde657901 | 205 | /** |
mbed_official | 87:085cde657901 | 206 | * @brief Gets the selected IWDG's flag status. |
mbed_official | 87:085cde657901 | 207 | * @param __HANDLE__: IWDG handle |
mbed_official | 87:085cde657901 | 208 | * @param __FLAG__: specifies the flag to check. |
mbed_official | 87:085cde657901 | 209 | * This parameter can be one of the following values: |
mbed_official | 87:085cde657901 | 210 | * @arg IWDG_FLAG_PVU: Watchdog counter reload value update flag |
mbed_official | 87:085cde657901 | 211 | * @arg IWDG_FLAG_RVU: Watchdog counter prescaler value flag |
mbed_official | 87:085cde657901 | 212 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
mbed_official | 87:085cde657901 | 213 | */ |
mbed_official | 87:085cde657901 | 214 | #define __HAL_IWDG_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
mbed_official | 87:085cde657901 | 215 | |
mbed_official | 87:085cde657901 | 216 | /** |
mbed_official | 87:085cde657901 | 217 | * @brief Clears the IWDG's pending flags. |
mbed_official | 87:085cde657901 | 218 | * @param __HANDLE__: IWDG handle |
mbed_official | 87:085cde657901 | 219 | * @param __FLAG__: specifies the flag to clear. |
mbed_official | 87:085cde657901 | 220 | * This parameter can be one of the following values: |
mbed_official | 87:085cde657901 | 221 | * @arg IWDG_FLAG_PVU: Watchdog counter reload value update flag |
mbed_official | 87:085cde657901 | 222 | * @arg IWDG_FLAG_RVU: Watchdog counter prescaler value flag |
mbed_official | 87:085cde657901 | 223 | * @retval None |
mbed_official | 87:085cde657901 | 224 | */ |
mbed_official | 87:085cde657901 | 225 | #define __HAL_IWDG_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR &= ~(__FLAG__)) |
mbed_official | 87:085cde657901 | 226 | |
mbed_official | 87:085cde657901 | 227 | |
mbed_official | 87:085cde657901 | 228 | /* Exported functions --------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 229 | |
mbed_official | 106:ced8cbb51063 | 230 | /* Initialization/de-initialization functions ********************************/ |
mbed_official | 87:085cde657901 | 231 | HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); |
mbed_official | 106:ced8cbb51063 | 232 | void HAL_IWDG_MspInit(IWDG_HandleTypeDef *hiwdg); |
mbed_official | 87:085cde657901 | 233 | |
mbed_official | 106:ced8cbb51063 | 234 | /* I/O operation functions ****************************************************/ |
mbed_official | 87:085cde657901 | 235 | HAL_StatusTypeDef HAL_IWDG_Start(IWDG_HandleTypeDef *hiwdg); |
mbed_official | 87:085cde657901 | 236 | HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); |
mbed_official | 87:085cde657901 | 237 | |
mbed_official | 106:ced8cbb51063 | 238 | /* Peripheral State functions ************************************************/ |
mbed_official | 87:085cde657901 | 239 | HAL_IWDG_StateTypeDef HAL_IWDG_GetState(IWDG_HandleTypeDef *hiwdg); |
mbed_official | 87:085cde657901 | 240 | |
mbed_official | 87:085cde657901 | 241 | /** |
mbed_official | 87:085cde657901 | 242 | * @} |
mbed_official | 87:085cde657901 | 243 | */ |
mbed_official | 87:085cde657901 | 244 | |
mbed_official | 87:085cde657901 | 245 | /** |
mbed_official | 87:085cde657901 | 246 | * @} |
mbed_official | 87:085cde657901 | 247 | */ |
mbed_official | 87:085cde657901 | 248 | |
mbed_official | 87:085cde657901 | 249 | #ifdef __cplusplus |
mbed_official | 87:085cde657901 | 250 | } |
mbed_official | 87:085cde657901 | 251 | #endif |
mbed_official | 87:085cde657901 | 252 | |
mbed_official | 87:085cde657901 | 253 | #endif /* __STM32F4xx_HAL_IWDG_H */ |
mbed_official | 87:085cde657901 | 254 | |
mbed_official | 87:085cde657901 | 255 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |