diff options
author | Josh Blum <josh@joshknows.com> | 2010-01-22 16:00:45 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-01-22 16:00:45 -0800 |
commit | 8b377a9d6d0ad281474a8dbff49ea3b093178b28 (patch) | |
tree | 8e3c7a1b60f96df6e2140666d3b7afa5166d885d /usrp2/opencores/spi_boot/sw/misc | |
parent | e92d36dcfe02afaedec348f2d8fc4523fb4e633b (diff) | |
download | uhd-8b377a9d6d0ad281474a8dbff49ea3b093178b28.tar.gz uhd-8b377a9d6d0ad281474a8dbff49ea3b093178b28.tar.bz2 uhd-8b377a9d6d0ad281474a8dbff49ea3b093178b28.zip |
moved into subdir
Diffstat (limited to 'usrp2/opencores/spi_boot/sw/misc')
-rw-r--r-- | usrp2/opencores/spi_boot/sw/misc/CVS/Entries | 2 | ||||
-rw-r--r-- | usrp2/opencores/spi_boot/sw/misc/CVS/Repository | 1 | ||||
-rw-r--r-- | usrp2/opencores/spi_boot/sw/misc/CVS/Root | 1 | ||||
-rw-r--r-- | usrp2/opencores/spi_boot/sw/misc/CVS/Template | 0 | ||||
-rw-r--r-- | usrp2/opencores/spi_boot/sw/misc/bit_reverse.c | 74 |
5 files changed, 78 insertions, 0 deletions
diff --git a/usrp2/opencores/spi_boot/sw/misc/CVS/Entries b/usrp2/opencores/spi_boot/sw/misc/CVS/Entries new file mode 100644 index 000000000..e46425fde --- /dev/null +++ b/usrp2/opencores/spi_boot/sw/misc/CVS/Entries @@ -0,0 +1,2 @@ +/bit_reverse.c/1.1/Sun May 21 11:58:00 2006/-ko/ +D diff --git a/usrp2/opencores/spi_boot/sw/misc/CVS/Repository b/usrp2/opencores/spi_boot/sw/misc/CVS/Repository new file mode 100644 index 000000000..0519f4b59 --- /dev/null +++ b/usrp2/opencores/spi_boot/sw/misc/CVS/Repository @@ -0,0 +1 @@ +spi_boot/sw/misc diff --git a/usrp2/opencores/spi_boot/sw/misc/CVS/Root b/usrp2/opencores/spi_boot/sw/misc/CVS/Root new file mode 100644 index 000000000..44b2aa23b --- /dev/null +++ b/usrp2/opencores/spi_boot/sw/misc/CVS/Root @@ -0,0 +1 @@ +:pserver:anonymous@cvs.opencores.org:/cvsroot/anonymous diff --git a/usrp2/opencores/spi_boot/sw/misc/CVS/Template b/usrp2/opencores/spi_boot/sw/misc/CVS/Template new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/usrp2/opencores/spi_boot/sw/misc/CVS/Template diff --git a/usrp2/opencores/spi_boot/sw/misc/bit_reverse.c b/usrp2/opencores/spi_boot/sw/misc/bit_reverse.c new file mode 100644 index 000000000..9defb106a --- /dev/null +++ b/usrp2/opencores/spi_boot/sw/misc/bit_reverse.c @@ -0,0 +1,74 @@ +// Altera requires configuration bytes to be sent LSB first but the +// SD Card reads bytes MSB first +// This code reverses the bits of the altera bitstream so +// it will come out correct when read from the SD card +// $Log: bit_reverse.c,v $ +// Revision 1.1 2006/01/06 14:44:17 mbl +// initial version +// + + + +#include "stdio.h" +#include "string.h" + +FILE* fileOut; +FILE* fileIn; + +void outIOerror(char* pfn); +void inIOerror(char* pfn); + +int main(int argc, char* arg[]) +{ + unsigned char input, output; + unsigned char in_mask, out_mask; + int i; + + fileOut = fopen(arg[2],"wb"); + if (fileOut == NULL) + { + outIOerror(arg[2]); + exit(-1); + } + + printf("Opening input file %s\n", arg[1]); + fileIn = fopen(arg[1],"rb"); + if (fileIn == NULL) + { + inIOerror(arg[1]); + exit(-1); + } + + while (!feof(fileIn) && fgets((char*)&input, 2 ,fileIn) != NULL) + { + in_mask = 1; + out_mask = 0x80; + output = 0; + + for ( i=0; i < 8; ++i ) + { + if (input & in_mask) + { + output |= out_mask; + } + out_mask = out_mask >> 1; + in_mask = in_mask << 1; + } + fwrite((void*)&output,sizeof(char),1,fileOut); + } + + fclose(fileIn); + fclose(fileOut); + printf("\n%s has been created\n", arg[2]); + exit(0); +} + +void outIOerror(char *pfn) +{ + printf("I/O Error while writing to file=%s\n",pfn); +} + +void inIOerror(char *pfn) +{ + printf("I/O Error while reading file=%s\n",pfn); +} |