Xicor SPI Serial Memory Interface Routines
Xicor offers a number of interesting and useful memory devices, including a line of serial EEPROMs and SerialFlash memories, which communicate using SPI-compatible signals. These routines implement a driver for the X25xxxx series of devices.
The functions allow you to read and write from the serial memory, using a bit-banged version of the interface. If you're using a microcontroller which implements SPI in hardware, you can easily modify the software to use that instead.
The functions let you read or write blocks of memory, or read 8, 16, or 32-bit variables. They also let you fiddle with the status register, and enable and disable the software-based data protection.
The code is provided in an archive (XICOR25.ZIP) that contains XICOR25.C and XICOR25.H. To use the module in your program, simply #include XICOR25.H from wherever you need to call the functions, and link XICOR25.C into your program.
This code was tested using an X25F032, using the PC parallel port for the interface, and using Borland's C/C++ v3.1 compiler, though it can easily be adapted for other targets and other compilers.