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 General Purpose I/O Defines
2
3@brief <b>Defined Constants and Types for the LM3S General Purpose I/O</b>
4
5@ingroup LM3Sxx_defines
6
7@version 1.0.0
8
9@author @htmlonly &copy; @endhtmlonly 2011
10Gareth McMullin <gareth@blacksphere.co.nz>
11
12@date 10 March 2013
13
14LGPL License Terms @ref lgpl_license
15 */
16/*
17 * This file is part of the libopencm3 project.
18 *
19 * Copyright (C) 2011 Gareth McMullin <gareth@blacksphere.co.nz>
20 *
21 * This library is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU Lesser General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
25 *
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU Lesser General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public License
32 * along with this library. If not, see <http://www.gnu.org/licenses/>.
33 */
34
35#ifndef LM3S_GPIO_H
36#define LM3S_GPIO_H
37
38/**@{*/
39
42
43/* --- Convenience macros -------------------------------------------------- */
44
45/* GPIO port base addresses (for convenience) */
46#define GPIOA GPIOA_APB_BASE
47#define GPIOB GPIOB_APB_BASE
48#define GPIOC GPIOC_APB_BASE
49#define GPIOD GPIOD_APB_BASE
50#define GPIOE GPIOE_APB_BASE
51#define GPIOF GPIOF_APB_BASE
52#define GPIOG GPIOG_APB_BASE
53#define GPIOH GPIOH_APB_BASE
54
55/* GPIO number definitions (for convenience) */
56#define GPIO0 (1 << 0)
57#define GPIO1 (1 << 1)
58#define GPIO2 (1 << 2)
59#define GPIO3 (1 << 3)
60#define GPIO4 (1 << 4)
61#define GPIO5 (1 << 5)
62#define GPIO6 (1 << 6)
63#define GPIO7 (1 << 7)
64
65/* --- GPIO registers ------------------------------------------------------ */
66
67#define GPIO_DATA(port) (&MMIO32((port) + 0x000))
68#define GPIO_DIR(port) MMIO32((port) + 0x400)
69#define GPIO_IS(port) MMIO32((port) + 0x404)
70#define GPIO_IBE(port) MMIO32((port) + 0x408)
71#define GPIO_IEV(port) MMIO32((port) + 0x40c)
72#define GPIO_IM(port) MMIO32((port) + 0x410)
73#define GPIO_RIS(port) MMIO32((port) + 0x414)
74#define GPIO_MIS(port) MMIO32((port) + 0x418)
75#define GPIO_ICR(port) MMIO32((port) + 0x41c)
76#define GPIO_AFSEL(port) MMIO32((port) + 0x420)
77#define GPIO_DR2R(port) MMIO32((port) + 0x500)
78#define GPIO_DR4R(port) MMIO32((port) + 0x504)
79#define GPIO_DR8R(port) MMIO32((port) + 0x508)
80#define GPIO_ODR(port) MMIO32((port) + 0x50c)
81#define GPIO_PUR(port) MMIO32((port) + 0x510)
82#define GPIO_PDR(port) MMIO32((port) + 0x514)
83#define GPIO_SLR(port) MMIO32((port) + 0x518)
84#define GPIO_DEN(port) MMIO32((port) + 0x51c)
85#define GPIO_LOCK(port) MMIO32((port) + 0x520)
86#define GPIO_CR(port) MMIO32((port) + 0x524)
87#define GPIO_AMSEL(port) MMIO32((port) + 0x528)
88
90
91void gpio_set(uint32_t gpioport, uint8_t gpios);
92void gpio_clear(uint32_t gpioport, uint8_t gpios);
93
95
96/**@}*/
97
98#endif
99
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void gpio_clear(uint32_t gpioport, uint8_t gpios)
Definition: gpio.c:46
void gpio_set(uint32_t gpioport, uint8_t gpios)
Definition: gpio.c:40