X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/ba8a80b30c4da36ef10854b53b06d9ff9acaca44..d3ae0de746962dfde04133fc2fdb8e9f6544771a:/armsrc/fpgaloader.c diff --git a/armsrc/fpgaloader.c b/armsrc/fpgaloader.c index 88fdc4cf..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<