aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports
diff options
context:
space:
mode:
authorFabio Utzig <utzig@utzig.org>2016-05-09 19:23:30 -0300
committerFabio Utzig <utzig@utzig.org>2016-05-09 19:23:30 -0300
commitb0dd73442bc0e0cd62a963b431aa9a72c6e86953 (patch)
tree5f5682c4d06385e6b48f3cc23412d298bacf64b6 /os/hal/ports
parentde959be01fde202b71a86e080a15a06db7ed044d (diff)
parent4b186ab80ec47d6551f3f8e65aceff98968958ef (diff)
downloadChibiOS-Contrib-b0dd73442bc0e0cd62a963b431aa9a72c6e86953.tar.gz
ChibiOS-Contrib-b0dd73442bc0e0cd62a963b431aa9a72c6e86953.tar.bz2
ChibiOS-Contrib-b0dd73442bc0e0cd62a963b431aa9a72c6e86953.zip
Merge pull request #74 from sdalu/palline
PAL Line
Diffstat (limited to 'os/hal/ports')
-rw-r--r--os/hal/ports/NRF51/NRF51822/hal_pal_lld.h63
1 files changed, 51 insertions, 12 deletions
diff --git a/os/hal/ports/NRF51/NRF51822/hal_pal_lld.h b/os/hal/ports/NRF51/NRF51822/hal_pal_lld.h
index 4425d24..e5b62ee 100644
--- a/os/hal/ports/NRF51/NRF51822/hal_pal_lld.h
+++ b/os/hal/ports/NRF51/NRF51822/hal_pal_lld.h
@@ -38,18 +38,9 @@
#define TOTAL_GPIO_PADS 32
/**
- * @brief Generic I/O ports static initializer.
- * @details An instance of this structure must be passed to @p palInit() at
- * system startup time in order to initialized the digital I/O
- * subsystem. This represents only the initial setup, specific pads
- * or whole ports can be reprogrammed at later time.
- * @note Implementations may extend this structure to contain more,
- * architecture dependent, fields.
+ * @name Port related definitions
+ * @{
*/
-typedef struct {
- uint32_t pads[TOTAL_GPIO_PADS];
-} PALConfig;
-
/**
* @brief Width, in bits, of an I/O port.
*/
@@ -60,6 +51,50 @@ typedef struct {
* @brief This macro specifies all the valid bits into a port.
*/
#define PAL_WHOLE_PORT ((ioportmask_t)0xFFFFFFFFU)
+/** @} */
+
+/**
+ * @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.
+ */
+#define PAL_LINE(port, pad) \
+ ((ioline_t)((uint32_t)(pad)))
+
+/**
+ * @brief Decodes a port identifier from a line identifier.
+ */
+#define PAL_PORT(line) \
+ ((ioportid_t)(IOPORT1))
+
+/**
+ * @brief Decodes a pad identifier from a line identifier.
+ */
+#define PAL_PAD(line) \
+ ((uint32_t)(line))
+
+/**
+ * @brief Value identifying an invalid line.
+ */
+#define PAL_NOLINE FFU
+/** @} */
+
+/**
+ * @brief Generic I/O ports static initializer.
+ * @details An instance of this structure must be passed to @p palInit() at
+ * system startup time in order to initialized the digital I/O
+ * subsystem. This represents only the initial setup, specific pads
+ * or whole ports can be reprogrammed at later time.
+ * @note Implementations may extend this structure to contain more,
+ * architecture dependent, fields.
+ */
+typedef struct {
+ uint32_t pads[TOTAL_GPIO_PADS];
+} PALConfig;
/**
* @brief Digital I/O port sized unsigned type.
@@ -72,6 +107,11 @@ typedef uint32_t ioportmask_t;
typedef uint8_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
@@ -266,7 +306,6 @@ typedef NRF_GPIO_Type *ioportid_t;
NRF_GPIO->OUTSET = 1 << (pad); \
} while (0)
-
/**
* @brief Pad mode setup.
* @details This function programs a pad with the specified mode.