summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc17xx/lpc17_gpio.h
blob: 993369aa2d164ce5dc0932548238aecebbfec094 (plain) (blame)
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
/************************************************************************************
 * arch/arm/src/lpc17xx/lpc17_gpio.h
 *
 *   Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved.
 *   Author: Gregory Nutt <gnutt@nuttx.org>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name NuttX nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ************************************************************************************/

#ifndef __ARCH_ARM_SRC_LPC17XX_LPC17_GPIO_H
#define __ARCH_ARM_SRC_LPC17XX_LPC17_GPIO_H

/************************************************************************************
 * Included Files
 ************************************************************************************/

#include <nuttx/config.h>

#ifndef __ASSEMBLY__
#  include <stdint.h>
#endif

#include <arch/lpc17xx/chip.h>

#include "chip/lpc17_gpio.h"
#include "chip/lpc17_pinconn.h"
#include "chip/lpc17_pinconfig.h"

/************************************************************************************
 * Pre-processor Definitions
 ************************************************************************************/
/* Bit-encoded input to lpc17_configgpio() ******************************************/

#if defined(LPC176x)

/* Encoding: FFFx MMOV PPPN NNNN
 *
 *   Pin Function:   FFF
 *   Pin Mode bits:  MM
 *   Open drain:     O (output pins)
 *   Initial value:  V (output pins)
 *   Port number:    PPP (0-4)
 *   Pin number:     NNNNN (0-31)
 */
 
/* Pin Function bits: FFF
 * Only meaningful when the GPIO function is GPIO_PIN
 */

#define GPIO_FUNC_SHIFT      (13)       /* Bits 13-15: GPIO mode */
#define GPIO_FUNC_MASK       (7 << GPIO_FUNC_SHIFT)
#  define GPIO_INPUT         (0 << GPIO_FUNC_SHIFT) /* 000 GPIO input pin */
#  define GPIO_INTFE         (1 << GPIO_FUNC_SHIFT) /* 001 GPIO interrupt falling edge */
#  define GPIO_INTRE         (2 << GPIO_FUNC_SHIFT) /* 010 GPIO interrupt rising edge */
#  define GPIO_INTBOTH       (3 << GPIO_FUNC_SHIFT) /* 011 GPIO interrupt both edges */
#  define GPIO_OUTPUT        (4 << GPIO_FUNC_SHIFT) /* 100 GPIO outpout pin */
#  define GPIO_ALT1          (5 << GPIO_FUNC_SHIFT) /* 101 Alternate function 1 */
#  define GPIO_ALT2          (6 << GPIO_FUNC_SHIFT) /* 110 Alternate function 2 */
#  define GPIO_ALT3          (7 << GPIO_FUNC_SHIFT) /* 111 Alternate function 3 */

#define GPIO_EDGE_SHIFT      (13)       /* Bits 13-14: Interrupt edge bits */
#define GPIO_EDGE_MASK       (3 << GPIO_EDGE_SHIFT)

#define GPIO_INOUT_MASK      GPIO_OUTPUT
#define GPIO_FE_MASK         GPIO_INTFE
#define GPIO_RE_MASK         GPIO_INTRE

#define GPIO_ISGPIO(ps)      ((uint16_t(ps) & GPIO_FUNC_MASK) <= GPIO_OUTPUT)
#define GPIO_ISALT(ps)       ((uint16_t(ps) & GPIO_FUNC_MASK) > GPIO_OUTPUT)
#define GPIO_ISINPUT(ps)     (((ps) & GPIO_FUNC_MASK) == GPIO_INPUT)
#define GPIO_ISOUTPUT(ps)    (((ps) & GPIO_FUNC_MASK) == GPIO_OUTPUT)
#define GPIO_ISINORINT(ps)   (((ps) & GPIO_INOUT_MASK) == 0)
#define GPIO_ISOUTORALT(ps)  (((ps) & GPIO_INOUT_MASK) != 0)
#define GPIO_ISINTERRUPT(ps) (GPIO_ISOUTPUT(ps) && !GPIO_ISINPUT(ps))
#define GPIO_ISFE(ps)        (((ps) & GPIO_FE_MASK) != 0)
#define GPIO_ISRE(ps)        (((ps) & GPIO_RE_MASK) != 0)

/* Pin Mode: MM */

