From ba35602e3dfe846b1aa905c72e3d5055ab924945 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Mon, 21 May 2012 22:39:21 -0600 Subject: started gpio.h lpc43xx changes --- include/libopencm3/lpc43xx/gpio.h | 60 ++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 7 deletions(-) diff --git a/include/libopencm3/lpc43xx/gpio.h b/include/libopencm3/lpc43xx/gpio.h index 7b07ac5..b3e6202 100644 --- a/include/libopencm3/lpc43xx/gpio.h +++ b/include/libopencm3/lpc43xx/gpio.h @@ -2,6 +2,7 @@ * This file is part of the libopencm3 project. * * Copyright (C) 2010 Uwe Hermann + * Copyright (C) 2012 Michael Ossmann * * 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 . */ -#ifndef LPC17XX_GPIO_H -#define LPC17XX_GPIO_H +#ifndef LPC43XX_GPIO_H +#define LPC43XX_GPIO_H #include #include @@ -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 */ -- cgit v1.2.3