rfLPC
A low level library for using NXP's LPC17xx SoC. Config is given for MBED prototyping board
pinconf.h
Go to the documentation of this file.
1 /* This file is part of rflpc. Copyright 2010-2011 Michael Hauspie
2  *
3  * rflpc is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * rflpc is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with rflpc. If not, see <http://www.gnu.org/licenses/>.
15  */
16 /*
17  Author: Michael Hauspie <michael.hauspie@univ-lille1.fr>
18  Created:
19  Time-stamp: <2014-05-28 16:58:46 (hauspie)>
20 
21  Provides macro to set pin function and modes
22 */
26 #ifndef __RFLPC_PINCONF_H__
27 #define __RFLPC_PINCONF_H__
28 
29 #include <stdint.h>
30 #include "nxp/LPC17xx.h"
31 
44 typedef uint8_t rflpc_pin_t;
45 
47 #define RFLPC_PIN_MAKE(port, pin) ((port) << 5 | (pin))
48 
50 #define RFLPC_PIN_GET_PORT(pin) (((pin) >> 5) & 0x7)
51 
52 #define RFLPC_PIN_GET_PIN(pin) ((pin) & 0x1F)
53 
55 enum
56 {
57  /* Port 0 */
58  RFLPC_PIN_P0_0,
59  RFLPC_PIN_P0_1,
60  RFLPC_PIN_P0_2,
61  RFLPC_PIN_P0_3,
62  RFLPC_PIN_P0_4,
63  RFLPC_PIN_P0_5,
64  RFLPC_PIN_P0_6,
65  RFLPC_PIN_P0_7,
66  RFLPC_PIN_P0_8,
67  RFLPC_PIN_P0_9,
68  RFLPC_PIN_P0_10,
69  RFLPC_PIN_P0_11,
70  RFLPC_PIN_P0_12,
71  RFLPC_PIN_P0_13,
72  RFLPC_PIN_P0_14,
73  RFLPC_PIN_P0_15,
74  RFLPC_PIN_P0_16,
75  RFLPC_PIN_P0_17,
76  RFLPC_PIN_P0_18,
77  RFLPC_PIN_P0_19,
78  RFLPC_PIN_P0_20,
79  RFLPC_PIN_P0_21,
80  RFLPC_PIN_P0_22,
81  RFLPC_PIN_P0_23,
82  RFLPC_PIN_P0_24,
83  RFLPC_PIN_P0_25,
84  RFLPC_PIN_P0_26,
85  RFLPC_PIN_P0_27,
86  RFLPC_PIN_P0_28,
87  RFLPC_PIN_P0_29,
88  RFLPC_PIN_P0_30,
89  RFLPC_PIN_P0_31,
90 
91 
92  /* Port 1 */
93  RFLPC_PIN_P1_0 = RFLPC_PIN_MAKE(1,0),
94  RFLPC_PIN_P1_1,
95  RFLPC_PIN_P1_2,
96  RFLPC_PIN_P1_3,
97  RFLPC_PIN_P1_4,
98  RFLPC_PIN_P1_5,
99  RFLPC_PIN_P1_6,
100  RFLPC_PIN_P1_7,
101  RFLPC_PIN_P1_8,
102  RFLPC_PIN_P1_9,
103  RFLPC_PIN_P1_10,
104  RFLPC_PIN_P1_11,
105  RFLPC_PIN_P1_12,
106  RFLPC_PIN_P1_13,
107  RFLPC_PIN_P1_14,
108  RFLPC_PIN_P1_15,
109  RFLPC_PIN_P1_16,
110  RFLPC_PIN_P1_17,
111  RFLPC_PIN_P1_18,
112  RFLPC_PIN_P1_19,
113  RFLPC_PIN_P1_20,
114  RFLPC_PIN_P1_21,
115  RFLPC_PIN_P1_22,
116  RFLPC_PIN_P1_23,
117  RFLPC_PIN_P1_24,
118  RFLPC_PIN_P1_25,
119  RFLPC_PIN_P1_26,
120  RFLPC_PIN_P1_27,
121  RFLPC_PIN_P1_28,
122  RFLPC_PIN_P1_29,
123  RFLPC_PIN_P1_30,
124  RFLPC_PIN_P1_31,
125 
126  /* Port 2 */
127  RFLPC_PIN_P2_0 = RFLPC_PIN_MAKE(2,0),
128  RFLPC_PIN_P2_1,
129  RFLPC_PIN_P2_2,
130  RFLPC_PIN_P2_3,
131  RFLPC_PIN_P2_4,
132  RFLPC_PIN_P2_5,
133  RFLPC_PIN_P2_6,
134  RFLPC_PIN_P2_7,
135  RFLPC_PIN_P2_8,
136  RFLPC_PIN_P2_9,
137  RFLPC_PIN_P2_10,
138  RFLPC_PIN_P2_11,
139  RFLPC_PIN_P2_12,
140  RFLPC_PIN_P2_13,
141 
142  /* Port 3 */
143  RFLPC_PIN_P3_25 = RFLPC_PIN_MAKE(3,25),
144  RFLPC_PIN_P3_26,
145 
146  /* Port 4 */
147  RFLPC_PIN_P4_28 = RFLPC_PIN_MAKE(4,28),
148  RFLPC_PIN_P4_29,
149 };
150 
151 
152 
156 typedef enum
157 {
163 
173 void rflpc_pin_set(rflpc_pin_t pin, int function, rflpc_pin_mode_t mode, int opendrain);
175 #endif
uint8_t rflpc_pin_t
Represents a pin.
Definition: pinconf.h:44
The pin has pull-down resistor enabled.
Definition: pinconf.h:161
The pin has repeater mode enabled.
Definition: pinconf.h:159
The pin has pull-up resistor enabled.
Definition: pinconf.h:158
rflpc_pin_mode_t
Pin mode.
Definition: pinconf.h:156
void rflpc_pin_set(rflpc_pin_t pin, int function, rflpc_pin_mode_t mode, int opendrain)
Sets the operational mode for a given pin on a given port.
The pin has neither pull-up nor pull-down.
Definition: pinconf.h:160
#define RFLPC_PIN_MAKE(port, pin)
Can be used to create a rflpc_pin_t from a port index and a pin index.
Definition: pinconf.h:47