#define GPIO_PUMODE_SHIFT    (10)      /* Bits 10-11: Pin pull-up mode */
#define GPIO_PUMODE_MASK     (3 << GPIO_PUMODE_SHIFT)
#  define GPIO_PULLUP        (0 << GPIO_PUMODE_SHIFT) /* Pull-up resistor enabled */
#  define GPIO_REPEATER      (1 << GPIO_PUMODE_SHIFT) /* Repeater mode enabled */
#  define GPIO_FLOAT         (2 << GPIO_PUMODE_SHIFT) /* Neither pull-up nor -down */
#  define GPIO_PULLDN        (3 << GPIO_PUMODE_SHIFT) /* Pull-down resistor enabled */

/* Open drain: O */

#define GPIO_OPEN_DRAIN      (1 << 9)  /* Bit 9:  Open drain mode */

/* Initial value: V */

#define GPIO_VALUE           (1 << 8)  /* Bit 8:  Initial GPIO output value */
#define GPIO_VALUE_ONE       GPIO_VALUE
#define GPIO_VALUE_ZERO      (0)

/* Port number:    PPP (0-4) */

#define GPIO_PORT_SHIFT      (5)         /* Bit 5-7:  Port number */
#define GPIO_PORT_MASK       (7 << GPIO_PORT_SHIFT)
#  define GPIO_PORT0         (0 << GPIO_PORT_SHIFT)
#  define GPIO_PORT1         (1 << GPIO_PORT_SHIFT)
#  define GPIO_PORT2         (2 << GPIO_PORT_SHIFT)
#  define GPIO_PORT3         (3 << GPIO_PORT_SHIFT)
#  define GPIO_PORT4         (4 << GPIO_PORT_SHIFT)

#define GPIO_NPORTS          5

/* Pin number:     NNNNN (0-31) */

#define GPIO_PIN_SHIFT       0        /* Bits 0-4: GPIO number: 0-31 */
#define GPIO_PIN_MASK        (31 << GPIO_PIN_SHIFT)
#define GPIO_PIN0            (0  << GPIO_PIN_SHIFT)
#define GPIO_PIN1            (1  << GPIO_PIN_SHIFT)
#define GPIO_PIN2            (2  << GPIO_PIN_SHIFT)
#define GPIO_PIN3            (3  << GPIO_PIN_SHIFT)
#define GPIO_PIN4            (4  << GPIO_PIN_SHIFT)
#define GPIO_PIN5            (5  << GPIO_PIN_SHIFT)
#define GPIO_PIN6            (6  << GPIO_PIN_SHIFT)
#define GPIO_PIN7            (7  << GPIO_PIN_SHIFT)
#define GPIO_PIN8            (8  << GPIO_PIN_SHIFT)
#define GPIO_PIN9            (9  << GPIO_PIN_SHIFT)
#define GPIO_PIN10           (10 << GPIO_PIN_SHIFT)
#define GPIO_PIN11           (11 << GPIO_PIN_SHIFT)
#define GPIO_PIN12           (12 << GPIO_PIN_SHIFT)
#define GPIO_PIN13           (13 << GPIO_PIN_SHIFT)
#define GPIO_PIN14           (14 << GPIO_PIN_SHIFT)
#define GPIO_PIN15           (15 << GPIO_PIN_SHIFT)
#define GPIO_PIN16           (16 << GPIO_PIN_SHIFT)
#define GPIO_PIN17           (17 << GPIO_PIN_SHIFT)
#define GPIO_PIN18           (18 << GPIO_PIN_SHIFT)
#define GPIO_PIN19           (19 << GPIO_PIN_SHIFT)
#define GPIO_PIN20           (20 << GPIO_PIN_SHIFT)
#define GPIO_PIN21           (21 << GPIO_PIN_SHIFT)
#define GPIO_PIN22           (22 << GPIO_PIN_SHIFT)
#define GPIO_PIN23           (23 << GPIO_PIN_SHIFT)
#define GPIO_PIN24           (24 << GPIO_PIN_SHIFT)
#define GPIO_PIN25           (25 << GPIO_PIN_SHIFT)
#define GPIO_PIN26           (26 << GPIO_PIN_SHIFT)
#define GPIO_PIN27           (27 << GPIO_PIN_SHIFT)
#define GPIO_PIN28           (28 << GPIO_PIN_SHIFT)
#define GPIO_PIN29           (29 << GPIO_PIN_SHIFT)
#define GPIO_PIN30           (30 << GPIO_PIN_SHIFT)
#define GPIO_PIN31           (31 << GPIO_PIN_SHIFT)

#elif defined(LPC178x)

/* Encoding: TTTT TTTT FFFF MMOV PPPN NNNN
 *   
 *   Special Pin Functions: TTTT TTTT
 *   Pin Function:           FFFF
 *   Pin Mode bits:          MM
 *   Open drain:             O (output pins)
 *   Initial value:          V (output pins)
 *   Port number:            PPP (0-4)
 *   Pin number:             NNNNN (0-31)
 */
 
