SPI is predecessor of TWI or I2C. SPI requires 4 + N lines, where is no of slave devices where as I2C requires 4(SCL SDA VCC GND) lines for 128 devices. But its still important, here it goes
MISO- Master In Slave Out (Master reads from Slave).
MOSI- Master Out Slave In (Slave reads from Master).
SCK- Master is the one who controls the clock and SS pins.
SS- Slave select. Which is active low. Pull it to ground to activate the particular slave. More the slaves more the slave lines.
this is how the connections goes
SPCR- Serial Peripheral Control Register
SPIE- Serial peripheral Interrupt enable. More info on SPIF(Interrupt flag).
SPE- Serial Peripheral Enable. To Enable SPI hardware unit in the Microcontroller.
DORD- Data Order. High- LSB transmitted first. Low- MSB transmitted first.
MSTR-High means the device is selected as the Master. SCK should be output. SS should be output too.
CPOL- Clock Polarity.
CPHA- Clock Phase. There are two edges of a clock. Leading and Trailing. Leading comes first and trailing comes second. CPHA- LOW. Microcontroller executes instructions on Leading edge. CPHA HIGH, Microcontroller executes instructions on Trailing edge.
SPR1 and SPR0 along with SPR2x sets the frequency SCK of communication.
SPSR- Serial Peripheral Status Register
SPIF- Serial peripheral interrupt flag. When Transmission is completed it is set to one and gets cleared automatically if Interrupts are enabled(ISR is called-ISR(SPI_STC_vect)). Also if Master’s slave select pin goes low then SPIF is set and one has to reconfigure master as master again.
SPDR-Serial Peripheral Data Register
SPI data register.
and been working on nRF24L01+ lately..Here’s the code to write and read registers and register bits in nRF via SPI..cheers..!!