Subversion Repositories LedShow

Rev

Rev 2 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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>&copy; Copyright (c) 2016 STMicroelectronics.
  10.   * All rights reserved.</center></h2>
  11.   *
  12.   * This software component is licensed by ST under BSD 3-Clause license,
  13.   * the "License"; You may not use this file except in compliance with the
  14.   * License. You may obtain a copy of the License at:
  15.   *                        opensource.org/licenses/BSD-3-Clause
  16.   *
  17.   ******************************************************************************
  18.   */
  19.  
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef STM32F1xx_HAL_IWDG_H
  22. #define STM32F1xx_HAL_IWDG_H
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. /* Includes ------------------------------------------------------------------*/
  29. #include "stm32f1xx_hal_def.h"
  30.  
  31. /** @addtogroup STM32F1xx_HAL_Driver
  32.   * @{
  33.   */
  34.  
  35. /** @defgroup IWDG IWDG
  36.   * @{
  37.   */
  38.  
  39. /* Exported types ------------------------------------------------------------*/
  40. /** @defgroup IWDG_Exported_Types IWDG Exported Types
  41.   * @{
  42.   */
  43.  
  44. /**
  45.   * @brief  IWDG Init structure definition
  46.   */
  47. typedef struct
  48. {
  49.   uint32_t Prescaler;  /*!< Select the prescaler of the IWDG.
  50.                             This parameter can be a value of @ref IWDG_Prescaler */
  51.  
  52.   uint32_t Reload;     /*!< Specifies the IWDG down-counter reload value.
  53.                             This parameter must be a number between Min_Data = 0 and Max_Data = 0x0FFF */
  54.  
  55. } IWDG_InitTypeDef;
  56.  
  57. /**
  58.   * @brief  IWDG Handle Structure definition
  59.   */
  60. typedef struct
  61. {
  62.   IWDG_TypeDef                 *Instance;  /*!< Register base address    */
  63.  
  64.   IWDG_InitTypeDef             Init;       /*!< IWDG required parameters */
  65. } IWDG_HandleTypeDef;
  66.  
  67.  
  68. /**
  69.   * @}
  70.   */
  71.  
  72. /* Exported constants --------------------------------------------------------*/
  73. /** @defgroup IWDG_Exported_Constants IWDG Exported Constants
  74.   * @{
  75.   */
  76.  
  77. /** @defgroup IWDG_Prescaler IWDG Prescaler
  78.   * @{
  79.   */
  80. #define IWDG_PRESCALER_4                0x00000000U                                     /*!< IWDG prescaler set to 4   */
  81. #define IWDG_PRESCALER_8                IWDG_PR_PR_0                                    /*!< IWDG prescaler set to 8   */
  82. #define IWDG_PRESCALER_16               IWDG_PR_PR_1                                    /*!< IWDG prescaler set to 16  */
  83. #define IWDG_PRESCALER_32               (IWDG_PR_PR_1 | IWDG_PR_PR_0)                   /*!< IWDG prescaler set to 32  */
  84. #define IWDG_PRESCALER_64               IWDG_PR_PR_2                                    /*!< IWDG prescaler set to 64  */
  85. #define IWDG_PRESCALER_128              (IWDG_PR_PR_2 | IWDG_PR_PR_0)                   /*!< IWDG prescaler set to 128 */
  86. #define IWDG_PRESCALER_256              (IWDG_PR_PR_2 | IWDG_PR_PR_1)                   /*!< IWDG prescaler set to 256 */
  87.  
  88. /**
  89.   * @}
  90.   */
  91.  
  92.  
  93.  
  94. /**
  95.   * @}
  96.   */
  97.  
  98. /* Exported macros -----------------------------------------------------------*/
  99. /** @defgroup IWDG_Exported_Macros IWDG Exported Macros
  100.   * @{
  101.   */
  102.  
  103. /**
  104.   * @brief  Enable the IWDG peripheral.
  105.   * @param  __HANDLE__  IWDG handle
  106.   * @retval None
  107.   */
  108. #define __HAL_IWDG_START(__HANDLE__)                WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_ENABLE)
  109.  
  110. /**
  111.   * @brief  Reload IWDG counter with value defined in the reload register
  112.   *         (write access to IWDG_PR and IWDG_RLR registers disabled).
  113.   * @param  __HANDLE__  IWDG handle
  114.   * @retval None
  115.   */
  116. #define __HAL_IWDG_RELOAD_COUNTER(__HANDLE__)       WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_RELOAD)
  117.  
  118. /**
  119.   * @}
  120.   */
  121.  
  122. /* Exported functions --------------------------------------------------------*/
  123. /** @defgroup IWDG_Exported_Functions  IWDG Exported Functions
  124.   * @{
  125.   */
  126.  
  127. /** @defgroup IWDG_Exported_Functions_Group1 Initialization and Start functions
  128.   * @{
  129.   */
  130. /* Initialization/Start functions  ********************************************/
  131. HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg);
  132. /**
  133.   * @}
  134.   */
  135.  
  136. /** @defgroup IWDG_Exported_Functions_Group2 IO operation functions
  137.   * @{
  138.   */
  139. /* I/O operation functions ****************************************************/
  140. HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg);
  141. /**
  142.   * @}
  143.   */
  144.  
  145. /**
  146.   * @}
  147.   */
  148.  
  149. /* Private constants ---------------------------------------------------------*/
  150. /** @defgroup IWDG_Private_Constants IWDG Private Constants
  151.   * @{
  152.   */
  153.  
  154. /**
  155.   * @brief  IWDG Key Register BitMask
  156.   */
  157. #define IWDG_KEY_RELOAD                 0x0000AAAAU  /*!< IWDG Reload Counter Enable   */
  158. #define IWDG_KEY_ENABLE                 0x0000CCCCU  /*!< IWDG Peripheral Enable       */
  159. #define IWDG_KEY_WRITE_ACCESS_ENABLE    0x00005555U  /*!< IWDG KR Write Access Enable  */
  160. #define IWDG_KEY_WRITE_ACCESS_DISABLE   0x00000000U  /*!< IWDG KR Write Access Disable */
  161.  
  162. /**
  163.   * @}
  164.   */
  165.  
  166. /* Private macros ------------------------------------------------------------*/
  167. /** @defgroup IWDG_Private_Macros IWDG Private Macros
  168.   * @{
  169.   */
  170.  
  171. /**
  172.   * @brief  Enable write access to IWDG_PR and IWDG_RLR registers.
  173.   * @param  __HANDLE__  IWDG handle
  174.   * @retval None
  175.   */
  176. #define IWDG_ENABLE_WRITE_ACCESS(__HANDLE__)  WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_ENABLE)
  177.  
  178. /**
  179.   * @brief  Disable write access to IWDG_PR and IWDG_RLR registers.
  180.   * @param  __HANDLE__  IWDG handle
  181.   * @retval None
  182.   */
  183. #define IWDG_DISABLE_WRITE_ACCESS(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->KR, IWDG_KEY_WRITE_ACCESS_DISABLE)
  184.  
  185. /**
  186.   * @brief  Check IWDG prescaler value.
  187.   * @param  __PRESCALER__  IWDG prescaler value
  188.   * @retval None
  189.   */
  190. #define IS_IWDG_PRESCALER(__PRESCALER__)      (((__PRESCALER__) == IWDG_PRESCALER_4)  || \
  191.                                                ((__PRESCALER__) == IWDG_PRESCALER_8)  || \
  192.                                                ((__PRESCALER__) == IWDG_PRESCALER_16) || \
  193.                                                ((__PRESCALER__) == IWDG_PRESCALER_32) || \
  194.                                                ((__PRESCALER__) == IWDG_PRESCALER_64) || \
  195.                                                ((__PRESCALER__) == IWDG_PRESCALER_128)|| \
  196.                                                ((__PRESCALER__) == IWDG_PRESCALER_256))
  197.  
  198. /**
  199.   * @brief  Check IWDG reload value.
  200.   * @param  __RELOAD__  IWDG reload value
  201.   * @retval None
  202.   */
  203. #define IS_IWDG_RELOAD(__RELOAD__)            ((__RELOAD__) <= IWDG_RLR_RL)
  204.  
  205.  
  206.  
  207. /**
  208.   * @}
  209.   */
  210.  
  211. /**
  212.   * @}
  213.   */
  214.  
  215. /**
  216.   * @}
  217.   */
  218.  
  219.  
  220. #ifdef __cplusplus
  221. }
  222. #endif
  223.  
  224. #endif /* STM32F1xx_HAL_IWDG_H */
  225.  
  226. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  227.