SDSPI_Configure
Default mainpageat91libmemoriessdmmcSDSPI_Configure
Description Source Call Graph
Start Line: 74
void SDSPI_Configure(SdSpi *pSdSpi, AT91PS_SPI pSpiHw, unsigned char spiId)
{
    // Initialize the SPI structure
    pSdSpi->pSpiHw = pSpiHw;
    pSdSpi->spiId = spiId;
    pSdSpi->semaphore = 1;

    // Enable the SPI clock
    AT91C_BASE_PMC->PMC_PCER = (1 << pSdSpi->spiId);
    
    // Execute a software reset of the SPI twice
    pSpiHw->SPI_CR = AT91C_SPI_SWRST;
    pSpiHw->SPI_CR = AT91C_SPI_SWRST;

    // Configure SPI in Master Mode with No CS selected !!!
    pSpiHw->SPI_MR = AT91C_SPI_MSTR | AT91C_SPI_MODFDIS  | AT91C_SPI_PCS;

    // Disables the receiver PDC transfer requests
    // Disables the transmitter PDC transfer requests.
    pSpiHw->SPI_PTCR = AT91C_PDC_RXTDIS | AT91C_PDC_TXTDIS;

    // Enable the SPI
    pSpiHw->SPI_CR = AT91C_SPI_SPIEN;

    // Disable the SPI clock
    AT91C_BASE_PMC->PMC_PCDR = (1 << pSdSpi->spiId);
}