Rev | Author | Line No. | Line |
---|---|---|---|
2294 | kaklik | 1 | #include "spi.h" |
2 | |||
3 | #include <avr/io.h> |
||
4 | |||
5 | void SPI_MasterInit(void) |
||
6 | { |
||
7 | /* Enable SPI, Master, set clock rate fck/4, SCK high when idle, sample on rising */ |
||
8 | // SPSR|= 0b00000001; //for fck/2 |
||
9 | SPCR = 0b01011100; |
||
10 | } |
||
11 | |||
12 | char SPI_MasterTransmit(char cData) { |
||
13 | /* Start transmission */ |
||
14 | SPDR = cData; |
||
15 | |||
16 | /* Wait for transmission complete */ |
||
17 | while(!(SPSR & (1<<SPIF))) |
||
18 | ; |
||
19 | return SPDR; |
||
20 | } |