Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
FlashIAP Class Reference

Flash IAP driver. More...

#include <FlashIAP.h>

Inheritance diagram for FlashIAP:
NonCopyable< FlashIAP >

Public Member Functions

int init ()
 Initialize a flash IAP device. More...
 
int deinit ()
 Deinitialize a flash IAP device. More...
 
int read (void *buffer, uint32_t addr, uint32_t size)
 Read data from a flash device. More...
 
int program (const void *buffer, uint32_t addr, uint32_t size)
 Program data to pages. More...
 
int erase (uint32_t addr, uint32_t size)
 Erase sectors. More...
 
uint32_t get_sector_size (uint32_t addr) const
 Get the sector size at the defined address. More...
 
uint32_t get_flash_start () const
 Get the flash start address. More...
 
uint32_t get_flash_size () const
 Get the flash size. More...
 
uint32_t get_page_size () const
 Get the program page size. More...
 
uint8_t get_erase_value () const
 Get the flash erase value. More...
 

Detailed Description

Flash IAP driver.

It invokes flash HAL functions.

Note
Synchronization level: Thread safe

Definition at line 59 of file FlashIAP.h.

Member Function Documentation

int deinit ( )

Deinitialize a flash IAP device.

Returns
0 on success or a negative error code on failure
int erase ( uint32_t  addr,
uint32_t  size 
)

Erase sectors.

The state of an erased sector is undefined until it has been programmed

Parameters
addrAddress of a sector to begin erasing, must be a multiple of the sector size
sizeSize to erase in bytes, must be a multiple of the sector size
Returns
0 on success, negative error code on failure
uint8_t get_erase_value ( ) const

Get the flash erase value.

Get the value we read after erase operation

Returns
flash erase value
uint32_t get_flash_size ( ) const

Get the flash size.

Returns
Flash size
uint32_t get_flash_start ( ) const

Get the flash start address.

Returns
Flash start address
uint32_t get_page_size ( ) const

Get the program page size.

The page size defines the writable page size

Returns
Size of a program page in bytes
uint32_t get_sector_size ( uint32_t  addr) const

Get the sector size at the defined address.

Sector size might differ at address ranges. An example <0-0x1000, sector size=1024; 0x10000-0x20000, size=2048>

Parameters
addrAddress of or inside the sector to query
Returns
Size of a sector in bytes or MBED_FLASH_INVALID_SIZE if not mapped
int init ( )

Initialize a flash IAP device.

Should be called once per lifetime of the object.

Returns
0 on success or a negative error code on failure
int program ( const void *  buffer,
uint32_t  addr,
uint32_t  size 
)

Program data to pages.

The sectors must have been erased prior to being programmed

Parameters
bufferBuffer of data to be written
addrAddress of a page to begin writing to
sizeSize to write in bytes, must be a multiple of program size
Returns
0 on success, negative error code on failure
int read ( void *  buffer,
uint32_t  addr,
uint32_t  size 
)

Read data from a flash device.

This method invokes memcpy - reads number of bytes from the address

Parameters
bufferBuffer to write to
addrFlash address to begin reading from
sizeSize to read in bytes
Returns
0 on success, negative error code on failure
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.