Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Hobbyking_Cheetah_0511
FlashIAP Class Reference
[Drivers]
  Flash IAP driver. More...
#include <FlashIAP.h>
Inherits 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. | |
Detailed Description
Flash IAP driver.
It invokes flash HAL functions.
- Note:
- Synchronization level: Thread safe
Definition at line 41 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
Definition at line 64 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:
- 
  addr Address of a sector to begin erasing, must be a multiple of the sector size size Size to erase in bytes, must be a multiple of the sector size 
- Returns:
- 0 on success, negative error code on failure
Definition at line 118 of file FlashIAP.cpp.
| uint32_t get_flash_size | ( | ) | const | 
| uint32_t get_flash_start | ( | ) | const | 
Get the flash start address.
- Returns:
- Flash start address
Definition at line 156 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
Definition at line 146 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:
- 
  addr Address 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 151 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 53 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:
- 
  buffer Buffer of data to be written addr Address of a page to begin writing to, must be a multiple of program and sector sizes size Size to write in bytes, must be a multiple of program and sector sizes 
- Returns:
- 0 on success, negative error code on failure
Definition at line 85 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:
- 
  buffer Buffer to write to addr Flash address to begin reading from size Size to read in bytes 
- Returns:
- 0 on success, negative error code on failure
Definition at line 76 of file FlashIAP.cpp.
Generated on Tue Jul 12 2022 18:31:30 by
 1.7.2
 1.7.2