at32f403a_407_exint.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /**
  2. **************************************************************************
  3. * @file at32f403a_407_exint.h
  4. * @brief at32f403a_407 exint header file
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. /* Define to prevent recursive inclusion -------------------------------------*/
  25. #ifndef __AT32F403A_407_EXINT_H
  26. #define __AT32F403A_407_EXINT_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* Includes ------------------------------------------------------------------*/
  31. #include "at32f403a_407.h"
  32. /** @addtogroup AT32F403A_407_periph_driver
  33. * @{
  34. */
  35. /** @addtogroup EXINT
  36. * @{
  37. */
  38. /** @defgroup EXINT_lines
  39. * @{
  40. */
  41. #define EXINT_LINE_NONE ((uint32_t)0x000000)
  42. #define EXINT_LINE_0 ((uint32_t)0x000001) /*!< external interrupt line 0 */
  43. #define EXINT_LINE_1 ((uint32_t)0x000002) /*!< external interrupt line 1 */
  44. #define EXINT_LINE_2 ((uint32_t)0x000004) /*!< external interrupt line 2 */
  45. #define EXINT_LINE_3 ((uint32_t)0x000008) /*!< external interrupt line 3 */
  46. #define EXINT_LINE_4 ((uint32_t)0x000010) /*!< external interrupt line 4 */
  47. #define EXINT_LINE_5 ((uint32_t)0x000020) /*!< external interrupt line 5 */
  48. #define EXINT_LINE_6 ((uint32_t)0x000040) /*!< external interrupt line 6 */
  49. #define EXINT_LINE_7 ((uint32_t)0x000080) /*!< external interrupt line 7 */
  50. #define EXINT_LINE_8 ((uint32_t)0x000100) /*!< external interrupt line 8 */
  51. #define EXINT_LINE_9 ((uint32_t)0x000200) /*!< external interrupt line 9 */
  52. #define EXINT_LINE_10 ((uint32_t)0x000400) /*!< external interrupt line 10 */
  53. #define EXINT_LINE_11 ((uint32_t)0x000800) /*!< external interrupt line 11 */
  54. #define EXINT_LINE_12 ((uint32_t)0x001000) /*!< external interrupt line 12 */
  55. #define EXINT_LINE_13 ((uint32_t)0x002000) /*!< external interrupt line 13 */
  56. #define EXINT_LINE_14 ((uint32_t)0x004000) /*!< external interrupt line 14 */
  57. #define EXINT_LINE_15 ((uint32_t)0x008000) /*!< external interrupt line 15 */
  58. #define EXINT_LINE_16 ((uint32_t)0x010000) /*!< external interrupt line 16 connected to the pvm output */
  59. #define EXINT_LINE_17 ((uint32_t)0x020000) /*!< external interrupt line 17 connected to the rtc alarm event */
  60. #define EXINT_LINE_18 ((uint32_t)0x040000) /*!< external interrupt line 18 connected to the usb device fs wakeup from suspend event */
  61. #define EXINT_LINE_19 ((uint32_t)0x080000) /*!< external interrupt line 19 connected to the comp1*/
  62. /**
  63. * @}
  64. */
  65. /** @defgroup EXINT_exported_types
  66. * @{
  67. */
  68. /**
  69. * @brief exint line mode type
  70. */
  71. typedef enum
  72. {
  73. EXINT_LINE_INTERRUPUT = 0x00, /*!< external interrupt line interrupt mode */
  74. EXINT_LINE_EVENT = 0x01 /*!< external interrupt line event mode */
  75. } exint_line_mode_type;
  76. /**
  77. * @brief exint polarity configuration type
  78. */
  79. typedef enum
  80. {
  81. EXINT_TRIGGER_RISING_EDGE = 0x00, /*!< external interrupt line rising trigger mode */
  82. EXINT_TRIGGER_FALLING_EDGE = 0x01, /*!< external interrupt line falling trigger mode */
  83. EXINT_TRIGGER_BOTH_EDGE = 0x02 /*!< external interrupt line both rising and falling trigger mode */
  84. } exint_polarity_config_type;
  85. /**
  86. * @brief exint init type
  87. */
  88. typedef struct
  89. {
  90. exint_line_mode_type line_mode; /*!< choose mode event or interrupt mode */
  91. uint32_t line_select; /*!< select the exint line, availiable for single line or multiple lines */
  92. exint_polarity_config_type line_polarity; /*!< select the tregger polarity, with rising edge, falling edge or both edge */
  93. confirm_state line_enable; /*!< enable or disable exint */
  94. } exint_init_type;
  95. /**
  96. * @brief type define exint register all
  97. */
  98. typedef struct
  99. {
  100. /**
  101. * @brief exint inten register, offset:0x00
  102. */
  103. union
  104. {
  105. __IO uint32_t inten;
  106. struct
  107. {
  108. __IO uint32_t intenx : 20;/* [19:0] */
  109. __IO uint32_t reserved1 : 12;/* [31:20] */
  110. } inten_bit;
  111. };
  112. /**
  113. * @brief exint evten register, offset:0x04
  114. */
  115. union
  116. {
  117. __IO uint32_t evten;
  118. struct
  119. {
  120. __IO uint32_t evtenx : 20;/* [19:0] */
  121. __IO uint32_t reserved1 : 12;/* [31:20] */
  122. } evten_bit;
  123. };
  124. /**
  125. * @brief exint polcfg1 register, offset:0x08
  126. */
  127. union
  128. {
  129. __IO uint32_t polcfg1;
  130. struct
  131. {
  132. __IO uint32_t rpx : 20;/* [19:0] */
  133. __IO uint32_t reserved1 : 12;/* [31:20] */
  134. } polcfg1_bit;
  135. };
  136. /**
  137. * @brief exint polcfg2 register, offset:0x0C
  138. */
  139. union
  140. {
  141. __IO uint32_t polcfg2;
  142. struct
  143. {
  144. __IO uint32_t fpx : 20;/* [19:0] */
  145. __IO uint32_t reserved1 : 12;/* [31:20] */
  146. } polcfg2_bit;
  147. };
  148. /**
  149. * @brief exint swtrg register, offset:0x10
  150. */
  151. union
  152. {
  153. __IO uint32_t swtrg;
  154. struct
  155. {
  156. __IO uint32_t swtx : 20;/* [19:0] */
  157. __IO uint32_t reserved1 : 12;/* [31:20] */
  158. } swtrg_bit;
  159. };
  160. /**
  161. * @brief exint intsts register, offset:0x14
  162. */
  163. union
  164. {
  165. __IO uint32_t intsts;
  166. struct
  167. {
  168. __IO uint32_t linex : 20;/* [19:0] */
  169. __IO uint32_t reserved1 : 12;/* [31:20] */
  170. } intsts_bit;
  171. };
  172. } exint_type;
  173. /**
  174. * @}
  175. */
  176. #define EXINT ((exint_type *) EXINT_BASE)
  177. /** @defgroup EXINT_exported_functions
  178. * @{
  179. */
  180. void exint_reset(void);
  181. void exint_default_para_init(exint_init_type *exint_struct);
  182. void exint_init(exint_init_type *exint_struct);
  183. void exint_flag_clear(uint32_t exint_line);
  184. flag_status exint_flag_get(uint32_t exint_line);
  185. flag_status exint_interrupt_flag_get(uint32_t exint_line);
  186. void exint_software_interrupt_event_generate(uint32_t exint_line);
  187. void exint_interrupt_enable(uint32_t exint_line, confirm_state new_state);
  188. void exint_event_enable(uint32_t exint_line, confirm_state new_state);
  189. /**
  190. * @}
  191. */
  192. /**
  193. * @}
  194. */
  195. /**
  196. * @}
  197. */
  198. #ifdef __cplusplus
  199. }
  200. #endif
  201. #endif