summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorNicolas Schodet2009-05-07 22:39:35 +0200
committerNicolas Schodet2009-05-07 22:39:35 +0200
commit362824bd00aad8e470baceef83f1c7b24dec6656 (patch)
treeca4cad11b6e48afeea58a398c5aaad6558dce1f9 /digital
parentee5a468417fb6810a5bbe4d46617618a9ddb588a (diff)
* digital/avr/common:
- added IO_ macros.
Diffstat (limited to 'digital')
-rw-r--r--digital/avr/common/io.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/digital/avr/common/io.h b/digital/avr/common/io.h
index 6fe5479a..4a6c1665 100644
--- a/digital/avr/common/io.h
+++ b/digital/avr/common/io.h
@@ -58,6 +58,12 @@
* IO_PIN (MY_IO) => PINB
* IO_BV (MY_IO) => _BV (5)
* IO_N (MY_IO) => (5)
+ *
+ * IO_GET (MY_IO) => (PINB & _BV (5))
+ * IO_SET (MY_IO) => PORTB |= _BV (5)
+ * IO_CLR (MY_IO) => PORTB &= ~_BV (5)
+ * IO_OUTPUT (MY_IO) => DDRB |= _BV (5)
+ * IO_INPUT (MY_IO) => DDRB &= ~_BV (5)
*/
#define IO_PORT(io) IO_PORT_ (io)
#define IO_PORT_(p, n) PORT ## p
@@ -70,4 +76,10 @@
#define IO_N(io) IO_N_ (io)
#define IO_N_(p, n) (n)
+#define IO_GET(io) (IO_PIN_ (io) & IO_BV_ (io))
+#define IO_SET(io) IO_PORT_ (io) |= IO_BV_ (io)
+#define IO_CLR(io) IO_PORT_ (io) &= ~IO_BV_ (io)
+#define IO_OUTPUT(io) IO_DDR_ (io) |= IO_BV_ (io)
+#define IO_INPUT(io) IO_DDR_ (io) &= ~IO_BV_ (io)
+
#endif /* io_h */