diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/pal.c | 7 | ||||
-rw-r--r-- | src/lib/pal.h | 24 |
2 files changed, 29 insertions, 2 deletions
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 <ch.h>
+#include <pal.h>
+
/**
* @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 @@ -61,6 +61,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
* that have to be handled as bus.
|