STM32F103xB HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f1xx_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) 2016 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 00020 /* Define to prevent recursive inclusion -------------------------------------*/ 00021 #ifndef STM32F1xx_HAL_IWDG_H 00022 #define STM32F1xx_HAL_IWDG_H 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /* Includes ------------------------------------------------------------------*/ 00029 #include "stm32f1xx_hal_def.h" 00030 00031 /** @addtogroup STM32F1xx_HAL_Driver 00032 * @{ 00033 */ 00034 00035 /** @defgroup IWDG IWDG 00036 * @{ 00037 */ 00038 00039 /* Exported types ------------------------------------------------------------*/ 00040 /** @defgroup IWDG_Exported_Types IWDG Exported Types 00041 * @{ 00042 */ 00043 00044 /** 00045 * @brief IWDG Init structure definition 00046 */ 00047 typedef struct 00048 { 00049 uint32_t Prescaler; /*!< Select the prescaler of the IWDG. 00050 This parameter can be a value of @ref IWDG_Prescaler */ 00051 00052 uint32_t Reload; /*!< Specifies the IWDG down-counter reload value. 00053 This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */ 00054 00055 } IWDG_InitTypeDef; 00056 00057 /** 00058 * @brief IWDG Handle Structure definition 00059 */ 00060 typedef struct 00061 { 00062 IWDG_TypeDef *Instance; /*!< Register base address */ 00063 00064 IWDG_InitTypeDef Init; /*!< IWDG required parameters */ 00065 } IWDG_HandleTypeDef; 00066 00067 00068 /** 00069 * @} 00070 */ 00071 00072 /* Exported constants --------------------------------------------------------*/ 00073 /** @defgroup IWDG_Exported_Constants IWDG Exported Constants 00074 * @{ 00075 */ 00076 00077 /** @defgroup IWDG_Prescaler IWDG Prescaler 00078 * @{ 00079 */ 00080 #define IWDG_PRESCALER_4 0x00000000u /*!< IWDG prescaler set to 4 */ 00081 #define IWDG_PRESCALER_8 IWDG_PR_PR_0 /*!< IWDG prescaler set to 8 */ 00082 #define IWDG_PRESCALER_16 IWDG_PR_PR_1 /*!< IWDG prescaler set to 16 */ 00083 #define IWDG_PRESCALER_32 (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32 */ 00084 #define IWDG_PRESCALER_64 IWDG_PR_PR_2 /*!< IWDG prescaler set to 64 */ 00085 #define IWDG_PRESCALER_128 (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */ 00086 #define IWDG_PRESCALER_256 (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */ 00087 /** 00088 * @} 00089 */ 00090 00091 /** 00092 * @} 00093 */ 00094 00095 /* Exported macros -----------------------------------------------------------*/ 00096 /** @defgroup IWDG_Exported_Macros IWDG Exported Macros 00097 * @{ 00098 */ 00099 00100 /** 00101 * @brief Enable the IWDG peripheral. 00102 * @param __HANDLE__ IWDG handle 00103 * @retval None 00104 */ 00105 #define __HAL_IWDG_START(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE) 00106 00107 /** 00108 * @brief Reload IWDG counter with value defined in the reload register 00109 * (write access to IWDG_PR and IWDG_RLR registers disabled). 00110 * @param __HANDLE__ IWDG handle 00111 * @retval None 00112 */ 00113 #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD) 00114 00115 /** 00116 * @} 00117 */ 00118 00119 /* Exported functions --------------------------------------------------------*/ 00120 /** @defgroup IWDG_Exported_Functions IWDG Exported Functions 00121 * @{ 00122 */ 00123 00124 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions 00125 * @{ 00126 */ 00127 /* Initialization/Start functions ********************************************/ 00128 HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg); 00129 /** 00130 * @} 00131 */ 00132 00133 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions 00134 * @{ 00135 */ 00136 /* I/O operation functions ****************************************************/ 00137 HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg); 00138 /** 00139 * @} 00140 */ 00141 00142 /** 00143 * @} 00144 */ 00145 00146 /* Private constants ---------------------------------------------------------*/ 00147 /** @defgroup IWDG_Private_Constants IWDG Private Constants 00148 * @{ 00149 */ 00150 00151 /** 00152 * @brief IWDG Key Register BitMask 00153 */ 00154 #define IWDG_KEY_RELOAD 0x0000AAAAu /*!< IWDG Reload Counter Enable */ 00155 #define IWDG_KEY_ENABLE 0x0000CCCCu /*!< IWDG Peripheral Enable */ 00156 #define IWDG_KEY_WRITE_ACCESS_ENABLE 0x00005555u /*!< IWDG KR Write Access Enable */ 00157 #define IWDG_KEY_WRITE_ACCESS_DISABLE 0x00000000u /*!< IWDG KR Write Access Disable */ 00158 00159 /** 00160 * @} 00161 */ 00162 00163 /* Private macros ------------------------------------------------------------*/ 00164 /** @defgroup IWDG_Private_Macros IWDG Private Macros 00165 * @{ 00166 */ 00167 00168 /** 00169 * @brief Enable write access to IWDG_PR and IWDG_RLR registers. 00170 * @param __HANDLE__ IWDG handle 00171 * @retval None 00172 */ 00173 #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE) 00174 00175 /** 00176 * @brief Disable write access to IWDG_PR and IWDG_RLR registers. 00177 * @param __HANDLE__ IWDG handle 00178 * @retval None 00179 */ 00180 #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE) 00181 00182 /** 00183 * @brief Check IWDG prescaler value. 00184 * @param __PRESCALER__ IWDG prescaler value 00185 * @retval None 00186 */ 00187 #define IS_IWDG_PRESCALER(__PRESCALER__) (((__PRESCALER__) == IWDG_PRESCALER_4) || \ 00188 ((__PRESCALER__) == IWDG_PRESCALER_8) || \ 00189 ((__PRESCALER__) == IWDG_PRESCALER_16) || \ 00190 ((__PRESCALER__) == IWDG_PRESCALER_32) || \ 00191 ((__PRESCALER__) == IWDG_PRESCALER_64) || \ 00192 ((__PRESCALER__) == IWDG_PRESCALER_128)|| \ 00193 ((__PRESCALER__) == IWDG_PRESCALER_256)) 00194 00195 /** 00196 * @brief Check IWDG reload value. 00197 * @param __RELOAD__ IWDG reload value 00198 * @retval None 00199 */ 00200 #define IS_IWDG_RELOAD(__RELOAD__) ((__RELOAD__) <= IWDG_RLR_RL) 00201 00202 00203 00204 /** 00205 * @} 00206 */ 00207 00208 /** 00209 * @} 00210 */ 00211 00212 /** 00213 * @} 00214 */ 00215 00216 00217 #ifdef __cplusplus 00218 } 00219 #endif 00220 00221 #endif /* STM32F1xx_HAL_IWDG_H */ 00222 00223 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/