aboutsummaryrefslogtreecommitdiff
path: root/examples/spiblink/master.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/spiblink/master.c')
-rw-r--r--examples/spiblink/master.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/spiblink/master.c b/examples/spiblink/master.c
new file mode 100644
index 0000000..267d7b2
--- /dev/null
+++ b/examples/spiblink/master.c
@@ -0,0 +1,20 @@
+#include <avr/io.h>
+#include <util/delay.h>
+#include "../../spi.h"
+
+int main() {
+ DDRB |= _BV(DDB1) | _BV(DDB2);
+ PORTC |= _BV(PORTC1);
+ spi_init(SPI_MODE_MASTER);
+ SREG |= _BV(7);
+ while (1) {
+ if (PINC & _BV(PINC1)) {
+ PORTB &= ~_BV(PORTB1);
+ } else {
+ PORTB |= _BV(PORTB1);
+ }
+ PORTB &= ~_BV(PORTB2);
+ spi_send(!(PINC & _BV(PINC1)));
+ PORTB |= _BV(PORTB2);
+ }
+}