ch32v30x_exti.h 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /********************************** (C) COPYRIGHT *******************************
  2. * File Name : ch32v30x_exti.h
  3. * Author : WCH
  4. * Version : V1.0.0
  5. * Date : 2021/06/06
  6. * Description : This file contains all the functions prototypes for the
  7. * EXTI firmware library.
  8. *********************************************************************************
  9. * Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
  10. * Attention: This software (modified or not) and binary are used for
  11. * microcontroller manufactured by Nanjing Qinheng Microelectronics.
  12. *******************************************************************************/
  13. #ifndef __CH32V30x_EXTI_H
  14. #define __CH32V30x_EXTI_H
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "ch32v30x.h"
  19. /* EXTI mode enumeration */
  20. typedef enum
  21. {
  22. EXTI_Mode_Interrupt = 0x00,
  23. EXTI_Mode_Event = 0x04
  24. }EXTIMode_TypeDef;
  25. /* EXTI Trigger enumeration */
  26. typedef enum
  27. {
  28. EXTI_Trigger_Rising = 0x08,
  29. EXTI_Trigger_Falling = 0x0C,
  30. EXTI_Trigger_Rising_Falling = 0x10
  31. }EXTITrigger_TypeDef;
  32. /* EXTI Init Structure definition */
  33. typedef struct
  34. {
  35. uint32_t EXTI_Line; /* Specifies the EXTI lines to be enabled or disabled.
  36. This parameter can be any combination of @ref EXTI_Lines */
  37. EXTIMode_TypeDef EXTI_Mode; /* Specifies the mode for the EXTI lines.
  38. This parameter can be a value of @ref EXTIMode_TypeDef */
  39. EXTITrigger_TypeDef EXTI_Trigger; /* Specifies the trigger signal active edge for the EXTI lines.
  40. This parameter can be a value of @ref EXTIMode_TypeDef */
  41. FunctionalState EXTI_LineCmd; /* Specifies the new state of the selected EXTI lines.
  42. This parameter can be set either to ENABLE or DISABLE */
  43. }EXTI_InitTypeDef;
  44. /* EXTI_Lines */
  45. #define EXTI_Line0 ((uint32_t)0x00001) /* External interrupt line 0 */
  46. #define EXTI_Line1 ((uint32_t)0x00002) /* External interrupt line 1 */
  47. #define EXTI_Line2 ((uint32_t)0x00004) /* External interrupt line 2 */
  48. #define EXTI_Line3 ((uint32_t)0x00008) /* External interrupt line 3 */
  49. #define EXTI_Line4 ((uint32_t)0x00010) /* External interrupt line 4 */
  50. #define EXTI_Line5 ((uint32_t)0x00020) /* External interrupt line 5 */
  51. #define EXTI_Line6 ((uint32_t)0x00040) /* External interrupt line 6 */
  52. #define EXTI_Line7 ((uint32_t)0x00080) /* External interrupt line 7 */
  53. #define EXTI_Line8 ((uint32_t)0x00100) /* External interrupt line 8 */
  54. #define EXTI_Line9 ((uint32_t)0x00200) /* External interrupt line 9 */
  55. #define EXTI_Line10 ((uint32_t)0x00400) /* External interrupt line 10 */
  56. #define EXTI_Line11 ((uint32_t)0x00800) /* External interrupt line 11 */
  57. #define EXTI_Line12 ((uint32_t)0x01000) /* External interrupt line 12 */
  58. #define EXTI_Line13 ((uint32_t)0x02000) /* External interrupt line 13 */
  59. #define EXTI_Line14 ((uint32_t)0x04000) /* External interrupt line 14 */
  60. #define EXTI_Line15 ((uint32_t)0x08000) /* External interrupt line 15 */
  61. #define EXTI_Line16 ((uint32_t)0x10000) /* External interrupt line 16 Connected to the PVD Output */
  62. #define EXTI_Line17 ((uint32_t)0x20000) /* External interrupt line 17 Connected to the RTC Alarm event */
  63. #define EXTI_Line18 ((uint32_t)0x40000) /* External interrupt line 18 Connected to the USBD/USBFS OTG
  64. Wakeup from suspend event */
  65. #define EXTI_Line19 ((uint32_t)0x80000) /* External interrupt line 19 Connected to the Ethernet Wakeup event */
  66. #define EXTI_Line20 ((uint32_t)0x100000) /* External interrupt line 20 Connected to the USBHS Wakeup event */
  67. void EXTI_DeInit(void);
  68. void EXTI_Init(EXTI_InitTypeDef* EXTI_InitStruct);
  69. void EXTI_StructInit(EXTI_InitTypeDef* EXTI_InitStruct);
  70. void EXTI_GenerateSWInterrupt(uint32_t EXTI_Line);
  71. FlagStatus EXTI_GetFlagStatus(uint32_t EXTI_Line);
  72. void EXTI_ClearFlag(uint32_t EXTI_Line);
  73. ITStatus EXTI_GetITStatus(uint32_t EXTI_Line);
  74. void EXTI_ClearITPendingBit(uint32_t EXTI_Line);
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif