diff options
author | Karel Kočí <cynerd@email.cz> | 2015-10-11 13:06:28 +0200 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2015-10-11 13:06:28 +0200 |
commit | bab75a6068ab0a64fe22395ad11efafccbf0d842 (patch) | |
tree | 59344457d25c2e72904acac20118eb16633908fe /examples/spiblink/master.c | |
parent | 1b0b3cb1b61759be5c2e100d08c84e5eec924a58 (diff) | |
download | avr-ioe-bab75a6068ab0a64fe22395ad11efafccbf0d842.tar.gz avr-ioe-bab75a6068ab0a64fe22395ad11efafccbf0d842.tar.bz2 avr-ioe-bab75a6068ab0a64fe22395ad11efafccbf0d842.zip |
Implement SPI and remove files
Diffstat (limited to 'examples/spiblink/master.c')
-rw-r--r-- | examples/spiblink/master.c | 20 |
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); + } +} |