The typical communication of an spi as I understand it looks like this.
SPDR = data; // Load data
while(!(SPSR & (1<<SPIF) )); //Wait for int flag
return(SPDR); // Return data
The complete flag is set when the data is loaded and cleared when the data is complete. I assume this means the full send/received data. I want to do this without interrupts. I'm wondering if the return data will remain until reloaded? So something like..
SPDR = data;//SPDR is now cleared.
_delay_ms(200);//some amount of time that ends after the total transition.
return(SPDR); //data should still be ready, right?
Does this have pitfalls or even work?
I have two main reasons for this.
1) Interrupts are not well suited in my case. Disabling them causes issues in my bit/bang usb design (this is another discussion). So I'd like to avoid them wherever possible.
2) I want to miss use the SPI a bit and replace my bit banging clock latch data logic. In this case I drop the latch generate a clock and read data. No start byte is required so I'd start the SPI with 0xff or 0 depending on the resting clock state and wait for the reply. This is sort of an experiment and I'm not sure its going to work but want to try. AFAIK there is no way to tell the SPI send nothing and assume a reply, unless maybe I set up the SPI to be a salve..but in this case the slave can not lower the SS line by design. Again this is just something I want to play with.
My question really is can I use SPI without the interrupt flags.