spid.h
Default mainpageat91libmemoriesspi-flashspid.h
Description Overview  
Description
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
  1. Initializes a SPI instance and the corresponding SPI hardware, Configure SPI in Master Mode using SPID_Configure().
  2. 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().
  3. Starts a SPI master transfer using SPID_SendCommand(). The transfer is performed using the PDC channels.
    1. It enable the SPI clock.
    2. Set the corresponding peripheral chip select.
    3. 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)
    4. Initialize the callback function if specified.
    5. Enable transmitter and receiver.
    6. Example for sending a command to the dataflash through the SPI.
      
      ...
      // Send Command and data through the SPI
      if (SPID_SendCommand(pAt45->pSpid, pCommand)) {
          return AT45_ERROR_SPI;
      }
      
  4. 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.
      AIC_ConfigureIT(AT91C_ID_SPI, 0, SPI_Handler);