Purpose
The Spi driver is a low level
spi driver which performs SPI
device Initializes,
spi transfer and receive. It
can be used by upper SPI driver such as AT45 driver and AT26 driver.
Usage
- Initializes a SPI instance and the corresponding SPI hardware, Configure SPI in Master Mode using SPID_Configure().
- Configures the SPI characteristics (such as Clock Polarity, Phase, transfers delay and Baud Rate) for the device corresponding to the chip select using SPID_ConfigureCS().
- Starts a SPI master transfer using SPID_SendCommand(). The transfer is performed using the PDC channels.
- It enable the SPI clock.
- Set the corresponding peripheral chip select.
- Initialize the two SPI PDC buffers.
- Initialize SPI_TPR and SPI_TCR with SPI command data and size to send command data first.
- Initialize SPI_RPR and SPI_RCR with SPI command data and size as dummy value.
- Initialize SPI_TNPR and SPI_TNCR with rest of the data to be transfered.(if the data specified in cmd structure)
- Initialize SPI_RNPR and SPI_RNCR with rest of the data to be received.(if the data specified in cmd structure)
- Initialize the callback function if specified.
- Enable transmitter and receiver.
- Example for sending a command to the dataflash through the SPI.
- The SPI_Handler() must be called by the SPI Interrupt Service Routine with the corresponding Spi instance. It is invokes to check for pending interrupts.
- Example for initializing SPI interrupt handler in upper application.