Go to most recent revision | Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 2 | mjames | 1 | /** |
| 2 | ****************************************************************************** |
||
| 3 | * @file stm32f1xx_hal_iwdg.h |
||
| 4 | * @author MCD Application Team |
||
| 5 | * @brief Header file of IWDG HAL module. |
||
| 6 | ****************************************************************************** |
||
| 7 | * @attention |
||
| 8 | * |
||
| 9 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
||
| 10 | * |
||
| 11 | * Redistribution and use in source and binary forms, with or without modification, |
||
| 12 | * are permitted provided that the following conditions are met: |
||
| 13 | * 1. Redistributions of source code must retain the above copyright notice, |
||
| 14 | * this list of conditions and the following disclaimer. |
||
| 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
||
| 16 | * this list of conditions and the following disclaimer in the documentation |
||
| 17 | * and/or other materials provided with the distribution. |
||
| 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
||
| 19 | * may be used to endorse or promote products derived from this software |
||
| 20 | * without specific prior written permission. |
||
| 21 | * |
||
| 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
| 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
| 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
| 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
||
| 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
||
| 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
||
| 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
||
| 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
||
| 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
| 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
| 32 | * |
||
| 33 | ****************************************************************************** |
||
| 34 | */ |
||
| 35 | |||
| 36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
||
| 37 | #ifndef __STM32F1xx_HAL_IWDG_H |
||
| 38 | #define __STM32F1xx_HAL_IWDG_H |
||
| 39 | |||
| 40 | #ifdef __cplusplus |
||
| 41 | extern "C" { |
||
| 42 | #endif |
||
| 43 | |||
| 44 | /* Includes ------------------------------------------------------------------*/ |
||
| 45 | #include "stm32f1xx_hal_def.h" |
||
| 46 | |||
| 47 | /** @addtogroup STM32F1xx_HAL_Driver |
||
| 48 | * @{ |
||
| 49 | */ |
||
| 50 | |||
| 51 | /** @addtogroup IWDG |
||
| 52 | * @{ |
||
| 53 | */ |
||
| 54 | |||
| 55 | /* Exported types ------------------------------------------------------------*/ |
||
| 56 | /** @defgroup IWDG_Exported_Types IWDG Exported Types |
||
| 57 | * @{ |
||
| 58 | */ |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @brief IWDG Init structure definition |
||
| 62 | */ |
||
| 63 | typedef struct |
||
| 64 | { |
||
| 65 | uint32_t Prescaler; /*!< Select the prescaler of the IWDG. |
||
| 66 | This parameter can be a value of @ref IWDG_Prescaler */ |
||
| 67 | |||
| 68 | uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. |
||
| 69 | This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ |
||
| 70 | |||
| 71 | } IWDG_InitTypeDef; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @brief IWDG Handle Structure definition |
||
| 75 | */ |
||
| 76 | typedef struct |
||
| 77 | { |
||
| 78 | IWDG_TypeDef *Instance; /*!< Register base address */ |
||
| 79 | |||
| 80 | IWDG_InitTypeDef Init; /*!< IWDG required parameters */ |
||
| 81 | |||
| 82 | } IWDG_HandleTypeDef; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @} |
||
| 86 | */ |
||
| 87 | |||
| 88 | /* Exported constants --------------------------------------------------------*/ |
||
| 89 | /** @defgroup IWDG_Exported_Constants IWDG Exported Constants |
||
| 90 | * @{ |
||
| 91 | */ |
||
| 92 | |||
| 93 | /** @defgroup IWDG_Prescaler IWDG Prescaler |
||
| 94 | * @{ |
||
| 95 | */ |
||
| 96 | #define IWDG_PRESCALER_4 0x00000000U /*!< IWDG prescaler set to 4 */ |
||
| 97 | #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */ |
||
| 98 | #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */ |
||
| 99 | #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */ |
||
| 100 | #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */ |
||
| 101 | #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */ |
||
| 102 | #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */ |
||
| 103 | /** |
||
| 104 | * @} |
||
| 105 | */ |
||
| 106 | |||
| 107 | /** |
||
| 108 | * @} |
||
| 109 | */ |
||
| 110 | |||
| 111 | |||
| 112 | /* Exported macros -----------------------------------------------------------*/ |
||
| 113 | /** @defgroup IWDG_Exported_Macros IWDG Exported Macros |
||
| 114 | * @{ |
||
| 115 | */ |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @brief Enable the IWDG peripheral. |
||
| 119 | * @param __HANDLE__ IWDG handle |
||
| 120 | * @retval None |
||
| 121 | */ |
||
| 122 | #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE) |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @brief Reload IWDG counter with value defined in the reload register |
||
| 126 | * (write access to IWDG_PR & IWDG_RLR registers disabled). |
||
| 127 | * @param __HANDLE__ IWDG handle |
||
| 128 | * @retval None |
||
| 129 | */ |
||
| 130 | #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD) |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @} |
||
| 134 | */ |
||
| 135 | |||
| 136 | /* Exported functions --------------------------------------------------------*/ |
||
| 137 | /** @defgroup IWDG_Exported_Functions IWDG Exported Functions |
||
| 138 | * @{ |
||
| 139 | */ |
||
| 140 | |||
| 141 | /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions |
||
| 142 | * @{ |
||
| 143 | */ |
||
| 144 | /* Initialization/Start functions ********************************************/ |
||
| 145 | HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); |
||
| 146 | /** |
||
| 147 | * @} |
||
| 148 | */ |
||
| 149 | |||
| 150 | /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions |
||
| 151 | * @{ |
||
| 152 | */ |
||
| 153 | /* I/O operation functions ****************************************************/ |
||
| 154 | HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); |
||
| 155 | /** |
||
| 156 | * @} |
||
| 157 | */ |
||
| 158 | |||
| 159 | /** |
||
| 160 | * @} |
||
| 161 | */ |
||
| 162 | |||
| 163 | /* Private constants ---------------------------------------------------------*/ |
||
| 164 | /** @defgroup IWDG_Private_Constants IWDG Private Constants |
||
| 165 | * @{ |
||
| 166 | */ |
||
| 167 | |||
| 168 | /** |
||
| 169 | * @brief IWDG Key Register BitMask |
||
| 170 | */ |
||
| 171 | #define IWDG_KEY_RELOAD 0x0000AAAAU /*!< IWDG Reload Counter Enable */ |
||
| 172 | #define IWDG_KEY_ENABLE 0x0000CCCCU /*!< IWDG Peripheral Enable */ |
||
| 173 | #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555U /*!< IWDG KR Write Access Enable */ |
||
| 174 | #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000U /*!< IWDG KR Write Access Disable */ |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @} |
||
| 178 | */ |
||
| 179 | |||
| 180 | /* Private macros ------------------------------------------------------------*/ |
||
| 181 | /** @defgroup IWDG_Private_Macros IWDG Private Macros |
||
| 182 | * @{ |
||
| 183 | */ |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @brief Enable write access to IWDG_PR and IWDG_RLR registers. |
||
| 187 | * @param __HANDLE__ IWDG handle |
||
| 188 | * @retval None |
||
| 189 | */ |
||
| 190 | #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE) |
||
| 191 | |||
| 192 | /** |
||
| 193 | * @brief Disable write access to IWDG_PR and IWDG_RLR registers. |
||
| 194 | * @param __HANDLE__ IWDG handle |
||
| 195 | * @retval None |
||
| 196 | */ |
||
| 197 | #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE) |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @brief Check IWDG prescaler value. |
||
| 201 | * @param __PRESCALER__ IWDG prescaler value |
||
| 202 | * @retval None |
||
| 203 | */ |
||
| 204 | #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \ |
||
| 205 | ((__PRESCALER__) == IWDG_PRESCALER_8) || \ |
||
| 206 | ((__PRESCALER__) == IWDG_PRESCALER_16) || \ |
||
| 207 | ((__PRESCALER__) == IWDG_PRESCALER_32) || \ |
||
| 208 | ((__PRESCALER__) == IWDG_PRESCALER_64) || \ |
||
| 209 | ((__PRESCALER__) == IWDG_PRESCALER_128)|| \ |
||
| 210 | ((__PRESCALER__) == IWDG_PRESCALER_256)) |
||
| 211 | |||
| 212 | /** |
||
| 213 | * @brief Check IWDG reload value. |
||
| 214 | * @param __RELOAD__ IWDG reload value |
||
| 215 | * @retval None |
||
| 216 | */ |
||
| 217 | #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL) |
||
| 218 | |||
| 219 | /** |
||
| 220 | * @} |
||
| 221 | */ |
||
| 222 | |||
| 223 | /** |
||
| 224 | * @} |
||
| 225 | */ |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @} |
||
| 229 | */ |
||
| 230 | |||
| 231 | |||
| 232 | #ifdef __cplusplus |
||
| 233 | } |
||
| 234 | #endif |
||
| 235 | |||
| 236 | #endif /* __STM32F1xx_HAL_IWDG_H */ |
||
| 237 | |||
| 238 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |