summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorNicolas Schodet2009-03-30 00:20:12 +0200
committerNicolas Schodet2009-03-30 00:20:12 +0200
commit5496a8e9da16286ecc7e486c37438c234167ea92 (patch)
tree6d7bec61a914ae911ff2e55ec7e932d9fcc6f5aa /digital
parent217942382d551a206fc386f20ca30d23828aebd8 (diff)
* digital/avr/common:
- added IO_* macros to define port/bit combinations.
Diffstat (limited to 'digital')
-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 */