1 /*!
2  * @file        apm32s10x_eint.h
3  *
4  * @brief       This file contains all the functions prototypes for the EINT firmware library
5  *
6  * @version     V1.0.1
7  *
8  * @date        2022-12-31
9  *
10  * @attention
11  *
12  *  Copyright (C) 2022-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 usefull 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 __APM32S10X_EINT_H
28 #define __APM32S10X_EINT_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* Includes */
35 #include "apm32s10x.h"
36 
37 /** @addtogroup APM32S10x_StdPeriphDriver
38   @{
39 */
40 
41 /** @addtogroup EINT_Driver 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 /** @defgroup EINT_Structures Structures
95   @{
96 */
97 
98 /**
99  * @brief    EINT Config structure definition
100  */
101 typedef struct
102 {
103     uint32_t        line;
104     EINT_MODE_T     mode;
105     EINT_TRIGGER_T  trigger;
106     uint8_t         lineCmd;
107 } EINT_Config_T;
108 
109 /**@} end of group EINT_Structures */
110 
111 /** @defgroup EINT_Functions Functions
112   @{
113 */
114 
115 /* Reset and configuration */
116 void EINT_Reset(void);
117 void EINT_Config(EINT_Config_T* eintConfig);
118 void EINT_ConfigStructInit(EINT_Config_T* eintConfig);
119 
120 /* Interrupt and flag */
121 void EINT_SelectSWInterrupt(uint32_t line);
122 uint8_t EINT_ReadStatusFlag(EINT_LINE_T line);
123 void EINT_ClearStatusFlag(uint32_t line);
124 uint8_t EINT_ReadIntFlag(EINT_LINE_T line);
125 void EINT_ClearIntFlag(uint32_t line);
126 
127 /**@} end of group EINT_Functions */
128 /**@} end of group EINT_Driver */
129 /**@} end of group APM32S10x_StdPeriphDriver */
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* __APM32S10XEINT_H */
136