/* Special Pin Functions
 * For pins that has ADC/DAC, USB, I2C
 */

#define GPIO_IOCON_TYPE_D_MASK (0x0000067f) /* All port except where ADC/DAC, USB, I2C is present */
#define GPIO_IOCON_TYPE_A_MASK (0x000105df) /* USB/ADC/DAC P0:12 to 13, P0:23 to 26, P1:30 to 31 */
#define GPIO_IOCON_TYPE_U_MASK (0x00000007) /* USB P0:29 to 31 */
#define GPIO_IOCON_TYPE_I_MASK (0x00000347) /* I2C/USB P0:27 to 28, P5:2 to 3  */
#define GPIO_IOCON_TYPE_W_MASK (0x000007ff) /* I2S P0:7 to 9 */

# define GPIO_HYS            (1 << 16) /* Bit 16: HYSTERESIS: 0-Disable, 1-Enabled */
# define GPIO_INV            (1 << 17) /* Bit 17: Input: 0-Not Inverted, 1-Inverted */
# define GPIO_SLEW           (1 << 18) /* Bit 18: Rate Control: 0-Standard mode, 1-Fast mode */
# define GPIO_ADMODE         (1 << 19) /* Bit 19: A/D Modes: 0-Analog, 1-Digital  */
# define GPIO_FILTER         (1 << 20) /* Bit 20: Filter: 0-Off, 1-ON */
# define GPIO_DACEN          (1 << 21) /* Bit 21: DAC: 0-Disabled, 1-Enabled, P0:26 only */
# define GPIO_I2CHS          (1 << 22) /* Bit 22: Filter and Rate Control: 0-Enabled, 1-Disabled */
# define GPIO_HIDRIVE        (1 << 23) /* Bit 23: Current Sink: 0-4mA, 1-20mA  P5:2 and P5:3 only,*/

/* Pin Function bits: FFFF
 * Only meaningful when the GPIO function is GPIO_PIN
 */

#define GPIO_FUNC_SHIFT      (12)       /* Bits 12-15: GPIO mode */
#define GPIO_FUNC_MASK       (15 << GPIO_FUNC_SHIFT)
#  define GPIO_INPUT         (0 << GPIO_FUNC_SHIFT) /* 0000 GPIO input pin */
#  define GPIO_INTFE         (1 << GPIO_FUNC_SHIFT) /* 0001 GPIO interrupt falling edge */
#  define GPIO_INTRE         (2 << GPIO_FUNC_SHIFT) /* 0010 GPIO interrupt rising edge */
#  define GPIO_INTBOTH       (3 << GPIO_FUNC_SHIFT) /* 0011 GPIO interrupt both edges */
#  define GPIO_OUTPUT        (4 << GPIO_FUNC_SHIFT) /* 0100 GPIO outpout pin */
#  define GPIO_ALT1          (5 << GPIO_FUNC_SHIFT) /* 0101 Alternate function 1 */
#  define GPIO_ALT2          (6 << GPIO_FUNC_SHIFT) /* 0110 Alternate function 2 */
#  define GPIO_ALT3          (7 << GPIO_FUNC_SHIFT) /* 0111 Alternate function 3 */
#  define GPIO_ALT4          (8 << GPIO_FUNC_SHIFT) /* 1000 Alternate function 4 */
#  define GPIO_ALT5          (9 << GPIO_FUNC_SHIFT) /* 1001 Alternate function 5 */
#  define GPIO_ALT6          (10 << GPIO_FUNC_SHIFT) /* 1010 Alternate function 6 */
#  define GPIO_ALT7          (11 << GPIO_FUNC_SHIFT) /* 1011 Alternate function 7 */

#define GPIO_EDGE_SHIFT      (13)       /* Bits 13-14: Interrupt edge bits */
#define GPIO_EDGE_MASK       (3 << GPIO_EDGE_SHIFT)

#define GPIO_INOUT_MASK      GPIO_OUTPUT
#define GPIO_FE_MASK         GPIO_INTFE
#define GPIO_RE_MASK         GPIO_INTRE

