Generic SPI Flash and enhanced SPI Driver
At this point I figured that I would simply share the generic SPI Flash Driver that I implemented. The SPI libraries have been slightly altered to make it so that the SPI Flash Driver and other SPI peripherals, regardless of clock mode, could operate nicely on the same bus. It's (SPI driver) only been tested in 8 bit mode, as I don't have the hardware to test it out in 16/32 bit mode. I have some basic hooks in the SPI Flash Driver to bolt into the MPFS file system, but since that library is blocking I haven't done much with it. You'll also get an EraseWrite function and support for byte, AAI, and page write modes. At a minimum, it can serve as a starting point for those of you interested in writing your own drivers. Please let me know if you run into issues with it, as I'd like to be able to correct my own code base.
I have attached zipped up folders for the spi and spi flash drivers. The spi driver folder should be unpacked to C:\microchip\harmony\v1_08\framework\driver and the generic_spi_flash driver to C:\microchip\harmony\v1_08\framework\driver\spi_flash. The config/drv_flash.hconfig file should have the following line added to it:
I've also attached the system_definitions.h.ftl, system_config.h.ftl, and system_tasks_rtos.c.ftl files so that you can see what needs to be added in order to get the generic spi flash driver bolted into the mhc. Those files are located here: C:\microchip\harmony\v1_08\utilities\mhc\templates\app\system_config.
I believe that is all that you need. It will take up more memory due to the EraseWrite functionality, but it's fairly easy to get rid of it. The reason is that with EraseWrite is that you'll need to read 4k sectors first (requires a buffer like the nvm library), erase the sector, and then write back the contents. It can be a lengthy operation if you only want to write a few bytes, but it will be necessary if you want to bolt serial flash drivers into the file system. If you need to add your own SPI flash chips to this, simply add the appropriate definitions to drv_generic_spi_flash_local.h and the appropriate code to drv_generic_spi_flash.c.