1 /*!
2  * @file       apm32e10x_eint.h
3  *
4  * @brief      This file contains all the functions prototypes for the EINT firmware library
5  *
6  * @version     V1.0.2
7  *
8  * @date        2022-12-31
9  *
10  * @attention
11  *
12  *  Copyright (C) 2021-2023 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 
26 /* Define to prevent recursive inclusion */
27 #ifndef __APM32E10X_EINT_H
28 #define __APM32E10X_EINT_H
29 
30 /* Includes */
31 #include "apm32e10x.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /** @addtogroup APM32E10x_StdPeriphDriver
38   @{
39 */
40 
41 /** @addtogroup EINT_Driver
42   @{
43 */
44 
45 /** @defgroup EINT_Enumerations Enumerations
46   @{
47 */
48 
49 /**
50  * @brief    EINT mode enumeration
51  */
52 typedef enum
53 {
54     EINT_MODE_INTERRUPT = 0x00,
55     EINT_MODE_EVENT     = 0x04
56 } EINT_MODE_T;
57 
58 /**
59  * @brief    EINT Trigger enumeration
60  */
61 typedef enum
62 {
63     EINT_TRIGGER_RISING         = 0x08,
64     EINT_TRIGGER_FALLING        = 0x0C,
65     EINT_TRIGGER_RISING_FALLING = 0x10
66 } EINT_TRIGGER_T;
67 
68 typedef enum
69 {
70     EINT_LINENONE = 0x00000,  /*!<No interrupt selected > */
71     EINT_LINE_0   = 0x00001,  /*!< External interrupt line 0 */
72     EINT_LINE_1   = 0x00002,  /*!< External interrupt line 1 */
73     EINT_LINE_2   = 0x00004,  /*!< External interrupt line 2 */
74     EINT_LINE_3   = 0x00008,  /*!< External interrupt line 3 */
75     EINT_LINE_4   = 0x00010,  /*!< External interrupt line 4 */
76     EINT_LINE_5   = 0x00020,  /*!< External interrupt line 5 */
77     EINT_LINE_6   = 0x00040,  /*!< External interrupt line 6 */
78     EINT_LINE_7   = 0x00080,  /*!< External interrupt line 7 */
79     EINT_LINE_8   = 0x00100,  /*!< External interrupt line 8 */
80     EINT_LINE_9   = 0x00200,  /*!< External interrupt line 9 */
81     EINT_LINE_10  = 0x00400,  /*!< External interrupt line 10 */
82     EINT_LINE_11  = 0x00800,  /*!< External interrupt line 11 */
83     EINT_LINE_12  = 0x01000,  /*!< External interrupt line 12 */
84     EINT_LINE_13  = 0x02000,  /*!< External interrupt line 13 */
85     EINT_LINE_14  = 0x04000,  /*!< External interrupt line 14 */
86     EINT_LINE_15  = 0x08000,  /*!< External interrupt line 15 */
87     EINT_LINE_16  = 0x10000,  /*!< External interrupt line 16 Connected to the PVD Output */
88     EINT_LINE_17  = 0x20000,  /*!< External interrupt line 17 Connected to the RTC Alarm event */
89     EINT_LINE_18  = 0x40000,  /*!< External interrupt line 18 Connected to the USB Device */
90 } EINT_LINE_T;
91 
92 /**@} end of group EINT_Enumerations*/
93 
94 
95 /** @defgroup EINT_Structures Structures
96   @{
97 */
98 
99 /**
100  * @brief    EINT Config structure definition
101  */
102 typedef struct
103 {
104     uint32_t        line;
105     EINT_MODE_T     mode;
106     EINT_TRIGGER_T  trigger;
107     uint8_t         lineCmd;
108 } EINT_Config_T;
109 
110 /**@} end of group EINT_Structures */
111 
112 
113 /** @defgroup EINT_Functions Functions
114   @{
115 */
116 
117 /* Reset and configuration */
118 void EINT_Reset(void);
119 void EINT_Config( EINT_Config_T* eintConfig);
120 void EINT_ConfigStructInit(EINT_Config_T* eintConfig);
121 
122 /* Interrupt and flag */
123 void EINT_SelectSWInterrupt(uint32_t line);
124 uint8_t EINT_ReadStatusFlag(EINT_LINE_T line);
125 void EINT_ClearStatusFlag(uint32_t line);
126 uint8_t EINT_ReadIntFlag(EINT_LINE_T line);
127 void EINT_ClearIntFlag(uint32_t line);
128 
129 /**@} end of group EINT_Functions*/
130 /**@} end of group EINT_Driver */
131 /**@} end of group APM32E10x_StdPeriphDriver*/
132 
133 #ifdef __APM32E10X_cplusplus
134 }
135 #endif
136 
137 #endif /* __EINT_H */
138