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
[flashsafe] Flash Safe

## Functions
__STATIC_INLINE bool | FlashsafeSMPHTryAcquire (void)
| Aquire the flash semaphore. More...
__STATIC_INLINE void | FlashsafeSMPHRelease (void)
| Release the flash semaphore. More...
uint32_t | FlashsafeSizeGet (void)
| Get the size of the flash. More...
uint32_t | FlashsafeSectorSizeGet (void)
| Get size of a flash sector in no of bytes. More...
uint32_t | FlashsafePowerModeSet (uint32_t ui32PowerMode, uint32_t ui32BankGracePeriode, uint32_t ui32PumpGracePeriode)
| Set power mode. More...
uint32_t | FlashsafePowerModeGet (void)
| Get current configured power mode. More...
uint32_t | FlashsafeProtectionSet (uint32_t ui32SectorAddress, uint32_t ui32ProtectMode)
| Set sector protection. More...
uint32_t | FlashsafeProtectionGet (uint32_t ui32SectorAddress)
| Get sector protection. More...
uint32_t | FlashsafeProtectionSave (uint32_t ui32SectorAddress)
| Save sector protection to make it permanent. More...
uint32_t | FlashsafeCheckFsmForError (void)
| Checks if the Flashsafe state machine has detected an error. More...
uint32_t | FlashsafeCheckFsmForReady (void)
| Checks if the Flash state machine is ready. More...
uint32_t | FlashsafeIntRegister (void(*pfnHandler)(void))
| Registers an interrupt handler for the flash interrupt. More...
uint32_t | FlashsafeIntUnregister (void)
| Unregisters the interrupt handler for the flash interrupt. More...
uint32_t | FlashsafeIntEnable (uint32_t ui32IntFlags)
| Enables flash controller interrupt sources. More...
uint32_t | FlashsafeIntDisable (uint32_t ui32IntFlags)
| Disables individual flash controller interrupt sources. More...
uint32_t | FlashsafeIntStatus (void)
| Gets the current interrupt status. More...
uint32_t | FlashsafeIntClear (uint32_t ui32IntFlags)
| Clears flash controller interrupt source. More...
uint32_t | FlashsafeSectorErase (uint32_t ui32SectorAddress)
| Erase a flash sector. More...
uint32_t | FlashsafeProgram (uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
| Programs unprotected main bank flash sectors. More...
uint32_t | FlashsafeDisableSectorsForWrite (void)
| Disables all sectors for erase and programming on the active bank. More...

## Detailed Description

## Function Documentation

uint32_t FlashsafeCheckFsmForError | ( | void |  | ) |

Checks if the Flashsafe state machine has detected an error.

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

Returns
  Returns status of Flashsafe state machine:
  - FAPI_STATUS_FSM_ERROR
  - FAPI_STATUS_SUCCESS

Definition at line 247 of file flashsafe.c.

uint32_t FlashsafeCheckFsmForReady | ( | 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.

Returns
  Returns readiness status of Flash state machine:
  - FAPI_STATUS_FSM_READY
  - FAPI_STATUS_FSM_BUSY

Definition at line 265 of file flashsafe.c.

uint32_t FlashsafeDisableSectorsForWrite | ( | 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.

Returns
  Returns the status of the flash sector erase disable:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FLASHSAFE_ACCESS_OK : Successful.

Definition at line 461 of file flashsafe.c.

uint32_t FlashsafeIntClear | ( | uint32_t | ui32IntFlags | ) |

Clears flash controller interrupt source.

The flash controller interrupt source is cleared, so that it no longer assert. 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 processor, 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 reentered (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 values

Returns
  Returns status of the flash interrupt source clearing:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FLASHSAFE_ACCESS_OK : Successful.

Definition at line 389 of file flashsafe.c.

uint32_t FlashsafeIntDisable | ( | 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
  Returns status of function call:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FLASHSAFE_ACCESS_OK : Successful.

Definition at line 358 of file flashsafe.c.

uint32_t FlashsafeIntEnable | ( | 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
  Returns status of the function call:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FLASHSAFE_ACCESS_OK : Successful.

Definition at line 337 of file flashsafe.c.

uint32_t FlashsafeIntRegister | ( | 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 FlashsafeIntEnable(). 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
  Returns the status of the flash registering:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FLASHSAFE_ACCESS_OK : Successful.

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

Definition at line 283 of file flashsafe.c.

uint32_t FlashsafeIntStatus | ( | void |  | ) |

Gets the current interrupt status.

This function returns the interrupt status for the Flash.

Returns
  Returns the current interrupt status:
  - FLASH_INT_FSM_DONE : FSM Done interrupt.
  - FLASH_INT_RV : Read verify error interrupt.

Definition at line 378 of file flashsafe.c.

uint32_t FlashsafeIntUnregister | ( | 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
  Returns status of the flash unregistering:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FLASHSAFE_ACCESS_OK : Successful.

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

Definition at line 310 of file flashsafe.c.

uint32_t FlashsafePowerModeGet | ( | void |  | ) |

Get current configured power mode.

This function will return the current configured power mode.

Returns
  Returns FLASHSAFE_ACCESS_DENIED if flash is blocked by another thread, otherwise the current configured power mode:
  - FLASH_PWR_ACTIVE_MODE
  - FLASH_PWR_OFF_MODE
  - FLASH_PWR_DEEP_STDBY_MODE
  - FLASHSAFE_ACCESS_DENIED : Flash is blocked by another thread.

Definition at line 148 of file flashsafe.c.

uint32_t FlashsafePowerModeSet | ( | 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.

In current flash module design the SW application has to call the FlashsafePowerModeSet() funtion with the FLASH_PWR_ACTIVE_MODE input parameter value if the flash modules comes out of any of the two low power modes, in in order to reestablish the factory configured idle reading power reduction 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 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
  Returns the status of the power mode setting:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread
  - FLASHSAFE_ACCESS_OK : Power mode was set successfully.

Definition at line 119 of file flashsafe.c.

uint32_t FlashsafeProgram | ( | 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. The actual programming function called by 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 flash sector program:
  - FAPI_STATUS_SUCCESS : Success.
  - FAPI_STATUS_FSM_ERROR : A programming error is encountered.
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.

Definition at line 435 of file flashsafe.c.

uint32_t FlashsafeProtectionGet | ( | 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 FLASHSAFE_ACCESS_DENIED if flash is used by another thread, else the sector protection:
  - FLASH_NO_PROTECT
  - FLASH_WRITE_PROTECT
  - FLASHSAFE_ACCESS_DENIED : Flash is blocked by another thread.

Definition at line 193 of file flashsafe.c.

uint32_t FlashsafeProtectionSave | ( | uint32_t | ui32SectorAddress | ) |

Save sector protection to make it permanent.

This function will save the the current protection mode for the specified flash bank sector. A write protected sector will become permanent write protected!! A device reset will not change the write protection!

Note
  The actual protection save function called by this function must only be executed from ROM or SRAM.

Parameters

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

Returns
  Returns status of the flash sector protection:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FAPI_STATUS_SUCCESS : Success
  - FAPI_STATUS_FSM_ERROR : An erase error is encountered.

Definition at line 220 of file flashsafe.c.

uint32_t FlashsafeProtectionSet | ( | 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!

Note
  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. The defined sector protection modes are: FLASH_NO_PROTECT FLASH_WRITE_PROTECT

Returns
  Returns status of the sector protection:
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.
  - FLASHSAFE_ACCESS_OK : Sector protection successful.

Definition at line 168 of file flashsafe.c.

uint32_t FlashsafeSectorErase | ( | 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 affects 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. The actual erase function called by 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 status of flash sector erase:
  - FAPI_STATUS_SUCCESS : Success.
  - FAPI_STATUS_FSM_ERROR : A programming error is encountered.
  - FLASHSAFE_ACCESS_DENIED : Flash is used by another thread.

Definition at line 407 of file flashsafe.c.

uint32_t FlashsafeSectorSizeGet | ( | void |  | ) |

Get size of a flash sector in no 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 108 of file flashsafe.c.

Referenced by FlashsafeProtectionGet(), FlashsafeProtectionSave(), FlashsafeProtectionSet(), and FlashsafeSectorErase().

uint32_t FlashsafeSizeGet | ( | 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 97 of file flashsafe.c.

Referenced by FlashsafeProgram(), FlashsafeProtectionGet(), FlashsafeProtectionSave(), FlashsafeProtectionSet(), and FlashsafeSectorErase().

__STATIC_INLINE void FlashsafeSMPHRelease | ( | void |  | ) |

Release the flash semaphore.

Returns
  None

Definition at line 191 of file flashsafe.h.

Referenced by FlashsafeDisableSectorsForWrite(), FlashsafeIntClear(), FlashsafeIntDisable(), FlashsafeIntEnable(), FlashsafeIntRegister(), FlashsafeIntUnregister(), FlashsafePowerModeGet(), FlashsafePowerModeSet(), FlashsafeProgram(), FlashsafeProtectionGet(), FlashsafeProtectionSave(), FlashsafeProtectionSet(), and FlashsafeSectorErase().

__STATIC_INLINE bool FlashsafeSMPHTryAcquire | ( | void |  | ) |

Aquire the flash semaphore.

Returns
  None

Definition at line 178 of file flashsafe.h.

Referenced by FlashsafeDisableSectorsForWrite(), FlashsafeIntClear(), FlashsafeIntDisable(), FlashsafeIntEnable(), FlashsafeIntRegister(), FlashsafeIntUnregister(), FlashsafePowerModeGet(), FlashsafePowerModeSet(), FlashsafeProgram(), FlashsafeProtectionGet(), FlashsafeProtectionSave(), FlashsafeProtectionSet(), and FlashsafeSectorErase().

## Macro Definition Documentation

#define FAPI_STATUS_FSM_BUSY 0x00000001

Definition at line 128 of file flashsafe.h.

#define FAPI_STATUS_FSM_ERROR 0x00000004

Definition at line 132 of file flashsafe.h.

#define FAPI_STATUS_FSM_READY 0x00000002

Definition at line 129 of file flashsafe.h.

#define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH 0x00000003

Definition at line 130 of file flashsafe.h.

#define FAPI_STATUS_SUCCESS 0x00000000

Definition at line 127 of file flashsafe.h.

#define FLASH_INT_FSM_DONE 0x00400000

Definition at line 140 of file flashsafe.h.

#define FLASH_INT_RV 0x00010000

Definition at line 141 of file flashsafe.h.

#define FLASH_NO_PROTECT 0x00000000

Definition at line 158 of file flashsafe.h.

#define FLASH_PWR_ACTIVE_MODE 0x00000000

Definition at line 148 of file flashsafe.h.

#define FLASH_PWR_DEEP_STDBY_MODE 0x00000002

Definition at line 150 of file flashsafe.h.

#define FLASH_PWR_OFF_MODE 0x00000001

Definition at line 149 of file flashsafe.h.

#define FLASH_WRITE_PROTECT 0x00000001

Definition at line 159 of file flashsafe.h.

#define FLASHSAFE_ACCESS_DENIED 0x000000ff

Definition at line 118 of file flashsafe.h.

Referenced by FlashsafeDisableSectorsForWrite(), FlashsafeIntClear(), FlashsafeIntDisable(), FlashsafeIntEnable(), FlashsafeIntRegister(), FlashsafeIntUnregister(), FlashsafePowerModeGet(), FlashsafePowerModeSet(), FlashsafeProgram(), FlashsafeProtectionGet(), FlashsafeProtectionSave(), FlashsafeProtectionSet(), and FlashsafeSectorErase().

#define FLASHSAFE_ACCESS_OK 0x000000ee

Definition at line 119 of file flashsafe.h.

Referenced by FlashsafeDisableSectorsForWrite(), FlashsafeIntClear(), FlashsafeIntDisable(), FlashsafeIntEnable(), FlashsafeIntRegister(), FlashsafeIntUnregister(), FlashsafePowerModeSet(), and FlashsafeProtectionSet().

#define FSM_REG_WRT_DISABLE 2

Definition at line 168 of file flashsafe.h.

#define FSM_REG_WRT_ENABLE 5

Definition at line 167 of file flashsafe.h.

#define SMPH_ALLOC_FLASH 1

Definition at line 120 of file flashsafe.h.

Referenced by FlashsafeSMPHRelease(), and FlashsafeSMPHTryAcquire().