diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/pal.c | 13 | ||||
-rw-r--r-- | src/lib/pal.h | 35 |
2 files changed, 41 insertions, 7 deletions
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
|