stm32f2xx_exti.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_exti.h
  4. * @author MCD Application Team
  5. * @version V1.1.3
  6. * @date 31-December-2021
  7. * @brief This file contains all the functions prototypes for the EXTI firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2012 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F2xx_EXTI_H
  23. #define __STM32F2xx_EXTI_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f2xx.h"
  29. /** @addtogroup STM32F2xx_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup EXTI
  33. * @{
  34. */
  35. /* Exported types ------------------------------------------------------------*/
  36. /**
  37. * @brief EXTI mode enumeration
  38. */
  39. typedef enum
  40. {
  41. EXTI_Mode_Interrupt = 0x00,
  42. EXTI_Mode_Event = 0x04
  43. }EXTIMode_TypeDef;
  44. #define IS_EXTI_MODE(MODE) (((MODE) == EXTI_Mode_Interrupt) || ((MODE) == EXTI_Mode_Event))
  45. /**
  46. * @brief EXTI Trigger enumeration
  47. */
  48. typedef enum
  49. {
  50. EXTI_Trigger_Rising = 0x08,
  51. EXTI_Trigger_Falling = 0x0C,
  52. EXTI_Trigger_Rising_Falling = 0x10
  53. }EXTITrigger_TypeDef;
  54. #define IS_EXTI_TRIGGER(TRIGGER) (((TRIGGER) == EXTI_Trigger_Rising) || \
  55. ((TRIGGER) == EXTI_Trigger_Falling) || \
  56. ((TRIGGER) == EXTI_Trigger_Rising_Falling))
  57. /**
  58. * @brief EXTI Init Structure definition
  59. */
  60. typedef struct
  61. {
  62. uint32_t EXTI_Line; /*!< Specifies the EXTI lines to be enabled or disabled.
  63. This parameter can be any combination value of @ref EXTI_Lines */
  64. EXTIMode_TypeDef EXTI_Mode; /*!< Specifies the mode for the EXTI lines.
  65. This parameter can be a value of @ref EXTIMode_TypeDef */
  66. EXTITrigger_TypeDef EXTI_Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines.
  67. This parameter can be a value of @ref EXTITrigger_TypeDef */
  68. FunctionalState EXTI_LineCmd; /*!< Specifies the new state of the selected EXTI lines.
  69. This parameter can be set either to ENABLE or DISABLE */
  70. }EXTI_InitTypeDef;
  71. /* Exported constants --------------------------------------------------------*/
  72. /** @defgroup EXTI_Exported_Constants
  73. * @{
  74. */
  75. /** @defgroup EXTI_Lines
  76. * @{
  77. */
  78. #define EXTI_Line0 ((uint32_t)0x00001) /*!< External interrupt line 0 */
  79. #define EXTI_Line1 ((uint32_t)0x00002) /*!< External interrupt line 1 */
  80. #define EXTI_Line2 ((uint32_t)0x00004) /*!< External interrupt line 2 */
  81. #define EXTI_Line3 ((uint32_t)0x00008) /*!< External interrupt line 3 */
  82. #define EXTI_Line4 ((uint32_t)0x00010) /*!< External interrupt line 4 */
  83. #define EXTI_Line5 ((uint32_t)0x00020) /*!< External interrupt line 5 */
  84. #define EXTI_Line6 ((uint32_t)0x00040) /*!< External interrupt line 6 */
  85. #define EXTI_Line7 ((uint32_t)0x00080) /*!< External interrupt line 7 */
  86. #define EXTI_Line8 ((uint32_t)0x00100) /*!< External interrupt line 8 */
  87. #define EXTI_Line9 ((uint32_t)0x00200) /*!< External interrupt line 9 */
  88. #define EXTI_Line10 ((uint32_t)0x00400) /*!< External interrupt line 10 */
  89. #define EXTI_Line11 ((uint32_t)0x00800) /*!< External interrupt line 11 */
  90. #define EXTI_Line12 ((uint32_t)0x01000) /*!< External interrupt line 12 */
  91. #define EXTI_Line13 ((uint32_t)0x02000) /*!< External interrupt line 13 */
  92. #define EXTI_Line14 ((uint32_t)0x04000) /*!< External interrupt line 14 */
  93. #define EXTI_Line15 ((uint32_t)0x08000) /*!< External interrupt line 15 */
  94. #define EXTI_Line16 ((uint32_t)0x10000) /*!< External interrupt line 16 Connected to the PVD Output */
  95. #define EXTI_Line17 ((uint32_t)0x20000) /*!< External interrupt line 17 Connected to the RTC Alarm event */
  96. #define EXTI_Line18 ((uint32_t)0x40000) /*!< External interrupt line 18 Connected to the USB OTG FS Wakeup from suspend event */
  97. #define EXTI_Line19 ((uint32_t)0x80000) /*!< External interrupt line 19 Connected to the Ethernet Wakeup event */
  98. #define EXTI_Line20 ((uint32_t)0x00100000) /*!< External interrupt line 20 Connected to the USB OTG HS (configured in FS) Wakeup event */
  99. #define EXTI_Line21 ((uint32_t)0x00200000) /*!< External interrupt line 21 Connected to the RTC Tamper and Time Stamp events */
  100. #define EXTI_Line22 ((uint32_t)0x00400000) /*!< External interrupt line 22 Connected to the RTC Wakeup event */
  101. #define IS_EXTI_LINE(LINE) ((((LINE) & (uint32_t)0xFF800000) == 0x00) && ((LINE) != (uint16_t)0x00))
  102. #define IS_GET_EXTI_LINE(LINE) (((LINE) == EXTI_Line0) || ((LINE) == EXTI_Line1) || \
  103. ((LINE) == EXTI_Line2) || ((LINE) == EXTI_Line3) || \
  104. ((LINE) == EXTI_Line4) || ((LINE) == EXTI_Line5) || \
  105. ((LINE) == EXTI_Line6) || ((LINE) == EXTI_Line7) || \
  106. ((LINE) == EXTI_Line8) || ((LINE) == EXTI_Line9) || \
  107. ((LINE) == EXTI_Line10) || ((LINE) == EXTI_Line11) || \
  108. ((LINE) == EXTI_Line12) || ((LINE) == EXTI_Line13) || \
  109. ((LINE) == EXTI_Line14) || ((LINE) == EXTI_Line15) || \
  110. ((LINE) == EXTI_Line16) || ((LINE) == EXTI_Line17) || \
  111. ((LINE) == EXTI_Line18) || ((LINE) == EXTI_Line19) || \
  112. ((LINE) == EXTI_Line20) || ((LINE) == EXTI_Line21) ||\
  113. ((LINE) == EXTI_Line22))
  114. /**
  115. * @}
  116. */
  117. /**
  118. * @}
  119. */
  120. /* Exported macro ------------------------------------------------------------*/
  121. /* Exported functions --------------------------------------------------------*/
  122. /* Function used to set the EXTI configuration to the default reset state *****/
  123. void EXTI_DeInit(void);
  124. /* Initialization and Configuration functions *********************************/
  125. void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct);
  126. void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct);
  127. void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line);
  128. /* Interrupts and flags management functions **********************************/
  129. FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line);
  130. void EXTI_ClearFlag(uint32_t EXTI_Line);
  131. ITStatus EXTI_GetITStatus(uint32_t EXTI_Line);
  132. void EXTI_ClearITPendingBit(uint32_t EXTI_Line);
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif /* __STM32F2xx_EXTI_H */
  137. /**
  138. * @}
  139. */
  140. /**
  141. * @}
  142. */