started gpio.h lpc43xx changes

This commit is contained in:
Michael Ossmann 2012-05-21 22:39:21 -06:00
parent b6d1dc06d1
commit ba35602e3d
1 changed files with 53 additions and 7 deletions

View File

@ -2,6 +2,7 @@
* This file is part of the libopencm3 project.
*
* Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
* Copyright (C) 2012 Michael Ossmann <mike@ossmann.com>
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
@ -17,8 +18,8 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LPC17XX_GPIO_H
#define LPC17XX_GPIO_H
#ifndef LPC43XX_GPIO_H
#define LPC43XX_GPIO_H
#include <libopencm3/cm3/common.h>
#include <libopencm3/lpc17xx/memorymap.h>
@ -31,6 +32,9 @@
#define GPIO2 GPIO_PIO2_BASE
#define GPIO3 GPIO_PIO3_BASE
#define GPIO4 GPIO_PIO4_BASE
#define GPIO5 GPIO_PIO5_BASE
#define GPIO6 GPIO_PIO6_BASE
#define GPIO7 GPIO_PIO7_BASE
/* GPIO number definitions (for convenience) */
#define GPIOPIN0 (1 << 0)
@ -68,45 +72,87 @@
/* --- GPIO registers ------------------------------------------------------ */
//FIXME byte/word access registers
/* GPIO data direction register (GPIOn_DIR) */
//FIXME port should be offset 0x2000
#define GPIO_DIR(port) MMIO32(port + 0x00)
#define GPIO0_DIR GPIO_DIR(GPIO0)
#define GPIO1_DIR GPIO_DIR(GPIO1)
#define GPIO2_DIR GPIO_DIR(GPIO2)
#define GPIO3_DIR GPIO_DIR(GPIO3)
#define GPIO4_DIR GPIO_DIR(GPIO4)
#define GPIO5_DIR GPIO_DIR(GPIO5)
#define GPIO6_DIR GPIO_DIR(GPIO6)
#define GPIO7_DIR GPIO_DIR(GPIO7)
/* GPIO fast mask register (GPIOn_DIR) */
#define GPIO_MASK(port) MMIO32(port + 0x10)
/* GPIO fast mask register (GPIOn_MASK) */
#define GPIO_MASK(port) MMIO32(port + 0x80)
#define GPIO0_MASK GPIO_MASK(GPIO0)
#define GPIO1_MASK GPIO_MASK(GPIO1)
#define GPIO2_MASK GPIO_MASK(GPIO2)
#define GPIO3_MASK GPIO_MASK(GPIO3)
#define GPIO4_MASK GPIO_MASK(GPIO4)
#define GPIO5_MASK GPIO_MASK(GPIO5)
#define GPIO6_MASK GPIO_MASK(GPIO6)
#define GPIO7_MASK GPIO_MASK(GPIO7)
/* GPIO port pin value register (GPIOn_PIN) */
#define GPIO_PIN(port) MMIO32(port + 0x14)
#define GPIO_PIN(port) MMIO32(port + 0x100)
#define GPIO0_PIN GPIO_PIN(GPIO0)
#define GPIO1_PIN GPIO_PIN(GPIO1)
#define GPIO2_PIN GPIO_PIN(GPIO2)
#define GPIO3_PIN GPIO_PIN(GPIO3)
#define GPIO4_PIN GPIO_PIN(GPIO4)
#define GPIO5_PIN GPIO_PIN(GPIO5)
#define GPIO6_PIN GPIO_PIN(GPIO6)
#define GPIO7_PIN GPIO_PIN(GPIO7)
/* GPIO port masked pin value register (GPIOn_MPIN) */
#define GPIO_PIN(port) MMIO32(port + 0x180)
#define GPIO0_PIN GPIO_PIN(GPIO0)
#define GPIO1_PIN GPIO_PIN(GPIO1)
#define GPIO2_PIN GPIO_PIN(GPIO2)
#define GPIO3_PIN GPIO_PIN(GPIO3)
#define GPIO4_PIN GPIO_PIN(GPIO4)
#define GPIO5_PIN GPIO_PIN(GPIO5)
#define GPIO6_PIN GPIO_PIN(GPIO6)
#define GPIO7_PIN GPIO_PIN(GPIO7)
/* GPIO port output set register (GPIOn_SET) */
#define GPIO_SET(port) MMIO32(port + 0x18)
#define GPIO_SET(port) MMIO32(port + 0x200)
#define GPIO0_SET GPIO_SET(GPIO0)
#define GPIO1_SET GPIO_SET(GPIO1)
#define GPIO2_SET GPIO_SET(GPIO2)
#define GPIO3_SET GPIO_SET(GPIO3)
#define GPIO4_SET GPIO_SET(GPIO4)
#define GPIO5_SET GPIO_SET(GPIO5)
#define GPIO6_SET GPIO_SET(GPIO6)
#define GPIO7_SET GPIO_SET(GPIO7)
/* GPIO port output clear register (GPIOn_CLR) */
#define GPIO_CLR(port) MMIO32(port + 0x1C)
#define GPIO_CLR(port) MMIO32(port + 0x280)
#define GPIO0_CLR GPIO_CLR(GPIO0)
#define GPIO1_CLR GPIO_CLR(GPIO1)
#define GPIO2_CLR GPIO_CLR(GPIO2)
#define GPIO3_CLR GPIO_CLR(GPIO3)
#define GPIO4_CLR GPIO_CLR(GPIO4)
#define GPIO5_CLR GPIO_CLR(GPIO5)
#define GPIO6_CLR GPIO_CLR(GPIO6)
#define GPIO7_CLR GPIO_CLR(GPIO7)
/* GPIO port toggle register (GPIOn_NOT) */
#define GPIO_NOT(port) MMIO32(port + 0x300)
#define GPIO0_NOT GPIO_NOT(GPIO0)
#define GPIO1_NOT GPIO_NOT(GPIO1)
#define GPIO2_NOT GPIO_NOT(GPIO2)
#define GPIO3_NOT GPIO_NOT(GPIO3)
#define GPIO4_NOT GPIO_NOT(GPIO4)
#define GPIO5_NOT GPIO_NOT(GPIO5)
#define GPIO6_NOT GPIO_NOT(GPIO6)
#define GPIO7_NOT GPIO_NOT(GPIO7)
//FIXME below
/* GPIO interrupt register map */
/* Interrupt enable rising edge */