25.3.1 Initialization
Initialize the SPI to a basic functional state by following these steps:
- Configure the SS pin in the Port peripheral.
- Select SPI Master / Slave operation by writing the Master/Slave Select bit (MASTER) in the Control A register (SPI.CTRLA).
- In Master mode, select the clock speed by writing the Prescaler bits (PRESC) and the Clock Double bit (CLK2X) in SPI.CTRLA.
- Optional: Select the data transfer mode by writing to the MODE bits in the Control B register (SPI.CTRLB).
- Optional: Write the Data Order bit (DORD) in SPI.CTRLA.
- Optional: Setup buffer mode by writing BUFEN and BUFWR bits in the Control B register (SPI.CTRLB).
- Optional: To disable the multimaster support in Master mode, write '1' to the Slave Select Disable bit (SSD) in SPI.CTRLB.
- Enable the SPI by writing a '1' to the ENABLE bit in SPI.CTRLA.