aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-21 08:52:44 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-06-21 08:52:44 +0000
commit1c7e52eb35c244e5855ea7978ab02d9540829e00 (patch)
treec9cbb85a1b4bbeab3c5460e46fb63321b0426412 /src
parentd737613d74644daf305133241f361038406b6295 (diff)
downloadChibiOS-1c7e52eb35c244e5855ea7978ab02d9540829e00.tar.gz
ChibiOS-1c7e52eb35c244e5855ea7978ab02d9540829e00.tar.bz2
ChibiOS-1c7e52eb35c244e5855ea7978ab02d9540829e00.zip
Added abstract port setup to PAL and to the MSP430 port.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1042 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/lib/pal.c8
-rw-r--r--src/lib/pal.h70
-rw-r--r--src/templates/pal_lld.h20
3 files changed, 95 insertions, 3 deletions
diff --git a/src/lib/pal.c b/src/lib/pal.c
index abe3db3f6..95ab43883 100644
--- a/src/lib/pal.c
+++ b/src/lib/pal.c
@@ -70,4 +70,12 @@ void palWriteBus(IOBus *bus, ioportmask_t bits) {
palWriteGroup(bus->bus_portid, bus->bus_mask, bus->bus_offset, bits);
}
+void palSetBusMode(IOBus *bus, uint_fast8_t mode) {
+
+ chDbgCheck((bus != NULL) &&
+ (bus->bus_offset > PAL_IOPORTS_WIDTH), "palSetBusMode");
+
+ palSetMode(bus->bus_portid, bus->bus_mask, mode);
+}
+
/** @} */
diff --git a/src/lib/pal.h b/src/lib/pal.h
index d4190e500..96ed8c312 100644
--- a/src/lib/pal.h
+++ b/src/lib/pal.h
@@ -27,6 +27,48 @@
#ifndef _PAL_H_
#define _PAL_H_
+/**
+ * @brief After reset state.
+ * @details The state itself is not specified and is architecture dependent,
+ * it is guaranteed to be equal to the after-reset state. It is
+ * usually an input state.
+ */
+#define PAL_MODE_RESET 0
+
+/**
+ * @brief Safe state for <b>unconnected</b> pads.
+ * @details The state itself is not specified and is architecture dependent,
+ * it may be mapped on @p PAL_MODE_INPUT_PULLUP,
+ * @p PAL_MODE_INPUT_PULLDOWN or @p PAL_MODE_OUTPUT_PUSHPULL as
+ * example.
+ */
+#define PAL_MODE_UNCONNECTED 1
+
+/**
+ * @brief Regular input high-Z pad.
+ */
+#define PAL_MODE_INPUT 2
+
+/**
+ * @brief Input pad with weak pull up resistor.
+ */
+#define PAL_MODE_INPUT_PULLUP 3
+
+/**
+ * @brief Input pad with weak pull down resistor.
+ */
+#define PAL_MODE_INPUT_PULLDOWN 4
+
+/**
+ * @brief Push-pull output pad.
+ */
+#define PAL_MODE_OUTPUT_PUSHPULL 5
+
+/**
+ * @brief Open-drain output pad.
+ */
+#define PAL_MODE_OUTPUT_OPENDRAIN 6
+
#ifndef _PAL_LLD_H_
#include "pal_lld.h"
#endif
@@ -70,7 +112,7 @@
* @param width the bus width in bits
* @param offset the bus bit offset within the port
*/
-#define _IOBUS_DATA(name, port, width, offset) \
+#define _IOBUS_DATA(name, port, width, offset) \
{port, PAL_GROUP_MASK(width), offset}
/**
@@ -102,9 +144,13 @@ typedef struct {
} IOBus;
/**
- * @brief PAL subsystem initialization.
+ * @brief PAL subsystem initialization.
+ *
+ * @param[in] config pointer to an architecture specific configuration
+ * structure. This structure is defined in the low level driver
+ * header.
*/
-#define palInit() pal_lld_init()
+#define palInit(config) pal_lld_init(config)
/**
* @brief Reads the physical I/O port states.
@@ -354,11 +400,29 @@ typedef struct {
#define palTogglePad(port, pad) pal_lld_togglepad(port, pad)
#endif
+/**
+ * @brief Pads mode setup.
+ * @details This function programs a pads group belonging to the same port
+ * with the specified mode.
+ *
+ * @param[in] port the port identifier
+ * @param[in] mask the group mask
+ * @param[in] mode the setup mode
+ *
+ * @note Programming an unknown or unsupported mode is silently ignored.
+ */
+#if !defined(pal_lld_setmode) || defined(__DOXYGEN__)
+#define palSetMode(port, mask, mode)
+#else
+#define palSetMode(port, mask, mode) pal_lld_setmode(port, mask, mode)
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
ioportmask_t palReadBus(IOBus *bus);
void palWriteBus(IOBus *bus, ioportmask_t bits);
+ void palSetBusMode(IOBus *bus, uint_fast8_t mode);
#ifdef __cplusplus
}
#endif
diff --git a/src/templates/pal_lld.h b/src/templates/pal_lld.h
index 38d0253e2..48c91811c 100644
--- a/src/templates/pal_lld.h
+++ b/src/templates/pal_lld.h
@@ -37,6 +37,12 @@
#define PAL_IOPORTS_WIDTH 32
/**
+ * @brief Whole port mask.
+ * @brief This macro specifies all the valid bits into a port.
+ */
+#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFFFFF)
+
+/**
* @brief Digital I/O port sized unsigned type.
*/
typedef uint32_t ioportmask_t;
@@ -254,6 +260,20 @@ typedef uint32_t ioportid_t;
*/
#define pal_lld_togglepad(port, pad)
+/**
+ * @brief Pads mode setup.
+ * @details This function programs a pads group belonging to the same port
+ * with the specified mode.
+ *
+ * @param[in] port the port identifier
+ * @param[in] mask the group mask
+ * @param[in] mode the setup mode
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ */
+#define pal_lld_setmode(port, mask, mode)
+
#endif /* _PAL_LLD_H_ */
/** @} */