STM32L486xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_iwdg.h 00004 * @author MCD Application Team 00005 * @brief Header file of IWDG HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Define to prevent recursive inclusion -------------------------------------*/ 00037 #ifndef __STM32L4xx_HAL_IWDG_H 00038 #define __STM32L4xx_HAL_IWDG_H 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "stm32l4xx_hal_def.h" 00046 00047 /** @addtogroup STM32L4xx_HAL_Driver 00048 * @{ 00049 */ 00050 00051 /** @defgroup IWDG IWDG 00052 * @{ 00053 */ 00054 00055 /* Exported types ------------------------------------------------------------*/ 00056 /** @defgroup IWDG_Exported_Types IWDG Exported Types 00057 * @{ 00058 */ 00059 00060 /** 00061 * @brief IWDG Init structure definition 00062 */ 00063 typedef struct 00064 { 00065 uint32_t Prescaler; /*!< Select the prescaler of the IWDG. 00066 This parameter can be a value of @ref IWDG_Prescaler */ 00067 00068 uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. 00069 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ 00070 00071 uint32_t Window; /*!< Specifies the window value to be compared to the down-counter. 00072 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ 00073 00074 } IWDG_InitTypeDef; 00075 00076 /** 00077 * @brief IWDG Handle Structure definition 00078 */ 00079 typedef struct 00080 { 00081 IWDG_TypeDef *Instance; /*!< Register base address */ 00082 00083 IWDG_InitTypeDef Init; /*!< IWDG required parameters */ 00084 00085 }IWDG_HandleTypeDef; 00086 00087 /** 00088 * @} 00089 */ 00090 00091 /* Exported constants --------------------------------------------------------*/ 00092 /** @defgroup IWDG_Exported_Constants IWDG Exported Constants 00093 * @{ 00094 */ 00095 00096 /** @defgroup IWDG_Prescaler IWDG Prescaler 00097 * @{ 00098 */ 00099 #define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */ 00100 #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */ 00101 #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */ 00102 #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */ 00103 #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */ 00104 #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */ 00105 #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */ 00106 /** 00107 * @} 00108 */ 00109 00110 /** @defgroup IWDG_Window_option IWDG Window option 00111 * @{ 00112 */ 00113 #define IWDG_WINDOW_DISABLE IWDG_WINR_WIN 00114 /** 00115 * @} 00116 */ 00117 00118 /** 00119 * @} 00120 */ 00121 00122 /* Exported macros -----------------------------------------------------------*/ 00123 /** @defgroup IWDG_Exported_Macros IWDG Exported Macros 00124 * @{ 00125 */ 00126 00127 /** 00128 * @brief Enable the IWDG peripheral. 00129 * @param __HANDLE__ IWDG handle 00130 * @retval None 00131 */ 00132 #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE) 00133 00134 /** 00135 * @brief Reload IWDG counter with value defined in the reload register 00136 * (write access to IWDG_PR, IWDG_RLR & IWDG_WINR registers disabled). 00137 * @param __HANDLE__ IWDG handle 00138 * @retval None 00139 */ 00140 #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD) 00141 00142 /** 00143 * @} 00144 */ 00145 00146 /* Exported functions --------------------------------------------------------*/ 00147 /** @defgroup IWDG_Exported_Functions IWDG Exported Functions 00148 * @{ 00149 */ 00150 00151 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions 00152 * @{ 00153 */ 00154 /* Initialization/Start functions ********************************************/ 00155 HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); 00156 /** 00157 * @} 00158 */ 00159 00160 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions 00161 * @{ 00162 */ 00163 /* I/O operation functions ****************************************************/ 00164 HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); 00165 /** 00166 * @} 00167 */ 00168 00169 /** 00170 * @} 00171 */ 00172 00173 /* Private constants ---------------------------------------------------------*/ 00174 /** @defgroup IWDG_Private_Constants IWDG Private Constants 00175 * @{ 00176 */ 00177 00178 /** 00179 * @brief IWDG Key Register BitMask 00180 */ 00181 #define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */ 00182 #define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */ 00183 #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */ 00184 #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */ 00185 00186 /** 00187 * @} 00188 */ 00189 00190 /* Private macros ------------------------------------------------------------*/ 00191 /** @defgroup IWDG_Private_Macros IWDG Private Macros 00192 * @{ 00193 */ 00194 00195 /** 00196 * @brief Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. 00197 * @param __HANDLE__ IWDG handle 00198 * @retval None 00199 */ 00200 #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE) 00201 00202 /** 00203 * @brief Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers. 00204 * @param __HANDLE__ IWDG handle 00205 * @retval None 00206 */ 00207 #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE) 00208 00209 /** 00210 * @brief Check IWDG prescaler value. 00211 * @param __PRESCALER__ IWDG prescaler value 00212 * @retval None 00213 */ 00214 #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \ 00215 ((__PRESCALER__) == IWDG_PRESCALER_8) || \ 00216 ((__PRESCALER__) == IWDG_PRESCALER_16) || \ 00217 ((__PRESCALER__) == IWDG_PRESCALER_32) || \ 00218 ((__PRESCALER__) == IWDG_PRESCALER_64) || \ 00219 ((__PRESCALER__) == IWDG_PRESCALER_128)|| \ 00220 ((__PRESCALER__) == IWDG_PRESCALER_256)) 00221 00222 /** 00223 * @brief Check IWDG reload value. 00224 * @param __RELOAD__ IWDG reload value 00225 * @retval None 00226 */ 00227 #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL) 00228 00229 /** 00230 * @brief Check IWDG window value. 00231 * @param __WINDOW__ IWDG window value 00232 * @retval None 00233 */ 00234 #define IS_IWDG_WINDOW(__WINDOW__) ((__WINDOW__) <= IWDG_WINR_WIN) 00235 00236 /** 00237 * @} 00238 */ 00239 00240 /** 00241 * @} 00242 */ 00243 00244 /** 00245 * @} 00246 */ 00247 00248 00249 #ifdef __cplusplus 00250 } 00251 #endif 00252 00253 #endif /* __STM32L4xx_HAL_IWDG_H */ 00254 00255 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/