From bab75a6068ab0a64fe22395ad11efafccbf0d842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sun, 11 Oct 2015 13:06:28 +0200 Subject: Implement SPI and remove files --- examples/spiblink/master.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 examples/spiblink/master.c (limited to 'examples/spiblink/master.c') 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 +#include +#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); + } +} -- cgit v1.2.3