X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/e3ae0257834f7d134c7f80db6fa23668b5a5fa6d..5d32e2bf6029c9efe5d191c13b82d59f6515e789:/armsrc/fpgaloader.c diff --git a/armsrc/fpgaloader.c b/armsrc/fpgaloader.c index 58385588..af2f02ab 100644 --- a/armsrc/fpgaloader.c +++ b/armsrc/fpgaloader.c @@ -135,52 +135,96 @@ void FpgaSetupSscDma(BYTE *buf, int len) PDC_CONTROL(SSC_BASE) = PDC_RX_ENABLE; } -// Download the fpga image starting at FpgaImage and with length FpgaImageLen DWORDs (e.g. 4 bytes) +static void DownloadFPGA_byte(unsigned char w) +{ +#define SEND_BIT(x) { if(w & (1<>(j*8); - else - w = v >>((3-j)*8); -#define SEND_BIT(x) { if(w & (1<0) + DownloadFPGA_byte(FpgaImage[(i++)^0x3]); + /* Explanation of the magic in the above line: + * i^0x3 inverts the lower two bits of the integer i, counting backwards + * for each 4 byte increment. The generated sequence of (i++)^3 is + * 3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12 etc. pp. + */ } + } else { + while(FpgaImageLen-->0) + DownloadFPGA_byte(*FpgaImage++); } + // continue to clock FPGA until ready signal goes high + i=100000; + while ( (i--) && ( !(PIO_PIN_DATA_STATUS & (1<