aboutsummaryrefslogtreecommitdiff
path: root/examples/spiblink/slave.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/spiblink/slave.c')
-rw-r--r--examples/spiblink/slave.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/spiblink/slave.c b/examples/spiblink/slave.c
new file mode 100644
index 0000000..cf14408
--- /dev/null
+++ b/examples/spiblink/slave.c
@@ -0,0 +1,21 @@
+#include <avr/io.h>
+#include <util/delay.h>
+#include "../../spi.h"
+
+void receive(uint8_t data);
+
+int main() {
+ DDRB |= _BV(DDB1);
+ spi_receive = receive;
+ spi_init(SPI_MODE_SLAVE);
+ SREG |= _BV(7);
+ while (1) {
+ }
+}
+
+void receive(uint8_t data) {
+ if (data)
+ PORTB |= _BV(PORTB1);
+ else
+ PORTB &= ~_BV(PORTB1);
+}