CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions | Enumerations
[flash] Flash

## Functions
__STATIC_INLINE uint32_t | FlashSectorSizeGet (void)
| Get size of a flash sector in number of bytes. More...
__STATIC_INLINE uint32_t | FlashSizeGet (void)
| Get the size of the flash. More...
void | FlashPowerModeSet (uint32_t ui32PowerMode, uint32_t ui32BankGracePeriode, uint32_t ui32PumpGracePeriode)
| Set power mode. More...
uint32_t | FlashPowerModeGet (void)
| Get current configured power mode. More...
void | FlashProtectionSet (uint32_t ui32SectorAddress, uint32_t ui32ProtectMode)
| Set sector protection. More...
uint32_t | FlashProtectionGet (uint32_t ui32SectorAddress)
| Get sector protection. More...
uint32_t | FlashProtectionSave (uint32_t ui32SectorAddress)
| Save sector protection to make it permanent. 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 void | FlashIntRegister (void(*pfnHandler)(void))
| Registers an interrupt handler for the flash interrupt. More...
__STATIC_INLINE void | FlashIntUnregister (void)
| Unregisters the interrupt handler for the flash interrupt. More...
__STATIC_INLINE void | FlashIntEnable (uint32_t ui32IntFlags)
| Enables flash controller interrupt sources. More...
__STATIC_INLINE void | FlashIntDisable (uint32_t ui32IntFlags)
| Disables individual flash controller interrupt sources. More...
__STATIC_INLINE uint32_t | FlashIntStatus (void)
| Gets the current interrupt status. More...
__STATIC_INLINE void | FlashIntClear (uint32_t ui32IntFlags)
| Clears flash controller interrupt source. More...
uint32_t | FlashSectorErase (uint32_t ui32SectorAddress)
| Erase a flash sector. More...
uint32_t | FlashProgram (uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
| Programs unprotected main bank flash sectors. More...
bool | FlashEfuseReadRow (uint32_t *pui32EfuseData, uint32_t ui32RowAddress)
| Reads efuse data from specified row. More...
void | FlashDisableSectorsForWrite (void)
| Disables all sectors for erase and programming on the active bank. More...

## Enumerations
enum | tFlashStateCommandsType { FAPI_PROGRAM_DATA = 0x0002, FAPI_ERASE_SECTOR = 0x0006, FAPI_ERASE_BANK = 0x0008, FAPI_VALIDATE_SECTOR = 0x000E, FAPI_CLEAR_STATUS = 0x0010, FAPI_PROGRAM_RESUME = 0x0014, FAPI_ERASE_RESUME = 0x0016, FAPI_CLEAR_MORE = 0x0018, FAPI_PROGRAM_SECTOR = 0x0020, FAPI_ERASE_OTP = 0x0030 }
| Defined values for Flash State Machine commands. More...

## Detailed Description

## Function Documentation

__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:
  - FAPI_STATUS_FSM_ERROR
  - FAPI_STATUS_SUCCESS

Definition at line 437 of file flash.h.

__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:
  - FAPI_STATUS_FSM_READY
  - FAPI_STATUS_FSM_BUSY

Definition at line 467 of file flash.h.

void FlashDisableSectorsForWrite | ( | void |  | ) |

Disables all sectors for erase and programming on the active bank.

This function disables all sectors for erase and programming on the active bank and enables the Idle Reading Power reduction mode if no low power mode is configured. Furthermore, an additional level of protection from erase is enabled.

Note
  Please note that code can not execute in flash while any part of the flash is being programmed or erased.

Returns
  None

Definition at line 520 of file flash.c.

Referenced by FlashsafeDisableSectorsForWrite().

bool FlashEfuseReadRow | ( | uint32_t * | pui32EfuseData,
|  | uint32_t | ui32RowAddress
| ) |  |

Reads efuse data from specified row.

This function will read one efuse row. It is assumed that any previous efuse operation has finished.

Parameters

  pui32EfuseData | is pointer to variable to be updated with efuse data.
  ui32RowAddress | is the efuse row number to be read. First row is row number 0.

Returns
  Returns the status of the efuse read operation.
  - `false` : OK status.
  - `true` : Error status

Definition at line 435 of file flash.c.

__STATIC_INLINE void FlashIntClear | ( | uint32_t | ui32IntFlags | ) |

Clears flash controller interrupt source.

The flash controller interrupt source is cleared, so that it no longer asserts. This must be done in the interrupt handler to keep it from being called again immediately upon exit.

Note
  Because there is a write buffer in the CM3, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately re-entered (because the interrupt controller still sees the interrupt source asserted).

Parameters

  ui32IntFlags | is the bit mask of the interrupt sources to be cleared. Can be any of: FLASH_INT_FSM_DONE FLASH_INT_RV

Returns
  None

Definition at line 646 of file flash.h.

Referenced by FlashsafeIntClear().

__STATIC_INLINE void FlashIntDisable | ( | uint32_t | ui32IntFlags | ) |

Disables individual flash controller interrupt sources.

This function disables the flash controller interrupt sources.

Parameters

  ui32IntFlags | is the bit mask of the interrupt sources to be disabled. The parameter is the bitwise OR of any of the following: FLASH_INT_FSM_DONE : FSM Done interrupt. FLASH_INT_RV : Read verify error interrupt.

Returns
  None

Definition at line 577 of file flash.h.

__STATIC_INLINE void FlashIntEnable | ( | uint32_t | ui32IntFlags | ) |

Enables flash controller interrupt sources.

This function enables the flash controller interrupt sources.

Parameters

  ui32IntFlags | is the bit mask of the interrupt sources to be enabled. The parameter is the bitwise OR of any of the following: FLASH_INT_FSM_DONE : FSM Done interrupt. FLASH_INT_RV : Read verify error interrupt.

Returns
  None

Definition at line 555 of file flash.h.

__STATIC_INLINE void FlashIntRegister | ( | void(*)(void) | pfnHandler | ) |

Registers an interrupt handler for the flash interrupt.

This function does the actual registering of the interrupt handler. This function enables the global interrupt in the interrupt controller; specific FLASH interrupts must be enabled via FlashIntEnable(). It is the interrupt handler's responsibility to clear the interrupt source.

Parameters

  pfnHandler | is a pointer to the function to be called when the flash interrupt occurs.

Returns
  None

See also
  IntRegister() for important information about registering interrupt handlers.

Definition at line 498 of file flash.h.

__STATIC_INLINE uint32_t FlashIntStatus | ( | void |  | ) |

Gets the current interrupt status.

This function returns the interrupt status for the Flash.

Returns
  Returns the current interrupt status as values described in FlashIntEnable().

Definition at line 595 of file flash.h.

Referenced by FlashsafeIntStatus().

__STATIC_INLINE void FlashIntUnregister | ( | void |  | ) |

Unregisters the interrupt handler for the flash interrupt.

This function does the actual unregistering of the interrupt handler. It clears the handler to be called when a FLASH interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

Returns
  None

See also
  IntRegister() for important information about registering interrupt handlers.

Definition at line 527 of file flash.h.

uint32_t FlashPowerModeGet | ( | void |  | ) |

Get current configured power mode.

This function will return the current configured power mode.

Returns
  Returns the current configured power mode. The defined power modes are:
  - FLASH_PWR_ACTIVE_MODE
  - FLASH_PWR_OFF_MODE
  - FLASH_PWR_DEEP_STDBY_MODE

Definition at line 194 of file flash.c.

Referenced by FlashsafePowerModeGet().

void FlashPowerModeSet | ( | uint32_t | ui32PowerMode,
|  | uint32_t | ui32BankGracePeriode,
|  | uint32_t | ui32PumpGracePeriode
| ) |  |

Set power mode.

This function will set the specified power mode.

Any access to the bank causes a reload of the specified bank grace periode input value into the bank down counter. After the last access to the flash bank, the down counter delays from 0 to 255 prescaled HCLK clock cycles before putting the bank into one of the fallback power modes as determined by `ui32PowerMode`. This value must be greater than 1 when the fallback mode is not FLASH_PWR_ACTIVE_MODE.

Note: The prescaled clock used for the down counter is a clock divided by 16 from input HCLK. The `ui32BankGracePeriode` parameter is ignored if `ui32PowerMode` is equal to FLASH_PWR_ACTIVE_MODE. Any access to flash memory causes the pump grace periode down counter to reload with value of `ui32PumpGracePeriode`. After the bank has gone to sleep, the down counter delays this number of prescaled HCLK clock cycles before entering one of the charge pump fallback power modes as determined by `ui32PowerMode`. The prescaled clock used for the pump grace periode down counter is a clock divided by 16 from input HCLK. This parameter is ignored if `ui32PowerMode` is equal to FLASH_PWR_ACTIVE_MODE.

Changing the power mode of the flash module must be a part within a device power mode transition requiring configuration of multiple modules. Refer to documents describing the device power modes.

Parameters

  ui32PowerMode | is the wanted power mode. The defined flash power modes are: FLASH_PWR_ACTIVE_MODE FLASH_PWR_OFF_MODE FLASH_PWR_DEEP_STDBY_MODE
  ui32BankGracePeriode | is the starting count value for the bank grace periode down counter.
  ui32PumpGracePeriode | is the starting count value for the pump grace periode down counter.

Returns
  None

Definition at line 103 of file flash.c.

Referenced by FlashsafePowerModeSet().

uint32_t FlashProgram | ( | uint8_t * | pui8DataBuffer,
|  | uint32_t | ui32Address,
|  | uint32_t | ui32Count
| ) |  |

Programs unprotected main bank flash sectors.

This function will program 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 will not return until the data has been programmed or an programming error has occurred.

Note
  Please note that code can not execute in flash while any part of the flash is being programmed or erased. This function must only be executed from ROM or SRAM.

The `pui8DataBuffer` pointer can not point to flash.

Parameters

  pui8DataBuffer | is a pointer to the data to be programmed.
  ui32Address | is the starting address in flash to be programmed.
  ui32Count | is the number of bytes to be programmed.

Returns
  Returns status of the flash programming:
  - FAPI_STATUS_SUCCESS : Success.
  - FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH : Too many bytes were requested.
  - FAPI_STATUS_FSM_ERROR : A programming error is encountered.

Definition at line 401 of file flash.c.

Referenced by FlashProtectionSave(), and FlashsafeProgram().

uint32_t FlashProtectionGet | ( | uint32_t | ui32SectorAddress | ) |

Get sector protection.

This return the protection mode for the specified flash bank sector.

Parameters

  ui32SectorAddress | is the start address of the desired sector.

Returns
  Returns the sector protection:
  - FLASH_NO_PROTECT
  - FLASH_WRITE_PROTECT

Definition at line 267 of file flash.c.

Referenced by FlashProtectionSave(), and FlashsafeProtectionGet().

uint32_t FlashProtectionSave | ( | uint32_t | ui32SectorAddress | ) |

Save sector protection to make it permanent.

This function will save the current protection mode for the specified flash bank sector.

This function must only be executed from ROM or SRAM.

Note
  A write protected sector will become permanent write protected!! A device reset will not change the write protection!

Parameters

  ui32SectorAddress | is the start address of the sector to be protected.

Returns
  Returns the status of the sector protection:
  - FAPI_STATUS_SUCCESS : Success.
  - FAPI_STATUS_FSM_ERROR : An erase error is encountered.

Definition at line 310 of file flash.c.

Referenced by FlashsafeProtectionSave().

void FlashProtectionSet | ( | uint32_t | ui32SectorAddress,
|  | uint32_t | ui32ProtectMode
| ) |  |

Set sector protection.

This function will set the specified protection on specified flash bank sector. A sector can either have no protection or have write protection which guards for both program and erase of that sector. Sector protection can only be changed from FLASH_NO_PROTECT to FLASH_WRITE_PROTECT! After write protecting a sector this sector can only be set back to unprotected by a device reset.

Parameters

  ui32SectorAddress | is the start address of the sector to protect.
  ui32ProtectMode | is the enumerated sector protection mode. FLASH_NO_PROTECT FLASH_WRITE_PROTECT

Returns
  None

Definition at line 227 of file flash.c.

Referenced by FlashsafeProtectionSet().

uint32_t FlashSectorErase | ( | uint32_t | ui32SectorAddress | ) |

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.

Note
  Please note that code can not execute in flash while any part of the flash is being programmed or erased. This function must only be executed from ROM or SRAM.

Parameters

  ui32SectorAddress | is the starting address in flash of the sector to be erased.

Returns
  Returns the status of the sector erase:
  - FAPI_STATUS_SUCCESS : Success.
  - FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH : Invalid argument.
  - FAPI_STATUS_FSM_ERROR : A programming error is encountered.

Definition at line 364 of file flash.c.

Referenced by FlashsafeSectorErase().

__STATIC_INLINE uint32_t FlashSectorSizeGet | ( | 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.

Definition at line 260 of file flash.h.

Referenced by FlashProtectionGet(), FlashProtectionSave(), FlashProtectionSet(), FlashsafeSectorSizeGet(), FlashSectorErase(), and FlashSizeGet().

__STATIC_INLINE uint32_t FlashSizeGet | ( | 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.

Definition at line 284 of file flash.h.

Referenced by FlashProgram(), FlashProtectionGet(), FlashProtectionSave(), FlashProtectionSet(), FlashsafeSizeGet(), and FlashSectorErase().

## Macro Definition Documentation

#define ADDR_OFFSET (0x1F800000 - FLASHMEM_BASE)

Definition at line 144 of file flash.h.

#define CCFG_OFFSET_SECT_PROT 0x00000FF0

Definition at line 246 of file flash.h.

Referenced by FlashProtectionSave().

#define CCFG_OFFSET_SECURITY 0x00000FD8

Definition at line 245 of file flash.h.

#define CCFG_SIZE_SECT_PROT 0x00000004

Definition at line 248 of file flash.h.

Referenced by FlashProtectionSave().

#define CCFG_SIZE_SECURITY 0x00000014

Definition at line 247 of file flash.h.

#define DUMPWORD_INSTR 0x04

Definition at line 231 of file flash.h.

Referenced by FlashEfuseReadRow().

#define FAPI_STATUS_FSM_BUSY 0x00000001

Definition at line 105 of file flash.h.

Referenced by FlashCheckFsmForReady(), and FlashsafeCheckFsmForReady().

#define FAPI_STATUS_FSM_ERROR 0x00000004

Definition at line 109 of file flash.h.

Referenced by FlashCheckFsmForError(), and FlashsafeCheckFsmForError().

#define FAPI_STATUS_FSM_READY 0x00000002

Definition at line 106 of file flash.h.

Referenced by FlashCheckFsmForReady(), and FlashsafeCheckFsmForReady().

#define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH 0x00000003

Definition at line 107 of file flash.h.

#define FAPI_STATUS_SUCCESS 0x00000000

Definition at line 104 of file flash.h.

Referenced by FlashCheckFsmForError(), FlashProtectionSave(), and FlashsafeCheckFsmForError().

#define FBFALLBACK_ACTIVE 3

Definition at line 194 of file flash.h.

Referenced by FlashPowerModeSet().

#define FBFALLBACK_DEEP_STDBY 1

Definition at line 193 of file flash.h.

Referenced by FlashPowerModeGet(), and FlashPowerModeSet().

#define FBFALLBACK_SLEEP 0

Definition at line 192 of file flash.h.

Referenced by FlashPowerModeGet().

#define FCFG1_OFFSET 0x1000

Definition at line 151 of file flash.h.

#define FLASH_BAGP 0x14

Definition at line 201 of file flash.h.

#define FLASH_CMD_EXEC 0x15

Definition at line 238 of file flash.h.

#define FLASH_INT_FSM_DONE 0x00400000

Definition at line 117 of file flash.h.

Referenced by FlashIntClear(), and FlashIntStatus().

#define FLASH_INT_RV 0x00010000

Definition at line 118 of file flash.h.

Referenced by FlashIntClear(), and FlashIntStatus().

#define FLASH_MODULE_CLK_FREQ 48

Definition at line 158 of file flash.h.

#define FLASH_NO_PROTECT 0x00000000

Definition at line 135 of file flash.h.

Referenced by FlashProtectionGet().

#define FLASH_PAGP 0x14

Definition at line 202 of file flash.h.

#define FLASH_PWR_ACTIVE_MODE 0x00000000

Definition at line 125 of file flash.h.

Referenced by FlashPowerModeGet(), FlashPowerModeSet(), and FlashsafePowerModeSet().

#define FLASH_PWR_DEEP_STDBY_MODE 0x00000002

Definition at line 127 of file flash.h.

Referenced by FlashPowerModeGet(), FlashPowerModeSet(), and FlashsafePowerModeSet().

#define FLASH_PWR_OFF_MODE 0x00000001

Definition at line 126 of file flash.h.

Referenced by FlashPowerModeGet(), FlashPowerModeSet(), and FlashsafePowerModeSet().

#define FLASH_WRITE_PROTECT 0x00000001

Definition at line 136 of file flash.h.

Referenced by FlashProtectionGet(), FlashProtectionSave(), and FlashProtectionSet().

#define FSM_REG_WRT_DISABLE 2

Definition at line 185 of file flash.h.

Referenced by FlashDisableSectorsForWrite(), FlashIntDisable(), FlashIntEnable(), FlashProtectionSet(), FlashsafeIntDisable(), and FlashsafeIntEnable().

#define FSM_REG_WRT_ENABLE 5

Definition at line 184 of file flash.h.

Referenced by FlashDisableSectorsForWrite(), FlashIntDisable(), FlashIntEnable(), FlashProtectionSet(), FlashsafeIntDisable(), and FlashsafeIntEnable().

#define FW_WRT_TRIMMED 0x00000001

Definition at line 216 of file flash.h.

#define FWPWRITE_BYTE_ADDRESS ((tFwpWriteByte *)((FLASH_BASE + FLASH_O_FWPWRITE0)))

Definition at line 224 of file flash.h.

#define PATTERN_BITS 0x20

Definition at line 209 of file flash.h.

## Enumeration Type Documentation

enum tFlashStateCommandsType

Defined values for Flash State Machine commands.

Enumerator
FAPI_PROGRAM_DATA | Program data.
FAPI_ERASE_SECTOR | Erase sector.
FAPI_ERASE_BANK | Erase bank.
FAPI_VALIDATE_SECTOR | Validate sector.
FAPI_CLEAR_STATUS | Clear status.
FAPI_PROGRAM_RESUME | Program resume.
FAPI_ERASE_RESUME | Erase resume.
FAPI_CLEAR_MORE | Clear more.
FAPI_PROGRAM_SECTOR | Program sector.
FAPI_ERASE_OTP | Erase OTP.

Definition at line 165 of file flash.h.