TI BLE-Stack for Bluetooth 4.2 API Documentation  3.02.03.00
Modules | Files | Macros | Functions
Flash Interface

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

Detailed Description

An interface that abstracts flash operations for OAD this allows on-chip and off-chip OAD to use the same flash APIs.

============================================================================

Header Include

The flash interface header file should be included as follows:

Overview

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.

Selecting an interface

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

Initialzation

Initialze the module as shown below

// Open the flash interface

Opening the module

Open the module as shown below

bool flashStat = flash_open();
if(flashStat != true)
{
// Report error
}

Using the module

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

Closing the module

Open the module as shown below

Macro Definition Documentation

§ FLASH_FAILURE

#define FLASH_FAILURE   0xFF

Flash operation failed

§ FLASH_SUCCESS

#define FLASH_SUCCESS   0x00

Flash operation succeeded

§ SPI_MAX_READ_SZ

#define SPI_MAX_READ_SZ   1024

Maximum SPI read size, used for off-chip

Function Documentation

§ eraseFlashPg()

uint8_t eraseFlashPg ( uint8_t  page)

Erase selected flash page.

Parameters
page- the page to erase.
Returns
status - FLASH_SUCCESS if page erased successfully or FLASH_FAILURE if erase failed

§ flash_close()

void flash_close ( void  )

Close/cleanup access to flash

§ flash_init()

void flash_init ( void  )

Initialize flash interface

§ flash_open()

bool flash_open ( void  )

Open access to flash through flash_interface

Returns
true if interface successfully opened, false otherwise

§ hasExternalFlash()

bool hasExternalFlash ( void  )

Check if the interface is built for external flash

Returns
true if the target has external flash, false otherwise

§ readFlash()

uint8_t readFlash ( uint_least32_t  addr,
uint8_t *  pBuf,
size_t  len 
)

Read data from flash using address

Parameters
addr- address to read from
pBuf- pointer to buffer into which data is read.
len- length of data to read in bytes.
Returns
FLASH_SUCCESS if read succeeded FLASH_FAILURE if the flash returned an error

§ readFlashPg()

uint8_t readFlashPg ( uint8_t  page,
uint32_t  offset,
uint8_t *  pBuf,
uint16_t  len 
)

Read data from flash using page and offset

Parameters
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.
Returns
status - FLASH_SUCCESS if programmed successfully or FLASH_FAILURE if programming failed

§ writeFlash()

uint8_t writeFlash ( uint_least32_t  addr,
uint8_t *  pBuf,
size_t  len 
)

Write data to flash using address

Parameters
addr- address to write to in flash
pBuf- pointer to buffer of data to write
len- length of data to write in bytes
Returns
status - FLASH_SUCCESS if programmed successfully or FLASH_FAILURE if programming failed

§ writeFlashPg()

uint8_t writeFlashPg ( uint8_t  page,
uint32_t  offset,
uint8_t *  pBuf,
uint16_t  len 
)

Write data to flash using page and offset

Parameters
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
Returns
status - FLASH_SUCCESS if programmed successfully or FLASH_FAILURE if programming failed
© Copyright 1995-2019, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale