aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorTheodore Ateba <tf.ateba@gmail.com>2017-09-16 15:50:38 +0000
committerTheodore Ateba <tf.ateba@gmail.com>2017-09-16 15:50:38 +0000
commit077c58efda0bf68e48053cbe8467ca0359993946 (patch)
tree585ccba423db67dadefcc272ab1000151c34088a /os
parent6c0086f449dca0dc4348986de20989df4c8e6cc7 (diff)
downloadChibiOS-077c58efda0bf68e48053cbe8467ca0359993946.tar.gz
ChibiOS-077c58efda0bf68e48053cbe8467ca0359993946.tar.bz2
ChibiOS-077c58efda0bf68e48053cbe8467ca0359993946.zip
AVR: Add PAL line support in ATTiny lld.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10592 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/ports/AVR/TINY/LLD/GPIOv1/hal_pal_lld.c82
-rw-r--r--os/hal/ports/AVR/TINY/LLD/GPIOv1/hal_pal_lld.h105
2 files changed, 187 insertions, 0 deletions
diff --git a/os/hal/ports/AVR/TINY/LLD/GPIOv1/hal_pal_lld.c b/os/hal/ports/AVR/TINY/LLD/GPIOv1/hal_pal_lld.c
index 1068a544b..ca5601196 100644
--- a/os/hal/ports/AVR/TINY/LLD/GPIOv1/hal_pal_lld.c
+++ b/os/hal/ports/AVR/TINY/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/TINY/LLD/GPIOv1/hal_pal_lld.h b/os/hal/ports/AVR/TINY/LLD/GPIOv1/hal_pal_lld.h
index 6cebbae79..495ea6e05 100644
--- a/os/hal/ports/AVR/TINY/LLD/GPIOv1/hal_pal_lld.h
+++ b/os/hal/ports/AVR/TINY/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,10 @@ 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