diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-06-21 09:35:39 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2009-06-21 09:35:39 +0000 |
commit | 8183016f1cb574d923c83eab468ca37617051d78 (patch) | |
tree | 41308cf6e02ac0bc848c2a6f5733e81f576495cd | |
parent | 1c7e52eb35c244e5855ea7978ab02d9540829e00 (diff) | |
download | ChibiOS-8183016f1cb574d923c83eab468ca37617051d78.tar.gz ChibiOS-8183016f1cb574d923c83eab468ca37617051d78.tar.bz2 ChibiOS-8183016f1cb574d923c83eab468ca37617051d78.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1043 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | demos/MSP430-MSP430x1611-GCC/board.c | 14 | ||||
-rw-r--r-- | ports/MSP430/pal_lld.c | 6 | ||||
-rw-r--r-- | ports/MSP430/pal_lld.h | 9 | ||||
-rw-r--r-- | src/lib/pal.c | 13 | ||||
-rw-r--r-- | src/lib/pal.h | 35 | ||||
-rw-r--r-- | src/templates/pal_lld.h | 41 |
6 files changed, 92 insertions, 26 deletions
diff --git a/demos/MSP430-MSP430x1611-GCC/board.c b/demos/MSP430-MSP430x1611-GCC/board.c index d24bd29e2..2d5341beb 100644 --- a/demos/MSP430-MSP430x1611-GCC/board.c +++ b/demos/MSP430-MSP430x1611-GCC/board.c @@ -26,16 +26,16 @@ #include "msp430_serial.h"
/*
- * Digital I/O ports static configuration. + * Digital I/O ports static configuration as defined in @p board.h. */
static const MSP430DIOConfig config =
{
- {VAL_P1OUT, VAL_P1DIR},
- {VAL_P2OUT, VAL_P2DIR},
- {VAL_P3OUT, VAL_P3DIR},
- {VAL_P4OUT, VAL_P4DIR},
- {VAL_P5OUT, VAL_P5DIR},
- {VAL_P6OUT, VAL_P6DIR},
+ {VAL_P1OUT, VAL_P1DIR},
+ {VAL_P2OUT, VAL_P2DIR},
+ {VAL_P3OUT, VAL_P3DIR},
+ {VAL_P4OUT, VAL_P4DIR},
+ {VAL_P5OUT, VAL_P5DIR},
+ {VAL_P6OUT, VAL_P6DIR},
};
/*
diff --git a/ports/MSP430/pal_lld.c b/ports/MSP430/pal_lld.c index a81b152c8..9b8652263 100644 --- a/ports/MSP430/pal_lld.c +++ b/ports/MSP430/pal_lld.c @@ -85,7 +85,7 @@ void _pal_lld_init(const MSP430DIOConfig *config) { *
* @param[in] port the port identifier
* @param[in] mask the group mask
- * @param[in] mode the setup mode
+ * @param[in] mode the mode
*
* @note This function is not meant to be invoked directly by the application
* code.
@@ -95,7 +95,9 @@ void _pal_lld_init(const MSP430DIOConfig *config) { * @note This function does not alter the @p PxSEL registers. Alternate
* functions setup must be handled by device-specific code.
*/
-void _pal_lld_setmode(ioportid_t port, ioportmask_t mask, uint_fast8_t mode) {
+void _pal_lld_setgroupmode(ioportid_t port,
+ ioportmask_t mask,
+ uint_fast8_t mode) {
switch (mode) {
case PAL_MODE_RESET:
diff --git a/ports/MSP430/pal_lld.h b/ports/MSP430/pal_lld.h index 940d3f7bd..cb47b4259 100644 --- a/ports/MSP430/pal_lld.h +++ b/ports/MSP430/pal_lld.h @@ -258,13 +258,13 @@ typedef union __ioport * ioportid_t; }
/**
- * @brief Pads mode setup.
+ * @brief Pads group 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
+ * @param[in] mode the mode
*
* @note This function is not meant to be invoked directly by the application
* code.
@@ -273,13 +273,14 @@ typedef union __ioport * ioportid_t; * @note This function does not alter the @p PxSEL registers. Alternate
* functions setup must be handled by device-specific code.
*/
-#define pal_lld_setmode(port, mask, mode) _pal_lld_setmode(port, mask, mode)
+#define pal_lld_setgroupmode(port, mask, mode) \
+ _pal_lld_setgroupmode(port, mask, mode)
#ifdef __cplusplus
extern "C" {
#endif
void _pal_lld_init(const MSP430DIOConfig *config);
- void _pal_lld_setmode(ioportid_t port, ioportmask_t mask, uint_fast8_t mode);
+ void _pal_lld_setgroupmode(ioportid_t port, ioportmask_t mask, uint_fast8_t mode);
#ifdef __cplusplus
}
#endif
diff --git a/src/lib/pal.c b/src/lib/pal.c index 95ab43883..4dec01589 100644 --- a/src/lib/pal.c +++ b/src/lib/pal.c @@ -70,6 +70,19 @@ void palWriteBus(IOBus *bus, ioportmask_t bits) { palWriteGroup(bus->bus_portid, bus->bus_mask, bus->bus_offset, bits);
}
+/**
+ * @brief Programs a bus with the specified mode.
+ * + * @param[in] bus the I/O bus, pointer to a @p IOBus structure
+ * @param[in] mode the mode
+ *
+ * @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().
+ * @note The default implementation is non atomic and not necessarily
+ * optimal. Low level drivers may optimize the function by using
+ * specific hardware or coding.
+ */
void palSetBusMode(IOBus *bus, uint_fast8_t mode) {
chDbgCheck((bus != NULL) &&
diff --git a/src/lib/pal.h b/src/lib/pal.h index 96ed8c312..c45a801e6 100644 --- a/src/lib/pal.h +++ b/src/lib/pal.h @@ -296,6 +296,24 @@ typedef struct { pal_lld_writegroup(port, mask, offset, bits)
#endif
+
+/**
+ * @brief Pads group 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_setgroupmode) || defined(__DOXYGEN__)
+#define palSetGroupMode(port, mask, mode)
+#else
+#define palSetGroupMode(port, mask, mode) pal_lld_setgroupmode(port, mask, mode)
+#endif
+
/**
* @brief Reads an input pad logical state.
*
@@ -400,21 +418,24 @@ 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. + * @brief Pad mode setup.
+ * @details This function programs a pad with the specified mode.
*
* @param[in] port the port identifier
- * @param[in] mask the group mask
+ * @param[in] pad the pad number within the port
* @param[in] mode the setup mode
*
+ * @note The default implementation not necessarily optimal. Low level drivers
+ * may optimize the function by using specific hardware or coding.
* @note Programming an unknown or unsupported mode is silently ignored.
*/
-#if !defined(pal_lld_setmode) || defined(__DOXYGEN__)
-#define palSetMode(port, mask, mode)
+#if !defined(pal_lld_setpadmode) || defined(__DOXYGEN__)
+#define palSetPadMode(port, pad, mode) \
+ palSetGroupMode(port, PAL_PORT_BIT(pad), mode)
#else
-#define palSetMode(port, mask, mode) pal_lld_setmode(port, mask, mode)
+#define palSetPadMode(port, pad, mode) pal_lld_setpadmode(port, pad, mode)
#endif
#ifdef __cplusplus
diff --git a/src/templates/pal_lld.h b/src/templates/pal_lld.h index 48c91811c..96cfe872d 100644 --- a/src/templates/pal_lld.h +++ b/src/templates/pal_lld.h @@ -187,6 +187,21 @@ typedef uint32_t ioportid_t; #define pal_lld_writegroup(port, mask, offset, bits)
/**
+ * @brief Pads group 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 mode
+ *
+ * @note This function is not meant to be invoked directly by the application
+ * code.
+ * @note Programming an unknown or unsupported mode is silently ignored.
+ */
+#define pal_lld_setgroupmode(port, mask, mode)
+
+/**
* @brief Reads a logical state from an I/O pad.
* * @param[in] port the port identifier
@@ -261,18 +276,32 @@ 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.
+ * @brief Pad mode setup.
+ * @details This function programs a pad with the specified mode.
*
* @param[in] port the port identifier
- * @param[in] mask the group mask
- * @param[in] mode the setup mode
+ * @param[in] pad the pad number within the port
+ * @param[in] mode the mode
*
* @note This function is not meant to be invoked directly by the application
* code.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ * @note Programming an unknown or unsupported mode is silently ignored.
*/
-#define pal_lld_setmode(port, mask, mode)
+#define pal_lld_setpadmode(port, pad, mode)
+
+#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
+
#endif /* _PAL_LLD_H_ */
|