aboutsummaryrefslogtreecommitdiffstats
path: root/ports/ARM7-LPC214x
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-02 13:41:38 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-02 13:41:38 +0000
commit2a7941ee58016ce7641ab8010aff5fe711e0bedc (patch)
tree4ac467770e31cbf9245936b998d47e0809bf28b7 /ports/ARM7-LPC214x
parent1aa2773ad03807e3d5c9822ea108bc2e280281db (diff)
downloadChibiOS-2a7941ee58016ce7641ab8010aff5fe711e0bedc.tar.gz
ChibiOS-2a7941ee58016ce7641ab8010aff5fe711e0bedc.tar.bz2
ChibiOS-2a7941ee58016ce7641ab8010aff5fe711e0bedc.zip
I/O port driver for LPC214x added.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1016 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'ports/ARM7-LPC214x')
-rw-r--r--ports/ARM7-LPC214x/ioports_lld.h174
-rw-r--r--ports/ARM7-LPC214x/lpc214x.h5
-rw-r--r--ports/ARM7-LPC214x/lpc214x_ssp.c5
-rw-r--r--ports/ARM7-LPC214x/port.dox16
4 files changed, 198 insertions, 2 deletions
diff --git a/ports/ARM7-LPC214x/ioports_lld.h b/ports/ARM7-LPC214x/ioports_lld.h
new file mode 100644
index 000000000..db82b8f97
--- /dev/null
+++ b/ports/ARM7-LPC214x/ioports_lld.h
@@ -0,0 +1,174 @@
+/*
+ ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file ports/ARM-LPC214x/ioports_lld.h
+ * @brief LPC214x FIO low level driver
+ * @addtogroup LPC214X_IOPORTS
+ * @{
+ */
+
+#ifndef _IOPORTS_LLD_H_
+#define _IOPORTS_LLD_H_
+
+#ifndef _LPC214X_H_
+#include "lpc214x.h"
+#endif
+
+/*===========================================================================*/
+/* I/O Ports Types and constants. */
+/*===========================================================================*/
+
+/**
+ * @brief Width, in bits, of an I/O port.
+ */
+#define IOPORTS_WIDTH 32
+
+/**
+ * @brief Digital I/O port sized unsigned type.
+ */
+typedef uint32_t ioportmask_t;
+
+/**
+ * @brief Port Identifier.
+ */
+typedef FIO * ioportid_t;
+
+/*===========================================================================*/
+/* I/O Ports Identifiers. */
+/*===========================================================================*/
+
+/**
+ * @brief FIO port 0 identifier.
+ */
+#define IOPORT_A FIO0Base
+
+/**
+ * @brief FIO port 1 identifier.
+ */
+#define IOPORT_B FIO1Base
+
+/*===========================================================================*/
+/* Implementation, some of the following macros could be implemented as */
+/* functions, please put them in a file named ioports_lld.c if so. */
+/*===========================================================================*/
+
+/**
+ * @brief FIO subsystem initialization.
+ * @details Enables the access through the fast registers.
+ */
+#define ioport_init_lld() { \
+ SCS = 3; \
+}
+
+/**
+ * @brief Writes a bits mask on a I/O port.
+ *
+ * @param[in] port the port identifier
+ * @param[in] bits the bits to be written on the specified port
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_write_lld(port, bits) ((port)->FIO_PIN = (bits))
+
+/**
+ * @brief Reads an I/O port.
+ *
+ * @param[in] port the port identifier
+ * @return the port bits
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_read_lld(port) ((port)->FIO_PIN)
+
+/**
+ * @brief Sets a bits mask on a I/O port.
+ *
+ * @param[in] port the port identifier
+ * @param[in] bits the bits to be ORed on the specified port
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_set_lld(port, bits) ((port)->FIO_SET = (bits))
+
+/**
+ * @brief Clears a bits mask on a I/O port.
+ *
+ * @param[in] port the port identifier
+ * @param[in] bits the bits to be cleared on the specified port
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_clear_lld(port, bits) ((port)->FIO_CLR = (bits))
+
+/**
+ * @brief Toggles a bits mask on a I/O port.
+ *
+ * @param[in] port the port identifier
+ * @param[in] bits the bits to be XORed on the specified port
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_toggle_lld(port, bits) ((port)->FIO_PIN ^= (bits))
+
+/**
+ * @brief Writes a value on an I/O bus.
+ *
+ * @param[in] bus the I/O bus, pointer to a @p IOBus structure
+ * @param[in] bits the bits to be written on the I/O bus. Values exceeding
+ * the bus width are masked so most significant bits are lost.
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_writebus_lld(bus, bits) { \
+ (port)->FIO_MASK = (bus)->bus_mask; \
+ (port)->FIO_PIN = (bits) << (bus)->bus_offset; \
+ (port)->FIO_MASK = 0; \
+}
+
+/**
+ * @brief Reads a value from an I/O bus.
+ *
+ * @param[in] bus the I/O bus, pointer to a @p IOBus structure
+ * @return the bus bits
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_readbus_lld(bus) \
+ (((bus)->bus_portid->FIO_PIN & (bus)->bus_mask) >> (bus)->bus_offset)
+
+/**
+ * @brief FIO port setup.
+ * @details This function initializes a FIO port, note that this functionality
+ * is LPC214x specific and non portable.
+ */
+#define ioport_lpc214x_set_direction_lld(port, dir) { \
+ (port)->FIO_DIR = (dir); \
+}
+
+#endif /* _IOPORTS_LLD_H_ */
+
+/** @} */
diff --git a/ports/ARM7-LPC214x/lpc214x.h b/ports/ARM7-LPC214x/lpc214x.h
index 96dfa437b..e260da713 100644
--- a/ports/ARM7-LPC214x/lpc214x.h
+++ b/ports/ARM7-LPC214x/lpc214x.h
@@ -17,6 +17,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * @file lpc214x.h
+ * @brief LPC214x register definitions
+ */
+
#ifndef _LPC214X_H_
#define _LPC214X_H_
diff --git a/ports/ARM7-LPC214x/lpc214x_ssp.c b/ports/ARM7-LPC214x/lpc214x_ssp.c
index 43c4100bc..00db41cbf 100644
--- a/ports/ARM7-LPC214x/lpc214x_ssp.c
+++ b/ports/ARM7-LPC214x/lpc214x_ssp.c
@@ -25,6 +25,7 @@
*/
#include <ch.h>
+#include <ioports.h>
#include "lpc214x.h"
#include "lpc214x_ssp.h"
@@ -43,7 +44,7 @@ void sspAcquireBus(void) {
#if LPC214x_SSP_USE_MUTEX
chSemWait(&me);
#endif
- IO0CLR = 1 << 20;
+ chPortClear(IOPORT_A, (1 << 20));
}
/**
@@ -53,7 +54,7 @@ void sspAcquireBus(void) {
*/
void sspReleaseBus(void) {
- IO0SET = 1 << 20;
+ chPortSet(IOPORT_A, (1 << 20));
#if LPC214x_SSP_USE_MUTEX
chSemSignal(&me);
#endif
diff --git a/ports/ARM7-LPC214x/port.dox b/ports/ARM7-LPC214x/port.dox
index ad567b2ae..35f0d128f 100644
--- a/ports/ARM7-LPC214x/port.dox
+++ b/ports/ARM7-LPC214x/port.dox
@@ -23,6 +23,7 @@
* @brief LPC214x specific support.
* @details The LPC214x support includes:
* - VIC support code.
+ * - I/O ports driver.
* - Buffered, interrupt driven, serial driver.
* - SSP driver.
* - A MMC/SD demo driver.
@@ -45,6 +46,21 @@
/** @} */
/**
+ * @defgroup LPC214x_IOPORTS I/O Ports Support
+ * @brief I/O Ports peripherals support.
+ * @details This module supports the LPC214x FIO controller. The controller
+ * supports the following features (see @ref IOPorts):
+ * - 32 bits wide ports.
+ * - Atomic set/reset functions.
+ * - Atomic set+reset function (atomic bus operations).
+ * - Output latched regardless of the pad setting.
+ * - Direct read of input pads regardless of the pad setting.
+ * .
+ * The only non atomic operations are bit toggling and bus writing.
+ * @ingroup LPC214x
+ */
+
+/**
* @defgroup LPC214x_SERIAL UART Support
* @{
* @brief UART peripherals support.