How can I send the string from Slave SPI to Master SPI?
I want to write code in Bare Metal.
The problem which I am facing is I can't make out what will be my blocking function in Master SPI code when receiving data from slave SPI.
As my SPIF bit is cleared in MAster code as soon as I shift out SPDR register from master to receive byte which is coming from the slave.
#define spi_data_reg SPDR
//Naster read byte function
uint8_t MA_SPI0_read_byte()
{
spi_port &= ~(1<<SS);
spi_data_reg = 0;
while(!(SPSR & (1<<SPIF))); //Wait until transmission complete
return(spi_data_reg); //Return received data
spi_port |= (1<<SS);
}
//Slave send byte function
void SL_SPI0_send_byte(uint8_t data)
{
spi_data_direc=(1<<MISO); //MISO as OUTPUT
spi_data_reg = data;
while(!(SPSR &(1<<SPIF)));
}