//----------------------------------------------------------------------------- // Routines to load the FPGA image, and then to configure the FPGA's major // mode once it is configured. // // Jonathan Westhues, April 2006 //----------------------------------------------------------------------------- #include #include "apps.h" //----------------------------------------------------------------------------- // Set up the Serial Peripheral Interface as master // Used to write the FPGA config word // May also be used to write to other SPI attached devices like an LCD //----------------------------------------------------------------------------- void SetupSpi(int mode) { // PA10 -> SPI_NCS2 chip select (LCD) // PA11 -> SPI_NCS0 chip select (FPGA) // PA12 -> SPI_MISO Master-In Slave-Out // PA13 -> SPI_MOSI Master-Out Slave-In // PA14 -> SPI_SPCK Serial Clock // Disable PIO control of the following pins, allows use by the SPI peripheral PIO_DISABLE = (1 << GPIO_NCS0) | (1 << GPIO_NCS2) | (1 << GPIO_MISO) | (1 << GPIO_MOSI) | (1 << GPIO_SPCK); PIO_PERIPHERAL_A_SEL = (1 << GPIO_NCS0) | (1 << GPIO_MISO) | (1 << GPIO_MOSI) | (1 << GPIO_SPCK); PIO_PERIPHERAL_B_SEL = (1 << GPIO_NCS2); //enable the SPI Peripheral clock PMC_PERIPHERAL_CLK_ENABLE = (1<