TI-OpenThread  1.08.02.01
Modules | 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...

+ Collaboration diagram for Flash Interface:

Modules

 Macros and constants for external flash
 

Macros

#define FLASH_FAILURE   0xFF
 
#define FLASH_FAILURE   0xFF
 
#define FLASH_FAILURE   0xFF
 
#define FLASH_FAILURE   0xFF
 
#define FLASH_FAILURE   0xFF
 
#define FLASH_FAILURE   0xFF
 
#define FLASH_SUCCESS   0x00
 
#define FLASH_SUCCESS   0x00
 
#define FLASH_SUCCESS   0x00
 
#define FLASH_SUCCESS   0x00
 
#define FLASH_SUCCESS   0x00
 
#define FLASH_SUCCESS   0x00
 
#define SPI_MAX_READ_SZ   1024
 
#define SPI_MAX_READ_SZ   1024
 
#define SPI_MAX_READ_SZ   1024
 
#define SPI_MAX_READ_SZ   1024
 
#define SPI_MAX_READ_SZ   1024
 
#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)
 

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:

#include <common/cc26xx/flash_interface/flash_interface.h>

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_SUCCESS [1/6]

#define FLASH_SUCCESS   0x00

§ FLASH_FAILURE [1/6]

#define FLASH_FAILURE   0xFF

§ SPI_MAX_READ_SZ [1/6]

#define SPI_MAX_READ_SZ   1024

Maximum SPI read size, used for off-chip

§ FLASH_SUCCESS [2/6]

#define FLASH_SUCCESS   0x00

Flash operation succeeded

§ FLASH_FAILURE [2/6]

#define FLASH_FAILURE   0xFF

Flash operation failed

§ SPI_MAX_READ_SZ [2/6]

#define SPI_MAX_READ_SZ   1024

Maximum SPI read size, used for off-chip

§ FLASH_SUCCESS [3/6]

#define FLASH_SUCCESS   0x00

Flash operation succeeded

§ FLASH_FAILURE [3/6]

#define FLASH_FAILURE   0xFF

Flash operation failed

§ SPI_MAX_READ_SZ [3/6]

#define SPI_MAX_READ_SZ   1024

Maximum SPI read size, used for off-chip

§ FLASH_SUCCESS [4/6]

#define FLASH_SUCCESS   0x00

Flash operation succeeded

§ FLASH_FAILURE [4/6]

#define FLASH_FAILURE   0xFF

Flash operation failed

§ SPI_MAX_READ_SZ [4/6]

#define SPI_MAX_READ_SZ   1024

Maximum SPI read size, used for off-chip

§ FLASH_SUCCESS [5/6]

#define FLASH_SUCCESS   0x00

Flash operation succeeded

§ FLASH_FAILURE [5/6]

#define FLASH_FAILURE   0xFF

Flash operation failed

§ SPI_MAX_READ_SZ [5/6]

#define SPI_MAX_READ_SZ   1024

Maximum SPI read size, used for off-chip

§ FLASH_SUCCESS [6/6]

#define FLASH_SUCCESS   0x00

Flash operation succeeded

§ FLASH_FAILURE [6/6]

#define FLASH_FAILURE   0xFF

Flash operation failed

§ SPI_MAX_READ_SZ [6/6]

#define SPI_MAX_READ_SZ   1024

Maximum SPI read size, used for off-chip

Function Documentation

§ flash_init()

void flash_init ( void  )

Initialize flash interface

References nvsParams.

§ flash_open()

bool flash_open ( void  )

Open access to flash through flash_interface

Returns
true if interface successfully opened, false otherwise

References isOpen, nvsHandle, nvsParams, and regionAttrs.

Referenced by OADStorage_checkFactoryImage(), OADStorage_createFactoryImageBackup(), OADStorage_getFactoryImage(), and OADStorage_init().

§ flash_close()

void flash_close ( void  )

§ hasExternalFlash()

bool hasExternalFlash ( void  )

Check if the interface is built for external flash

Returns
true if the target has external flash, false otherwise

Referenced by OAD_open(), and OADStorage_init().

§ 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

References FLASH_FAILURE, FLASH_SUCCESS, isOpen, and nvsHandle.

Referenced by OADStorage_checkFactoryImage(), and OADStorage_getFactoryImage().

§ 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

References EXT_FLASH_ADDRESS, FLASH_FAILURE, FLASH_SUCCESS, isOpen, and nvsHandle.

Referenced by CRC32_calc(), oadCheckDL(), oadFindExtFlMetaPage(), OADStorage_imgBlockRead(), OADStorage_imgFinalise(), and OADStorage_init().

§ 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

References FLASH_FAILURE, FLASH_SUCCESS, isOpen, and nvsHandle.

Referenced by OADStorage_createFactoryImageBackup().

§ 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

References EXT_FLASH_ADDRESS, FLASH_FAILURE, FLASH_SUCCESS, isOpen, and nvsHandle.

Referenced by oadCheckDL(), OADStorage_imgBlockWrite(), and OADStorage_imgFinalise().

§ 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

References EFL_PAGE_SIZE, EXT_FLASH_ADDRESS, FLASH_FAILURE, FLASH_SUCCESS, isOpen, and nvsHandle.

Referenced by oadEraseExtFlashPages(), oadFindExtFlMetaPage(), OADStorage_createFactoryImageBackup(), OADStorage_eraseImgPage(), OADStorage_imgBlockWrite(), and OADStorage_imgFinalise().

§ eraseFlash()

uint8_t eraseFlash ( uint8_t  page)

Erase flash page.

Parameters
page- the page to erase.
Returns
status - FLASH_SUCCESS if page erased successfully or FLASH_FAILURE if erase failed
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale