diff options
author | Theodore Ateba <tf.ateba@gmail.com> | 2017-09-13 21:22:38 +0000 |
---|---|---|
committer | Theodore Ateba <tf.ateba@gmail.com> | 2017-09-13 21:22:38 +0000 |
commit | 1fb6dc3e55cb7fa5c52b990717af5ee0c9efaf36 (patch) | |
tree | 0c81502743cf2c098b0091f68347d6ad0c4f6a44 /os/hal/ports/AVR/MEGA | |
parent | dab0220e94d296e9b3d430eb988dceca712ddcd1 (diff) | |
download | ChibiOS-1fb6dc3e55cb7fa5c52b990717af5ee0c9efaf36.tar.gz ChibiOS-1fb6dc3e55cb7fa5c52b990717af5ee0c9efaf36.tar.bz2 ChibiOS-1fb6dc3e55cb7fa5c52b990717af5ee0c9efaf36.zip |
Add PAL line support in PAL lld for AVR port.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10580 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/AVR/MEGA')
-rw-r--r-- | os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c | 86 | ||||
-rw-r--r-- | os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h | 113 |
2 files changed, 199 insertions, 0 deletions
diff --git a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c index bf764c108..491fc58d4 100644 --- a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c +++ b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.c @@ -29,6 +29,10 @@ /*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
+/**
+ * @brief Event records for the 16 GPIO EXTI channels.
+ */
+palevent_t _pal_events[16];
/*===========================================================================*/
/* Driver local variables and types. */
@@ -151,6 +155,88 @@ void _pal_lld_setgroupmode(ioportid_t port, }
}
+/**
+ * @brief Pad event enable.
+ * @details This function programs an event callback in the specified mode.
+ * @note Programming an unknown or unsupported mode is silently ignored.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ * @param[in] mode pad event mode
+ * @param[in] callback event callback function
+ * @param[in] arg callback argument
+ *
+ * @notapi
+ */
+void _pal_lld_enablepadevent(ioportid_t port,
+ iopadid_t pad,
+ ioeventmode_t mode,
+ palcallback_t callback,
+ void *arg) {
+ (void)port;
+ (void)pad;
+ (void)mode;
+ (void)callback;
+ (void)arg;
+
+ /* TODO: Implement the interruption here. */
+ /*
+ #if (port == IOPORT4)
+ #elif (port == IOPORT5)
+ #else
+ #error The selected port dont have an EXT INTx pin.
+ */
+ //}
+}
+
+/**
+ * @brief Make a line identifier with a given port and pad identifiers.
+ *
+ * @param[in] port the port identifier
+ * @param[in] pad the pad identifier
+ *
+ * @return line the builded line
+ *
+ * @notapi
+ */
+ioline_t _pal_lld_setlineid(ioportid_t port, uint8_t pad) {
+
+ ioline_t line;
+
+ line.port = port;
+ line.pad = pad;
+
+ return line;
+}
+
+/**
+ * @brief Get a port identifier from a line identifier.
+ *
+ * @param[in] line the line identifier
+ *
+ * @return port the port of the corresponding line
+ *
+ * @notapi
+ */
+ioportid_t _pal_lld_getportfromline(ioline_t line) {
+
+ return line.port;
+}
+
+/**
+ * @brief Get a pad identifier from a line identifier.
+ *
+ * @param[in] line the line identifier
+ *
+ * @return pad the pad of the corresponding line
+ *
+ * @notapi
+ */
+uint8_t _pal_lld_getpadfromline(ioline_t line) {
+
+ return line.pad;
+}
+
#endif /* HAL_USE_PAL */
/** @} */
diff --git a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h index 4b23b6db4..c174a260c 100644 --- a/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h +++ b/os/hal/ports/AVR/MEGA/LLD/GPIOv1/hal_pal_lld.h @@ -52,6 +52,35 @@ #define PAL_WHOLE_PORT ((ioportmask_t)0xFF)
/**
+ * @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 and the port identifier are
+ * encoded in a structure of type ioline_t.
+ */
+#define PAL_LINE(port, pad) _pal_lld_setlineid(port, pad)
+
+/**
+ * @brief Decodes a port identifier from a line identifier.
+ */
+#define PAL_PORT(line) _pal_lld_getportfromline(line)
+
+/**
+ * @brief Decodes a pad identifier from a line identifier.
+ */
+#define PAL_PAD(line) _pal_lld_getpadfromline(line)
+
+/**
+ * @brief Value identifying an invalid line.
+ */
+#define PAL_NOLINE 0U
+/** @} */
+
+/**
* @brief AVR setup registers.
*/
typedef struct {
@@ -132,6 +161,24 @@ typedef uint8_t iomode_t; */
typedef volatile avr_gpio_registers_t * ioportid_t;
+/**
+ * @brief Type of an pad identifier.
+ */
+typedef uint8_t iopadid_t;
+
+/**
+ * @brief Type of an I/O line.
+ */
+typedef struct {
+ ioportid_t port; /* Line port identifier. */
+ iopadid_t pad; /* Line pad identifier. */
+}ioline_t;
+
+/**
+ * @brief Type of an event mode.
+ */
+typedef uint8_t ioeventmode_t;
+
/*===========================================================================*/
/* I/O Ports Identifiers. */
/*===========================================================================*/
@@ -311,6 +358,60 @@ typedef volatile avr_gpio_registers_t * ioportid_t; #define pal_lld_clearpad(port, pad) \
port->out &= ~_BV(pad)
+/**
+ * @brief Pad event enable.
+ * @details This function programs an event callback in the specified mode.
+ * @note Programming an unknown or unsupported mode is silently ignored.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ * @param[in] mode pad event mode
+ * @param[in] callback event callback function
+ * @param[in] arg callback argument
+ *
+ * @notapi
+ */
+#define pal_lld_enablepadevent(port, pad, mode, callback, arg) \
+ _pal_lld_enablepadevent(port, pad, mode, callback, arg)
+
+/**
+ * @brief Pad event disable.
+ * @details This function disables previously programmed event callbacks.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ *
+ * @notapi
+ */
+#define pal_lld_disablepadevent(port, pad) \
+ _pal_lld_disablepadevent(port, pad)
+
+/**
+ * @brief Returns a PAL event structure associated to a pad.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ *
+ * @notapi
+ */
+#define pal_lld_get_pad_event(port, pad) \
+ &_pal_events[pad]; (void)(port)
+
+/**
+ * @brief Returns a PAL event structure associated to a line.
+ *
+ * @param[in] line line identifier
+ *
+ * @notapi
+ */
+#define pal_lld_get_line_event(line) \
+ &_pal_events[PAL_PAD(line)]
+
+#if !defined(__DOXYGEN__)
+extern const PALConfig pal_default_config;
+extern palevent_t _pal_events[16];
+#endif
+
extern ROMCONST PALConfig pal_default_config;
#ifdef __cplusplus
@@ -320,6 +421,18 @@ extern "C" { void _pal_lld_setgroupmode(ioportid_t port,
ioportmask_t mask,
iomode_t mode);
+
+ void _pal_lld_enablepadevent(ioportid_t port,
+ iopadid_t pad,
+ ioeventmode_t mode,
+ palcallback_t callback,
+ void *arg);
+ void _pal_lld_disablepadevent(ioportid_t port, iopadid_t pad);
+
+ ioline_t _pal_lld_setlineid(ioportid_t port, uint8_t pad);
+ ioportid_t _pal_lld_getportfromline(ioline_t line);
+ uint8_t _pal_lld_getpadfromline(ioline_t line);
+
#ifdef __cplusplus
}
#endif
|