10 #define SPI_SPCR(rat, pha, pol, mst, dor) ((rat & 3) | (pha?(1<<CPHA):0) | (pol?(1<<CPOL):0) | (mst?(1<<MSTR):0) | (dor?(1<<DORD):0) | (1<<SPE))
11 #define SPI_SPSR(rat) ((rat & 4)?(1<<SPI2X):0)
18 #if defined(__cplusplus)
22 static inline void spi_init()
24 DDRB &= ~((1 << DD_SCK) | (1 << DD_MOSI) | (1 << DD_MISO));
25 DDRB |= (1 << DD_SS) | (1 << DD_SCK) | (1 << DD_MOSI);
26 PORTB &= ~((1 << DD_SCK) | (1 << DD_MOSI) | (1 << DD_MISO));
27 PORTB |= (1 << DD_SS);
28 SPCR = SPI_SPCR(0, 0, 0, 1, 0);
32 static inline void spi_setup(uint8_t spcr, uint8_t spsr)
38 static inline uint8_t spi_txrx(uint8_t tx)
41 while (!(SPSR & (1 << SPIF)));
45 #if defined(__cplusplus)