apm32f0xx_eint.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*!
  2. * @file apm32f0xx_eint.h
  3. *
  4. * @brief This file contains all the functions prototypes for the EINT firmware library
  5. *
  6. * @version V1.0.3
  7. *
  8. * @date 2022-09-20
  9. *
  10. * @attention
  11. *
  12. * Copyright (C) 2020-2022 Geehy Semiconductor
  13. *
  14. * You may not use this file except in compliance with the
  15. * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. * The program is only for reference, which is distributed in the hope
  18. * that it will be useful and instructional for customers to develop
  19. * their software. Unless required by applicable law or agreed to in
  20. * writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. * and limitations under the License.
  24. */
  25. /* Define to prevent recursive inclusion */
  26. #ifndef __APM32F0XX_EINT_H
  27. #define __APM32F0XX_EINT_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* Includes */
  32. #include "apm32f0xx.h"
  33. /** @addtogroup APM32F0xx_StdPeriphDriver
  34. @{
  35. */
  36. /** @addtogroup EINT_Driver
  37. @{
  38. */
  39. /** @defgroup EINT_Macros Macros
  40. @{
  41. */
  42. /* No interrupt selected */
  43. #define EINT_LINENONE ((uint32_t)0x00000) /*!< clear EINT line config */
  44. /* EINT register reset value */
  45. #if defined (APM32F030) || defined (APM32F051)
  46. #define EINT_INTMASK_RESET_VALUE ((uint32_t)(0x0F940000))
  47. #elif defined (APM32F091) || defined (APM32F072) || defined (APM32F071) || defined (APM32F070)
  48. #define EINT_INTMASK_RESET_VALUE ((uint32_t)(0x7F840000))
  49. #endif
  50. #define EINT_EVTMASK_RESET_VALUE ((uint32_t)(0x00000000)) /*!< EINT Event MASK register reset value */
  51. #define EINT_RTSEL_RESET_VALUE ((uint32_t)(0x00000000)) /*!< EINT Rising Trigger enable register reset value */
  52. #define EINT_FTSEL_RESET_VALUE ((uint32_t)(0x00000000)) /*!< EINT Falling Trigger enable register reset value */
  53. #define EINT_PEND_RESET_VALUE ((uint32_t)(0x00000000)) /*!< EINT Interrupt Pending register reset value */
  54. /**@} end of group EINT_Macros */
  55. /** @defgroup EINT_Enumerations Enumerations
  56. @{
  57. */
  58. /*!
  59. * @brief EINT mode
  60. */
  61. typedef enum
  62. {
  63. EINT_MODE_INTERRUPT = ((uint8_t)0x00), /*!< EINT mode select interrupt */
  64. EINT_MODE_EVENT = ((uint8_t)0x01), /*!< EINT mode select event */
  65. } EINT_MODE_T;
  66. /*!
  67. * @brief EINT trigger mode
  68. */
  69. typedef enum
  70. {
  71. EINT_TRIGGER_RISING = ((uint8_t)0x00), /*!< EINT trigger select rising edge */
  72. EINT_TRIGGER_FALLING = ((uint8_t)0x01), /*!< EINT trigger select falling edge */
  73. EINT_TRIGGER_ALL = ((uint8_t)0x02), /*!< EINT trigger select rising and falling edge */
  74. } EINT_TRIGGER_T;
  75. /*!
  76. * @brief EINT line
  77. */
  78. typedef enum
  79. {
  80. EINT_LINE0 = ((uint32_t)0x00000001), /*!< External interrupt line 0 */
  81. EINT_LINE1 = ((uint32_t)0x00000002), /*!< External interrupt line 1 */
  82. EINT_LINE2 = ((uint32_t)0x00000004), /*!< External interrupt line 2 */
  83. EINT_LINE3 = ((uint32_t)0x00000008), /*!< External interrupt line 3 */
  84. EINT_LINE4 = ((uint32_t)0x00000010), /*!< External interrupt line 4 */
  85. EINT_LINE5 = ((uint32_t)0x00000020), /*!< External interrupt line 5 */
  86. EINT_LINE6 = ((uint32_t)0x00000040), /*!< External interrupt line 6 */
  87. EINT_LINE7 = ((uint32_t)0x00000080), /*!< External interrupt line 7 */
  88. EINT_LINE8 = ((uint32_t)0x00000100), /*!< External interrupt line 8 */
  89. EINT_LINE9 = ((uint32_t)0x00000200), /*!< External interrupt line 9 */
  90. EINT_LINE10 = ((uint32_t)0x00000400), /*!< External interrupt line 10 */
  91. EINT_LINE11 = ((uint32_t)0x00000800), /*!< External interrupt line 11 */
  92. EINT_LINE12 = ((uint32_t)0x00001000), /*!< External interrupt line 12 */
  93. EINT_LINE13 = ((uint32_t)0x00002000), /*!< External interrupt line 13 */
  94. EINT_LINE14 = ((uint32_t)0x00004000), /*!< External interrupt line 14 */
  95. EINT_LINE15 = ((uint32_t)0x00008000), /*!< External interrupt line 15 */
  96. EINT_LINE16 = ((uint32_t)0x00010000), /*!< External interrupt line 16 Connected to the PVD Output, not applicable for 030 */
  97. EINT_LINE17 = ((uint32_t)0x00020000), /*!< External interrupt line 17 Connected to the RTC Alarm event */
  98. EINT_LINE18 = ((uint32_t)0x00040000), /*!< External interrupt line 18 Connected to the RTC Alarm event, only applicable for 072 devices */
  99. EINT_LINE19 = ((uint32_t)0x00080000), /*!< External interrupt line 19 Connected to the RTC Tamper and TimeStamp events */
  100. EINT_LINE20 = ((uint32_t)0x00100000), /*!< External interrupt line 20 Connected to the RTC wakeup event,only applicable for 072 and 091 */
  101. EINT_LINE21 = ((uint32_t)0x00200000), /*!< External interrupt line 21 Connected to the Comparator 1 event,only applicable for 072 and 091 */
  102. EINT_LINE22 = ((uint32_t)0x00400000), /*!< External interrupt line 22 Connected to the Comparator 2 event,only applicable for 072 and 091 */
  103. EINT_LINE23 = ((uint32_t)0x00800000), /*!< External interrupt line 23 Connected to the I2C1 wakeup event,not applicable for 030 */
  104. EINT_LINE25 = ((uint32_t)0x02000000), /*!< External interrupt line 25 Connected to the USART1 wakeup event,not applicable for 030 */
  105. EINT_LINE26 = ((uint32_t)0x04000000), /*!< External interrupt line 26 Connected to the USART2 wakeup event,only applicable for 072 and 091 */
  106. EINT_LINE27 = ((uint32_t)0x08000000), /*!< External interrupt line 27 Connected to the CEC wakeup event,only applicable for 072*/
  107. EINT_LINE28 = ((uint32_t)0x10000000), /*!< External interrupt line 28 Connected to the USART3 wakeup event,only applicable for 091 */
  108. EINT_LINE31 = ((int)0x80000000), /*!< External interrupt line 31 Connected to the VDD USB monitor,only applicable for 072 */
  109. } EINT_LINE_T;
  110. /**@} end of group EINT_Enumerations */
  111. /** @defgroup EINT_Structures Structures
  112. @{
  113. */
  114. /*!
  115. * @brief EINT Config struct definition
  116. */
  117. typedef struct
  118. {
  119. uint32_t line; /*!< Specifies the new state of the selected EINT lines. */
  120. EINT_MODE_T mode; /*!< Specifies the mode for the EINT lines. */
  121. EINT_TRIGGER_T trigger; /*!< Specifies the trigger signal active edge for the EINT lines. */
  122. uint8_t lineCmd; /*!< Specifies the EINT lines to be enabled or disabled. */
  123. } EINT_Config_T;
  124. /**@} end of group EINT_Structures */
  125. /** @defgroup EINT_Variables Variables
  126. @{
  127. */
  128. /**@} end of group EINT_Variables */
  129. /** @defgroup EINT_Functions Functions
  130. @{
  131. */
  132. /* Reset and configuration */
  133. void EINT_Reset(void);
  134. void EINT_Config(EINT_Config_T* eintConfig);
  135. void EINT_ConfigStructInit(EINT_Config_T* eintConfig);
  136. /* Interrupt */
  137. void EINT_SelectSWInterrupt(uint32_t line);
  138. /* Flag */
  139. uint8_t EINT_ReadStatusFlag(uint32_t line);
  140. void EINT_ClearStatusFlag(uint32_t line);
  141. uint8_t EINT_ReadIntFlag(uint32_t line);
  142. void EINT_ClearIntFlag(uint32_t line);
  143. #ifdef __cplusplus
  144. }
  145. #endif
  146. #endif /* __APM32F0XX_EINT_H */
  147. /**@} end of group EINT_Functions */
  148. /**@} end of group EINT_Driver */
  149. /**@} end of group APM32F0xx_StdPeriphDriver */