User | Revision | Line number | New contents of line |
lynxeyed_atsu |
0:63ed631d8c3a
|
1
|
/***********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
2
|
* @file lpc17xx_pinsel.c
|
lynxeyed_atsu |
0:63ed631d8c3a
|
3
|
* @brief Contains all functions support for Pin connect block firmware
|
lynxeyed_atsu |
0:63ed631d8c3a
|
4
|
* library on LPC17xx
|
lynxeyed_atsu |
0:63ed631d8c3a
|
5
|
* @version 2.0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
6
|
* @date 21. May. 2010
|
lynxeyed_atsu |
0:63ed631d8c3a
|
7
|
* @author NXP MCU SW Application Team
|
lynxeyed_atsu |
0:63ed631d8c3a
|
8
|
**************************************************************************
|
lynxeyed_atsu |
0:63ed631d8c3a
|
9
|
* Software that is described herein is for illustrative purposes only
|
lynxeyed_atsu |
0:63ed631d8c3a
|
10
|
* which provides customers with programming information regarding the
|
lynxeyed_atsu |
0:63ed631d8c3a
|
11
|
* products. This software is supplied "AS IS" without any warranties.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
12
|
* NXP Semiconductors assumes no responsibility or liability for the
|
lynxeyed_atsu |
0:63ed631d8c3a
|
13
|
* use of the software, conveys no license or title under any patent,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
14
|
* copyright, or mask work right to the product. NXP Semiconductors
|
lynxeyed_atsu |
0:63ed631d8c3a
|
15
|
* reserves the right to make changes in the software without
|
lynxeyed_atsu |
0:63ed631d8c3a
|
16
|
* notification. NXP Semiconductors also make no representation or
|
lynxeyed_atsu |
0:63ed631d8c3a
|
17
|
* warranty that such application will be suitable for the specified
|
lynxeyed_atsu |
0:63ed631d8c3a
|
18
|
* use without further testing or modification.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
19
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
20
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
21
|
/* Peripheral group ----------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
22
|
/** @addtogroup PINSEL
|
lynxeyed_atsu |
0:63ed631d8c3a
|
23
|
* @{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
24
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
25
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
26
|
/* Includes ------------------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
27
|
#include "lpc17xx_pinsel.h"
|
lynxeyed_atsu |
0:63ed631d8c3a
|
28
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
29
|
/* Public Functions ----------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
30
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
31
|
static void set_PinFunc ( uint8_t portnum, uint8_t pinnum, uint8_t funcnum);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
32
|
static void set_ResistorMode ( uint8_t portnum, uint8_t pinnum, uint8_t modenum);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
33
|
static void set_OpenDrainMode( uint8_t portnum, uint8_t pinnum, uint8_t modenum);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
34
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
35
|
/*********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
36
|
* @brief Setup the pin selection function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
37
|
* @param[in] portnum PORT number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
38
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
39
|
* - PINSEL_PORT_0 : Port 0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
40
|
* - PINSEL_PORT_1 : Port 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
41
|
* - PINSEL_PORT_2 : Port 2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
42
|
* - PINSEL_PORT_3 : Port 3
|
lynxeyed_atsu |
0:63ed631d8c3a
|
43
|
*
|
lynxeyed_atsu |
0:63ed631d8c3a
|
44
|
* @param[in] pinnum Pin number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
45
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
46
|
- PINSEL_PIN_0 : Pin 0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
47
|
- PINSEL_PIN_1 : Pin 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
48
|
- PINSEL_PIN_2 : Pin 2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
49
|
- PINSEL_PIN_3 : Pin 3
|
lynxeyed_atsu |
0:63ed631d8c3a
|
50
|
- PINSEL_PIN_4 : Pin 4
|
lynxeyed_atsu |
0:63ed631d8c3a
|
51
|
- PINSEL_PIN_5 : Pin 5
|
lynxeyed_atsu |
0:63ed631d8c3a
|
52
|
- PINSEL_PIN_6 : Pin 6
|
lynxeyed_atsu |
0:63ed631d8c3a
|
53
|
- PINSEL_PIN_7 : Pin 7
|
lynxeyed_atsu |
0:63ed631d8c3a
|
54
|
- PINSEL_PIN_8 : Pin 8
|
lynxeyed_atsu |
0:63ed631d8c3a
|
55
|
- PINSEL_PIN_9 : Pin 9
|
lynxeyed_atsu |
0:63ed631d8c3a
|
56
|
- PINSEL_PIN_10 : Pin 10
|
lynxeyed_atsu |
0:63ed631d8c3a
|
57
|
- PINSEL_PIN_11 : Pin 11
|
lynxeyed_atsu |
0:63ed631d8c3a
|
58
|
- PINSEL_PIN_12 : Pin 12
|
lynxeyed_atsu |
0:63ed631d8c3a
|
59
|
- PINSEL_PIN_13 : Pin 13
|
lynxeyed_atsu |
0:63ed631d8c3a
|
60
|
- PINSEL_PIN_14 : Pin 14
|
lynxeyed_atsu |
0:63ed631d8c3a
|
61
|
- PINSEL_PIN_15 : Pin 15
|
lynxeyed_atsu |
0:63ed631d8c3a
|
62
|
- PINSEL_PIN_16 : Pin 16
|
lynxeyed_atsu |
0:63ed631d8c3a
|
63
|
- PINSEL_PIN_17 : Pin 17
|
lynxeyed_atsu |
0:63ed631d8c3a
|
64
|
- PINSEL_PIN_18 : Pin 18
|
lynxeyed_atsu |
0:63ed631d8c3a
|
65
|
- PINSEL_PIN_19 : Pin 19
|
lynxeyed_atsu |
0:63ed631d8c3a
|
66
|
- PINSEL_PIN_20 : Pin 20
|
lynxeyed_atsu |
0:63ed631d8c3a
|
67
|
- PINSEL_PIN_21 : Pin 21
|
lynxeyed_atsu |
0:63ed631d8c3a
|
68
|
- PINSEL_PIN_22 : Pin 22
|
lynxeyed_atsu |
0:63ed631d8c3a
|
69
|
- PINSEL_PIN_23 : Pin 23
|
lynxeyed_atsu |
0:63ed631d8c3a
|
70
|
- PINSEL_PIN_24 : Pin 24
|
lynxeyed_atsu |
0:63ed631d8c3a
|
71
|
- PINSEL_PIN_25 : Pin 25
|
lynxeyed_atsu |
0:63ed631d8c3a
|
72
|
- PINSEL_PIN_26 : Pin 26
|
lynxeyed_atsu |
0:63ed631d8c3a
|
73
|
- PINSEL_PIN_27 : Pin 27
|
lynxeyed_atsu |
0:63ed631d8c3a
|
74
|
- PINSEL_PIN_28 : Pin 28
|
lynxeyed_atsu |
0:63ed631d8c3a
|
75
|
- PINSEL_PIN_29 : Pin 29
|
lynxeyed_atsu |
0:63ed631d8c3a
|
76
|
- PINSEL_PIN_30 : Pin 30
|
lynxeyed_atsu |
0:63ed631d8c3a
|
77
|
- PINSEL_PIN_31 : Pin 31
|
lynxeyed_atsu |
0:63ed631d8c3a
|
78
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
79
|
* @param[in] funcnum Function number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
80
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
81
|
* - PINSEL_FUNC_0 : default function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
82
|
* - PINSEL_FUNC_1 : first alternate function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
83
|
* - PINSEL_FUNC_2 : second alternate function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
84
|
* - PINSEL_FUNC_3 : third alternate function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
85
|
*
|
lynxeyed_atsu |
0:63ed631d8c3a
|
86
|
* @return None
|
lynxeyed_atsu |
0:63ed631d8c3a
|
87
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
88
|
static void set_PinFunc ( uint8_t portnum, uint8_t pinnum, uint8_t funcnum)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
89
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
90
|
uint32_t pinnum_t = pinnum;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
91
|
uint32_t pinselreg_idx = 2 * portnum;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
92
|
uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINSEL0;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
93
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
94
|
if (pinnum_t >= 16) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
95
|
pinnum_t -= 16;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
96
|
pinselreg_idx++;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
97
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
98
|
*(uint32_t *)(pPinCon + pinselreg_idx) &= ~(0x03UL << (pinnum_t * 2));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
99
|
*(uint32_t *)(pPinCon + pinselreg_idx) |= ((uint32_t)funcnum) << (pinnum_t * 2);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
100
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
101
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
102
|
/*********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
103
|
* @brief Setup resistor mode for each pin
|
lynxeyed_atsu |
0:63ed631d8c3a
|
104
|
* @param[in] portnum PORT number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
105
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
106
|
* - PINSEL_PORT_0 : Port 0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
107
|
* - PINSEL_PORT_1 : Port 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
108
|
* - PINSEL_PORT_2 : Port 2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
109
|
* - PINSEL_PORT_3 : Port 3
|
lynxeyed_atsu |
0:63ed631d8c3a
|
110
|
* @param[in] pinnum Pin number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
111
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
112
|
- PINSEL_PIN_0 : Pin 0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
113
|
- PINSEL_PIN_1 : Pin 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
114
|
- PINSEL_PIN_2 : Pin 2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
115
|
- PINSEL_PIN_3 : Pin 3
|
lynxeyed_atsu |
0:63ed631d8c3a
|
116
|
- PINSEL_PIN_4 : Pin 4
|
lynxeyed_atsu |
0:63ed631d8c3a
|
117
|
- PINSEL_PIN_5 : Pin 5
|
lynxeyed_atsu |
0:63ed631d8c3a
|
118
|
- PINSEL_PIN_6 : Pin 6
|
lynxeyed_atsu |
0:63ed631d8c3a
|
119
|
- PINSEL_PIN_7 : Pin 7
|
lynxeyed_atsu |
0:63ed631d8c3a
|
120
|
- PINSEL_PIN_8 : Pin 8
|
lynxeyed_atsu |
0:63ed631d8c3a
|
121
|
- PINSEL_PIN_9 : Pin 9
|
lynxeyed_atsu |
0:63ed631d8c3a
|
122
|
- PINSEL_PIN_10 : Pin 10
|
lynxeyed_atsu |
0:63ed631d8c3a
|
123
|
- PINSEL_PIN_11 : Pin 11
|
lynxeyed_atsu |
0:63ed631d8c3a
|
124
|
- PINSEL_PIN_12 : Pin 12
|
lynxeyed_atsu |
0:63ed631d8c3a
|
125
|
- PINSEL_PIN_13 : Pin 13
|
lynxeyed_atsu |
0:63ed631d8c3a
|
126
|
- PINSEL_PIN_14 : Pin 14
|
lynxeyed_atsu |
0:63ed631d8c3a
|
127
|
- PINSEL_PIN_15 : Pin 15
|
lynxeyed_atsu |
0:63ed631d8c3a
|
128
|
- PINSEL_PIN_16 : Pin 16
|
lynxeyed_atsu |
0:63ed631d8c3a
|
129
|
- PINSEL_PIN_17 : Pin 17
|
lynxeyed_atsu |
0:63ed631d8c3a
|
130
|
- PINSEL_PIN_18 : Pin 18
|
lynxeyed_atsu |
0:63ed631d8c3a
|
131
|
- PINSEL_PIN_19 : Pin 19
|
lynxeyed_atsu |
0:63ed631d8c3a
|
132
|
- PINSEL_PIN_20 : Pin 20
|
lynxeyed_atsu |
0:63ed631d8c3a
|
133
|
- PINSEL_PIN_21 : Pin 21
|
lynxeyed_atsu |
0:63ed631d8c3a
|
134
|
- PINSEL_PIN_22 : Pin 22
|
lynxeyed_atsu |
0:63ed631d8c3a
|
135
|
- PINSEL_PIN_23 : Pin 23
|
lynxeyed_atsu |
0:63ed631d8c3a
|
136
|
- PINSEL_PIN_24 : Pin 24
|
lynxeyed_atsu |
0:63ed631d8c3a
|
137
|
- PINSEL_PIN_25 : Pin 25
|
lynxeyed_atsu |
0:63ed631d8c3a
|
138
|
- PINSEL_PIN_26 : Pin 26
|
lynxeyed_atsu |
0:63ed631d8c3a
|
139
|
- PINSEL_PIN_27 : Pin 27
|
lynxeyed_atsu |
0:63ed631d8c3a
|
140
|
- PINSEL_PIN_28 : Pin 28
|
lynxeyed_atsu |
0:63ed631d8c3a
|
141
|
- PINSEL_PIN_29 : Pin 29
|
lynxeyed_atsu |
0:63ed631d8c3a
|
142
|
- PINSEL_PIN_30 : Pin 30
|
lynxeyed_atsu |
0:63ed631d8c3a
|
143
|
- PINSEL_PIN_31 : Pin 31
|
lynxeyed_atsu |
0:63ed631d8c3a
|
144
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
145
|
* @param[in] modenum: Mode number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
146
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
147
|
- PINSEL_PINMODE_PULLUP : Internal pull-up resistor
|
lynxeyed_atsu |
0:63ed631d8c3a
|
148
|
- PINSEL_PINMODE_TRISTATE : Tri-state
|
lynxeyed_atsu |
0:63ed631d8c3a
|
149
|
- PINSEL_PINMODE_PULLDOWN : Internal pull-down resistor
|
lynxeyed_atsu |
0:63ed631d8c3a
|
150
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
151
|
* @return None
|
lynxeyed_atsu |
0:63ed631d8c3a
|
152
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
153
|
void set_ResistorMode ( uint8_t portnum, uint8_t pinnum, uint8_t modenum)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
154
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
155
|
uint32_t pinnum_t = pinnum;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
156
|
uint32_t pinmodereg_idx = 2 * portnum;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
157
|
uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINMODE0;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
158
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
159
|
if (pinnum_t >= 16) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
160
|
pinnum_t -= 16;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
161
|
pinmodereg_idx++ ;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
162
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
163
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
164
|
*(uint32_t *)(pPinCon + pinmodereg_idx) &= ~(0x03UL << (pinnum_t * 2));
|
lynxeyed_atsu |
0:63ed631d8c3a
|
165
|
*(uint32_t *)(pPinCon + pinmodereg_idx) |= ((uint32_t)modenum) << (pinnum_t * 2);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
166
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
167
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
168
|
/*********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
169
|
* @brief Setup Open drain mode for each pin
|
lynxeyed_atsu |
0:63ed631d8c3a
|
170
|
* @param[in] portnum PORT number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
171
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
172
|
* - PINSEL_PORT_0 : Port 0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
173
|
* - PINSEL_PORT_1 : Port 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
174
|
* - PINSEL_PORT_2 : Port 2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
175
|
* - PINSEL_PORT_3 : Port 3
|
lynxeyed_atsu |
0:63ed631d8c3a
|
176
|
*
|
lynxeyed_atsu |
0:63ed631d8c3a
|
177
|
* @param[in] pinnum Pin number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
178
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
179
|
- PINSEL_PIN_0 : Pin 0
|
lynxeyed_atsu |
0:63ed631d8c3a
|
180
|
- PINSEL_PIN_1 : Pin 1
|
lynxeyed_atsu |
0:63ed631d8c3a
|
181
|
- PINSEL_PIN_2 : Pin 2
|
lynxeyed_atsu |
0:63ed631d8c3a
|
182
|
- PINSEL_PIN_3 : Pin 3
|
lynxeyed_atsu |
0:63ed631d8c3a
|
183
|
- PINSEL_PIN_4 : Pin 4
|
lynxeyed_atsu |
0:63ed631d8c3a
|
184
|
- PINSEL_PIN_5 : Pin 5
|
lynxeyed_atsu |
0:63ed631d8c3a
|
185
|
- PINSEL_PIN_6 : Pin 6
|
lynxeyed_atsu |
0:63ed631d8c3a
|
186
|
- PINSEL_PIN_7 : Pin 7
|
lynxeyed_atsu |
0:63ed631d8c3a
|
187
|
- PINSEL_PIN_8 : Pin 8
|
lynxeyed_atsu |
0:63ed631d8c3a
|
188
|
- PINSEL_PIN_9 : Pin 9
|
lynxeyed_atsu |
0:63ed631d8c3a
|
189
|
- PINSEL_PIN_10 : Pin 10
|
lynxeyed_atsu |
0:63ed631d8c3a
|
190
|
- PINSEL_PIN_11 : Pin 11
|
lynxeyed_atsu |
0:63ed631d8c3a
|
191
|
- PINSEL_PIN_12 : Pin 12
|
lynxeyed_atsu |
0:63ed631d8c3a
|
192
|
- PINSEL_PIN_13 : Pin 13
|
lynxeyed_atsu |
0:63ed631d8c3a
|
193
|
- PINSEL_PIN_14 : Pin 14
|
lynxeyed_atsu |
0:63ed631d8c3a
|
194
|
- PINSEL_PIN_15 : Pin 15
|
lynxeyed_atsu |
0:63ed631d8c3a
|
195
|
- PINSEL_PIN_16 : Pin 16
|
lynxeyed_atsu |
0:63ed631d8c3a
|
196
|
- PINSEL_PIN_17 : Pin 17
|
lynxeyed_atsu |
0:63ed631d8c3a
|
197
|
- PINSEL_PIN_18 : Pin 18
|
lynxeyed_atsu |
0:63ed631d8c3a
|
198
|
- PINSEL_PIN_19 : Pin 19
|
lynxeyed_atsu |
0:63ed631d8c3a
|
199
|
- PINSEL_PIN_20 : Pin 20
|
lynxeyed_atsu |
0:63ed631d8c3a
|
200
|
- PINSEL_PIN_21 : Pin 21
|
lynxeyed_atsu |
0:63ed631d8c3a
|
201
|
- PINSEL_PIN_22 : Pin 22
|
lynxeyed_atsu |
0:63ed631d8c3a
|
202
|
- PINSEL_PIN_23 : Pin 23
|
lynxeyed_atsu |
0:63ed631d8c3a
|
203
|
- PINSEL_PIN_24 : Pin 24
|
lynxeyed_atsu |
0:63ed631d8c3a
|
204
|
- PINSEL_PIN_25 : Pin 25
|
lynxeyed_atsu |
0:63ed631d8c3a
|
205
|
- PINSEL_PIN_26 : Pin 26
|
lynxeyed_atsu |
0:63ed631d8c3a
|
206
|
- PINSEL_PIN_27 : Pin 27
|
lynxeyed_atsu |
0:63ed631d8c3a
|
207
|
- PINSEL_PIN_28 : Pin 28
|
lynxeyed_atsu |
0:63ed631d8c3a
|
208
|
- PINSEL_PIN_29 : Pin 29
|
lynxeyed_atsu |
0:63ed631d8c3a
|
209
|
- PINSEL_PIN_30 : Pin 30
|
lynxeyed_atsu |
0:63ed631d8c3a
|
210
|
- PINSEL_PIN_31 : Pin 31
|
lynxeyed_atsu |
0:63ed631d8c3a
|
211
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
212
|
* @param[in] modenum Open drain mode number,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
213
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
214
|
* - PINSEL_PINMODE_NORMAL : Pin is in the normal (not open drain) mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
215
|
* - PINSEL_PINMODE_OPENDRAIN : Pin is in the open drain mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
216
|
*
|
lynxeyed_atsu |
0:63ed631d8c3a
|
217
|
* @return None
|
lynxeyed_atsu |
0:63ed631d8c3a
|
218
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
219
|
void set_OpenDrainMode( uint8_t portnum, uint8_t pinnum, uint8_t modenum)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
220
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
221
|
uint32_t *pPinCon = (uint32_t *)&LPC_PINCON->PINMODE_OD0;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
222
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
223
|
if (modenum == PINSEL_PINMODE_OPENDRAIN){
|
lynxeyed_atsu |
0:63ed631d8c3a
|
224
|
*(uint32_t *)(pPinCon + portnum) |= (0x01UL << pinnum);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
225
|
} else {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
226
|
*(uint32_t *)(pPinCon + portnum) &= ~(0x01UL << pinnum);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
227
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
228
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
229
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
230
|
/* End of Public Functions ---------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
231
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
232
|
/* Public Functions ----------------------------------------------------------- */
|
lynxeyed_atsu |
0:63ed631d8c3a
|
233
|
/** @addtogroup PINSEL_Public_Functions
|
lynxeyed_atsu |
0:63ed631d8c3a
|
234
|
* @{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
235
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
236
|
/*********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
237
|
* @brief Configure trace function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
238
|
* @param[in] NewState State of the Trace function configuration,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
239
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
240
|
* - ENABLE : Enable Trace Function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
241
|
* - DISABLE : Disable Trace Function
|
lynxeyed_atsu |
0:63ed631d8c3a
|
242
|
*
|
lynxeyed_atsu |
0:63ed631d8c3a
|
243
|
* @return None
|
lynxeyed_atsu |
0:63ed631d8c3a
|
244
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
245
|
void PINSEL_ConfigTraceFunc(FunctionalState NewState)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
246
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
247
|
if (NewState == ENABLE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
248
|
LPC_PINCON->PINSEL10 |= (0x01UL << 3);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
249
|
} else if (NewState == DISABLE) {
|
lynxeyed_atsu |
0:63ed631d8c3a
|
250
|
LPC_PINCON->PINSEL10 &= ~(0x01UL << 3);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
251
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
252
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
253
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
254
|
/*********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
255
|
* @brief Setup I2C0 pins
|
lynxeyed_atsu |
0:63ed631d8c3a
|
256
|
* @param[in] i2cPinMode I2C pin mode,
|
lynxeyed_atsu |
0:63ed631d8c3a
|
257
|
* should be one of the following:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
258
|
* - PINSEL_I2C_Normal_Mode : The standard drive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
259
|
* - PINSEL_I2C_Fast_Mode : Fast Mode Plus drive mode
|
lynxeyed_atsu |
0:63ed631d8c3a
|
260
|
*
|
lynxeyed_atsu |
0:63ed631d8c3a
|
261
|
* @param[in] filterSlewRateEnable should be:
|
lynxeyed_atsu |
0:63ed631d8c3a
|
262
|
* - ENABLE: Enable filter and slew rate.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
263
|
* - DISABLE: Disable filter and slew rate.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
264
|
*
|
lynxeyed_atsu |
0:63ed631d8c3a
|
265
|
* @return None
|
lynxeyed_atsu |
0:63ed631d8c3a
|
266
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
267
|
void PINSEL_SetI2C0Pins(uint8_t i2cPinMode, FunctionalState filterSlewRateEnable)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
268
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
269
|
uint32_t regVal = 0;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
270
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
271
|
if (i2cPinMode == PINSEL_I2C_Fast_Mode){
|
lynxeyed_atsu |
0:63ed631d8c3a
|
272
|
regVal = PINSEL_I2CPADCFG_SCLDRV0 | PINSEL_I2CPADCFG_SDADRV0;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
273
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
274
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
275
|
if (filterSlewRateEnable == DISABLE){
|
lynxeyed_atsu |
0:63ed631d8c3a
|
276
|
regVal = PINSEL_I2CPADCFG_SCLI2C0 | PINSEL_I2CPADCFG_SDAI2C0;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
277
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
278
|
LPC_PINCON->I2CPADCFG = regVal;
|
lynxeyed_atsu |
0:63ed631d8c3a
|
279
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
280
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
281
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
282
|
/*********************************************************************//**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
283
|
* @brief Configure Pin corresponding to specified parameters passed
|
lynxeyed_atsu |
0:63ed631d8c3a
|
284
|
* in the PinCfg
|
lynxeyed_atsu |
0:63ed631d8c3a
|
285
|
* @param[in] PinCfg Pointer to a PINSEL_CFG_Type structure
|
lynxeyed_atsu |
0:63ed631d8c3a
|
286
|
* that contains the configuration information for the
|
lynxeyed_atsu |
0:63ed631d8c3a
|
287
|
* specified pin.
|
lynxeyed_atsu |
0:63ed631d8c3a
|
288
|
* @return None
|
lynxeyed_atsu |
0:63ed631d8c3a
|
289
|
**********************************************************************/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
290
|
void PINSEL_ConfigPin(PINSEL_CFG_Type *PinCfg)
|
lynxeyed_atsu |
0:63ed631d8c3a
|
291
|
{
|
lynxeyed_atsu |
0:63ed631d8c3a
|
292
|
set_PinFunc(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->Funcnum);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
293
|
set_ResistorMode(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->Pinmode);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
294
|
set_OpenDrainMode(PinCfg->Portnum, PinCfg->Pinnum, PinCfg->OpenDrain);
|
lynxeyed_atsu |
0:63ed631d8c3a
|
295
|
}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
296
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
297
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
298
|
/**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
299
|
* @}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
300
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
301
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
302
|
/**
|
lynxeyed_atsu |
0:63ed631d8c3a
|
303
|
* @}
|
lynxeyed_atsu |
0:63ed631d8c3a
|
304
|
*/
|
lynxeyed_atsu |
0:63ed631d8c3a
|
305
|
|
lynxeyed_atsu |
0:63ed631d8c3a
|
306
|
/* --------------------------------- End Of File ------------------------------ */
|