Use these steps to successfully complete a SPI transaction:
- Start from the proper state including SPI bus arbitration.
- Configure the master DGIER and IPIER registers. Also configure the slave DGIER and IPIER registers as required.
- Write configuration data to the master SPI device SPICR register as required.
- Write configuration data to the slave SPI device SPICR register as required.
- Write the active-Low, one-hot encoded slave select address to the master SPISSR register.
- Write initial data to the slave transmit FIFO as required.
- Write initial data to the master transmit FIFO.
- Write the enable bit to the master SPICR register which starts the transfer.
- Continue writing data to both the master and slave FIFOs.
- Wait for interrupt (typically IPISR bit 4) or poll status for completion.
- Read the IPISR register of both master and slave SPI devices as required.
- Perform interrupt requests as required.
- Read the SPISR register of both master and slave SPI devices as required.
- Perform actions as required or dictated by SPISR register data.