TI OAD API Documentation
2.02.08.00
|
An interface that abstracts flash operations for OAD this allows on-chip and off-chip OAD to use the same flash APIs. More...
Modules | |
Macros and constants for external flash | |
Files | |
file | flash_interface.h |
An interface that abstracts flash operations for OAD this allows on-chip and off-chip OAD to use the same flash APIs. | |
Macros | |
#define | FLASH_FAILURE 0xFF |
#define | FLASH_SUCCESS 0x00 |
#define | SPI_MAX_READ_SZ 1024 |
Functions | |
uint8_t | eraseFlash (uint8_t page) |
uint8_t | eraseFlashPg (uint8_t page) |
void | flash_close (void) |
void | flash_init (void) |
bool | flash_open (void) |
bool | hasExternalFlash (void) |
uint8_t | readFlash (uint_least32_t addr, uint8_t *pBuf, size_t len) |
uint8_t | readFlashPg (uint8_t page, uint32_t offset, uint8_t *pBuf, uint16_t len) |
uint8_t | writeFlash (uint_least32_t addr, uint8_t *pBuf, size_t len) |
uint8_t | writeFlashPg (uint8_t page, uint32_t offset, uint8_t *pBuf, uint16_t len) |
An interface that abstracts flash operations for OAD this allows on-chip and off-chip OAD to use the same flash APIs.
============================================================================
The flash interface header file should be included as follows:
The flash interface is a layer of abstraction between the OAD application and protocol and the targeted flash implementation. The flash interface provides a common set of APIs for both internal flash and external flash. In this way, OAD applications can be written in the same way for both on-chip (internal flash) and off-chip (external flash) OAD.
There are three implementations of the flash interface provided:
To select the interface, the user should include one of the above .c files within their project
Initialze the module as shown below
Open the module as shown below
After initialzing and opening the module, the read and write APIs can be at any time. It is recommended to check the return value to see if the operation succeeded
Open the module as shown below
#define FLASH_FAILURE 0xFF |
Flash operation failed
#define FLASH_SUCCESS 0x00 |
Flash operation succeeded
#define SPI_MAX_READ_SZ 1024 |
Maximum SPI read size, used for off-chip
uint8_t eraseFlash | ( | uint8_t | page | ) |
Erase flash page.
page | - the page to erase. |
uint8_t eraseFlashPg | ( | uint8_t | page | ) |
Erase selected flash page.
page | - the page to erase. |
void flash_close | ( | void | ) |
Close/cleanup access to flash
void flash_init | ( | void | ) |
Initialize flash interface
bool flash_open | ( | void | ) |
Open access to flash through flash_interface
bool hasExternalFlash | ( | void | ) |
Check if the interface is built for external flash
uint8_t readFlash | ( | uint_least32_t | addr, |
uint8_t * | pBuf, | ||
size_t | len | ||
) |
Read data from flash using address
addr | - address to read from |
pBuf | - pointer to buffer into which data is read. |
len | - length of data to read in bytes. |
uint8_t readFlashPg | ( | uint8_t | page, |
uint32_t | offset, | ||
uint8_t * | pBuf, | ||
uint16_t | len | ||
) |
Read data from flash using page and offset
page | - page to read from in flash |
offset | - offset into flash page to begin reading |
pBuf | - pointer to buffer into which data is read. |
len | - length of data to read in bytes. |
uint8_t writeFlash | ( | uint_least32_t | addr, |
uint8_t * | pBuf, | ||
size_t | len | ||
) |
Write data to flash using address
addr | - address to write to in flash |
pBuf | - pointer to buffer of data to write |
len | - length of data to write in bytes |
uint8_t writeFlashPg | ( | uint8_t | page, |
uint32_t | offset, | ||
uint8_t * | pBuf, | ||
uint16_t | len | ||
) |
Write data to flash using page and offset
page | - page to write to in flash |
offset | - offset into flash page to begin writing |
pBuf | - pointer to buffer of data to write |
len | - length of data to write in bytes |