MCUSW
FLS Driver API

Introduction

The flash driver provides services for reading, writing and erasing flash memory.
The Flash Driver implements a standardized interface specified in the AUTOSAR_SWS_FlashDriver document.

Only the following combinations of modes are supported:

Following combinations of modes are not supported:

See also
FLS Configuration

Sub Modules

 FLS Configuration
 

FLS Driver Module SW Version Info

Defines for FLS Driver version used for compatibility checks

#define FLS_SW_MAJOR_VERSION   (12U)
 Driver Implementation Major Version. More...
 
#define FLS_SW_MINOR_VERSION   (0U)
 Driver Implementation Minor Version. More...
 
#define FLS_SW_PATCH_VERSION   (0U)
 Driver Implementation Patch Version. More...
 

FLS Driver Module AUTOSAR Version Info

Defines for FLS Driver AUTOSAR version used for compatibility checks

#define FLS_AR_RELEASE_MAJOR_VERSION   (4U)
 AUTOSAR Major version specification implemented by FLS Driver. More...
 
#define FLS_AR_RELEASE_MINOR_VERSION   (3U)
 AUTOSAR Minor version specification implemented by FLS Driver. More...
 
#define FLS_AR_RELEASE_REVISION_VERSION   (1U)
 AUTOSAR Patch version specification implemented by FLS Driver. More...
 

FLS Driver ID Info

typedef uint32 Fls_AddressType
 Type of address type. More...
 
typedef uint32 Fls_LengthType
 
#define FLS_VENDOR_ID   ((uint16) 44U)
 Texas Instruments Vendor ID. More...
 
#define FLS_MODULE_ID   ((uint16) 92U)
 FLS Driver Module ID. More...
 
#define FLS_INSTANCE_ID   ((uint8) 0U)
 FLS Driver Instance ID. More...
 

FLS Error Codes

Error codes returned by FLS functions

#define FLS_E_PARAM_CONFIG   ((uint8) 0x01U)
 API service called with wrong parameter. More...
 
#define FLS_E_PARAM_ADDRESS   ((uint8) 0x02U)
 API service called with wrong parameter. More...
 
#define FLS_E_PARAM_LENGTH   ((uint8) 0x03U)
 API service called with wrong parameter. More...
 
#define FLS_E_PARAM_DATA   ((uint8) 0x04U)
 API service called with wrong parameter. More...
 
#define FLS_E_UNINIT   ((uint8) 0x05U)
 API service used without module initiali-zation. More...
 
#define FLS_E_BUSY   ((uint8) 0x06U)
 APIs called when module is busy. More...
 
#define FLS_E_PARAM_POINTER   ((uint8) 0x0AU)
 APIs called with a Null Pointer. More...
 
#define FLS_E_VERIFY_ERASE_FAILED   ((uint8) 0x07U)
 APIs service Erase Verification (BlankCheck) failed. More...
 
#define FLS_E_VERIFY_WRITE_FAILED   ((uint8) 0x08U)
 APIs serice Write Verification (Compare) failed. More...
 
#define FLS_E_TIMEOUT   ((uint8) 0x09U)
 APIs Timeout Exceeded. More...
 
#define FLS_E_ERASE_FAILED   ((uint8) 0x01U)
 Flash Erase Failed in HW. More...
 
#define FLS_E_WRITE_FAILED   ((uint8) 0x02U)
 Flash Write Failed in HW. More...
 
#define FLS_E_READ_FAILED   ((uint8) 0x03U)
 Flash Read Failed in HW. More...
 
#define FLS_E_COMPARE_FAILED   ((uint8) 0x04U)
 Flash Compare Failediin HW. More...
 
#define FLS_E_UNEXPECTED_FLASH_ID   ((uint8) 0x05U)
 Expected HW ID not matched. More...
 

FLS Service Ids

The Service Id is one of the argument to Det_ReportError function and is used to identify the source of the error

#define FLS_SID_INIT   ((uint8) 0x00U)
 FLS_Init() API Service ID. More...
 
#define FLS_SID_ERASE   ((uint8) 0x01U)
 FLS_Erase() API Service ID. More...
 
#define FLS_SID_WRITE   ((uint8) 0x02U)
 FLS_Write() API Service ID. More...
 
#define FLS_SID_CANCEL   ((uint8) 0x03U)
 FLS_Cancel() API Service ID. More...
 
#define FLS_SID_GET_STATUS   ((uint8) 0x04U)
 FLS_GetStatus() API Service ID. More...
 
#define FLS_SID_GET_JOB_RESULT   ((uint8) 0x05U)
 Fls_GetJobResult() API Service ID. More...
 
#define FLS_SID_READ   ((uint8) 0x07U)
 FLS_Read() API Service ID. More...
 
#define FLS_SID_COMPARE   ((uint8) 0x08U)
 FLS_Compare() API Service ID. More...
 
#define FLS_SID_SET_MODE   ((uint8) 0x09U)
 FLS_SetMode() API Service ID. More...
 
#define FLS_SID_GET_VERSION_INFO   ((uint8) 0x10U)
 Fls_GetVersionInfo() API Service ID. More...
 
#define FLS_SID_BLANK_CHECK   ((uint8) 0x0AU)
 FLS_BlankCheck() API Service ID. More...
 
#define FLS_SID_MAIN_FUNCTION   ((uint8) 0x06U)
 FLS_MainFunction() API Service ID. More...
 
enum  OSPI_xferLines { OSPI_XFER_LINES_SINGLE = 0U, OSPI_XFER_LINES_DUAL, OSPI_XFER_LINES_QUAD, OSPI_XFER_LINES_OCTAL }
 Number of lines used for OSPI read/write transaction. More...
 
enum  FLASH_Protocol { FLS_OSPI = 0U, FLS_XSPI = 1U, FLS_QSPI = 2U }
 
const FlsNorDeviceConfig FlsNorDevice
 
boolean xipEnable
 
 AUTOMATIC
 
FLS_CONFIG_DATA ConfigPtr
 
Fls_LengthType Length
 
const uint8 * SourceAddressPtr
 
uint8 * TargetAddressPtr
 
