From 600cf9a77d21f4d3a56a7cbfa5f1132b05913f74 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 7 Jun 2009 14:50:14 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1021 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- src/lib/pal.c | 7 +++++-- src/lib/pal.h | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/pal.c b/src/lib/pal.c index 045c35c20..abe3db3f6 100644 --- a/src/lib/pal.c +++ b/src/lib/pal.c @@ -24,6 +24,9 @@ * @{ */ +#include +#include + /** * @brief Read from an I/O bus. * @@ -42,7 +45,7 @@ ioportmask_t palReadBus(IOBus *bus) { chDbgCheck((bus != NULL) && (bus->bus_offset > PAL_IOPORTS_WIDTH), "palReadBus"); - return palReadGroup(bus->bus_port, bus->bus_mask, bus->bus_offset); + return palReadGroup(bus->bus_portid, bus->bus_mask, bus->bus_offset); } /** @@ -64,7 +67,7 @@ void palWriteBus(IOBus *bus, ioportmask_t bits) { chDbgCheck((bus != NULL) && (bus->bus_offset > PAL_IOPORTS_WIDTH), "palWriteBus"); - palWriteBus(bus->bus_port, bus->bus_mask, bus->bus_offset, bits); + palWriteGroup(bus->bus_portid, bus->bus_mask, bus->bus_offset, bits); } /** @} */ diff --git a/src/lib/pal.h b/src/lib/pal.h index cac306c43..72f824aab 100644 --- a/src/lib/pal.h +++ b/src/lib/pal.h @@ -60,6 +60,30 @@ */ #define PAL_GROUP_MASK(width) ((ioportmask_t)(1 << (width)) - 1) +/** + * @brief Data part of a static I/O bus initializer. + * @details This macro should be used when statically initializing an I/O bus + * that is part of a bigger structure. + * + * @param name the name of the IOBus variable + * @param port the I/O port descriptor + * @param width the bus width in bits + * @param offset the bus bit offset within the port + */ +#define _IOBUS_DATA(name, port, width, offset) \ + {port, PAL_GROUP_MASK(width), offset} + +/** + * @brief Static I/O bus initializer. + * + * @param name the name of the IOBus variable + * @param port the I/O port descriptor + * @param width the bus width in bits + * @param offset the bus bit offset within the port + */ +#define IOBUS_DECL(name, port, width, offset) \ + IOBus name = _IOBUS_DATA(name, port, width, offset) + /** * @brief I/O bus descriptor. * @details This structure describes a group of contiguous digital I/O lines -- cgit v1.2.3