5.13.0.0R1
Software Development Kit
spi_flash.h File Reference

Typedefs

struct {
sflash_handle_t
 

Functions

int deinit_sflash (sflash_handle_t *const handle)
 
int init_sflash (sflash_handle_t *const handle, void *peripheral_id, sflash_write_allowed_t write_allowed_in)
 
int sflash_chip_erase (const sflash_handle_t *const handle)
 
int sflash_dct_read_secure (const sflash_handle_t *const sflash_handle, unsigned long device_address, void *data_addr, unsigned int size)
 
int sflash_dct_write_secure (const sflash_handle_t *const sflash_handle, unsigned long device_address, const void *const data_addr, unsigned int size)
 
int sflash_get_size (const sflash_handle_t *const handle, unsigned long *size)
 
int sflash_read (const sflash_handle_t *const handle, unsigned long device_address, void *data_addr, unsigned int size)
 
int sflash_read_secure (const sflash_handle_t *const handle, unsigned long device_address, void *data_addr, unsigned int size)
 
int sflash_sector_erase (const sflash_handle_t *const handle, unsigned long device_address)
 
int sflash_write (const sflash_handle_t *const handle, unsigned long device_address, const void *const data_addr, unsigned int size)
 
int sflash_write_secure (const sflash_handle_t *const handle, unsigned long device_address, const void *const data_addr, unsigned int size)
 

Detailed Description

API for accessing SPI flash chips.

Typedef Documentation

typedef { ... } sflash_handle_t

Handle for a sflash access instance Users should not access these values - they are provided here only to provide the compiler with datatype size information allowing static declarations

Function Documentation

int deinit_sflash ( sflash_handle_t *const  handle)

De-initializes a SPI Flash chip

Parameters
[in]handleHandle structure that will be used for this sflash instance - allocated by caller.
Returns
wiced_result_t
int init_sflash ( sflash_handle_t *const  handle,
void *  peripheral_id,
sflash_write_allowed_t  write_allowed_in 
)

Initializes a SPI Flash chip

Internally this initializes the associated SPI port, then reads the chip ID from the SPI flash to determine what type it is.

Parameters
[in]handleHandle structure that will be used for this sflash instance - allocated by caller.
[in]peripheral_idAn ID value which is passed to the underlying sflash_platform_init function
[in]write_allowed_inDetermines whether writing will be allowed to this sflash handle
Returns
wiced_result_t
int sflash_chip_erase ( const sflash_handle_t *const  handle)

Erase the contents of a SPI Flash chip

Parameters
[in]handleHandle structure that was initialized with init_sflash
Returns
wiced_result_t
int sflash_dct_read_secure ( const sflash_handle_t *const  sflash_handle,
unsigned long  device_address,
void *  data_addr,
unsigned int  size 
)

Reads data from DCT, Decrypts/Authenticates the data read, returns error if Authentication fails

Parameters
[in]handleHandle structure that was initialized with init_sflash
[in]device_addressThe location on the SPI flash where reading will start
[out]data_addrDestination buffer in memory that will receive the data
[in]sizeNumber of bytes to read from the chip
Returns
wiced_result_t
int sflash_dct_write_secure ( const sflash_handle_t *const  sflash_handle,
unsigned long  device_address,
const void *const  data_addr,
unsigned int  size 
)

Writes data to DCT, Encrypts and Sign the data

Parameters
[in]handleHandle structure that was initialized with init_sflash
[in]device_addressThe location on the SPI flash where reading will start
[out]data_addrDestination buffer in memory that will receive the data
[in]sizeNumber of bytes to read from the chip
Returns
wiced_result_t
int sflash_get_size ( const sflash_handle_t *const  handle,
unsigned long *  size 
)

Erase one sector of a SPI Flash chip

Parameters
[in]handleHandle structure that was initialized with init_sflash
[out]sizeVariable which will receive the capacity size in bytes of the sflash chip
Returns
wiced_result_t
int sflash_read ( const sflash_handle_t *const  handle,
unsigned long  device_address,
void *  data_addr,
unsigned int  size 
)

Reads data from a SPI Flash chip

Parameters
[in]handleHandle structure that was initialized with init_sflash
[in]device_addressThe location on the SPI flash where reading will start
[out]data_addrDestination buffer in memory that will receive the data
[in]sizeNumber of bytes to read from the chip
Returns
wiced_result_t
int sflash_read_secure ( const sflash_handle_t *const  handle,
unsigned long  device_address,
void *  data_addr,
unsigned int  size 
)

Reads data from a SPI Flash chip, Decrypts/Authenticates the data read, returns error if Authentication fails

Parameters
[in]handleHandle structure that was initialized with init_sflash
[in]device_addressThe location on the SPI flash where reading will start
[out]data_addrDestination buffer in memory that will receive the data
[in]sizeNumber of bytes to read from the chip
Returns
wiced_result_t
int sflash_sector_erase ( const sflash_handle_t *const  handle,
unsigned long  device_address 
)

Erase one sector of a SPI Flash chip

Parameters
[in]handleHandle structure that was initialized with init_sflash
[in]device_addressThe location on the sflash chip of the first byte of the sector to erase
Returns
wiced_result_t
int sflash_write ( const sflash_handle_t *const  handle,
unsigned long  device_address,
const void *const  data_addr,
unsigned int  size 
)

Write data to a SPI Flash chip

Parameters
[in]handleHandle structure that was initialized with init_sflash
[in]device_addressThe location on the SPI flash where writing will start
[in]data_addrPointer to the buffer in memory that contains the data being written
[in]sizeNumber of bytes to write to the chip
Returns
wiced_result_t
int sflash_write_secure ( const sflash_handle_t *const  handle,
unsigned long  device_address,
const void *const  data_addr,
unsigned int  size 
)

Secure-Write data to a SPI Flash chip (Encrypt and Authenticate data sector by sector before being written)

Parameters
[in]handleHandle structure that was initialized with init_sflash
[in]device_addressThe location on the SPI flash where writing will start
[in]data_addrPointer to the buffer in memory that contains the data being written
[in]sizeNumber of bytes to write to the chip
Returns
wiced_result_t