CC23x0r2DriverLibrary
[flash.h] Flash
Collaboration diagram for [flash.h] Flash:

Macros

#define FAPI_STATUS_SUCCESS   0x00000000
 Function completed successfully. More...
 
#define FAPI_STATUS_FSM_BUSY   0x00000001
 FSM is Busy. More...
 
#define FAPI_STATUS_FSM_READY   0x00000002
 FSM is Ready. More...
 
#define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH   0x00000003
 Incorrect parameter value. More...
 
#define FAPI_STATUS_FSM_ERROR   0x00000004
 Flash program/erase operation failed. More...
 
#define FAPI_STATUS_ADDRESS_ERROR   0x00000005
 Address range or alignment error. More...
 
#define FAPI_STATUS_INVALID_KEY   0x00000010
 Invalid random jump protection key. More...
 

Functions

__STATIC_INLINE uint32_t FlashGetSectorSize (void)
 Get size of a flash sector in number of bytes. More...
 
__STATIC_INLINE uint32_t FlashGetSize (void)
 Get the size of the flash. More...
 
__STATIC_INLINE uint32_t FlashCheckFsmForError (void)
 Checks if the Flash state machine has detected an error. More...
 
__STATIC_INLINE uint32_t FlashCheckFsmForReady (void)
 Checks if the Flash state machine is ready. More...
 
__STATIC_INLINE uint32_t FlashEraseSector (uint32_t sectorAddress)
 Erase a flash sector. More...
 
__STATIC_INLINE uint32_t FlashEraseBank (void)
 
__STATIC_INLINE uint32_t FlashProgram (uint8_t *dataBuffer, uint32_t address, uint32_t count)
 Programs unprotected flash sectors in the main bank. More...
 

Detailed Description

Macro Definition Documentation

§ FAPI_STATUS_SUCCESS

#define FAPI_STATUS_SUCCESS   0x00000000

Function completed successfully.

Referenced by FlashCheckFsmForError().

§ FAPI_STATUS_FSM_BUSY

#define FAPI_STATUS_FSM_BUSY   0x00000001

FSM is Busy.

Referenced by FlashCheckFsmForReady().

§ FAPI_STATUS_FSM_READY

#define FAPI_STATUS_FSM_READY   0x00000002

FSM is Ready.

Referenced by FlashCheckFsmForReady().

§ FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH

#define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH   0x00000003

Incorrect parameter value.

§ FAPI_STATUS_FSM_ERROR

#define FAPI_STATUS_FSM_ERROR   0x00000004

Flash program/erase operation failed.

Referenced by FlashCheckFsmForError().

§ FAPI_STATUS_ADDRESS_ERROR

#define FAPI_STATUS_ADDRESS_ERROR   0x00000005

Address range or alignment error.

§ FAPI_STATUS_INVALID_KEY

#define FAPI_STATUS_INVALID_KEY   0x00000010

Invalid random jump protection key.

Function Documentation

§ FlashGetSectorSize()

__STATIC_INLINE uint32_t FlashGetSectorSize ( void  )

Get size of a flash sector in number of bytes.

This function will return the size of a flash sector in number of bytes.

Returns
Returns size of a flash sector in number of bytes.

References FLASH_MAIN_SECTOR_SIZE.

§ FlashGetSize()

__STATIC_INLINE uint32_t FlashGetSize ( void  )

Get the size of the flash.

This function returns the size of the flash main bank in number of bytes.

Returns
Returns the flash size in number of bytes.

References FLASH_MAIN_SIZE.

§ FlashCheckFsmForError()

__STATIC_INLINE uint32_t FlashCheckFsmForError ( void  )

Checks if the Flash state machine has detected an error.

This function returns the status of the Flash State Machine indicating if an error is detected or not. Primary use is to check if an Erase or Program operation has failed.

Note
Please note that code can not execute in flash while any part of the flash is being programmed or erased. This function must be called from ROM or SRAM while any part of the flash is being programmed or erased.
Returns
Returns status of Flash state machine:

References FAPI_STATUS_FSM_ERROR, FAPI_STATUS_SUCCESS, FLASH_BASE, FLASH_O_STATCMD, FLASH_STATCMD_CMDPASS_M, and HWREG.

§ FlashCheckFsmForReady()

__STATIC_INLINE uint32_t FlashCheckFsmForReady ( void  )

Checks if the Flash state machine is ready.

This function returns the status of the Flash State Machine indicating if it is ready to accept a new command or not. Primary use is to check if an Erase or Program operation has finished.

Note
Please note that code can not execute in flash while any part of the flash is being programmed or erased. This function must be called from ROM or SRAMh while any part of the flash is being programmed or erased.
Returns
Returns readiness status of Flash state machine:

References FAPI_STATUS_FSM_BUSY, FAPI_STATUS_FSM_READY, FLASH_BASE, FLASH_O_STATCMD, FLASH_STATCMD_CMDDONE_M, and HWREG.

§ FlashEraseSector()

__STATIC_INLINE uint32_t FlashEraseSector ( uint32_t  sectorAddress)

Erase a flash sector.

This function will erase the specified flash sector. The function will not return until the flash sector has been erased or an error condition occurred. If flash top sector is erased the function will program the the device security data bytes with default values. The device security data located in the customer configuration area of the flash top sector, must have valid values at all times. These values affect the configuration of the device during boot.

Warning
Please note that code can not execute in flash while any part of the flash is being programmed or erased. The application must disable interrupts that have interrupt routines in flash. This function calls a ROM function which handles the actual program operation.
Parameters
sectorAddressis the starting address in flash of the sector to be erased.
Returns
Returns the status of the sector erase:

References FLASH_API_KEY, HapiFlashSectorErase, HWREG, VIMS_BASE, VIMS_CCHCTRL_CCHEN_DISABLE, VIMS_CCHCTRL_CCHMPEN_DISABLE, VIMS_CCHCTRL_CCHPFEN_DISABLE, and VIMS_O_CCHCTRL.

§ FlashEraseBank()

§ FlashProgram()

__STATIC_INLINE uint32_t FlashProgram ( uint8_t *  dataBuffer,
uint32_t  address,
uint32_t  count 
)

Programs unprotected flash sectors in the main bank.

This function programs a sequence of bytes into the on-chip flash. Programming each location consists of the result of an AND operation of the new data and the existing data; in other words bits that contain 1 can remain 1 or be changed to 0, but bits that are 0 cannot be changed to 1. Therefore, a byte can be programmed multiple times as long as these rules are followed; if a program operation attempts to change a 0 bit to a 1 bit, that bit will not have its value changed.

This function does not return until the data has been programmed or a programming error occurs.

Warning
Please note that code can not execute in flash while any part of the flash is being programmed or erased. The application must disable interrupts that have interrupt routines in flash. This function calls a ROM function which handles the actual program operation.

The dataBuffer pointer can not point to flash.

Parameters
dataBufferis a pointer to the data to be programmed.
addressis the starting address in flash to be programmed.
countis the number of bytes to be programmed.
Returns
Returns status of the flash programming:

References FLASH_API_KEY, HapiFlashProgram, HWREG, VIMS_BASE, VIMS_CCHCTRL_CCHEN_DISABLE, VIMS_CCHCTRL_CCHMPEN_DISABLE, VIMS_CCHCTRL_CCHPFEN_DISABLE, and VIMS_O_CCHCTRL.