mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Embed: (wiki syntax)

« Back to documentation index

FlashIAP Class Reference

Flash IAP driver. More...

#include <FlashIAP.h>

Inherits NonCopyable< FlashIAP >, and NonCopyable< FlashIAP >.

Public Member Functions

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

Private Member Functions

 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.
 MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
 NonCopyable copy constructor.
 MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
 NonCopyable copy assignment operator.

Detailed Description

Flash IAP driver.

It invokes flash HAL functions.

Note:
Synchronization level: Thread safe

Definition at line 59 of file cmsis/BUILD/mbed/drivers/FlashIAP.h.


Member Function Documentation

int deinit (  )

Deinitialize a flash IAP device.

Returns:
0 on success or a negative error code on failure

Definition at line 77 of file FlashIAP.cpp.

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

Definition at line 179 of file FlashIAP.cpp.

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

Definition at line 239 of file FlashIAP.cpp.

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

Definition at line 234 of file FlashIAP.cpp.

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_flash_start (  ) const

Get the flash start address.

Returns:
Flash start address

Definition at line 229 of file FlashIAP.cpp.

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_page_size (  ) const

Get the program page size.

The page size defines the writable page size

Returns:
Size of a program page in bytes

Definition at line 219 of file FlashIAP.cpp.

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
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

Definition at line 224 of file FlashIAP.cpp.

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

Definition at line 59 of file FlashIAP.cpp.

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

Definition at line 107 of file FlashIAP.cpp.

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

Definition at line 94 of file FlashIAP.cpp.

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