STM32F103xB HAL User Manual
stm32f1xx_hal_exti.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f1xx_hal_exti.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of EXTI HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2019 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_EXTI_H
00022 #define STM32F1xx_HAL_EXTI_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 EXTI EXTI
00036   * @brief EXTI HAL module driver
00037   * @{
00038   */
00039 
00040 /* Exported types ------------------------------------------------------------*/
00041 
00042 /** @defgroup EXTI_Exported_Types EXTI Exported Types
00043   * @{
00044   */
00045 
00046 /**
00047   * @brief  HAL EXTI common Callback ID enumeration definition
00048   */
00049 typedef enum
00050 {
00051   HAL_EXTI_COMMON_CB_ID          = 0x00U
00052 } EXTI_CallbackIDTypeDef;
00053 
00054 /**
00055   * @brief  EXTI Handle structure definition
00056   */
00057 typedef struct
00058 {
00059   uint32_t Line;                    /*!<  Exti line number */
00060   void (* PendingCallback)(void);   /*!<  Exti pending callback */
00061 } EXTI_HandleTypeDef;
00062 
00063 /**
00064   * @brief  EXTI Configuration structure definition
00065   */
00066 typedef struct
00067 {
00068   uint32_t Line;      /*!< The Exti line to be configured. This parameter
00069                            can be a value of @ref EXTI_Line */
00070   uint32_t Mode;      /*!< The Exit Mode to be configured for a core.
00071                            This parameter can be a combination of @ref EXTI_Mode */
00072   uint32_t Trigger;   /*!< The Exti Trigger to be configured. This parameter
00073                            can be a value of @ref EXTI_Trigger */
00074   uint32_t GPIOSel;   /*!< The Exti GPIO multiplexer selection to be configured.
00075                            This parameter is only possible for line 0 to 15. It
00076                            can be a value of @ref EXTI_GPIOSel */
00077 } EXTI_ConfigTypeDef;
00078 
00079 /**
00080   * @}
00081   */
00082 
00083 /* Exported constants --------------------------------------------------------*/
00084 /** @defgroup EXTI_Exported_Constants EXTI Exported Constants
00085   * @{
00086   */
00087 
00088 /** @defgroup EXTI_Line  EXTI Line
00089   * @{
00090   */
00091 #define EXTI_LINE_0                        (EXTI_GPIO     | 0x00u)    /*!< External interrupt line 0 */
00092 #define EXTI_LINE_1                        (EXTI_GPIO     | 0x01u)    /*!< External interrupt line 1 */
00093 #define EXTI_LINE_2                        (EXTI_GPIO     | 0x02u)    /*!< External interrupt line 2 */
00094 #define EXTI_LINE_3                        (EXTI_GPIO     | 0x03u)    /*!< External interrupt line 3 */
00095 #define EXTI_LINE_4                        (EXTI_GPIO     | 0x04u)    /*!< External interrupt line 4 */
00096 #define EXTI_LINE_5                        (EXTI_GPIO     | 0x05u)    /*!< External interrupt line 5 */
00097 #define EXTI_LINE_6                        (EXTI_GPIO     | 0x06u)    /*!< External interrupt line 6 */
00098 #define EXTI_LINE_7                        (EXTI_GPIO     | 0x07u)    /*!< External interrupt line 7 */
00099 #define EXTI_LINE_8                        (EXTI_GPIO     | 0x08u)    /*!< External interrupt line 8 */
00100 #define EXTI_LINE_9                        (EXTI_GPIO     | 0x09u)    /*!< External interrupt line 9 */
00101 #define EXTI_LINE_10                       (EXTI_GPIO     | 0x0Au)    /*!< External interrupt line 10 */
00102 #define EXTI_LINE_11                       (EXTI_GPIO     | 0x0Bu)    /*!< External interrupt line 11 */
00103 #define EXTI_LINE_12                       (EXTI_GPIO     | 0x0Cu)    /*!< External interrupt line 12 */
00104 #define EXTI_LINE_13                       (EXTI_GPIO     | 0x0Du)    /*!< External interrupt line 13 */
00105 #define EXTI_LINE_14                       (EXTI_GPIO     | 0x0Eu)    /*!< External interrupt line 14 */
00106 #define EXTI_LINE_15                       (EXTI_GPIO     | 0x0Fu)    /*!< External interrupt line 15 */
00107 #define EXTI_LINE_16                       (EXTI_CONFIG   | 0x10u)    /*!< External interrupt line 16 Connected to the PVD Output */
00108 #define EXTI_LINE_17                       (EXTI_CONFIG   | 0x11u)    /*!< External interrupt line 17 Connected to the RTC Alarm event */
00109 #if defined(EXTI_IMR_IM18)
00110 #define EXTI_LINE_18                       (EXTI_CONFIG   | 0x12u)    /*!< External interrupt line 18 Connected to the USB Wakeup from suspend event */
00111 #endif /* EXTI_IMR_IM18 */
00112 #if defined(EXTI_IMR_IM19)
00113 #define EXTI_LINE_19                       (EXTI_CONFIG   | 0x13u)    /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */
00114 #endif /* EXTI_IMR_IM19 */
00115 
00116 /**
00117   * @}
00118   */
00119 
00120 /** @defgroup EXTI_Mode  EXTI Mode
00121   * @{
00122   */
00123 #define EXTI_MODE_NONE                      0x00000000u
00124 #define EXTI_MODE_INTERRUPT                 0x00000001u
00125 #define EXTI_MODE_EVENT                     0x00000002u
00126 /**
00127   * @}
00128   */
00129 
00130 /** @defgroup EXTI_Trigger  EXTI Trigger
00131   * @{
00132   */
00133 #define EXTI_TRIGGER_NONE                   0x00000000u
00134 #define EXTI_TRIGGER_RISING                 0x00000001u
00135 #define EXTI_TRIGGER_FALLING                0x00000002u
00136 #define EXTI_TRIGGER_RISING_FALLING         (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
00137 /**
00138   * @}
00139   */
00140 
00141 /** @defgroup EXTI_GPIOSel  EXTI GPIOSel
00142   * @brief
00143   * @{
00144   */
00145 #define EXTI_GPIOA                          0x00000000u
00146 #define EXTI_GPIOB                          0x00000001u
00147 #define EXTI_GPIOC                          0x00000002u
00148 #define EXTI_GPIOD                          0x00000003u
00149 #if defined (GPIOE)
00150 #define EXTI_GPIOE                          0x00000004u
00151 #endif /* GPIOE */
00152 #if defined (GPIOF)
00153 #define EXTI_GPIOF                          0x00000005u
00154 #endif /* GPIOF */
00155 #if defined (GPIOG)
00156 #define EXTI_GPIOG                          0x00000006u
00157 #endif /* GPIOG */
00158 /**
00159   * @}
00160   */
00161 
00162 /**
00163   * @}
00164   */
00165 
00166 /* Exported macro ------------------------------------------------------------*/
00167 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros
00168   * @{
00169   */
00170 
00171 /**
00172   * @}
00173   */
00174 
00175 /* Private constants --------------------------------------------------------*/
00176 /** @defgroup EXTI_Private_Constants EXTI Private Constants
00177   * @{
00178   */
00179 /**
00180   * @brief  EXTI Line property definition
00181   */
00182 #define EXTI_PROPERTY_SHIFT                 24u
00183 #define EXTI_CONFIG                         (0x02uL << EXTI_PROPERTY_SHIFT)
00184 #define EXTI_GPIO                           ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
00185 #define EXTI_PROPERTY_MASK                  (EXTI_CONFIG | EXTI_GPIO)
00186 
00187 /**
00188   * @brief  EXTI bit usage
00189   */
00190 #define EXTI_PIN_MASK                       0x0000001Fu
00191 
00192 /**
00193   * @brief  EXTI Mask for interrupt & event mode
00194   */
00195 #define EXTI_MODE_MASK                      (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
00196 
00197 /**
00198   * @brief  EXTI Mask for trigger possibilities
00199   */
00200 #define EXTI_TRIGGER_MASK                   (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
00201 
00202 /**
00203   * @brief  EXTI Line number
00204   */
00205 #if defined(EXTI_IMR_IM19)
00206 #define EXTI_LINE_NB                        20UL
00207 #elif defined(EXTI_IMR_IM18)
00208 #define EXTI_LINE_NB                        19UL
00209 #else /* EXTI_IMR_IM17 */
00210 #define EXTI_LINE_NB                        18UL
00211 #endif /* EXTI_IMR_IM19 */
00212 /**
00213   * @}
00214   */
00215 
00216 /* Private macros ------------------------------------------------------------*/
00217 /** @defgroup EXTI_Private_Macros EXTI Private Macros
00218   * @{
00219   */
00220 #define IS_EXTI_LINE(__EXTI_LINE__)          ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \
00221                                              ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG)   || \
00222                                               (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO))    && \
00223                                               (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB))
00224 
00225 #define IS_EXTI_MODE(__EXTI_LINE__)          ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \
00226                                               (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u))
00227 
00228 #define IS_EXTI_TRIGGER(__EXTI_LINE__)       (((__EXTI_LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u)
00229 
00230 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__)  ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING)
00231 
00232 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__)   (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u)
00233 
00234 #if defined (GPIOG)
00235 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00236                                          ((__PORT__) == EXTI_GPIOB) || \
00237                                          ((__PORT__) == EXTI_GPIOC) || \
00238                                          ((__PORT__) == EXTI_GPIOD) || \
00239                                          ((__PORT__) == EXTI_GPIOE) || \
00240                                          ((__PORT__) == EXTI_GPIOF) || \
00241                                          ((__PORT__) == EXTI_GPIOG))
00242 #elif defined (GPIOF)
00243 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00244                                          ((__PORT__) == EXTI_GPIOB) || \
00245                                          ((__PORT__) == EXTI_GPIOC) || \
00246                                          ((__PORT__) == EXTI_GPIOD) || \
00247                                          ((__PORT__) == EXTI_GPIOE) || \
00248                                          ((__PORT__) == EXTI_GPIOF))
00249 #elif defined (GPIOE)
00250 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00251                                          ((__PORT__) == EXTI_GPIOB) || \
00252                                          ((__PORT__) == EXTI_GPIOC) || \
00253                                          ((__PORT__) == EXTI_GPIOD) || \
00254                                          ((__PORT__) == EXTI_GPIOE))
00255 #else
00256 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00257                                          ((__PORT__) == EXTI_GPIOB) || \
00258                                          ((__PORT__) == EXTI_GPIOC) || \
00259                                          ((__PORT__) == EXTI_GPIOD))
00260 #endif /* GPIOG */
00261 
00262 #define IS_EXTI_GPIO_PIN(__PIN__)       ((__PIN__) < 16u)
00263 
00264 /**
00265   * @}
00266   */
00267 
00268 /* Exported functions --------------------------------------------------------*/
00269 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions
00270   * @brief    EXTI Exported Functions
00271   * @{
00272   */
00273 
00274 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
00275   * @brief    Configuration functions
00276   * @{
00277   */
00278 /* Configuration functions ****************************************************/
00279 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
00280 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
00281 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
00282 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
00283 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
00284 /**
00285   * @}
00286   */
00287 
00288 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
00289   * @brief    IO operation functions
00290   * @{
00291   */
00292 /* IO operation functions *****************************************************/
00293 void              HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
00294 uint32_t          HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
00295 void              HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
00296 void              HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
00297 
00298 /**
00299   * @}
00300   */
00301 
00302 /**
00303   * @}
00304   */
00305 
00306 /**
00307   * @}
00308   */
00309 
00310 /**
00311   * @}
00312   */
00313 
00314 #ifdef __cplusplus
00315 }
00316 #endif
00317 
00318 #endif /* STM32F1xx_HAL_EXTI_H */
00319 
00320 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/