Infineon Logo AIROC BTSDK v4.9 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Serial Flash Interface

Defines a driver for the Serial Flash interface. More...

Functions

void wiced_hal_sflash_init (void)
 Initialize the SPI lines and low-level Serial Flash Interface Driver. More...
 
uint32_t wiced_hal_sflash_get_size (void)
 Returns the installed SF module size. More...
 
uint32_t wiced_hal_sflash_read (uint32_t addr, uint32_t len, uint8_t *buf)
 Load data from a certain location on the serial flash module into memory. More...
 
uint32_t wiced_hal_sflash_write (uint32_t addr, uint32_t len, uint8_t *buf)
 Write data from memory to a certain location on the serial flash module. More...
 
void wiced_hal_sflash_erase (uint32_t addr, uint32_t len)
 Erase len number of bytes from the serial flash. More...
 

Detailed Description

Defines a driver for the Serial Flash interface.

The driver is responsible for interfacing with a Serial Flash memory module via the second SPI bus, with its main purpose being data handling operations. For instance, any unused space (from the system partition) can be used for any purpose to store and access data. It is a handy way for an app to save information to non-volatile storage.

The software driver supports SPI Flashes with the following parameters:

  1. Address Width - 24 bit addressing
  2. Data Rate is specific to the IoT chip: CYW207x9 supports SPI data rate upto 24MHz
  3. Supports JEDEC's CFI (Common Flash Interface) compatible SPI Flash chips from Cypress Semiconductors, SST, STMicroelectronics, Atmel, MXIC, Adesto, Winbond.

Similar to the I2C EEPROM Interface Driver, this driver includes checks to ensure safe data handling operation–it will not allow any write or erase operations to take place within active sections (i.e., sections that the system currently uses for boot, etc). Note that read operations are unrestricted. Please reference the Kit Guide or HW User Manual for your device for more information regarding these active sections, their importance, and what roles they play in the system.

Function Documentation

void wiced_hal_sflash_erase ( uint32_t  addr,
uint32_t  len 
)

Erase len number of bytes from the serial flash.

Depending on the starting address and length, it calls sector or block erase to do the work.

(!) Please ensure that the address and (address + length) of data to be written does not go beyond the size of the memory module. If they do, the erase operation will "wrap around" and start erasing the starting address of the memory (boot sector), rendering the device inoperable.

(!) Note that due to the nature of Serial Flash memory and the limitations of sector and/or block boundaries, it is possible that the number of bytes erased could be greater than len.

Parameters
addr- The starting erase address on the serial flash.
len- The number of bytes to erase.
Returns
none
uint32_t wiced_hal_sflash_get_size ( void  )

Returns the installed SF module size.

The low-level Serial Flash Interface Driver sends specific commands to the chip, which then reports its size.

Note that this function is a good way to make sure that the SF module is installed and is communicating correctly with the system.

Parameters
none
Returns
none
void wiced_hal_sflash_init ( void  )

Initialize the SPI lines and low-level Serial Flash Interface Driver.

Call this before performing any SF operations.

Parameters
none
Returns
none
uint32_t wiced_hal_sflash_read ( uint32_t  addr,
uint32_t  len,
uint8_t *  buf 
)

Load data from a certain location on the serial flash module into memory.

To have a better read performance, place the destination data buffer at a word boundary.

Parameters
addr- The starting source address on the serial flash.
len- The number of bytes to read.
buf- Pointer to destination data buffer.
Returns
The number of bytes read.
uint32_t wiced_hal_sflash_write ( uint32_t  addr,
uint32_t  len,
uint8_t *  buf 
)

Write data from memory to a certain location on the serial flash module.

(!) Please ensure that the address and (address + length) of data to be written does not go beyond the size of the memory module. If they do, the write operation will "wrap around" and start corrupting the starting address of the memory (boot sector), rendering the device inoperable.

(!) Note that this function will not allow corruption of certain memory locations, such as currently active sections (boot sectors) and sections required for the proper function of the Bluetooth subsystem.

Parameters
addr- The starting destination address on the serial flash.
len- The number of bytes to write.
buf- Pointer to source data buffer.
Returns
The number of bytes written.