stm8s_exti.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. ******************************************************************************
  3. * @file stm8s_exti.h
  4. * @author MCD Application Team
  5. * @version V2.3.0
  6. * @date 16-June-2017
  7. * @brief This file contains all functions prototype and macros for the EXTI peripheral.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2014 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. /* Define to prevent recursive inclusion -------------------------------------*/
  28. #ifndef __STM8S_EXTI_H
  29. #define __STM8S_EXTI_H
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "stm8s.h"
  32. /* Exported types ------------------------------------------------------------*/
  33. /** @addtogroup EXTI_Exported_Types
  34. * @{
  35. */
  36. /**
  37. * @brief EXTI Sensitivity values for PORTA to PORTE
  38. */
  39. typedef enum {
  40. EXTI_SENSITIVITY_FALL_LOW = (uint8_t)0x00, /*!< Interrupt on Falling edge and Low level */
  41. EXTI_SENSITIVITY_RISE_ONLY = (uint8_t)0x01, /*!< Interrupt on Rising edge only */
  42. EXTI_SENSITIVITY_FALL_ONLY = (uint8_t)0x02, /*!< Interrupt on Falling edge only */
  43. EXTI_SENSITIVITY_RISE_FALL = (uint8_t)0x03 /*!< Interrupt on Rising and Falling edges */
  44. } EXTI_Sensitivity_TypeDef;
  45. /**
  46. * @brief EXTI Sensitivity values for TLI
  47. */
  48. typedef enum {
  49. EXTI_TLISENSITIVITY_FALL_ONLY = (uint8_t)0x00, /*!< Top Level Interrupt on Falling edge only */
  50. EXTI_TLISENSITIVITY_RISE_ONLY = (uint8_t)0x04 /*!< Top Level Interrupt on Rising edge only */
  51. } EXTI_TLISensitivity_TypeDef;
  52. /**
  53. * @brief EXTI PortNum possible values
  54. */
  55. typedef enum {
  56. EXTI_PORT_GPIOA = (uint8_t)0x00, /*!< GPIO Port A */
  57. EXTI_PORT_GPIOB = (uint8_t)0x01, /*!< GPIO Port B */
  58. EXTI_PORT_GPIOC = (uint8_t)0x02, /*!< GPIO Port C */
  59. EXTI_PORT_GPIOD = (uint8_t)0x03, /*!< GPIO Port D */
  60. EXTI_PORT_GPIOE = (uint8_t)0x04 /*!< GPIO Port E */
  61. } EXTI_Port_TypeDef;
  62. /**
  63. * @}
  64. */
  65. /* Private macros ------------------------------------------------------------*/
  66. /** @addtogroup EXTI_Private_Macros
  67. * @{
  68. */
  69. /**
  70. * @brief Macro used by the assert function in order to check the different sensitivity values for PORTA to PORTE.
  71. */
  72. #define IS_EXTI_SENSITIVITY_OK(SensitivityValue) \
  73. (((SensitivityValue) == EXTI_SENSITIVITY_FALL_LOW) || \
  74. ((SensitivityValue) == EXTI_SENSITIVITY_RISE_ONLY) || \
  75. ((SensitivityValue) == EXTI_SENSITIVITY_FALL_ONLY) || \
  76. ((SensitivityValue) == EXTI_SENSITIVITY_RISE_FALL))
  77. /**
  78. * @brief Macro used by the assert function in order to check the different sensitivity values for TLI.
  79. */
  80. #define IS_EXTI_TLISENSITIVITY_OK(SensitivityValue) \
  81. (((SensitivityValue) == EXTI_TLISENSITIVITY_FALL_ONLY) || \
  82. ((SensitivityValue) == EXTI_TLISENSITIVITY_RISE_ONLY))
  83. /**
  84. * @brief Macro used by the assert function in order to check the different Port values
  85. */
  86. #define IS_EXTI_PORT_OK(PORT) \
  87. (((PORT) == EXTI_PORT_GPIOA) ||\
  88. ((PORT) == EXTI_PORT_GPIOB) ||\
  89. ((PORT) == EXTI_PORT_GPIOC) ||\
  90. ((PORT) == EXTI_PORT_GPIOD) ||\
  91. ((PORT) == EXTI_PORT_GPIOE))
  92. /**
  93. * @brief Macro used by the assert function in order to check the different values of the EXTI PinMask
  94. */
  95. #define IS_EXTI_PINMASK_OK(PinMask) ((((PinMask) & (uint8_t)0x00) == (uint8_t)0x00) && ((PinMask) != (uint8_t)0x00))
  96. /**
  97. * @}
  98. */
  99. /* Exported functions ------------------------------------------------------- */
  100. /** @addtogroup EXTI_Exported_Functions
  101. * @{
  102. */
  103. void EXTI_DeInit(void);
  104. void EXTI_SetExtIntSensitivity(EXTI_Port_TypeDef Port, EXTI_Sensitivity_TypeDef SensitivityValue);
  105. void EXTI_SetTLISensitivity(EXTI_TLISensitivity_TypeDef SensitivityValue);
  106. EXTI_Sensitivity_TypeDef EXTI_GetExtIntSensitivity(EXTI_Port_TypeDef Port);
  107. EXTI_TLISensitivity_TypeDef EXTI_GetTLISensitivity(void);
  108. /**
  109. * @}
  110. */
  111. #endif /* __STM8S_EXTI_H */
  112. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/