/* Configures a SPI peripheral as specified. The configuration can be computed using several macros (see "SPI configuration macros") and the constants defined in LibV3 (AT91C_SPI_*).  */
void SPI_Configure(AT91S_SPI *spi, unsigned int id, unsigned int configuration)
/* Configures a SPI peripheral as specified. The configuration can be computed using several macros (see "SPI configuration macros") and the constants defined in LibV3 (AT91C_SPI_*).  */
void SPI_Configure(AT91S_SPI *spi, unsigned int id, unsigned int configuration)
{
    AT91C_BASE_PMC->PMC_PCER = 1 << id;
    spi->SPI_CR = AT91C_SPI_SPIDIS;
    spi->SPI_CR = AT91C_SPI_SWRST;
    spi->SPI_CR = AT91C_SPI_SWRST;
    spi->SPI_MR = configuration;
}