blob: cc0eafe579df45f4c50f1a461c51d79e11e3e608 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
/*!
* @file apm32f10x_eint.c
*
* @brief This file provides all the EINT firmware functions
*
* @version V1.0.1
*
* @date 2021-03-23
*
*/
#include "apm32f10x_eint.h"
/** @addtogroup Peripherals_Library Standard Peripheral Library
@{
*/
/** @addtogroup EINT_Driver EINT Driver
@{
*/
/** @addtogroup EINT_Fuctions Fuctions
@{
*/
/*!
* @brief Reset the EINT peripheral registers to their default reset values.
*
* @param None
*
* @retval None
*/
void EINT_Reset(void)
{
EINT->IMASK = 0x00000000;
EINT->EMASK = 0x00000000;
EINT->RTEN = 0x00000000;
EINT->FTEN = 0x00000000;
EINT->IPEND = 0x000FFFFF;
}
/*!
* @brief Configure the EINT
*
* @param eintConfig: pointer to a EINT_Config_T structure.
*
* @retval None
*/
void EINT_Config(EINT_Config_T* eintConfig)
{
uint32_t temp = 0;
temp = (uint32_t)EINT_BASE;
if(eintConfig->lineCmd != DISABLE)
{
EINT->IMASK &= ~eintConfig->line;
EINT->EMASK &= ~eintConfig->line;
temp += eintConfig->mode;
*(__IOM uint32_t *) temp |= eintConfig->line;
EINT->RTEN &= ~eintConfig->line;
EINT->FTEN &= ~eintConfig->line;
if (eintConfig->trigger == EINT_TRIGGER_RISING_FALLING)
{
EINT->RTEN |= eintConfig->line;
EINT->FTEN |= eintConfig->line;
}
else
{
temp = (uint32_t)EINT_BASE;
temp += eintConfig->trigger;
*(__IOM uint32_t *) temp |= eintConfig->line;
}
}
else
{
temp += eintConfig->mode;
*(__IOM uint32_t *) temp &= ~eintConfig->line;
}
}
/*!
* @brief Select Software interrupt on EINT line
*
* @param line: specifies the EINT lines.
* This parameter can be any combination of EINT_LINE_T(can be from 0 to 18)
*
* @retval None
*/
void EINT_SelectSWInterrupt(uint32_t line)
{
EINT->SWINTE |= line;
}
/*!
* @brief Read the specified EINT_Line flag
*
* @param line: Select the EINT_Line.
* This parameter can be one of EINT_LINE_T(can be from 0 to 18)
*
* @retval status: The new state of flag (SET or RESET)
*/
uint8_t EINT_ReadStatusFlag(EINT_LINE_T line)
{
uint8_t status = RESET;
if((EINT->IPEND & line) != (uint32_t)RESET)
{
status = SET;
}
else
{
status = RESET;
}
return status;
}
/*!
* @brief Clears the EINT_Line pending bits
*
* @param line: Select the EINT_Line.
* This parameter can be any combination of EINT_LINE_T(can be from 0 to 18)
*
* @retval None
*/
void EINT_ClearStatusFlag(uint32_t line)
{
EINT->IPEND = line;
}
/*!
* @brief Read the specified EINT_Line Interrupt Flag.
*
* @param line: Select the EINT_Line.
* This parameter can be one of EINT_LINE_T(can be from 0 to 18)
*
* @retval None
*/
uint8_t EINT_ReadIntFlag(EINT_LINE_T line)
{
uint8_t status = RESET;
uint32_t enablestatus = 0;
enablestatus = EINT->IMASK & line;
if((EINT->IPEND & line) != ((uint32_t)RESET) && (enablestatus != (uint32_t)RESET))
{
status = SET;
}
else
{
status = RESET;
}
return status;
}
/*!
* @brief Clears the EINT_Line pending bits
*
* @param line: Select the EINT_Line
* This parameter can be any combination of EINT_LINE_T(can be from 0 to 18)
*
* @retval None
*/
void EINT_ClearIntFlag(uint32_t line)
{
EINT->IPEND = line;
}
/**@} end of group EINT_Fuctions*/
/**@} end of group EINT_Driver */
/**@} end of group Peripherals_Library*/
|