libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
gpio.h
Go to the documentation of this file.
1/** @defgroup gpio_defines GPIO Defines
2
3@brief <b>Defined Constants and Types for the LPC13xx General Purpose I/O</b>
4
5@ingroup LPC13xx_defines
6
7@version 1.0.0
8
9@author @htmlonly &copy; @endhtmlonly 2009 Uwe Hermann <uwe@hermann-uwe.de>
10
11@date 10 March 2013
12
13LGPL License Terms @ref lgpl_license
14 */
15/*
16 * This file is part of the libopencm3 project.
17 *
18 * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
19 *
20 * This library is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public License
31 * along with this library. If not, see <http://www.gnu.org/licenses/>.
32 */
33
34/**@{*/
35
36#ifndef LPC13XX_GPIO_H
37#define LPC13XX_GPIO_H
38
41
42/* --- Convenience macros -------------------------------------------------- */
43
44/* GPIO port base addresses (for convenience) */
45#define GPIO0 GPIO_PIO0_BASE
46#define GPIO1 GPIO_PIO1_BASE
47#define GPIO2 GPIO_PIO2_BASE
48#define GPIO3 GPIO_PIO3_BASE
49
50/* --- GPIO registers ------------------------------------------------------ */
51
52/* GPIO data register (GPIOn_DATA) */
53#define GPIO_DATA(port) MMIO32((port) + 0x3ffc)
54#define GPIO0_DATA GPIO_DATA(GPIO0)
55#define GPIO1_DATA GPIO_DATA(GPIO1)
56#define GPIO2_DATA GPIO_DATA(GPIO2)
57#define GPIO3_DATA GPIO_DATA(GPIO3)
58
59/* GPIO data direction register (GPIOn_DIR) */
60#define GPIO_DIR(port) MMIO32((port) + 0x00)
61#define GPIO0_DIR GPIO_DIR(GPIO0)
62#define GPIO1_DIR GPIO_DIR(GPIO1)
63#define GPIO2_DIR GPIO_DIR(GPIO2)
64#define GPIO3_DIR GPIO_DIR(GPIO3)
65
66/* GPIO interrupt sense register (GPIOn_IS) */
67#define GPIO_IS(port) MMIO32((port) + 0x04)
68#define GPIO0_IS GPIO_IS(GPIO0)
69#define GPIO1_IS GPIO_IS(GPIO1)
70#define GPIO2_IS GPIO_IS(GPIO2)
71#define GPIO3_IS GPIO_IS(GPIO3)
72
73/* GPIO interrupt both edges sense register (GPIOn_IBE) */
74#define GPIO_IBE(port) MMIO32((port) + 0x08)
75#define GPIO0_IBE GPIO_IBE(GPIO0)
76#define GPIO1_IBE GPIO_IBE(GPIO1)
77#define GPIO2_IBE GPIO_IBE(GPIO2)
78#define GPIO3_IBE GPIO_IBE(GPIO3)
79
80/* GPIO interrupt event register (GPIOn_IEV) */
81#define GPIO_IEV(port) MMIO32((port) + 0x0c)
82#define GPIO0_IEV GPIO_IEV(GPIO0)
83#define GPIO1_IEV GPIO_IEV(GPIO1)
84#define GPIO2_IEV GPIO_IEV(GPIO2)
85#define GPIO3_IEV GPIO_IEV(GPIO3)
86
87/* GPIO interrupt mask register (GPIOn_IE) */
88#define GPIO_IE(port) MMIO16((port) + 0x10)
89#define GPIO0_IE GPIO_IE(GPIO0)
90#define GPIO1_IE GPIO_IE(GPIO1)
91#define GPIO2_IE GPIO_IE(GPIO2)
92#define GPIO3_IE GPIO_IE(GPIO3)
93
94/* FIXME: IRS or RIS? Datasheet is not consistent here. */
95/* GPIO raw interrupt status register (GPIOn_IRS) */
96#define GPIO_IRS(port) MMIO16((port) + 0x14)
97#define GPIO0_IRS GPIO_IRS(GPIO0)
98#define GPIO1_IRS GPIO_IRS(GPIO1)
99#define GPIO2_IRS GPIO_IRS(GPIO2)
100#define GPIO3_IRS GPIO_IRS(GPIO3)
101
102/* GPIO masked interrupt status register (GPIOn_MIS) */
103#define GPIO_MIS(port) MMIO16((port) + 0x18)
104#define GPIO0_MIS GPIO_MIS(GPIO0)
105#define GPIO1_MIS GPIO_MIS(GPIO1)
106#define GPIO2_MIS GPIO_MIS(GPIO2)
107#define GPIO3_MIS GPIO_MIS(GPIO3)
108
109/* GPIO interrupt clear register (GPIOn_IC) */
110#define GPIO_IC(port) MMIO16((port) + 0x1c)
111#define GPIO0_IC GPIO_IC(GPIO0)
112#define GPIO1_IC GPIO_IC(GPIO1)
113#define GPIO2_IC GPIO_IC(GPIO2)
114#define GPIO3_IC GPIO_IC(GPIO3)
115
117
118void gpio_set(uint32_t gpioport, uint16_t gpios);
119
121
122/**@}*/
123
124#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void gpio_set(uint32_t gpioport, uint16_t gpios)
Definition: gpio.c:36