1 | #include <avr/io.h>
|
2 | #include "spi_via_usi_driver.h"
|
3 |
|
4 | #define SPIMODE 0 // Sample on leading _rising_ edge, setup on trailing _falling_ edge.
|
5 |
|
6 | int main()
|
7 | {
|
8 | unsigned char val = 0; // Temp value to send.
|
9 | DDRB = 0xFF; // Set PORTB to all output.
|
10 | spiX_initmaster(SPI_MODE_RISING); // Init SPI driver as master.
|
11 | sei(); // Must do this to make driver work.
|
12 | do {
|
13 | spiX_put( val++ ); // Send temp value to SPI and increment,
|
14 | spiX_wait(); // wait for transmission to finish
|
15 | PORTB = spiX_get(); // and finally put result on PORTB.
|
16 | } while(1); // Loop forever...
|
17 | }
|