aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/KINETIS
diff options
context:
space:
mode:
authorflabbergast <s3+flabbergast@sdfeu.org>2016-05-08 09:09:43 +0100
committerflabbergast <s3+flabbergast@sdfeu.org>2016-05-08 09:09:43 +0100
commit7d99206f055a3527bf1aa92052f9923f6cb744a5 (patch)
tree80fc513f4a5f47e3bb1be9aae57c20bad30e7641 /os/hal/ports/KINETIS
parentcf02c79b5aa7209542cbf1b0cefe703a2c0c60be (diff)
downloadChibiOS-Contrib-7d99206f055a3527bf1aa92052f9923f6cb744a5.tar.gz
ChibiOS-Contrib-7d99206f055a3527bf1aa92052f9923f6cb744a5.tar.bz2
ChibiOS-Contrib-7d99206f055a3527bf1aa92052f9923f6cb744a5.zip
[KINETIS] PAL driver: implement PAL_LINE.
Diffstat (limited to 'os/hal/ports/KINETIS')
-rw-r--r--os/hal/ports/KINETIS/LLD/hal_pal_lld.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/os/hal/ports/KINETIS/LLD/hal_pal_lld.h b/os/hal/ports/KINETIS/LLD/hal_pal_lld.h
index 05749d5..833d95e 100644
--- a/os/hal/ports/KINETIS/LLD/hal_pal_lld.h
+++ b/os/hal/ports/KINETIS/LLD/hal_pal_lld.h
@@ -70,6 +70,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
@@ -129,6 +134,38 @@ typedef struct {
*/
#define IOPORT5 GPIOE
+/**
+ * @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 byte of the GPIO
+ * address that's zero on all Kinetis devices.
+ */
+#define PAL_LINE(port, pad) \
+ ((ioline_t)((uint32_t)(port) | ((uint32_t)(pad)<<20)))
+
+/**
+ * @brief Decodes a port identifier from a line identifier.
+ */
+#define PAL_PORT(line) \
+ ((GPIO_TypeDef *)(((uint32_t)(line)) & 0xF00FFFFFU))
+
+/**
+ * @brief Decodes a pad identifier from a line identifier.
+ */
+#define PAL_PAD(line) \
+ ((uint32_t)((uint32_t)(line) & 0x0FF00000U)>>20)
+
+/**
+ * @brief Value identifying an invalid line.
+ */
+#define PAL_NOLINE 0U
+/** @} */
+
/*===========================================================================*/
/* Implementation, some of the following macros could be implemented as */
/* functions, if so please put them in pal_lld.c. */