LPCOpen SPIFI FLASH Library (LPCSPIFILIB)
Documentation for the LPCSPIFILIB library
Adding a new LPCSPIFILIB Library device

Library source files at http://www.lpcware.com/SPIFI

This document explains the functions and structures needed for a new LPCSPIFILIB device and how to add the driver to the library.

A common family has been implemented and provides mechanisms to support virtually any device. The SPIFI_DEVICE_DATA_T structure contains device specific information which allows the driver to correctly handle operations such as init, de-init, get / set status, read, and program. The spiflib_fam_standard_cmd.c module contains relevent code to support Spansion, Macronix and Winbond devices. When adding a new device, review the characteristics of the device and compare against the currently supported devices. When comparing review things such as:

  1. Relevent status bit defines (QUAD mode enable, WIP etc).
  2. Relevent command op codes: (Get status, Clear status, dual read, quad read, program etc). Next, find an existing device that most closely matches the characteristics.

For example: If support for a new Winbond part is desired, the existing Winbond part definitions are most likely to provide a good starting point. If any incompatibility is discovered, it can be accounted for by implementing a new function to handle the difference.
For example: We want to add a support for a new device and have found that it most closely resembles the Winbond W25Q80BV device. The one difference we found is that the new device has the enable Quad mode bit in bit 7 (current supported options are bit 6 or bit 9). The new device can be added by copying the device structure for the W25Q80BV device and inserting into the spifi_REG_FAMILY_CommonCommandSet() function. Adjust the geometry params to match the new part and set the device string name to the desired value (the string name is only used when calling the enumeration function).
To add support for a new device specific function, 2 things are required: 1. An enum define in the SPIFI_DEVFX_T list, and a corresponding function which will be assigned to the enum constant. Once these are defined, the last step is to modify the appropriate assignment routine to make the assignment at run-time. In this case it would be the spifiDeviceAssignFxSetOptions() function. In the spifiDeviceAssignFxSetOptions function add code to compare the structure variable and assign to the new function created above. The final step is to place the new enum defined above in the SPIFI_DEVICE_DATA_T structure definition in place of the current definition.
The reason the structure has defines rather than the address of the functions directly is to facilitate adding devices at run-time. Otherwise adding support at run time would require an onerous amount of work by the user thus rendering this feature unusable.

If logistical requirements do not allow re-compilation of the LPCOpen library, new devices can also be registered via the spifiDevRegister() API as long as existing device specific functions will support the device.

NOTE: Be sure to make the spifiDevRegister() call before calling spifiInitDevice()

Copyright (C) 2014 NXP Semiconductors. All rights reserved.