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 VF6xx_gpio_defines GPIO Defines
2 *
3 * @brief <b>Defined Constants and Types for the VF6xx GPIO Module</b>
4 *
5 * @ingroup VF6xx_defines
6 *
7 * @version 1.0.0
8 *
9 * @author @htmlonly &copy; @endhtmlonly 2014
10 * Stefan Agner <stefan@agner.ch>
11 *
12 * @date 03 July 2014
13 *
14 * LGPL License Terms @ref lgpl_license
15 * */
16/*
17 * This file is part of the libopencm3 project.
18 *
19 * Copyright (C) 2014 Stefan Agner <stefan@agner.ch>
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 LIBOPENCM3_VF6XX_GPIO_H
36#define LIBOPENCM3_VF6XX_GPIO_H
37
40
41/* --- Convenience macros -------------------------------------------------- */
42
43/****************************************************************************/
44/** @defgroup gpio_reg_base GPIO register base addresses
45@ingroup VF6xx_gpio_defines
46
47@{*/
48#define GPIO(port) (GPIO_BASE + (0x040 * (port)))
49#define GPIO0 (GPIO_BASE + 0x000)
50#define GPIO1 (GPIO_BASE + 0x040)
51#define GPIO2 (GPIO_BASE + 0x080)
52#define GPIO3 (GPIO_BASE + 0x0C0)
53#define GPIO4 (GPIO_BASE + 0x100)
54
55#define GPIO_OFFSET(gpio) (0x1 << ((gpio) % 32))
56
57/* --- GPIO registers ------------------------------------------------------ */
58
59#define GPIO_PDOR(gpio_base) MMIO32((gpio_base) + 0x00)
60#define GPIO_PSOR(gpio_base) MMIO32((gpio_base) + 0x04)
61#define GPIO_PCOR(gpio_base) MMIO32((gpio_base) + 0x08)
62#define GPIO_PTOR(gpio_base) MMIO32((gpio_base) + 0x0C)
63#define GPIO_PDIR(gpio_base) MMIO32((gpio_base) + 0x10)
64
65/* --- Function prototypes ------------------------------------------------- */
66
68
70
71void gpio_set(uint32_t gpio);
72void gpio_clear(uint32_t gpio);
73bool gpio_get(uint32_t gpio);
74void gpio_toggle(uint32_t gpio);
75uint32_t gpio_port_read(uint32_t gpioport);
76void gpio_port_write(uint32_t gpioport, uint32_t data);
77
79
80#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
uint32_t gpio_port_read(uint32_t gpioport)
Read a whole GPIO Port.
Definition: gpio.c:110
bool gpio_get(uint32_t gpio)
Get GPIOs logic state.
Definition: gpio.c:81
void gpio_set(uint32_t gpio)
Set GPIO.
Definition: gpio.c:51
void gpio_port_write(uint32_t gpioport, uint32_t data)
Write a whole GPIO Port.
Definition: gpio.c:125
void gpio_toggle(uint32_t gpio)
Toggles GPIO.
Definition: gpio.c:95
void gpio_clear(uint32_t gpio)
Set GPIO.
Definition: gpio.c:65