Macros | Functions
FlashCC26X4_ns.h File Reference

Detailed Description

Non-Secure Flash Client Interface for CC26X4 devices.


The defined APIs are identical to the function calls in flash.c. This client interface allows the access to the Secure Flash Service.

Initialization

Users will need to call FlashOpen() once prior to any other function calls. FlashOpen() will only need to be called again if FlashClose() is called.

Error Codes

Typically the Flash Driver (flash.c) returns either a FAPI_STATUS code or a valid value greater than the FAPI_STATUS code range. FAPI_STATUS codes are positive and are defined below in FlashCC26X4_ns.h. The Non-Secure Flash Client Interface is responsible for interfacing with the Secure Partition Manager (SPM). Requests to the SPM may result in Platform Security Architecture (PSA) error codes. These error codes are referred to as PSA_ERROR codes. PSA_ERROR codes are negative values and are defined in "error.h". Due to the FAPI_STATUS and PSA_ERROR codes not overlapping, API's of the Non-Secure Flash Client Interface can dynamically return either value type. PSA_ERROR codes are considered higher priority and will take precedence. Therefore, if a PSA_ERROR occurs, a PSA_ERROR is returned. Otherwise, a valid Flash driver value will be returned. Each API will follow this guideline but please reference each API individually for specific return characteristics.

PSA_ERROR_PROGRAMMER_ERROR

A PSA_ERROR_PROGRAMMER_ERROR is a strict error code returned by the SPM. Once this error code is returned, the SPM will terminate the connection to the service. All subsequent requests to the service from the same client will not be processed and will continue to return a PSA_ERROR_PROGRAMMER_ERROR. The client must close the connection to the SPM and then re-establish the connection to continue. This can be accomplished in the Non-Secure Flash Client Interface by calling FlashClose() followed by FlashOpen(). In the Non-Secure Flash Client Interface, PSA_ERROR_PROGRAMMER_ERROR codes will primarily be returned due to requests trying to read from or write to secure memory regions. Please reference the PSA Firmware Framework specification for more details regarding the PSA_ERROR_PROGRAMMER_ERROR code.


#include <stddef.h>
#include <stdint.h>
#include <ti/devices/DeviceFamily.h>
#include <DeviceFamily_constructPath(inc/hw_nvmnw.h)>
#include <DeviceFamily_constructPath(inc/hw_memmap.h)>
#include <DeviceFamily_constructPath(inc/hw_types.h)>
#include <DeviceFamily_constructPath(cmsis/core/cmsis_compiler.h)>
Include dependency graph for FlashCC26X4_ns.h:

Go to the source code of this file.

Macros

#define FAPI_STATUS_SUCCESS   0x00000000
 
#define FAPI_STATUS_FSM_BUSY   0x00000001
 
#define FAPI_STATUS_FSM_READY   0x00000002
 
#define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH   0x00000003
 
#define FAPI_STATUS_FSM_ERROR   0x00000004
 
#define FAPI_STATUS_ADDRESS_ERROR   0x00000005
 
#define FAPI_STATUS_ADDRESS_ALIGN_ERROR   0x00000006
 
#define FAPI_STATUS_BANK_NUM_ERROR   0x00000007
 
#define FAPI_STATUS_NOSUPPORT_ERROR   0x00000008
 
#define FAPI_STATUS_UNPROTECT_ERROR   0x00000009
 

Functions

int_fast16_t FlashOpen (void)
 Initialize a PSA connection to the Secure Flash Service. More...
 
void FlashClose (void)
 End the PSA connection to the Secure Flash Service. More...
 
uint32_t FlashProtectionGet (uint32_t ui32SectorAddress)
 Call FlashProtectionGet API using Secure Flash Service. More...
 
uint32_t FlashSectorErase (uint32_t ui32SectorAddress)
 Call FlashSectorErase API using Secure Flash Service. More...
 