#define GPIO_ISGPIO(ps)      ((uint16_t(ps) & GPIO_FUNC_MASK) <= GPIO_OUTPUT)
#define GPIO_ISALT(ps)       ((uint16_t(ps) & GPIO_FUNC_MASK) > GPIO_OUTPUT)
#define GPIO_ISINPUT(ps)     (((ps) & GPIO_FUNC_MASK) == GPIO_INPUT)
#define GPIO_ISOUTPUT(ps)    (((ps) & GPIO_FUNC_MASK) == GPIO_OUTPUT)
#define GPIO_ISINORINT(ps)   (((ps) & GPIO_INOUT_MASK) == 0)
#define GPIO_ISOUTORALT(ps)  (((ps) & GPIO_INOUT_MASK) != 0)
#define GPIO_ISINTERRUPT(ps) (GPIO_ISOUTPUT(ps) && !GPIO_ISINPUT(ps))
#define GPIO_ISFE(ps)        (((ps) & GPIO_FE_MASK) != 0)
#define GPIO_ISRE(ps)        (((ps) & GPIO_RE_MASK) != 0)

/* Pin Mode: MM */

#define GPIO_PUMODE_SHIFT    (10)      /* Bits 10-11: Pin pull-up mode */
#define GPIO_PUMODE_MASK     (3 << GPIO_PUMODE_SHIFT)
#  define GPIO_PULLUP        (0 << GPIO_PUMODE_SHIFT) /* Pull-up resistor enabled */
#  define GPIO_REPEATER      (1 << GPIO_PUMODE_SHIFT) /* Repeater mode enabled */
#  define GPIO_FLOAT         (2 << GPIO_PUMODE_SHIFT) /* Neither pull-up nor -down */
#  define GPIO_PULLDN        (3 << GPIO_PUMODE_SHIFT) /* Pull-down resistor enabled */

/* Open drain: O */

#define GPIO_OPEN_DRAIN      (1 << 9)  /* Bit 9:  Open drain mode */

/* Initial value: V */

#define GPIO_VALUE           (1 << 8)  /* Bit 8: Initial GPIO output value */
#define GPIO_VALUE_ONE       GPIO_VALUE
#define GPIO_VALUE_ZERO      (0)

/* Port number:    PPP (0-5) */

#define GPIO_PORT_SHIFT      (5)         /* Bit 5-7:  Port number */
#define GPIO_PORT_MASK       (7 << GPIO_PORT_SHIFT)
#  define GPIO_PORT0         (0 << GPIO_PORT_SHIFT)
#  define GPIO_PORT1         (1 << GPIO_PORT_SHIFT)
#  define GPIO_PORT2         (2 << GPIO_PORT_SHIFT)
#  define GPIO_PORT3         (3 << GPIO_PORT_SHIFT)
#  define GPIO_PORT4         (4 << GPIO_PORT_SHIFT)
#  define GPIO_PORT5         (5 << GPIO_PORT_SHIFT)

#define GPIO_NPORTS          6

/* Pin number:     NNNNN (0-31) */

#define GPIO_PIN_SHIFT       0        /* Bits 0-4: GPIO number: 0-31 */
#define GPIO_PIN_MASK        (31 << GPIO_PIN_SHIFT)
#define GPIO_PIN0            (0  << GPIO_PIN_SHIFT)
#define GPIO_PIN1            (1  << GPIO_PIN_SHIFT)
#define GPIO_PIN2            (2  << GPIO_PIN_SHIFT)
#define GPIO_PIN3            (3  << GPIO_PIN_SHIFT)
#define GPIO_PIN4            (4  << GPIO_PIN_SHIFT)
#define GPIO_PIN5            (5  << GPIO_PIN_SHIFT)
#define GPIO_PIN6            (6  << GPIO_PIN_SHIFT)
#define GPIO_PIN7            (7  << GPIO_PIN_SHIFT)
#define GPIO_PIN8            (8  << GPIO_PIN_SHIFT)
#define GPIO_PIN9            (9  << GPIO_PIN_SHIFT)
#define GPIO_PIN10           (10 << GPIO_PIN_SHIFT)
#define GPIO_PIN11           (11 << GPIO_PIN_SHIFT)
#define GPIO_PIN12           (12 << GPIO_PIN_SHIFT)
#define GPIO_PIN13           (13 << GPIO_PIN_SHIFT)
#define GPIO_PIN14           (14 << GPIO_PIN_SHIFT)
#define GPIO_PIN15           (15 << GPIO_PIN_SHIFT)
#define GPIO_PIN16           (16 << GPIO_PIN_SHIFT)
#define GPIO_PIN17           (17 << GPIO_PIN_SHIFT)
#define GPIO_PIN18           (18 << GPIO_PIN_SHIFT)
#define GPIO_PIN19           (19 << GPIO_PIN_SHIFT)
#define GPIO_PIN20           (20 << GPIO_PIN_SHIFT)
#define GPIO_PIN21           (21 << GPIO_PIN_SHIFT)
#define GPIO_PIN22           (22 << GPIO_PIN_SHIFT)
#define GPIO_PIN23           (23 << GPIO_PIN_SHIFT)
#define GPIO_PIN24           (24 << GPIO_PIN_SHIFT)
#define GPIO_PIN25           (25 << GPIO_PIN_SHIFT)
#define GPIO_PIN26           (26 << GPIO_PIN_SHIFT)
#define GPIO_PIN27           (27 << GPIO_PIN_SHIFT)
#define GPIO_PIN28           (28 << GPIO_PIN_SHIFT)
#define GPIO_PIN29           (29 << GPIO_PIN_SHIFT)
#define GPIO_PIN30           (30 << GPIO_PIN_SHIFT)
#define GPIO_PIN31           (31 << GPIO_PIN_SHIFT)

