STM32F439xx HAL User Manual
stm32f4xx_hal_iwdg.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_iwdg.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of IWDG HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; 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 __STM32F4xx_HAL_IWDG_H
00038 #define __STM32F4xx_HAL_IWDG_H
00039 
00040 #ifdef __cplusplus
00041  extern "C" {
00042 #endif
00043 
00044 /* Includes ------------------------------------------------------------------*/
00045 #include "stm32f4xx_hal_def.h"
00046 
00047 /** @addtogroup STM32F4xx_HAL_Driver
00048   * @{
00049   */
00050 
00051 /** @addtogroup 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 } IWDG_InitTypeDef;
00072 
00073 /**
00074   * @brief  IWDG Handle Structure definition
00075   */
00076 typedef struct
00077 {
00078   IWDG_TypeDef                 *Instance;  /*!< Register base address    */
00079 
00080   IWDG_InitTypeDef             Init;       /*!< IWDG required parameters */
00081 
00082 }IWDG_HandleTypeDef;
00083 
00084 /**
00085   * @}
00086   */
00087 
00088 /* Exported constants --------------------------------------------------------*/
00089 /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
00090   * @{
00091   */
00092 
00093 /** @defgroup IWDG_Prescaler IWDG Prescaler
00094   * @{
00095   */
00096 #define IWDG_PRESCALER_4                0x00000000U                   /*!< IWDG prescaler set to 4   */
00097 #define IWDG_PRESCALER_8                IWDG_PR_PR_0                  /*!< IWDG prescaler set to 8   */
00098 #define IWDG_PRESCALER_16               IWDG_PR_PR_1                  /*!< IWDG prescaler set to 16  */
00099 #define IWDG_PRESCALER_32               (IWDG_PR_PR_1 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 32  */
00100 #define IWDG_PRESCALER_64               IWDG_PR_PR_2                  /*!< IWDG prescaler set to 64  */
00101 #define IWDG_PRESCALER_128              (IWDG_PR_PR_2 | IWDG_PR_PR_0) /*!< IWDG prescaler set to 128 */
00102 #define IWDG_PRESCALER_256              (IWDG_PR_PR_2 | IWDG_PR_PR_1) /*!< IWDG prescaler set to 256 */
00103 /**
00104   * @}
00105   */
00106 
00107 /**
00108   * @}
00109   */
00110 
00111 /* Exported macros -----------------------------------------------------------*/
00112 /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
00113   * @{
00114   */
00115 
00116 /**
00117   * @brief  Enable the IWDG peripheral.
00118   * @param  __HANDLE__  IWDG handle
00119   * @retval None
00120   */
00121 #define __HAL_IWDG_START(__HANDLE__)                WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
00122 
00123 /**
00124   * @brief  Reload IWDG counter with value defined in the reload register
00125   *         (write access to IWDG_PR & IWDG_RLR registers disabled).
00126   * @param  __HANDLE__  IWDG handle
00127   * @retval None
00128   */
00129 #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__)       WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
00130 
00131 /**
00132   * @}
00133   */
00134 
00135 /* Exported functions --------------------------------------------------------*/
00136 /** @defgroup IWDG_Exported_Functions  IWDG Exported Functions
00137   * @{
00138   */
00139 
00140 /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
00141   * @{
00142   */
00143 /* Initialization/Start functions  ********************************************/
00144 HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
00145 /**
00146   * @}
00147   */
00148 
00149 /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
00150   * @{
00151   */
00152 /* I/O operation functions ****************************************************/
00153 HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
00154 /**
00155   * @}
00156   */
00157 
00158 /**
00159   * @}
00160   */
00161 
00162 /* Private constants ---------------------------------------------------------*/
00163 /** @defgroup IWDG_Private_Constants IWDG Private Constants
00164   * @{
00165   */
00166 
00167 /**
00168   * @brief  IWDG Key Register BitMask
00169   */
00170 #define IWDG_KEY_RELOAD                 0x0000AAAAU  /*!< IWDG Reload Counter Enable   */
00171 #define IWDG_KEY_ENABLE                 0x0000CCCCU  /*!< IWDG Peripheral Enable       */
00172 #define IWDG_KEY_WRITE_ACCESS_ENABLE    0x00005555U  /*!< IWDG KR Write Access Enable  */
00173 #define IWDG_KEY_WRITE_ACCESS_DISABLE   0x00000000U  /*!< IWDG KR Write Access Disable */
00174 
00175 /**
00176   * @}
00177   */
00178 
00179 /* Private macros ------------------------------------------------------------*/
00180 /** @defgroup IWDG_Private_Macros IWDG Private Macros
00181   * @{
00182   */
00183 
00184 /**
00185   * @brief  Enable write access to IWDG_PR and IWDG_RLR registers.
00186   * @param  __HANDLE__  IWDG handle
00187   * @retval None
00188   */
00189 #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__)  WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
00190 
00191 /**
00192   * @brief  Disable write access to IWDG_PR and IWDG_RLR registers.
00193   * @param  __HANDLE__  IWDG handle
00194   * @retval None
00195   */
00196 #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
00197 
00198 /**
00199   * @brief  Check IWDG prescaler value.
00200   * @param  __PRESCALER__  IWDG prescaler value
00201   * @retval None
00202   */
00203 #define IS_IWDG_PRESCALER(__PRESCALER__)      (((__PRESCALER__) == IWDG_PRESCALER_4)  || \
00204                                                ((__PRESCALER__) == IWDG_PRESCALER_8)  || \
00205                                                ((__PRESCALER__) == IWDG_PRESCALER_16) || \
00206                                                ((__PRESCALER__) == IWDG_PRESCALER_32) || \
00207                                                ((__PRESCALER__) == IWDG_PRESCALER_64) || \
00208                                                ((__PRESCALER__) == IWDG_PRESCALER_128)|| \
00209                                                ((__PRESCALER__) == IWDG_PRESCALER_256))
00210 
00211 /**
00212   * @brief  Check IWDG reload value.
00213   * @param  __RELOAD__  IWDG reload value
00214   * @retval None
00215   */
00216 #define IS_IWDG_RELOAD(__RELOAD__)            ((__RELOAD__) <= IWDG_RLR_RL)
00217 
00218 /**
00219   * @}
00220   */
00221 
00222 /**
00223   * @}
00224   */
00225 
00226 /**
00227   * @}
00228   */
00229 
00230 
00231 #ifdef __cplusplus
00232 }
00233 #endif
00234 
00235 #endif /* __STM32F4xx_HAL_IWDG_H */
00236 
00237 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/