Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <avr/io.h>
void InitSPI(void)
{
DDRB = (1<<PB4)|(1<<PB5) | (1<<PB7); // Set MOSI , SCK , and SS output
SPCR = ( (1<<SPE)|(1<<MSTR) | (1<<SPR1) |(1<<SPR0)); // Enable SPI, Master, set clock rate fck/128
}
void WriteByteSPI(unsigned char byte)
{
SPDR = byte; //Load byte to Data register
while(!(SPSR & (1<<SPIF))); // Wait for transmission complete
}
char ReadByteSPI(char addr)
{
SPDR = addr; //Load byte to Data register
while(!(SPSR & (1<<SPIF))); // Wait for transmission complete
addr=SPDR;
return addr;
}