blob: ce9a9b2fa0301205206d18255740abf6c284d345 (
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
|
/*!
* @file apm32f4xx_syscfg.c
*
* @brief This file provides all the SYSCFG firmware functions
*
* @version V1.0.2
*
* @date 2022-06-23
*
* @attention
*
* Copyright (C) 2021-2022 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
* and limitations under the License.
*/
#include "apm32f4xx_syscfg.h"
#include "apm32f4xx_rcm.h"
/** @addtogroup APM32F4xx_StdPeriphDriver
@{
*/
/** @defgroup SYSCFG_Driver
* @brief SYSCFG driver modules
@{
*/
/** @defgroup SYSCFG_Functions
@{
*/
/*!
* @brief Reset the remap and EINT configuration registers to their default values.
*
* @param None
*
* @retval None
*/
void SYSCFG_Reset(void)
{
RCM_EnableAPB2PeriphReset(RCM_APB2_PERIPH_SYSCFG);
RCM_DisableAPB2PeriphReset(RCM_APB2_PERIPH_SYSCFG);
}
/*!
* @brief Changes the mapping of the specified pin.
*
* @param memory: selects the memory remapping.
* The parameter can be one of the following values:
* @arg SYSCFG_REMAP_FLASH : Memory mapping to Flash
* @arg SYSCFG_REMAP_SYSTEM_FLASH : Memory mapping to SystemFlash
* @arg SYSCFG_REMAP_SMC_BANK1 : Memory mapping to bank1 of SMC (NOR-flash/PSRAM)
* @arg SYSCFG_REMAP_SRAM : Memory mapping to SRAM
*
* @retval None
*/
void SYSCFG_ConfigMemoryRemap(SYSCFG_REMAP_T memory)
{
SYSCFG->MMSEL_B.MMSEL = memory;
}
/*!
* @brief Config the GPIO pin used as EINT Line.
*
* @param port: select the port
* The parameter can be one of the following values
* @arg SYSCFG_PORT_GPIOA : Port Source GPIOA
* @arg SYSCFG_PORT_GPIOB : Port Source GPIOB
* @arg SYSCFG_PORT_GPIOC : Port Source GPIOC
* @arg SYSCFG_PORT_GPIOD : Port Source GPIOD
* @arg SYSCFG_PORT_GPIOE : Port Source GPIOE
* @arg SYSCFG_PORT_GPIOF : Port Source GPIOF
* @arg SYSCFG_PORT_GPIOG : Port Source GPIOG
* @arg SYSCFG_PORT_GPIOH : Port Source GPIOH
* @arg SYSCFG_PORT_GPIOI : Port Source GPIOI
*
* @param pin: select the pin
* The parameter can be one of the following values
* @arg SYSCFG_PIN_0 : Pin Source 0
* @arg SYSCFG_PIN_1 : Pin Source 1
* @arg SYSCFG_PIN_2 : Pin Source 2
* @arg SYSCFG_PIN_3 : Pin Source 3
* @arg SYSCFG_PIN_4 : Pin Source 4
* @arg SYSCFG_PIN_5 : Pin Source 5
* @arg SYSCFG_PIN_6 : Pin Source 6
* @arg SYSCFG_PIN_7 : Pin Source 7
* @arg SYSCFG_PIN_8 : Pin Source 8
* @arg SYSCFG_PIN_9 : Pin Source 9
* @arg SYSCFG_PIN_10: Pin Source 10
* @arg SYSCFG_PIN_11: Pin Source 11
* @arg SYSCFG_PIN_12: Pin Source 12
* @arg SYSCFG_PIN_13: Pin Source 13
* @arg SYSCFG_PIN_14: Pin Source 14
* @arg SYSCFG_PIN_15: Pin Source 15
*
* @retval None
*
* @note pin from SYSCFG_PIN_12 to SYSCFG_PIN_15 is not fit for
* SYSCFG_PORT_GPIOI of the port.
*/
void SYSCFG_ConfigEINTLine(SYSCFG_PORT_T port, SYSCFG_PIN_T pin)
{
uint32_t status;
status = ((uint32_t)(port & 0x0F)) << (0x04 * (pin & 0x03));
if ((pin >> 2) == 0)
{
SYSCFG->EINTCFG1 |= status;
}
else if ((pin >> 2) == 1)
{
SYSCFG->EINTCFG2 |= status;
}
else if ((pin >> 2) == 2)
{
SYSCFG->EINTCFG3 |= status;
}
else if ((pin >> 2) == 3)
{
SYSCFG->EINTCFG4 |= status;
}
}
/*!
* @brief Selects the ETHERNET media interface
*
* @param media: select the media
* The parameter can be combination of folling values
* @arg SYSCFG_INTERFACE_MII : MII mode selected
* @arg SYSCFG_INTERFACE_RMII : RMII mode selected
*
* @retval None
*/
void SYSCFG_ConfigMediaInterface(SYSCFG_INTERFACE_T media)
{
SYSCFG->PMC_B.ENETSEL = media;
}
/*!
* @brief Enables the I/O Compensation Cell.
*
* @param None
*
* @retval None
*
* @note The I/O compensation cell can be used only when the device supply
* voltage ranges from 2.4 to 3.6 V.
*/
void SYSCFG_EnableCompensationCell(void)
{
SYSCFG->CCCTRL_B.CCPD = BIT_SET;
}
/*!
* @brief Disables the I/O Compensation Cell.
*
* @param None
*
* @retval None
*
* @note The I/O compensation cell can be used only when the device supply
* voltage ranges from 2.4 to 3.6 V.
*/
void SYSCFG_DisableCompensationCell(void)
{
SYSCFG->CCCTRL_B.CCPD = BIT_RESET;
}
/*!
* @brief Read the I/O Compensation Cell ready flag.
*
* @param None
*
* @retval SET or RESET
*/
uint8_t SYSCFG_ReadCompensationCellStatus(void)
{
return (SYSCFG->CCCTRL & BIT8) ? SET : RESET;
}
/**@} end of group SYSCFG_Functions */
/**@} end of group SYSCFG_Driver */
/**@} end of group APM32F4xx_StdPeriphDriver */
|