aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-01 18:35:07 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-01 18:35:07 +0000
commit080e6abe804c5404c4d81614cf130b4ce332efcd (patch)
treec6bb1f9fbff7139c2fcf696b2f2e64a15c06e86a /src
parentd9d8d0bc90fa38243946a19aec789ea7d2280fbf (diff)
downloadChibiOS-080e6abe804c5404c4d81614cf130b4ce332efcd.tar.gz
ChibiOS-080e6abe804c5404c4d81614cf130b4ce332efcd.tar.bz2
ChibiOS-080e6abe804c5404c4d81614cf130b4ce332efcd.zip
Added I/O ports low level driver template.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1006 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/include/ioports.h22
-rw-r--r--src/templates/ioports_lld.h148
2 files changed, 159 insertions, 11 deletions
diff --git a/src/include/ioports.h b/src/include/ioports.h
index 26a393730..0114e4347 100644
--- a/src/include/ioports.h
+++ b/src/include/ioports.h
@@ -70,9 +70,9 @@ typedef struct {
* @brief Writes a bits mask on a I/O port.
*
* @param[in] port the port identifier
- * @param[in] value the value to be written on the specified port
+ * @param[in] bits the bits to be written on the specified port
*/
-#define chPortWrite(port, value) ioport_write_lld(port, value)
+#define chPortWrite(port, bits) ioport_write_lld(port, bits)
/**
* @brief Reads an I/O port.
@@ -86,50 +86,50 @@ typedef struct {
* @brief Sets a bits mask on a I/O port.
*
* @param[in] port the port identifier
- * @param[in] mask the mask to be ORed on the specified port
+ * @param[in] bits the bits to be ORed on the specified port
*
* @note The operation is not guaranteed to be atomic on all the architectures,
* for atomicity and/or portability reasons you may need to enclose port
* I/O operations between @p chSysLock() and @p chSysUnlock().
*/
-#define chPortSet(port, mask) ioport_set_lld(port, mask)
+#define chPortSet(port, bits) ioport_set_lld(port, bits)
/**
* @brief Clears a bits mask on a I/O port.
*
* @param[in] port the port identifier
- * @param[in] mask the mask to be cleared on the specified port
+ * @param[in] bits the bits to be cleared on the specified port
*
* @note The operation is not guaranteed to be atomic on all the architectures,
* for atomicity and/or portability reasons you may need to enclose port
* I/O operations between @p chSysLock() and @p chSysUnlock().
*/
-#define chPortClear(port, mask) ioport_clear_lld(port mask)
+#define chPortClear(port, bits) ioport_clear_lld(port, bits)
/**
* @brief Toggles a bits mask on a I/O port.
*
* @param[in] port the port identifier
- * @param[in] mask the mask to be XORed on the specified port
+ * @param[in] bits the bits to be XORed on the specified port
*
* @note The operation is not guaranteed to be atomic on all the architectures,
* for atomicity and/or portability reasons you may need to enclose port
* I/O operations between @p chSysLock() and @p chSysUnlock().
*/
-#define chPortToggle(port, mask) ioport_clear_lld(port mask)
+#define chPortToggle(port, bits) ioport_clear_lld(port, bits)
/**
* @brief Writes a value on an I/O bus.
*
* @param[in] bus the I/O bus
- * @param[in] value the value to be written on the I/O bus. Values exceeding
- * the bus width are masked so most significant bits may be lost.
+ * @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 The operation is not guaranteed to be atomic on all the architectures,
* for atomicity and/or portability reasons you may need to enclose port
* I/O operations between @p chSysLock() and @p chSysUnlock().
*/
-#define chPortWriteBus(bus, value) ioport_writebus_lld(bus, value)
+#define chPortWriteBus(bus, bits) ioport_writebus_lld(bus, bits)
/**
* @brief Reads a value from an I/O bus.
diff --git a/src/templates/ioports_lld.h b/src/templates/ioports_lld.h
new file mode 100644
index 000000000..77a9c93ba
--- /dev/null
+++ b/src/templates/ioports_lld.h
@@ -0,0 +1,148 @@
+/*
+ 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 ioports_lld.h
+ * @brief I/O ports low level driver
+ * @addtogroup IOPortsLLD
+ * @{
+ */
+
+#ifndef _IOPORTS_LLD_H_
+#define _IOPORTS_LLD_H_
+
+/*===========================================================================*/
+/* 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.
+ * @details This type can be a scalar or some kind of pointer, do not make
+ * any assumption about it, use the provided macros when populating
+ * variables of this type.
+ */
+typedef uint32_t ioportid_t;
+
+/*===========================================================================*/
+/* I/O Ports Identifiers. */
+/*===========================================================================*/
+
+/**
+ * @brief First I/O port identifier.
+ * @details Low level drivers can define multiple ports, please use this
+ * naming convention.
+ */
+#define IOPORT_A 0
+
+/*===========================================================================*/
+/* Implementation, some of the following macros could be implemented as */
+/* functions, please put them in a file named ioports_lld.c if so. */
+/*===========================================================================*/
+
+/**
+ * @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)
+
+/**
+ * @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)
+
+/**
+ * @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)
+
+/**
+ * @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)
+
+/**
+ * @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_clear_lld(port, bits)
+
+/**
+ * @brief Writes a value on an I/O bus.
+ *
+ * @param[in] bus the I/O bus
+ * @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)
+
+/**
+ * @brief Reads a value from an I/O bus.
+ *
+ * @param[in] bus the I/O bus
+ * @return the bus bits
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define ioport_readbus_lld(bus)
+
+#endif /* _IOPORTS_LLD_H_ */
+
+/** @} */