AIROC™ BTSDK v4.9 - Documentation | ||||
Defines a driver for the Serial Flash interface. More...
Macros | |
#define | wiced_hal_sflash_force_erase(addr, len) sfi_erase(addr, len) |
Force to erase len number of bytes from the serial flash. More... | |
#define | wiced_hal_sflash_force_write(addr, len, buffer) sfi_write(addr, len, buffer) |
Force to write data from memory to a certain location on the serial flash module. 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_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... | |
void | wiced_hal_sflash_set_erase_sector_size_256K (wiced_bool_t enable) |
Enable serial flash using 256K sectors. More... | |
void | wiced_hal_sflash_set_4_byte_address (wiced_bool_t enable) |
Use 4 byte addressing instead of 3 byte addressing with serial flash. More... | |
wiced_bool_t | wiced_hal_sflash_get_erase_sector_size_256K (void) |
Get serial flash 256K sectors setting. More... | |
wiced_bool_t | wiced_hal_sflash_get_4_byte_address (void) |
Get serial flash 4 byte address setting. More... | |
void | wiced_hal_sflash_set_size (uint32_t sflash_size) |
Set the Serial flash size installed. More... | |
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:
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 for more information regarding these active sections, their importance, and what roles they play in the system.
Force to 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.
addr | - The starting erase address on the serial flash. |
len | - The number of bytes to erase. |
Force to 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.
addr | - The starting destination address on the serial flash. |
len | - The number of bytes to write. |
buf | - Pointer to source data buffer. |
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.
addr | - The starting erase address on the serial flash. |
len | - The number of bytes to erase. |
wiced_bool_t wiced_hal_sflash_get_4_byte_address | ( | void | ) |
Get serial flash 4 byte address setting.
wiced_bool_t wiced_hal_sflash_get_erase_sector_size_256K | ( | void | ) |
Get serial flash 256K sectors setting.
void wiced_hal_sflash_init | ( | void | ) |
Initialize the SPI lines and low-level Serial Flash Interface Driver.
Call this before performing any SF operations.
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.
addr | - The starting source address on the serial flash. |
len | - The number of bytes to read. |
buf | - Pointer to destination data buffer. |
void wiced_hal_sflash_set_4_byte_address | ( | wiced_bool_t | enable | ) |
Use 4 byte addressing instead of 3 byte addressing with serial flash.
Note that the 4 byte addressing must be supported by the serial flash used
enable | - True to use 4 byte addressing, False for default 3 byte addressing |
void wiced_hal_sflash_set_erase_sector_size_256K | ( | wiced_bool_t | enable | ) |
Enable serial flash using 256K sectors.
Note that the 256K sector size must be supported by the serial flash used
enable | - True to use 256K sector size, False for default 4K sector size |
void wiced_hal_sflash_set_size | ( | uint32_t | sflash_size | ) |
Set the Serial flash size installed.
sflash_size | - Serial flash size |
Note: This API should be called before using wiced_hal_sflash_write and wiced_hal_sflash_erase APIS. Otherwise write/erase fails.
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.
addr | - The starting destination address on the serial flash. |
len | - The number of bytes to write. |
buf | - Pointer to source data buffer. |