Wirepas SDK
external_flash.h File Reference

Go to the source code of this file.

Functions

extFlash_res_e externalFlash_init (void)
 Initialize the external flash driver. More...
 
extFlash_res_e externalFlash_startRead (void *to, const void *from, size_t amount)
 Read bytes from external flash. More...
 
extFlash_res_e externalFlash_startWrite (void *to, const void *from, size_t amount)
 Write bytes to flash. More...
 
extFlash_res_e externalFlash_startErase (size_t *sector_base, size_t *number_of_sector)
 Erase a sector of flash. More...
 
bool externalFlash_isBusy (void)
 Checks if flash driver is busy. More...
 
extFlash_res_e externalFlash_getInfo (flash_info_t *info)
 Fills a structure with info about flash. More...
 

Data Structures

struct  flash_info_t
 Flash memory info definition. More...
 

Enumerations

enum  extFlash_res_e {
  EXTFLASH_RES_OK = 0, EXTFLASH_RES_ERROR = 1, EXTFLASH_RES_BUSY = 2, EXTFLASH_RES_NODRIVER = 3,
  EXTFLASH_RES_PARAM = 4
}
 External flash operations result. More...
 

Function Documentation

◆ externalFlash_getInfo()

extFlash_res_e externalFlash_getInfo ( flash_info_t info)

Fills a structure with info about flash.

Parameters
infopointer to an flash_info_t structure.
Returns
Result code, EXTFLASH_RES_OK if successful. See extFlash_res_e for other result codes.

◆ externalFlash_init()

extFlash_res_e externalFlash_init ( void  )

Initialize the external flash driver.

Returns
Result code, EXTFLASH_RES_OK if successful. See extFlash_res_e for other result codes.

◆ externalFlash_isBusy()

bool externalFlash_isBusy ( void  )

Checks if flash driver is busy.

Returns
true: driver is busy, false otherwise.

◆ externalFlash_startErase()

extFlash_res_e externalFlash_startErase ( size_t *  sector_base,
size_t *  number_of_sector 
)

Erase a sector of flash.

Parameters
sector_basepointer to the base address of the sector to be erased. If the flash driver can’t erase all requested sector, return the base address of the next sector to be erased.
number_of_sectorPointer to number of sector to erase. Returns the number of remaining sector to erase.
Returns
Result code, EXTFLASH_RES_OK if successful. See extFlash_res_e for other result codes.

◆ externalFlash_startRead()

extFlash_res_e externalFlash_startRead ( void *  to,
const void *  from,
size_t  amount 
)

Read bytes from external flash.

Parameters
toPointer in RAM to store read data.
fromAddress in flash to read data from.
amountNumber of bytes to read.
Returns
Result code, EXTFLASH_RES_OK if successful. See extFlash_res_e for other result codes.

◆ externalFlash_startWrite()

extFlash_res_e externalFlash_startWrite ( void *  to,
const void *  from,
size_t  amount 
)

Write bytes to flash.

Parameters
toAddress in flash to write data to.
fromPointer in RAM to the data to be written.
amountNumber of bytes to write.
Returns
Result code, EXTFLASH_RES_OK if successful. See extFlash_res_e for other result codes.

Data Structure Documentation

◆ flash_info_t

struct flash_info_t

Flash memory info definition.

Definition at line 26 of file external_flash.h.

Data Fields
uint32_t byte_write_call_time

Time taken by startWrite() call for one byte in uS

uint32_t byte_write_time

Time taken by the Flash chipset to write one byte in uS

Note
For internal flash driver write (erase) time is 0. Du to hardware limitation the driver is fully synchronous so the write (erase) to flash is finished when startWrite (startErase) returns.
size_t erase_sector_size

Size of an erase sector

size_t flash_size

Size in bytes of the flash

uint32_t is_busy_call_time

Time taken by isBusy() call in uS

uint32_t page_write_call_time

Time taken by startWrite() call for one page in uS

uint32_t page_write_time

Time taken by the Flash chipset write one page in uS

uint32_t sector_erase_call_time

Time taken by startErase() call for one sector in uS

uint32_t sector_erase_time

Time taken by the Flash chipset to erase on sector in uS

size_t write_alignment

Minimum write alignment supported by the flash hardware. Write address must be aligned on write_alignment and write amount must be a multiple of write_alignment bytes.

size_t write_page_size

Size of a write page

Enumeration Type Documentation

◆ extFlash_res_e

External flash operations result.

Enumerator
EXTFLASH_RES_OK 
EXTFLASH_RES_ERROR 
EXTFLASH_RES_BUSY 
EXTFLASH_RES_NODRIVER 
EXTFLASH_RES_PARAM 

Definition at line 16 of file external_flash.h.

17 {
18  EXTFLASH_RES_OK = 0, /* Operation is successful */
19  EXTFLASH_RES_ERROR = 1, /* Error during operation */
20  EXTFLASH_RES_BUSY = 2, /* Flash driver is busy */
21  EXTFLASH_RES_NODRIVER = 3, /* Flash driver not implemented */
22  EXTFLASH_RES_PARAM = 4 /* Invalid parameters */
EXTFLASH_RES_PARAM
@ EXTFLASH_RES_PARAM
Definition: external_flash.h:22
EXTFLASH_RES_NODRIVER
@ EXTFLASH_RES_NODRIVER
Definition: external_flash.h:21
EXTFLASH_RES_ERROR
@ EXTFLASH_RES_ERROR
Definition: external_flash.h:19
EXTFLASH_RES_BUSY
@ EXTFLASH_RES_BUSY
Definition: external_flash.h:20
extFlash_res_e
extFlash_res_e
External flash operations result.
Definition: external_flash.h:16
EXTFLASH_RES_OK
@ EXTFLASH_RES_OK
Definition: external_flash.h:18