From 7d99206f055a3527bf1aa92052f9923f6cb744a5 Mon Sep 17 00:00:00 2001 From: flabbergast Date: Sun, 8 May 2016 09:09:43 +0100 Subject: [KINETIS] PAL driver: implement PAL_LINE. --- os/hal/ports/KINETIS/LLD/hal_pal_lld.h | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'os/hal/ports') 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 @@ -69,6 +69,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 @@ -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. */ -- cgit v1.2.3