aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/GPIOv1
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-11-02 10:07:40 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-11-02 10:07:40 +0000
commitb8c517e46d35e5c9691545eda8fe9b6c40d6943a (patch)
tree1979780cb2222b6ee45d49fe054343e5cc99fbd8 /os/hal/ports/STM32/LLD/GPIOv1
parentca59ce3238108443bf04729f717f9c37d3472937 (diff)
downloadChibiOS-b8c517e46d35e5c9691545eda8fe9b6c40d6943a.tar.gz
ChibiOS-b8c517e46d35e5c9691545eda8fe9b6c40d6943a.tar.bz2
ChibiOS-b8c517e46d35e5c9691545eda8fe9b6c40d6943a.zip
Lines support in PAL driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8417 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/GPIOv1')
-rw-r--r--os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h64
1 files changed, 53 insertions, 11 deletions
diff --git a/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h b/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h
index c083ca0ff..bf84466c3 100644
--- a/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h
+++ b/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h
@@ -51,6 +51,54 @@
/*===========================================================================*/
/**
+ * @name Port related definitions
+ * @{
+ */
+/**
+ * @brief Width, in bits, of an I/O port.
+ */
+#define PAL_IOPORTS_WIDTH 16
+
+/**
+ * @brief Whole port mask.
+ * @details This macro specifies all the valid bits into a port.
+ */
+#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFF)
+/** @} */
+
+/**
+ * @name Line handling macros
+ * @{
+ */
+/**
+ * @brief Forms a line identifier.
+ * @details A port/pad pair are encoded into an @p ioline_t type. The encoding
+ * of this type is platform-dependent.
+ * @note In this driver the pad number is encoded in the lower 4 bits of
+ * the GPIO address which are guaranteed to be zero.
+ */
+#define PAL_LINE(port, pad) \
+ ((ioline_t)((uint32_t)(port)) | ((uint32_t)(pad)))
+
+/**
+ * @brief Decodes a port identifier from a line identifier.
+ */
+#define PAL_PORT(line) \
+ ((stm32_gpio_t *)(((uint32_t)(line)) & 0xFFFFFFF0U))
+
+/**
+ * @brief Decodes a pad identifier from a line identifier.
+ */
+#define PAL_PAD(line) \
+ ((uint32_t)((uint32_t)(line) & 0x0000000FU))
+
+/**
+ * @brief Value identifying an invalid line.
+ */
+#define PAL_NOLINE 0U
+/** @} */
+
+/**
* @brief GPIO port setup info.
*/
typedef struct {
@@ -93,17 +141,6 @@ typedef struct {
} PALConfig;
/**
- * @brief Width, in bits, of an I/O port.
- */
-#define PAL_IOPORTS_WIDTH 16
-
-/**
- * @brief Whole port mask.
- * @details This macro specifies all the valid bits into a port.
- */
-#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFF)
-
-/**
* @brief Digital I/O port sized unsigned type.
*/
typedef uint32_t ioportmask_t;
@@ -114,6 +151,11 @@ typedef uint32_t ioportmask_t;
typedef uint32_t iomode_t;
/**
+ * @brief Type of an I/O line.
+ */
+typedef uint32_t ioline_t;
+
+/**
* @brief Port Identifier.
* @details This type can be a scalar or some kind of pointer, do not make
* any assumption about it, use the provided macros when populating