stm8l15x_exti.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /**
  2. ******************************************************************************
  3. * @file stm8l15x_exti.h
  4. * @author MCD Application Team
  5. * @version V1.6.1
  6. * @date 30-September-2014
  7. * @brief This file contains all the functions prototypes for the EXTI firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  13. *
  14. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  15. * You may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at:
  17. *
  18. * http://www.st.com/software_license_agreement_liberty_v2
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. ******************************************************************************
  27. */
  28. /* Define to prevent recursive inclusion -------------------------------------*/
  29. #ifndef __STM8L15x_EXTI_H
  30. #define __STM8L15x_EXTI_H
  31. /* Includes ------------------------------------------------------------------*/
  32. #include "stm8l15x.h"
  33. /** @addtogroup STM8L15x_StdPeriph_Driver
  34. * @{
  35. */
  36. /** @addtogroup EXTI
  37. * @{
  38. */
  39. /* Exported types ------------------------------------------------------------*/
  40. /** @addtogroup EXTI_Exported_Types
  41. * @{
  42. */
  43. /** @defgroup EXTI_Trigger
  44. * @{
  45. */
  46. typedef enum
  47. {
  48. EXTI_Trigger_Falling_Low = (uint8_t)0x00, /*!< Interrupt on Falling edge and Low level */
  49. EXTI_Trigger_Rising = (uint8_t)0x01, /*!< Interrupt on Rising edge only */
  50. EXTI_Trigger_Falling = (uint8_t)0x02, /*!< Interrupt on Falling edge only */
  51. EXTI_Trigger_Rising_Falling = (uint8_t)0x03 /*!< Interrupt on Rising and Falling edges */
  52. } EXTI_Trigger_TypeDef;
  53. /**
  54. * @}
  55. */
  56. /** @defgroup EXTI_Half_Port
  57. *
  58. * @brief EXTI halfPort possible values
  59. * Values are coded as following:
  60. * - Bit 7: 0 => the half port is in EXTI_CONF1 register
  61. * 1 => the half port is in EXTI_CONF2 register
  62. * - Bits[6:0] => the half port selection mask
  63. * @{
  64. */
  65. typedef enum
  66. {
  67. EXTI_HalfPort_B_LSB = (uint8_t)0x01, /*!< Interrupt selector PB(3:0) */
  68. EXTI_HalfPort_B_MSB = (uint8_t)0x02, /*!< Interrupt selector PB(7:4) */
  69. EXTI_HalfPort_D_LSB = (uint8_t)0x04, /*!< Interrupt selector PD(3:0) */
  70. EXTI_HalfPort_D_MSB = (uint8_t)0x08, /*!< Interrupt selector PD(7:4) */
  71. EXTI_HalfPort_E_LSB = (uint8_t)0x10, /*!< Interrupt selector PE(3:0) */
  72. EXTI_HalfPort_E_MSB = (uint8_t)0x20, /*!< Interrupt selector PE(7:4) */
  73. EXTI_HalfPort_F_LSB = (uint8_t)0x40, /*!< Interrupt selector PF(3:0) */
  74. EXTI_HalfPort_F_MSB = (uint8_t)0x81, /*!< Interrupt selector PF(7:4) */
  75. EXTI_HalfPort_G_LSB = (uint8_t)0x82, /*!< Interrupt selector PG(3:0) */
  76. EXTI_HalfPort_G_MSB = (uint8_t)0x84, /*!< Interrupt selector PG(7:4) */
  77. EXTI_HalfPort_H_LSB = (uint8_t)0x88, /*!< Interrupt selector PH(3:0) */
  78. EXTI_HalfPort_H_MSB = (uint8_t)0x90 /*!< Interrupt selector PH(7:4) */
  79. } EXTI_HalfPort_TypeDef;
  80. /**
  81. * @}
  82. */
  83. /** @defgroup EXTI_Port
  84. *
  85. * @brief EXTI Port possible values
  86. * Values are coded in 0xXY format where
  87. * X: the register index
  88. * X = 0: EXTI_CR3
  89. * X = 1: EXTI_CR4
  90. * Y: the number of shift to be performed
  91. * @{
  92. */
  93. typedef enum
  94. {
  95. EXTI_Port_B = (uint8_t)0x00, /*!< GPIO Port B */
  96. EXTI_Port_D = (uint8_t)0x02, /*!< GPIO Port D */
  97. EXTI_Port_E = (uint8_t)0x04, /*!< GPIO Port E */
  98. EXTI_Port_F = (uint8_t)0x06, /*!< GPIO Port F */
  99. EXTI_Port_G = (uint8_t)0x10, /*!< GPIO Port G */
  100. EXTI_Port_H = (uint8_t)0x12 /*!< GPIO Port H */
  101. } EXTI_Port_TypeDef;
  102. /**
  103. * @}
  104. */
  105. /** @defgroup EXTI_Pin
  106. *
  107. * @brief EXTI PinNum possible values
  108. * Values are coded in 0xXY format where
  109. * X: the register index
  110. * X = 0: EXTI_CR1
  111. * X = 1: EXTI_CR2
  112. * Y: the number of shift to be performed
  113. * @{
  114. */
  115. typedef enum
  116. {
  117. EXTI_Pin_0 = (uint8_t)0x00, /*!< GPIO Pin 0 */
  118. EXTI_Pin_1 = (uint8_t)0x02, /*!< GPIO Pin 1 */
  119. EXTI_Pin_2 = (uint8_t)0x04, /*!< GPIO Pin 2 */
  120. EXTI_Pin_3 = (uint8_t)0x06, /*!< GPIO Pin 3 */
  121. EXTI_Pin_4 = (uint8_t)0x10, /*!< GPIO Pin 4 */
  122. EXTI_Pin_5 = (uint8_t)0x12, /*!< GPIO Pin 5 */
  123. EXTI_Pin_6 = (uint8_t)0x14, /*!< GPIO Pin 6 */
  124. EXTI_Pin_7 = (uint8_t)0x16 /*!< GPIO Pin 7 */
  125. } EXTI_Pin_TypeDef;
  126. /**
  127. * @}
  128. */
  129. /** @defgroup EXTI_Interrupts
  130. *
  131. * @brief EXTI IT pending bit possible values
  132. * Values are coded in 0xXY format where
  133. * X: the register index
  134. * X = 00: EXTI_SR1
  135. * X = 01: EXTI_SR2
  136. * Y: the IT pending bit mask
  137. * @{
  138. */
  139. typedef enum
  140. {
  141. EXTI_IT_Pin0 = (uint16_t)0x0001, /*!< GPIO Pin pos 0 */
  142. EXTI_IT_Pin1 = (uint16_t)0x0002, /*!< GPIO Pin pos 1 */
  143. EXTI_IT_Pin2 = (uint16_t)0x0004, /*!< GPIO Pin pos 2 */
  144. EXTI_IT_Pin3 = (uint16_t)0x0008, /*!< GPIO Pin pos 3 */
  145. EXTI_IT_Pin4 = (uint16_t)0x0010, /*!< GPIO Pin pos 4 */
  146. EXTI_IT_Pin5 = (uint16_t)0x0020, /*!< GPIO Pin pos 5 */
  147. EXTI_IT_Pin6 = (uint16_t)0x0040, /*!< GPIO Pin pos 6 */
  148. EXTI_IT_Pin7 = (uint16_t)0x0080, /*!< GPIO Pin pos 7 */
  149. EXTI_IT_PortB = (uint16_t)0x0101, /*!< GPIO Port B */
  150. EXTI_IT_PortD = (uint16_t)0x0102, /*!< GPIO Port D */
  151. EXTI_IT_PortE = (uint16_t)0x0104, /*!< GPIO Port E */
  152. EXTI_IT_PortF = (uint16_t)0x0108, /*!< GPIO Port F */
  153. EXTI_IT_PortG = (uint16_t)0x0110, /*!< GPIO Port G */
  154. EXTI_IT_PortH = (uint16_t)0x0120 /*!< GPIO Port H */
  155. } EXTI_IT_TypeDef;
  156. /**
  157. * @}
  158. */
  159. /**
  160. * @}
  161. */
  162. /* Exported constants --------------------------------------------------------*/
  163. /* Exported macros -----------------------------------------------------------*/
  164. /** @addtogroup EXTI_Exported_Macros
  165. * @{
  166. */
  167. /**
  168. * @brief Macro used by the assert function to check the different functions parameters.
  169. */
  170. /**
  171. * @brief Macro used by the assert function in order to check the different values
  172. * of EXTI Sensitivity
  173. */
  174. #define IS_EXTI_TRIGGER(TRIGGER) \
  175. (((TRIGGER) == EXTI_Trigger_Falling_Low) || \
  176. ((TRIGGER) == EXTI_Trigger_Rising) || \
  177. ((TRIGGER) == EXTI_Trigger_Falling) || \
  178. ((TRIGGER) == EXTI_Trigger_Rising_Falling))
  179. /**
  180. * @brief Macro used by the assert function in order to check the different
  181. * half ports values for configuration.
  182. */
  183. #define IS_EXTI_HALFPORT(HALFPORT) \
  184. (((HALFPORT) == EXTI_HalfPort_B_LSB) ||\
  185. ((HALFPORT) == EXTI_HalfPort_B_MSB) ||\
  186. ((HALFPORT) == EXTI_HalfPort_D_LSB) ||\
  187. ((HALFPORT) == EXTI_HalfPort_D_MSB) ||\
  188. ((HALFPORT) == EXTI_HalfPort_E_LSB) ||\
  189. ((HALFPORT) == EXTI_HalfPort_E_MSB) ||\
  190. ((HALFPORT) == EXTI_HalfPort_F_LSB) ||\
  191. ((HALFPORT) == EXTI_HalfPort_F_MSB) ||\
  192. ((HALFPORT) == EXTI_HalfPort_G_LSB) ||\
  193. ((HALFPORT) == EXTI_HalfPort_G_MSB) ||\
  194. ((HALFPORT) == EXTI_HalfPort_H_LSB) ||\
  195. ((HALFPORT) == EXTI_HalfPort_H_MSB))
  196. /**
  197. * @brief Macro used by the assert function in order to check the different Port Number values
  198. */
  199. #define IS_EXTI_PORT(PORT) (((PORT) == EXTI_Port_B) ||\
  200. ((PORT) == EXTI_Port_D) ||\
  201. ((PORT) == EXTI_Port_E) ||\
  202. ((PORT) == EXTI_Port_F) ||\
  203. ((PORT) == EXTI_Port_G) ||\
  204. ((PORT) == EXTI_Port_H))
  205. /**
  206. * @brief Macro used by the assert function in order to check the different Pin numbers values
  207. */
  208. #define IS_EXTI_PINNUM(PINNUM) \
  209. (((PINNUM) == EXTI_Pin_0) ||\
  210. ((PINNUM) == EXTI_Pin_1) ||\
  211. ((PINNUM) == EXTI_Pin_2) ||\
  212. ((PINNUM) == EXTI_Pin_3) ||\
  213. ((PINNUM) == EXTI_Pin_4) ||\
  214. ((PINNUM) == EXTI_Pin_5) ||\
  215. ((PINNUM) == EXTI_Pin_6) ||\
  216. ((PINNUM) == EXTI_Pin_7))
  217. /**
  218. * @brief Macro used by the assert function in order to check the different flags values
  219. */
  220. #define IS_EXTI_ITPENDINGBIT(ITPENDINGBIT) \
  221. (((ITPENDINGBIT) == EXTI_IT_Pin0) ||\
  222. ((ITPENDINGBIT) == EXTI_IT_Pin1) ||\
  223. ((ITPENDINGBIT) == EXTI_IT_Pin2) ||\
  224. ((ITPENDINGBIT) == EXTI_IT_Pin3) ||\
  225. ((ITPENDINGBIT) == EXTI_IT_Pin4) ||\
  226. ((ITPENDINGBIT) == EXTI_IT_Pin5) ||\
  227. ((ITPENDINGBIT) == EXTI_IT_Pin6) ||\
  228. ((ITPENDINGBIT) == EXTI_IT_Pin7) ||\
  229. ((ITPENDINGBIT) == EXTI_IT_PortB) ||\
  230. ((ITPENDINGBIT) == EXTI_IT_PortD) ||\
  231. ((ITPENDINGBIT) == EXTI_IT_PortE) ||\
  232. ((ITPENDINGBIT) == EXTI_IT_PortF) ||\
  233. ((ITPENDINGBIT) == EXTI_IT_PortG) ||\
  234. ((ITPENDINGBIT) == EXTI_IT_PortH))
  235. /**
  236. * @}
  237. */
  238. /* Exported functions ------------------------------------------------------- */
  239. /* EXTI configuration *********************************************************/
  240. void EXTI_DeInit(void);
  241. void EXTI_SetPinSensitivity(EXTI_Pin_TypeDef EXTI_Pin, EXTI_Trigger_TypeDef EXTI_Trigger);
  242. void EXTI_SelectPort(EXTI_Port_TypeDef EXTI_Port);
  243. void EXTI_SetHalfPortSelection(EXTI_HalfPort_TypeDef EXTI_HalfPort, FunctionalState NewState);
  244. void EXTI_SetPortSensitivity(EXTI_Port_TypeDef EXTI_Port, EXTI_Trigger_TypeDef EXTI_Trigger);
  245. EXTI_Trigger_TypeDef EXTI_GetPinSensitivity(EXTI_Pin_TypeDef EXTI_Pin);
  246. EXTI_Trigger_TypeDef EXTI_GetPortSensitivity(EXTI_Port_TypeDef EXTI_Port);
  247. /* EXTI Interrupt status management *******************************************/
  248. ITStatus EXTI_GetITStatus(EXTI_IT_TypeDef EXTI_IT);
  249. void EXTI_ClearITPendingBit(EXTI_IT_TypeDef EXTI_IT);
  250. #endif /* __STM8L15x_EXTI_H */
  251. /**
  252. * @}
  253. */
  254. /**
  255. * @}
  256. */
  257. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/