#else
#  error "Unrecognized LPC17xx family"
#endif

/************************************************************************************
 * Public Types
 ************************************************************************************/

#ifdef LPC176x
typedef uint16_t lpc17_pinset_t;
#else
typedef uint32_t lpc17_pinset_t;
#endif

/************************************************************************************
 * Public Data
 ************************************************************************************/

#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif

/* These tables have global scope only because they are shared between lpc17_gpio.c,
 * lpc17_gpioint.c, and lpc17_gpiodbg.c
 */

#ifdef CONFIG_GPIO_IRQ
EXTERN uint64_t g_intedge0;
EXTERN uint64_t g_intedge2;
#endif

EXTERN const uint32_t g_fiobase[GPIO_NPORTS];
EXTERN const uint32_t g_intbase[GPIO_NPORTS];
EXTERN const uint32_t g_lopinsel[GPIO_NPORTS];
EXTERN const uint32_t g_hipinsel[GPIO_NPORTS];
EXTERN const uint32_t g_lopinmode[GPIO_NPORTS];
EXTERN const uint32_t g_hipinmode[GPIO_NPORTS];
EXTERN const uint32_t g_odmode[GPIO_NPORTS];

/****************************************************************************
 * Public Functions
 ****************************************************************************/

/************************************************************************************
 * Name: lpc17_gpioirqinitialize
 *
 * Description:
 *   Initialize logic to support a second level of interrupt decoding for GPIO pins.
 *
 ************************************************************************************/

#ifdef CONFIG_GPIO_IRQ
void lpc17_gpioirqinitialize(void);
#else
#  define lpc17_gpioirqinitialize()
#endif

/************************************************************************************
 * Name: lpc17_configgpio
 *
 * Description:
 *   Configure a GPIO pin based on bit-encoded description of the pin.
 *
 ************************************************************************************/

int lpc17_configgpio(lpc17_pinset_t cfgset);

/************************************************************************************
 * Name: lpc17_gpiowrite
 *
 * Description:
 *   Write one or zero to the selected GPIO pin
 *
 ************************************************************************************/

void lpc17_gpiowrite(lpc17_pinset_t pinset, bool value);

/************************************************************************************
 * Name: lpc17_gpioread
 *
 * Description:
 *   Read one or zero from the selected GPIO pin
 *
 ************************************************************************************/

bool lpc17_gpioread(lpc17_pinset_t pinset);

/************************************************************************************
 * Name: lpc17_gpioirqenable
 *
 * Description:
 *   Enable the interrupt for specified GPIO IRQ
 *
 ************************************************************************************/

#ifdef CONFIG_GPIO_IRQ
void lpc17_gpioirqenable(int irq);
#else
#  define lpc17_gpioirqenable(irq)
#endif

/************************************************************************************
 * Name: lpc17_gpioirqdisable
 *
 * Description:
 *   Disable the interrupt for specified GPIO IRQ
 *
 ************************************************************************************/

#ifdef CONFIG_GPIO_IRQ
void lpc17_gpioirqdisable(int irq);
#else
#  define lpc17_gpioirqdisable(irq)
#endif

/************************************************************************************
 * Function:  lpc17_dumpgpio
 *
 * Description:
 *   Dump all GPIO registers associated with the base address of the provided pinset.
 *
 ************************************************************************************/

#ifdef CONFIG_DEBUG_GPIO
int lpc17_dumpgpio(lpc17_pinset_t pinset, const char *msg);
#else
#  define lpc17_dumpgpio(p,m)
#endif

#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */

#endif /* __ARCH_ARM_SRC_LPC17XX_LPC17_GPIO_H */