summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--digital/avr/common/io.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/digital/avr/common/io.h b/digital/avr/common/io.h
index d6be6042..6fe5479a 100644
--- a/digital/avr/common/io.h
+++ b/digital/avr/common/io.h
@@ -49,4 +49,25 @@
#endif /* HOST */
+/** Use these macros to define port and bit number combination.
+ * For example:
+ *
+ * #define MY_IO B, 5
+ * IO_PORT (MY_IO) => PORTB
+ * IO_DDR (MY_IO) => DDRB
+ * IO_PIN (MY_IO) => PINB
+ * IO_BV (MY_IO) => _BV (5)
+ * IO_N (MY_IO) => (5)
+ */
+#define IO_PORT(io) IO_PORT_ (io)
+#define IO_PORT_(p, n) PORT ## p
+#define IO_DDR(io) IO_DDR_ (io)
+#define IO_DDR_(p, n) DDR ## p
+#define IO_PIN(io) IO_PIN_ (io)
+#define IO_PIN_(p, n) PIN ## p
+#define IO_BV(io) IO_BV_ (io)
+#define IO_BV_(p, n) _BV (n)
+#define IO_N(io) IO_N_ (io)
+#define IO_N_(p, n) (n)
+
#endif /* io_h */