diff options
Diffstat (limited to 'os/hal/ports/AVR/XMEGA')
-rw-r--r-- | os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.c | 82 | ||||
-rw-r--r-- | os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.h | 107 |
2 files changed, 187 insertions, 2 deletions
diff --git a/os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.c b/os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.c index e7f220da4..f80d5e0e1 100644 --- a/os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.c +++ b/os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.c @@ -151,6 +151,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/XMEGA/LLD/GPIOv1/hal_pal_lld.h b/os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.h index 9e98a66da..d552f161b 100644 --- a/os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.h +++ b/os/hal/ports/AVR/XMEGA/LLD/GPIOv1/hal_pal_lld.h @@ -50,6 +50,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 {
@@ -122,15 +151,32 @@ typedef uint8_t ioportmask_t; */
typedef uint8_t iomode_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
* variables of this type.
*/
-//typedef volatile avr_gpio_registers_t * ioportid_t;
typedef volatile PORT_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. */
/*===========================================================================*/
@@ -294,6 +340,60 @@ typedef volatile PORT_t * ioportid_t; */
#define pal_lld_clearpad(port, pad) ((port)->OUTCLR |= (1 << 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
@@ -303,6 +403,9 @@ extern "C" { void _pal_lld_setgroupmode(ioportid_t port,
ioportmask_t mask,
iomode_t mode);
+ 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
|