X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/b811cc51f9a21324dc7589d1254e767374488a20..6658905f18a1eebc148836f26c731dea9c1377dc:/armsrc/fpga.c?ds=sidebyside diff --git a/armsrc/fpga.c b/armsrc/fpga.c new file mode 100644 index 00000000..2bcade28 --- /dev/null +++ b/armsrc/fpga.c @@ -0,0 +1,222 @@ +//----------------------------------------------------------------------------- +// 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<