SPI_APPL_DATA RegRbPtr
 
 FUNC (void, FLS_CODE) Fls_SwitchMode(boolean dacEnable
 Switch Mode of the OSPI Driver Parameters (in) : boolean dacEnable - should DAC mode be enaled or disabled Parameters (in) : boolean xipEnable - should XIP mode be enaled or disabled Mode : Supervisor Mode (Privileged Mode) More...
 
 FUNC (Std_ReturnType, FLS_CODE) Fls_Erase(Fls_AddressType TargetAddress
 Erases flash sector(s). More...
 
 FUNC (MemIf_StatusType, FLS_CODE) Fls_GetStatus(void)
 Returns the driver state. More...
 
 FUNC (MemIf_JobResultType, FLS_CODE) Fls_GetJobResult(void)
 Returns the result of the last job. More...
 
 FUNC (Std_ReturnType, SPI_CODE) Ospi_RegisterReadback(P2VAR(CSL_ospi_flash_cfgRegs
 This function reads the important registers of the hardware unit and returns the value in the structure. More...
 

Macro Definition Documentation

◆ FLS_SW_MAJOR_VERSION

#define FLS_SW_MAJOR_VERSION   (12U)

Driver Implementation Major Version.

◆ FLS_SW_MINOR_VERSION

#define FLS_SW_MINOR_VERSION   (0U)

Driver Implementation Minor Version.

◆ FLS_SW_PATCH_VERSION

#define FLS_SW_PATCH_VERSION   (0U)

Driver Implementation Patch Version.

◆ FLS_AR_RELEASE_MAJOR_VERSION

#define FLS_AR_RELEASE_MAJOR_VERSION   (4U)

AUTOSAR Major version specification implemented by FLS Driver.

◆ FLS_AR_RELEASE_MINOR_VERSION

#define FLS_AR_RELEASE_MINOR_VERSION   (3U)

AUTOSAR Minor version specification implemented by FLS Driver.

◆ FLS_AR_RELEASE_REVISION_VERSION

#define FLS_AR_RELEASE_REVISION_VERSION   (1U)

AUTOSAR Patch version specification implemented by FLS Driver.

◆ FLS_VENDOR_ID

#define FLS_VENDOR_ID   ((uint16) 44U)

Texas Instruments Vendor ID.

◆ FLS_MODULE_ID

#define FLS_MODULE_ID   ((uint16) 92U)

FLS Driver Module ID.

◆ FLS_INSTANCE_ID

#define FLS_INSTANCE_ID   ((uint8) 0U)

FLS Driver Instance ID.

◆ FLS_E_PARAM_CONFIG

#define FLS_E_PARAM_CONFIG   ((uint8) 0x01U)

API service called with wrong parameter.

◆ FLS_E_PARAM_ADDRESS

#define FLS_E_PARAM_ADDRESS   ((uint8) 0x02U)

API service called with wrong parameter.

◆ FLS_E_PARAM_LENGTH

#define FLS_E_PARAM_LENGTH   ((uint8) 0x03U)

API service called with wrong parameter.

◆ FLS_E_PARAM_DATA

#define FLS_E_PARAM_DATA   ((uint8) 0x04U)

API service called with wrong parameter.

◆ FLS_E_UNINIT

#define FLS_E_UNINIT   ((uint8) 0x05U)

API service used without module initiali-zation.

◆ FLS_E_BUSY

#define FLS_E_BUSY   ((uint8) 0x06U)

APIs called when module is busy.

◆ FLS_E_PARAM_POINTER

#define FLS_E_PARAM_POINTER   ((uint8) 0x0AU)

APIs called with a Null Pointer.

◆ FLS_E_VERIFY_ERASE_FAILED

#define FLS_E_VERIFY_ERASE_FAILED   ((uint8) 0x07U)

APIs service Erase Verification (BlankCheck) failed.

◆ FLS_E_VERIFY_WRITE_FAILED

#define FLS_E_VERIFY_WRITE_FAILED   ((uint8) 0x08U)

APIs serice Write Verification (Compare) failed.

◆ FLS_E_TIMEOUT

#define FLS_E_TIMEOUT   ((uint8) 0x09U)

APIs Timeout Exceeded.

◆ FLS_E_ERASE_FAILED

#define FLS_E_ERASE_FAILED   ((uint8) 0x01U)

Flash Erase Failed in HW.

◆ FLS_E_WRITE_FAILED

#define FLS_E_WRITE_FAILED   ((uint8) 0x02U)

Flash Write Failed in HW.

◆ FLS_E_READ_FAILED

#define FLS_E_READ_FAILED   ((uint8) 0x03U)

Flash Read Failed in HW.

◆ FLS_E_COMPARE_FAILED

#define FLS_E_COMPARE_FAILED   ((uint8) 0x04U)

Flash Compare Failediin HW.

◆ FLS_E_UNEXPECTED_FLASH_ID

#define FLS_E_UNEXPECTED_FLASH_ID   ((uint8) 0x05U)

Expected HW ID not matched.

◆ FLS_SID_INIT

#define FLS_SID_INIT   ((uint8) 0x00U)

FLS_Init() API Service ID.

◆ FLS_SID_ERASE

#define FLS_SID_ERASE   ((uint8) 0x01U)

FLS_Erase() API Service ID.

◆ FLS_SID_WRITE

#define FLS_SID_WRITE   ((uint8) 0x02U)

FLS_Write() API Service ID.

◆ FLS_SID_CANCEL

#define FLS_SID_CANCEL   ((uint8) 0x03U)

FLS_Cancel() API Service ID.

◆ FLS_SID_GET_STATUS

#define FLS_SID_GET_STATUS   ((uint8) 0x04U)

FLS_GetStatus() API Service ID.

◆ FLS_SID_GET_JOB_RESULT

#define FLS_SID_GET_JOB_RESULT   ((uint8) 0x05U)

Fls_GetJobResult() API Service ID.

◆ FLS_SID_READ

#define FLS_SID_READ   ((uint8) 0x07U)

FLS_Read() API Service ID.

◆ FLS_SID_COMPARE

#define FLS_SID_COMPARE   ((uint8) 0x08U)

FLS_Compare() API Service ID.

◆ FLS_SID_SET_MODE

#define FLS_SID_SET_MODE   ((uint8) 0x09U)

FLS_SetMode() API Service ID.

◆ FLS_SID_GET_VERSION_INFO

#define FLS_SID_GET_VERSION_INFO   ((uint8) 0x10U)

Fls_GetVersionInfo() API Service ID.

◆ FLS_SID_BLANK_CHECK

#define FLS_SID_BLANK_CHECK   ((uint8) 0x0AU)

FLS_BlankCheck() API Service ID.

◆ FLS_SID_MAIN_FUNCTION

#define FLS_SID_MAIN_FUNCTION   ((uint8) 0x06U)

FLS_MainFunction() API Service ID.

Typedef Documentation

◆ Fls_AddressType

typedef uint32 Fls_AddressType

Type of address type.

◆ Fls_LengthType

typedef uint32 Fls_LengthType

Enumeration Type Documentation

◆ OSPI_xferLines

Number of lines used for OSPI read/write transaction.

Enumerator
OSPI_XFER_LINES_SINGLE 

Single line is used

OSPI_XFER_LINES_DUAL 

Two lines are used

OSPI_XFER_LINES_QUAD 

Four lines are used

OSPI_XFER_LINES_OCTAL 

Four lines are used

◆ FLASH_Protocol

Enumerator
FLS_OSPI 

Ospi is used

FLS_XSPI 

Xspi used

FLS_QSPI 

QSPI used

Function Documentation

◆ FUNC() [1/5]

FUNC ( void  ,
FLS_CODE   
)

Switch Mode of the OSPI Driver Parameters (in) : boolean dacEnable - should DAC mode be enaled or disabled Parameters (in) : boolean xipEnable - should XIP mode be enaled or disabled Mode : Supervisor Mode (Privileged Mode)

Cancels an ongoing job.

Performs the processing of jobs.

Initializes the Flash Driver.

*  Service name        : Fls_Init
*  Syntax              : void Fls_Init( const Fls_ConfigType* ConfigPtr )
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x00
*  Sync/Async          : Synchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : ConfigPtr - Pointer to flash driver configuration set
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : None
*  Description         : Initializes the Flash Driver
*  
*  Service name        : Fls_MainFunction
*  Syntax              : void Fls_MainFunction(void)
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x06
*  Description         : Performs the processing of jobs.
*  
*  Service name        : Fls_Cancel
*  Syntax              : void Fls_Cancel(void)
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x03
*  Sync/Async          : Synchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : None
*  Description         : Cancels an ongoing job.
*  

◆ FUNC() [2/5]

FUNC ( Std_ReturnType  ,
FLS_CODE   
)

Erases flash sector(s).

This service returns the version information of this module.

The function Fls_BlankCheck shall verify, whether a given memory area has been erased but not (yet) programmed.

Compares the contents of an area of flash memory with that of an application data buffer.

Reads from flash memory..

Writes one or more complete flash pages.

*  Service name        : Fls_Erase
*  Syntax              : Std_ReturnType Fls_Erase(Fls_AddressType TargetAddress
*                        ,Fls_LengthType Length)
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x01
*  Sync/Async          : Asynchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : TargetAddress - Target address in flash memory.
*                        This address offset will be added to the flash memory
*                        base address.
*                        Length - Number of bytes to erase
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType -
*                        E_OK: erase command has been accepted
*                        E_NOT_OK: erase command has not been accepted
*  Description         : Erases flash sector(s).
*  
*  Service name        : Fls_Write
*  Syntax              : Std_ReturnType Fls_Write(Fls_AddressType TargetAddress
*                        ,const uint8* SourceAddressPtr,
*                        Fls_LengthType Length)
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x02
*  Sync/Async          : Asynchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : TargetAddress - Target address in flash memory.
*                        This address offset will be added to the flash memory
*                        base address.
*                        SourceAddressPtr - Pointer to source data buffer
*                        Length - Number of bytes to erase
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType -
*                        E_OK: write command has been accepted
*                        E_NOT_OK: write command has not been accepted
*  Description         : Writes one or more complete flash pages.
*  
*  Service name        : Fls_Read
*  Syntax              : Std_ReturnType Fls_Read((Fls_AddressType SourceAddress
*                        ,const uint8* TargetAddressPtr,
*                        Fls_LengthType Length)
*  Mode                : Supervisor Mode (Privileged Mode)
*  Service ID[hex]     : 0x07
*  Sync/Async          : Asynchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : SourceAddress - source address in flash memory.
*                        This address offset will be added to the flash memory
*                        base address.
*                        TargetAddressPtr - Pointer to source data buffer
*                        Length - Number of bytes to erase
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType -
*                        E_OK: read command has been accepted
*                        E_NOT_OK: read command has not been accepted
*  Description         : Reads from flash memory.
*  
*  Service name        : Fls_Compare
*  Syntax              : Std_ReturnType Fls_Compare
*                        (Fls_AddressType SourceAddress,
*                        const uint8* TargetAddressPtr,
*                        Fls_LengthType Length)
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x08
*  Sync/Async          : Asynchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : SourceAddress - Target address in flash memory.
*                        This address offset will be added to the flash memory
*                        base address.
*                        TargetAddressPtr - Pointer to source data buffer
*                        Length - Number of bytes to erase
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType -
*                        E_OK: compare command has been accepted
*                        E_NOT_OK: compare command has not been accepted
*  Description         : Compares the contents of an area of flash memory
*                        with that of an application data buffer.
*  
*  Service name        : Fls_BlankCheck
*  Syntax              : Std_ReturnType Fls_Compare
*                        (Fls_AddressType TargetAddress,,
*                        Fls_LengthType Length)
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x0a
*  Sync/Async          : Asynchronous
*  Reentrancy          : Non Reentrant
*  Parameters (in)     : TargetAddress - Target address in flash memory.
*                        This address offset will be added to the flash memory
*                        base address.
*                        SourceAddressPtr - Pointer to source data buffer
*                        Length - Number of bytes to erase
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : Std_ReturnType -
*                        E_OK: BlankCheck command has been accepted
*                        E_NOT_OK: BlankCheck command has not been accepted
*  Description         : The function Fls_BlankCheck shall verify,
*                        whether a given memory area has been
*                        erased but not (yet) programmed.
*  
*  Service name        : Fls_GetVersionInfo
*  Syntax              : void Fls_GetVersionInfo( Std_VersionInfoType*
*                                                                 versioninfo )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x10
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : versioninfo - Pointer to where to store the version
*                        information of this module
*  Parameters (out)    : None
*  Return value        : None
*  Description         : This service returns the version information of this
*                        module
*  

◆ FUNC() [3/5]

FUNC ( MemIf_StatusType  ,
FLS_CODE   
)

Returns the driver state.

*  Service name        : Fls_GetStatus
*  Syntax              : MemIf_StatusType Fls_GetStatus( void )
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x04
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : MemIf_StatusType
*  Description         : Returns the driver state.
*  

◆ FUNC() [4/5]

FUNC ( MemIf_JobResultType  ,
FLS_CODE   
)

Returns the result of the last job.

*  Service name        : Fls_GetJobResult
*  Syntax              : MemIf_JobResultType Fls_GetJobResult(void)
*  Mode                : User Mode (Non-Privileged Mode)
*  Service ID[hex]     : 0x05
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (in)     : None
*  Parameters (inout)  : None
*  Parameters (out)    : None
*  Return value        : MemIf_JobResultType
*  Description         : Returns the result of the last job.
*  

◆ FUNC() [5/5]

FUNC ( Std_ReturnType  ,
SPI_CODE   
)

This function reads the important registers of the hardware unit and returns the value in the structure.

This API should be called after Ospi_Init is called. Otherwise this API will return E_NOT_OK.

This API could be used to readback the register contents after Ospi_Init and then the readback value could be compared during SPI execution to check the correctness of the HW unit. Since this API is used for this purpose, the register returned are the ones which doesn't change after init based on job or channel config.

*  Service name        : Ospi_RegisterReadback
*  Mode                : Supervisor Mode (Privileged Mode)
*  Sync/Async          : Synchronous
*  Reentrancy          : Reentrant
*  Parameters (inout)  : RegRbPtr - Pointer to where to store the readback
*                        values. If this pointer is NULL_PTR, then the API
*                        will return E_NOT_OK.
*  Return value        : Std_ReturnType
*                        E_OK: Register read back has been done
*                        E_NOT_OK: Register read back failed
*  

Variable Documentation

◆ FlsNorDevice

const FlsNorDeviceConfig FlsNorDevice
extern

◆ xipEnable

boolean xipEnable

◆ AUTOMATIC

AUTOMATIC

◆ ConfigPtr

FLS_CONFIG_DATA ConfigPtr

◆ Length

◆ SourceAddressPtr

const uint8* SourceAddressPtr

◆ TargetAddressPtr

const uint8 * TargetAddressPtr

◆ RegRbPtr

SPI_APPL_DATA RegRbPtr