diff options
author | Fabio Utzig <utzig@utzig.org> | 2016-05-08 20:59:01 -0300 |
---|---|---|
committer | Fabio Utzig <utzig@utzig.org> | 2016-05-08 20:59:01 -0300 |
commit | 03c1e5074237ce5bc45f2655e0564eee8233c012 (patch) | |
tree | 80fc513f4a5f47e3bb1be9aae57c20bad30e7641 /os/hal/ports/KINETIS | |
parent | cf02c79b5aa7209542cbf1b0cefe703a2c0c60be (diff) | |
parent | 7d99206f055a3527bf1aa92052f9923f6cb744a5 (diff) | |
download | ChibiOS-Contrib-03c1e5074237ce5bc45f2655e0564eee8233c012.tar.gz ChibiOS-Contrib-03c1e5074237ce5bc45f2655e0564eee8233c012.tar.bz2 ChibiOS-Contrib-03c1e5074237ce5bc45f2655e0564eee8233c012.zip |
Merge pull request #71 from flabbergast/kinetis
[KINETIS] PAL driver: implement PAL_LINE.
Diffstat (limited to 'os/hal/ports/KINETIS')
-rw-r--r-- | os/hal/ports/KINETIS/LLD/hal_pal_lld.h | 37 |
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. */
|