20 lines
310 B
C
20 lines
310 B
C
#include "spi.h"
|
|
#include <util/delay.h>
|
|
|
|
|
|
void spi_init_master() {
|
|
|
|
|
|
SPI_PORT |= _BV(SCK_PIN)| _BV(SS_PIN);
|
|
SPI_DDR |= _BV(MOSI_PIN) | _BV(SCK_PIN) | _BV(SS_PIN);
|
|
SPCR = _BV(SPE) | _BV(MSTR) ;
|
|
|
|
}
|
|
|
|
uint8_t spi_transfer(uint8_t b) {
|
|
SPDR = b;
|
|
while (!(SPSR & _BV(SPIF)));
|
|
return SPDR;
|
|
|
|
}
|
|
|