Use these steps to successfully complete a SPI transaction:
- Start from a known 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 data to the slave SPI DTR as required.
- Write data to the master SPI DTR to start the transfer.
- 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 the SPISR register data.