uint32_t FlashProgram (uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
 Call FlashProgram API using Secure Flash Service. More...
 
uint32_t FlashProgram4X (uint8_t *pui8DataBuffer, uint32_t ui32Address, uint32_t ui32Count)
 Call FlashProgram4X API using Secure Flash Service. More...
 
uint32_t FlashSectorSizeGet (void)
 Call FlashSectorSizeGet API using Secure Flash Service. More...
 
uint32_t FlashSizeGet (void)
 Call FlashSizeGet API using Secure Flash Service. More...
 

Macro Definition Documentation

§ FAPI_STATUS_SUCCESS

#define FAPI_STATUS_SUCCESS   0x00000000

§ FAPI_STATUS_FSM_BUSY

#define FAPI_STATUS_FSM_BUSY   0x00000001

§ FAPI_STATUS_FSM_READY

#define FAPI_STATUS_FSM_READY   0x00000002

§ FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH

#define FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH   0x00000003

§ FAPI_STATUS_FSM_ERROR

#define FAPI_STATUS_FSM_ERROR   0x00000004

§ FAPI_STATUS_ADDRESS_ERROR

#define FAPI_STATUS_ADDRESS_ERROR   0x00000005

§ FAPI_STATUS_ADDRESS_ALIGN_ERROR

#define FAPI_STATUS_ADDRESS_ALIGN_ERROR   0x00000006

§ FAPI_STATUS_BANK_NUM_ERROR

#define FAPI_STATUS_BANK_NUM_ERROR   0x00000007

§ FAPI_STATUS_NOSUPPORT_ERROR

#define FAPI_STATUS_NOSUPPORT_ERROR   0x00000008

§ FAPI_STATUS_UNPROTECT_ERROR

#define FAPI_STATUS_UNPROTECT_ERROR   0x00000009

Function Documentation

§ FlashOpen()

int_fast16_t FlashOpen ( void  )

Initialize a PSA connection to the Secure Flash Service.

Precondition
None
Returns
A value greater than 0 indicates the value of a successfuly established connection handle. On failure a PSA_ERROR code will be returned.

§ FlashClose()

void FlashClose ( void  )

End the PSA connection to the Secure Flash Service.

Precondition
FlashOpen() was called.
Returns
void

§ FlashProtectionGet()

uint32_t FlashProtectionGet ( uint32_t  ui32SectorAddress)

Call FlashProtectionGet API using Secure Flash Service.

Precondition
FlashOpen() was called.
Parameters
[in]ui32SectorAddressThe start address of the sector to protect.
Returns
Returns the sector protection value (0 or 1) on success or FAPI_STATUS code on failure. If a PSA error occurs this will take precedence and a PSA_ERROR code will be returned instead.

§ FlashSectorErase()

uint32_t FlashSectorErase ( uint32_t  ui32SectorAddress)

Call FlashSectorErase API using Secure Flash Service.

Precondition
FlashOpen() was called.
Parameters
[in]ui32SectorAddressThe start address of the sector to erase.
Returns
Returns an FAPI_STATUS status code based on status of erase operation. If a PSA error occurs this will take precedence and a PSA_ERROR code will be returned instead.

§ FlashProgram()

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

Call FlashProgram API using Secure Flash Service.

Precondition
FlashOpen() was called.
Parameters
[in]pui8DataBufferPointer to the data to be programmed.
[in]ui32AddressStarting address in flash to be programmed.
[in]ui32CountNumber of bytes to be programmed.
Returns
Returns an FAPI_STATUS status code based on status of flash operation. If a PSA error occurs this will take precedence and a PSA_ERROR code will be returned instead.

§ FlashProgram4X()

uint32_t FlashProgram4X ( uint8_t *  pui8DataBuffer,
uint32_t  ui32Address,
uint32_t  ui32Count 
)

Call FlashProgram4X API using Secure Flash Service.

Precondition
FlashOpen() was called.
Parameters
[in]pui8DataBufferPointer to the data to be programmed.
[in]ui32AddressStarting address in flash to be programmed.
[in]ui32CountNumber of bytes to be programmed.
Returns
Returns an FAPI_STATUS status code based on status of flash operation. If a PSA error occurs this will take precedence and a PSA_ERROR code will be returned instead.

§ FlashSectorSizeGet()

uint32_t FlashSectorSizeGet ( void  )

Call FlashSectorSizeGet API using Secure Flash Service.

Precondition
FlashOpen() was called.
Returns
Returns the size of Flash Sector on success or an FAPI_STATUS status code on failure. Values greater than FAPI_STATUS_UNPROTECT_ERROR will be considered a valid Flash Sector size. If a PSA error occurs this will take precedence and a PSA_ERROR code will be returned instead.

§ FlashSizeGet()

uint32_t FlashSizeGet ( void  )

Call FlashSizeGet API using Secure Flash Service.

Precondition
FlashOpen() was called.
Returns
Returns the size of Flash on success or an FAPI_STATUS status code on failure. Values greater than FAPI_STATUS_UNPROTECT_ERROR will be considered a valid Flash size. If a PSA error occurs this will take precedence and a PSA_ERROR code will be returned instead.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale