STM32F479xx HAL User Manual
stm32f4xx_hal_exti.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_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) 2018 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 STM32f4xx_HAL_EXTI_H
00022 #define STM32f4xx_HAL_EXTI_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx_hal_def.h"
00030 
00031 /** @addtogroup STM32F4xx_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 typedef enum
00046 {
00047   HAL_EXTI_COMMON_CB_ID          = 0x00U
00048 } EXTI_CallbackIDTypeDef;
00049 
00050 /**
00051   * @brief  EXTI Handle structure definition
00052   */
00053 typedef struct
00054 {
00055   uint32_t Line;                    /*!<  Exti line number */
00056   void (* PendingCallback)(void);   /*!<  Exti pending callback */
00057 } EXTI_HandleTypeDef;
00058 
00059 /**
00060   * @brief  EXTI Configuration structure definition
00061   */
00062 typedef struct
00063 {
00064   uint32_t Line;      /*!< The Exti line to be configured. This parameter
00065                            can be a value of @ref EXTI_Line */
00066   uint32_t Mode;      /*!< The Exit Mode to be configured for a core.
00067                            This parameter can be a combination of @ref EXTI_Mode */
00068   uint32_t Trigger;   /*!< The Exti Trigger to be configured. This parameter
00069                            can be a value of @ref EXTI_Trigger */
00070   uint32_t GPIOSel;   /*!< The Exti GPIO multiplexer selection to be configured.
00071                            This parameter is only possible for line 0 to 15. It
00072                            can be a value of @ref EXTI_GPIOSel */
00073 } EXTI_ConfigTypeDef;
00074 
00075 /**
00076   * @}
00077   */
00078 
00079 /* Exported constants --------------------------------------------------------*/
00080 /** @defgroup EXTI_Exported_Constants EXTI Exported Constants
00081   * @{
00082   */
00083 
00084 /** @defgroup EXTI_Line  EXTI Line
00085   * @{
00086   */
00087 #define EXTI_LINE_0                        (EXTI_GPIO       | 0x00u)    /*!< External interrupt line 0 */
00088 #define EXTI_LINE_1                        (EXTI_GPIO       | 0x01u)    /*!< External interrupt line 1 */
00089 #define EXTI_LINE_2                        (EXTI_GPIO       | 0x02u)    /*!< External interrupt line 2 */
00090 #define EXTI_LINE_3                        (EXTI_GPIO       | 0x03u)    /*!< External interrupt line 3 */
00091 #define EXTI_LINE_4                        (EXTI_GPIO       | 0x04u)    /*!< External interrupt line 4 */
00092 #define EXTI_LINE_5                        (EXTI_GPIO       | 0x05u)    /*!< External interrupt line 5 */
00093 #define EXTI_LINE_6                        (EXTI_GPIO       | 0x06u)    /*!< External interrupt line 6 */
00094 #define EXTI_LINE_7                        (EXTI_GPIO       | 0x07u)    /*!< External interrupt line 7 */
00095 #define EXTI_LINE_8                        (EXTI_GPIO       | 0x08u)    /*!< External interrupt line 8 */
00096 #define EXTI_LINE_9                        (EXTI_GPIO       | 0x09u)    /*!< External interrupt line 9 */
00097 #define EXTI_LINE_10                       (EXTI_GPIO       | 0x0Au)    /*!< External interrupt line 10 */
00098 #define EXTI_LINE_11                       (EXTI_GPIO       | 0x0Bu)    /*!< External interrupt line 11 */
00099 #define EXTI_LINE_12                       (EXTI_GPIO       | 0x0Cu)    /*!< External interrupt line 12 */
00100 #define EXTI_LINE_13                       (EXTI_GPIO       | 0x0Du)    /*!< External interrupt line 13 */
00101 #define EXTI_LINE_14                       (EXTI_GPIO       | 0x0Eu)    /*!< External interrupt line 14 */
00102 #define EXTI_LINE_15                       (EXTI_GPIO       | 0x0Fu)    /*!< External interrupt line 15 */
00103 #define EXTI_LINE_16                       (EXTI_CONFIG     | 0x10u)    /*!< External interrupt line 16 Connected to the PVD Output */
00104 #define EXTI_LINE_17                       (EXTI_CONFIG     | 0x11u)    /*!< External interrupt line 17 Connected to the RTC Alarm event */
00105 #if defined(EXTI_IMR_IM18)
00106 #define EXTI_LINE_18                       (EXTI_CONFIG     | 0x12u)    /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */
00107 #else
00108 #define EXTI_LINE_18                       (EXTI_RESERVED   | 0x12u)    /*!< No interrupt supported in this line */
00109 #endif /* EXTI_IMR_IM18 */
00110 #if defined(EXTI_IMR_IM19)
00111 #define EXTI_LINE_19                       (EXTI_CONFIG     | 0x13u)    /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */
00112 #else
00113 #define EXTI_LINE_19                       (EXTI_RESERVED   | 0x13u)    /*!< No interrupt supported in this line */
00114 #endif /* EXTI_IMR_IM19 */
00115 #if defined(EXTI_IMR_IM20)
00116 #define EXTI_LINE_20                       (EXTI_CONFIG     | 0x14u)    /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event  */
00117 #else
00118 #define EXTI_LINE_20                       (EXTI_RESERVED   | 0x14u)    /*!< No interrupt supported in this line */
00119 #endif /* EXTI_IMR_IM20 */
00120 #define EXTI_LINE_21                       (EXTI_CONFIG     | 0x15u)    /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */
00121 #define EXTI_LINE_22                       (EXTI_CONFIG     | 0x16u)    /*!< External interrupt line 22 Connected to the RTC Wakeup event */
00122 #if defined(EXTI_IMR_IM23)
00123 #define EXTI_LINE_23                       (EXTI_CONFIG     | 0x17u)    /*!< External interrupt line 23 Connected to the LPTIM1 asynchronous event */
00124 #endif /* EXTI_IMR_IM23 */
00125 
00126 /**
00127   * @}
00128   */
00129 
00130 /** @defgroup EXTI_Mode  EXTI Mode
00131   * @{
00132   */
00133 #define EXTI_MODE_NONE                      0x00000000u
00134 #define EXTI_MODE_INTERRUPT                 0x00000001u
00135 #define EXTI_MODE_EVENT                     0x00000002u
00136 /**
00137   * @}
00138   */
00139 
00140 /** @defgroup EXTI_Trigger  EXTI Trigger
00141   * @{
00142   */
00143 
00144 #define EXTI_TRIGGER_NONE                   0x00000000u
00145 #define EXTI_TRIGGER_RISING                 0x00000001u
00146 #define EXTI_TRIGGER_FALLING                0x00000002u
00147 #define EXTI_TRIGGER_RISING_FALLING         (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
00148 /**
00149   * @}
00150   */
00151 
00152 /** @defgroup EXTI_GPIOSel  EXTI GPIOSel
00153   * @brief
00154   * @{
00155   */
00156 #define EXTI_GPIOA                          0x00000000u
00157 #define EXTI_GPIOB                          0x00000001u
00158 #define EXTI_GPIOC                          0x00000002u
00159 #if defined (GPIOD)
00160 #define EXTI_GPIOD                          0x00000003u
00161 #endif /* GPIOD */
00162 #if defined (GPIOE)
00163 #define EXTI_GPIOE                          0x00000004u
00164 #endif /* GPIOE */
00165 #if defined (GPIOF)
00166 #define EXTI_GPIOF                          0x00000005u
00167 #endif /* GPIOF */
00168 #if defined (GPIOG)
00169 #define EXTI_GPIOG                          0x00000006u
00170 #endif /* GPIOG */
00171 #if defined (GPIOH)
00172 #define EXTI_GPIOH                          0x00000007u
00173 #endif /* GPIOH */
00174 #if defined (GPIOI)
00175 #define EXTI_GPIOI                          0x00000008u
00176 #endif /* GPIOI */
00177 #if defined (GPIOJ)
00178 #define EXTI_GPIOJ                          0x00000009u
00179 #endif /* GPIOJ */
00180 #if defined (GPIOK)
00181 #define EXTI_GPIOK                          0x0000000Au
00182 #endif /* GPIOK */
00183 
00184 /**
00185   * @}
00186   */
00187 
00188 /**
00189   * @}
00190   */
00191 
00192 /* Exported macro ------------------------------------------------------------*/
00193 /** @defgroup EXTI_Exported_Macros EXTI Exported Macros
00194   * @{
00195   */
00196 
00197 /**
00198   * @}
00199   */
00200 
00201 /* Private constants --------------------------------------------------------*/
00202 /** @defgroup EXTI_Private_Constants EXTI Private Constants
00203   * @{
00204   */
00205 /**
00206   * @brief  EXTI Line property definition
00207   */
00208 #define EXTI_PROPERTY_SHIFT                  24u
00209 #define EXTI_CONFIG                         (0x02uL << EXTI_PROPERTY_SHIFT)
00210 #define EXTI_GPIO                           ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
00211 #define EXTI_RESERVED                       (0x08uL << EXTI_PROPERTY_SHIFT)
00212 #define EXTI_PROPERTY_MASK                  (EXTI_CONFIG | EXTI_GPIO)
00213 
00214 /**
00215   * @brief  EXTI bit usage
00216   */
00217 #define EXTI_PIN_MASK                       0x0000001Fu
00218 
00219 /**
00220   * @brief  EXTI Mask for interrupt & event mode
00221   */
00222 #define EXTI_MODE_MASK                      (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
00223 
00224 /**
00225   * @brief  EXTI Mask for trigger possibilities
00226   */
00227 #define EXTI_TRIGGER_MASK                   (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
00228 
00229 /**
00230   * @brief  EXTI Line number
00231   */
00232 #if defined(EXTI_IMR_IM23)
00233 #define EXTI_LINE_NB                        24UL
00234 #else
00235 #define EXTI_LINE_NB                        23UL
00236 #endif /* EXTI_IMR_IM23 */
00237 
00238 /**
00239   * @}
00240   */
00241 
00242 /* Private macros ------------------------------------------------------------*/
00243 /** @defgroup EXTI_Private_Macros EXTI Private Macros
00244   * @{
00245   */
00246 #define IS_EXTI_LINE(__EXTI_LINE__)          ((((__EXTI_LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_PIN_MASK)) == 0x00u) && \
00247                                              ((((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG)              || \
00248                                               (((__EXTI_LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO))               && \
00249                                               (((__EXTI_LINE__) & EXTI_PIN_MASK) < EXTI_LINE_NB))
00250 
00251 #define IS_EXTI_MODE(__EXTI_LINE__)          ((((__EXTI_LINE__) & EXTI_MODE_MASK) != 0x00u) && \
00252                                               (((__EXTI_LINE__) & ~EXTI_MODE_MASK) == 0x00u))
00253 
00254 #define IS_EXTI_TRIGGER(__EXTI_LINE__)       (((__EXTI_LINE__)  & ~EXTI_TRIGGER_MASK) == 0x00u)
00255 
00256 #define IS_EXTI_PENDING_EDGE(__EXTI_LINE__)  ((__EXTI_LINE__) == EXTI_TRIGGER_RISING_FALLING)
00257 
00258 #define IS_EXTI_CONFIG_LINE(__EXTI_LINE__)   (((__EXTI_LINE__) & EXTI_CONFIG) != 0x00u)
00259 
00260 #if !defined (GPIOD)
00261 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00262                                          ((__PORT__) == EXTI_GPIOB) || \
00263                                          ((__PORT__) == EXTI_GPIOC) || \
00264                                          ((__PORT__) == EXTI_GPIOH))
00265 #elif !defined (GPIOE)
00266 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00267                                          ((__PORT__) == EXTI_GPIOB) || \
00268                                          ((__PORT__) == EXTI_GPIOC) || \
00269                                          ((__PORT__) == EXTI_GPIOD) || \
00270                                          ((__PORT__) == EXTI_GPIOH))
00271 #elif !defined (GPIOF)
00272 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00273                                          ((__PORT__) == EXTI_GPIOB) || \
00274                                          ((__PORT__) == EXTI_GPIOC) || \
00275                                          ((__PORT__) == EXTI_GPIOD) || \
00276                                          ((__PORT__) == EXTI_GPIOE) || \
00277                                          ((__PORT__) == EXTI_GPIOH))
00278 #elif !defined (GPIOI)
00279 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00280                                          ((__PORT__) == EXTI_GPIOB) || \
00281                                          ((__PORT__) == EXTI_GPIOC) || \
00282                                          ((__PORT__) == EXTI_GPIOD) || \
00283                                          ((__PORT__) == EXTI_GPIOE) || \
00284                                          ((__PORT__) == EXTI_GPIOF) || \
00285                                          ((__PORT__) == EXTI_GPIOG) || \
00286                                          ((__PORT__) == EXTI_GPIOH))
00287 #elif !defined (GPIOJ)
00288 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00289                                          ((__PORT__) == EXTI_GPIOB) || \
00290                                          ((__PORT__) == EXTI_GPIOC) || \
00291                                          ((__PORT__) == EXTI_GPIOD) || \
00292                                          ((__PORT__) == EXTI_GPIOE) || \
00293                                          ((__PORT__) == EXTI_GPIOF) || \
00294                                          ((__PORT__) == EXTI_GPIOG) || \
00295                                          ((__PORT__) == EXTI_GPIOH) || \
00296                                          ((__PORT__) == EXTI_GPIOI))
00297 #else
00298 #define IS_EXTI_GPIO_PORT(__PORT__)     (((__PORT__) == EXTI_GPIOA) || \
00299                                          ((__PORT__) == EXTI_GPIOB) || \
00300                                          ((__PORT__) == EXTI_GPIOC) || \
00301                                          ((__PORT__) == EXTI_GPIOD) || \
00302                                          ((__PORT__) == EXTI_GPIOE) || \
00303                                          ((__PORT__) == EXTI_GPIOF) || \
00304                                          ((__PORT__) == EXTI_GPIOG) || \
00305                                          ((__PORT__) == EXTI_GPIOH) || \
00306                                          ((__PORT__) == EXTI_GPIOI) || \
00307                                          ((__PORT__) == EXTI_GPIOJ) || \
00308                                          ((__PORT__) == EXTI_GPIOK))
00309 #endif /* GPIOD */
00310 
00311 #define IS_EXTI_GPIO_PIN(__PIN__)       ((__PIN__) < 16U)
00312 /**
00313   * @}
00314   */
00315 
00316 /* Exported functions --------------------------------------------------------*/
00317 /** @defgroup EXTI_Exported_Functions EXTI Exported Functions
00318   * @brief    EXTI Exported Functions
00319   * @{
00320   */
00321 
00322 /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
00323   * @brief    Configuration functions
00324   * @{
00325   */
00326 /* Configuration functions ****************************************************/
00327 HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
00328 HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
00329 HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
00330 HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
00331 HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
00332 /**
00333   * @}
00334   */
00335 
00336 /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
00337   * @brief    IO operation functions
00338   * @{
00339   */
00340 /* IO operation functions *****************************************************/
00341 void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
00342 uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
00343 void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
00344 void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
00345 
00346 /**
00347   * @}
00348   */
00349 
00350 /**
00351   * @}
00352   */
00353 
00354 /**
00355   * @}
00356   */
00357 
00358 /**
00359   * @}
00360   */
00361 
00362 #ifdef __cplusplus
00363 }
00364 #endif
00365 
00366 #endif /* STM32f4xx_HAL_EXTI_H */
00367 
00368 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/