S32 SDK
flash_driver.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include "status.h"
#include "device_registers.h"

Go to the source code of this file.

Data Structures

struct  flash_user_config_t
 Flash User Configuration Structure. More...
 
struct  flash_ssd_config_t
 Flash SSD Configuration Structure. More...
 
struct  flash_eeprom_status_t
 EEPROM status structure. More...
 

Macros

#define FTFx_BASE   FTFC_BASE
 
#define FTFx_FSTAT   FTFC->FSTAT
 
#define FTFx_FCNFG   FTFC->FCNFG
 
#define FTFx_FSEC   FTFC->FSEC
 
#define FTFx_FOPT   FTFC->FOPT
 
#define FTFx_FCCOB3   FTFC->FCCOB[0]
 
#define FTFx_FCCOB2   FTFC->FCCOB[1]
 
#define FTFx_FCCOB1   FTFC->FCCOB[2]
 
#define FTFx_FCCOB0   FTFC->FCCOB[3]
 
#define FTFx_FCCOB7   FTFC->FCCOB[4]
 
#define FTFx_FCCOB6   FTFC->FCCOB[5]
 
#define FTFx_FCCOB5   FTFC->FCCOB[6]
 
#define FTFx_FCCOB4   FTFC->FCCOB[7]
 
#define FTFx_FCCOBB   FTFC->FCCOB[8]
 
#define FTFx_FCCOBA   FTFC->FCCOB[9]
 
#define FTFx_FCCOB9   FTFC->FCCOB[10]
 
#define FTFx_FCCOB8   FTFC->FCCOB[11]
 
#define FTFx_FPROT3   FTFC->FPROT[0]
 
#define FTFx_FPROT2   FTFC->FPROT[1]
 
#define FTFx_FPROT1   FTFC->FPROT[2]
 
#define FTFx_FPROT0   FTFC->FPROT[3]
 
#define FTFx_FEPROT   FTFC->FEPROT
 
#define FTFx_FDPROT   FTFC->FDPROT
 
#define FTFx_FCSESTAT   FTFC->FCSESTAT
 
#define FTFx_FSTAT_MGSTAT0_MASK   FTFC_FSTAT_MGSTAT0_MASK
 
#define FTFx_FSTAT_MGSTAT0_SHIFT   FTFC_FSTAT_MGSTAT0_SHIFT
 
#define FTFx_FSTAT_MGSTAT0_WIDTH   FTFC_FSTAT_MGSTAT0_WIDTH
 
#define FTFx_FSTAT_MGSTAT0(x)    FTFC_FSTAT_MGSTAT0(x)
 
#define FTFx_FSTAT_FPVIOL_MASK   FTFC_FSTAT_FPVIOL_MASK
 
#define FTFx_FSTAT_FPVIOL_SHIFT   FTFC_FSTAT_FPVIOL_SHIFT
 
#define FTFx_FSTAT_FPVIOL_WIDTH   FTFC_FSTAT_FPVIOL_WIDTH
 
#define FTFx_FSTAT_FPVIOL(x)    FTFC_FSTAT_FPVIOL(x)
 
#define FTFx_FSTAT_ACCERR_MASK   FTFC_FSTAT_ACCERR_MASK
 
#define FTFx_FSTAT_ACCERR_SHIFT   FTFC_FSTAT_ACCERR_SHIFT
 
#define FTFx_FSTAT_ACCERR_WIDTH   FTFC_FSTAT_ACCERR_WIDTH
 
#define FTFx_FSTAT_ACCERR(x)    FTFC_FSTAT_ACCERR(x)
 
#define FTFx_FSTAT_RDCOLERR_MASK   FTFC_FSTAT_RDCOLERR_MASK
 
#define FTFx_FSTAT_RDCOLERR_SHIFT   FTFC_FSTAT_RDCOLERR_SHIFT
 
#define FTFx_FSTAT_RDCOLERR_WIDTH   FTFC_FSTAT_RDCOLERR_WIDTH
 
#define FTFx_FSTAT_RDCOLERR(x)    FTFC_FSTAT_RDCOLERR(x)
 
#define FTFx_FSTAT_CCIF_MASK   FTFC_FSTAT_CCIF_MASK
 
#define FTFx_FSTAT_CCIF_SHIFT   FTFC_FSTAT_CCIF_SHIFT
 
#define FTFx_FSTAT_CCIF_WIDTH   FTFC_FSTAT_CCIF_WIDTH
 
#define FTFx_FSTAT_CCIF(x)    FTFC_FSTAT_CCIF(x)
 
#define FTFx_FCNFG_EEERDY_MASK   FTFC_FCNFG_EEERDY_MASK
 
#define FTFx_FCNFG_EEERDY_SHIFT   FTFC_FCNFG_EEERDY_SHIFT
 
#define FTFx_FCNFG_EEERDY_WIDTH   FTFC_FCNFG_EEERDY_WIDTH
 
#define FTFx_FCNFG_EEERDY(x)    FTFC_FCNFG_EEERDY(x)
 
#define FTFx_FCNFG_RAMRDY_MASK   FTFC_FCNFG_RAMRDY_MASK
 
#define FTFx_FCNFG_RAMRDY_SHIFT   FTFC_FCNFG_RAMRDY_SHIFT
 
#define FTFx_FCNFG_RAMRDY_WIDTH   FTFC_FCNFG_RAMRDY_WIDTH
 
#define FTFx_FCNFG_RAMRDY(x)    FTFC_FCNFG_RAMRDY(x)
 
#define FTFx_FCNFG_ERSSUSP_MASK   FTFC_FCNFG_ERSSUSP_MASK
 
#define FTFx_FCNFG_ERSSUSP_SHIFT   FTFC_FCNFG_ERSSUSP_SHIFT
 
#define FTFx_FCNFG_ERSSUSP_WIDTH   FTFC_FCNFG_ERSSUSP_WIDTH
 
#define FTFx_FCNFG_ERSSUSP(x)    FTFC_FCNFG_ERSSUSP(x)
 
#define FTFx_FCNFG_ERSAREQ_MASK   FTFC_FCNFG_ERSAREQ_MASK
 
#define FTFx_FCNFG_ERSAREQ_SHIFT   FTFC_FCNFG_ERSAREQ_SHIFT
 
#define FTFx_FCNFG_ERSAREQ_WIDTH   FTFC_FCNFG_ERSAREQ_WIDTH
 
#define FTFx_FCNFG_ERSAREQ(x)    FTFC_FCNFG_ERSAREQ(x)
 
#define FTFx_FCNFG_RDCOLLIE_MASK   FTFC_FCNFG_RDCOLLIE_MASK
 
#define FTFx_FCNFG_RDCOLLIE_SHIFT   FTFC_FCNFG_RDCOLLIE_SHIFT
 
#define FTFx_FCNFG_RDCOLLIE_WIDTH   FTFC_FCNFG_RDCOLLIE_WIDTH
 
#define FTFx_FCNFG_RDCOLLIE(x)    FTFC_FCNFG_RDCOLLIE(x)
 
#define FTFx_FCNFG_CCIE_MASK   FTFC_FCNFG_CCIE_MASK
 
#define FTFx_FCNFG_CCIE_SHIFT   FTFC_FCNFG_CCIE_SHIFT
 
#define FTFx_FCNFG_CCIE_WIDTH   FTFC_FCNFG_CCIE_WIDTH
 
#define FTFx_FCNFG_CCIE(x)    FTFC_FCNFG_CCIE(x)
 
#define FTFx_FSEC_SEC_MASK   FTFC_FSEC_SEC_MASK
 
#define FTFx_FSEC_SEC_SHIFT   FTFC_FSEC_SEC_SHIFT
 
#define FTFx_FSEC_SEC_WIDTH   FTFC_FSEC_SEC_WIDTH
 
#define FTFx_FSEC_SEC(x)    FTFC_FSEC_SEC(x)
 
#define FTFx_FSEC_FSLACC_MASK   FTFC_FSEC_FSLACC_MASK
 
#define FTFx_FSEC_FSLACC_SHIFT   FTFC_FSEC_FSLACC_SHIFT
 
#define FTFx_FSEC_FSLACC_WIDTH   FTFC_FSEC_FSLACC_WIDTH
 
#define FTFx_FSEC_FSLACC(x)    FTFC_FSEC_FSLACC(x)
 
#define FTFx_FSEC_MEEN_MASK   FTFC_FSEC_MEEN_MASK
 
#define FTFx_FSEC_MEEN_SHIFT   FTFC_FSEC_MEEN_SHIFT
 
#define FTFx_FSEC_MEEN_WIDTH   FTFC_FSEC_MEEN_WIDTH
 
#define FTFx_FSEC_MEEN(x)    FTFC_FSEC_MEEN(x)
 
#define FTFx_FSEC_KEYEN_MASK   FTFC_FSEC_KEYEN_MASK
 
#define FTFx_FSEC_KEYEN_SHIFT   FTFC_FSEC_KEYEN_SHIFT
 
#define FTFx_FSEC_KEYEN_WIDTH   FTFC_FSEC_KEYEN_WIDTH
 
#define FTFx_FSEC_KEYEN(x)    FTFC_FSEC_KEYEN(x)
 
#define FTFx_FOPT_OPT_MASK   FTFC_FOPT_OPT_MASK
 
#define FTFx_FOPT_OPT_SHIFT   FTFC_FOPT_OPT_SHIFT
 
#define FTFx_FOPT_OPT_WIDTH   FTFC_FOPT_OPT_WIDTH
 
#define FTFx_FOPT_OPT(x)    FTFC_FOPT_OPT(x)
 
#define FTFx_FCCOB_CCOBn_MASK   FTFC_FCCOB_CCOBn_MASK
 
#define FTFx_FCCOB_CCOBn_SHIFT   FTFC_FCCOB_CCOBn_SHIFT
 
#define FTFx_FCCOB_CCOBn_WIDTH   FTFC_FCCOB_CCOBn_WIDTH
 
#define FTFx_FCCOB_CCOBn(x)    FTFC_FCCOB_CCOBn(x)
 
#define FTFx_FPROT_PROT_MASK   FTFC_FPROT_PROT_MASK
 
#define FTFx_FPROT_PROT_SHIFT   FTFC_FPROT_PROT_SHIFT
 
#define FTFx_FPROT_PROT_WIDTH   FTFC_FPROT_PROT_WIDTH
 
#define FTFx_FPROT_PROT(x)    FTFC_FPROT_PROT(x)
 
#define FTFx_FEPROT_EPROT_MASK   FTFC_FEPROT_EPROT_MASK
 
#define FTFx_FEPROT_EPROT_SHIFT   FTFC_FEPROT_EPROT_SHIFT
 
#define FTFx_FEPROT_EPROT_WIDTH   FTFC_FEPROT_EPROT_WIDTH
 
#define FTFx_FEPROT_EPROT(x)    FTFC_FEPROT_EPROT(x)
 
#define FTFx_FDPROT_DPROT_MASK   FTFC_FDPROT_DPROT_MASK
 
#define FTFx_FDPROT_DPROT_SHIFT   FTFC_FDPROT_DPROT_SHIFT
 
#define FTFx_FDPROT_DPROT_WIDTH   FTFC_FDPROT_DPROT_WIDTH
 
#define FTFx_FDPROT_DPROT(x)    FTFC_FDPROT_DPROT(x)
 
#define FTFX_FCSESTAT_IDB_MASK   FTFC_FCSESTAT_IDB_MASK
 
#define FTFX_FCSESTAT_IDB_SHIFT   FTFC_FCSESTAT_IDB_SHIFT
 
#define FTFX_FCSESTAT_IDB_WIDTH   FTFC_FCSESTAT_IDB_WIDTH
 
#define FTFX_FCSESTAT_IDB(x)    FTFC_FCSESTAT_IDB(x)
 
#define FTFX_FCSESTAT_EDB_MASK   FTFC_FCSESTAT_EDB_MASK
 
#define FTFX_FCSESTAT_EDB_SHIFT   FTFC_FCSESTAT_EDB_SHIFT
 
#define FTFX_FCSESTAT_EDB_WIDTH   FTFC_FCSESTAT_EDB_WIDTH
 
#define FTFX_FCSESTAT_EDB(x)    FTFC_FCSESTAT_EDB(x)
 
#define FTFX_FCSESTAT_RIN_MASK   FTFC_FCSESTAT_RIN_MASK
 
#define FTFX_FCSESTAT_RIN_SHIFT   FTFC_FCSESTAT_RIN_SHIFT
 
#define FTFX_FCSESTAT_RIN_WIDTH   FTFC_FCSESTAT_RIN_WIDTH
 
#define FTFX_FCSESTAT_RIN(x)    FTFC_FCSESTAT_RIN(x)
 
#define FTFX_FCSESTAT_BOK_MASK   FTFC_FCSESTAT_BOK_MASK
 
#define FTFX_FCSESTAT_BOK_SHIFT   FTFC_FCSESTAT_BOK_SHIFT
 
#define FTFX_FCSESTAT_BOK_WIDTH   FTFC_FCSESTAT_BOK_WIDTH
 
#define FTFX_FCSESTAT_BOK(x)    FTFC_FCSESTAT_BOK(x)
 
#define FTFX_FCSESTAT_BFN_MASK   FTFC_FCSESTAT_BFN_MASK
 
#define FTFX_FCSESTAT_BFN_SHIFT   FTFC_FCSESTAT_BFN_SHIFT
 
#define FTFX_FCSESTAT_BFN_WIDTH   FTFC_FCSESTAT_BFN_WIDTH
 
#define FTFX_FCSESTAT_BFN(x)    FTFC_FCSESTAT_BFN(x)
 
#define FTFX_FCSESTAT_BIN_MASK   FTFC_FCSESTAT_BIN_MASK
 
#define FTFX_FCSESTAT_BIN_SHIFT   FTFC_FCSESTAT_BIN_SHIFT
 
#define FTFX_FCSESTAT_BIN_WIDTH   FTFC_FCSESTAT_BIN_WIDTH
 
#define FTFX_FCSESTAT_BIN(x)    FTFC_FCSESTAT_BIN(x)
 
#define FTFX_FCSESTAT_SB_MASK   FTFC_FCSESTAT_SB_MASK
 
#define FTFX_FCSESTAT_SB_SHIFT   FTFC_FCSESTAT_SB_SHIFT
 
#define FTFX_FCSESTAT_SB_WIDTH   FTFC_FCSESTAT_SB_WIDTH
 
#define FTFX_FCSESTAT_SB(x)    FTFC_FCSESTAT_SB(x)
 
#define FTFX_FCSESTAT_BSY_MASK   FTFC_FCSESTAT_BSY_MASK
 
#define FTFX_FCSESTAT_BSY_SHIFT   FTFC_FCSESTAT_BSY_SHIFT
 
#define FTFX_FCSESTAT_BSY_WIDTH   FTFC_FCSESTAT_BSY_WIDTH
 
#define FTFX_FCSESTAT_BSY(x)    FTFC_FCSESTAT_BSY(x)
 
#define CLEAR_FTFx_FSTAT_ERROR_BITS   FTFx_FSTAT = (uint8_t)(FTFx_FSTAT_FPVIOL_MASK | FTFx_FSTAT_ACCERR_MASK | FTFx_FSTAT_RDCOLERR_MASK)
 
#define FTFx_WORD_SIZE   0x0002U
 
#define FTFx_LONGWORD_SIZE   0x0004U
 
#define FTFx_PHRASE_SIZE   0x0008U
 
#define FTFx_DPHRASE_SIZE   0x0010U
 
#define FTFx_RSRC_CODE_REG   FTFx_FCCOB4
 
#define FTFx_VERIFY_BLOCK   0x00U
 
#define FTFx_VERIFY_SECTION   0x01U
 
#define FTFx_PROGRAM_CHECK   0x02U
 
#define FTFx_READ_RESOURCE   0x03U
 
#define FTFx_PROGRAM_LONGWORD   0x06U
 
#define FTFx_PROGRAM_PHRASE   0x07U
 
#define FTFx_ERASE_BLOCK   0x08U
 
#define FTFx_ERASE_SECTOR   0x09U
 
#define FTFx_PROGRAM_SECTION   0x0BU
 
#define FTFx_VERIFY_ALL_BLOCK   0x40U
 
#define FTFx_READ_ONCE   0x41U
 
#define FTFx_PROGRAM_ONCE   0x43U
 
#define FTFx_ERASE_ALL_BLOCK   0x44U
 
#define FTFx_SECURITY_BY_PASS   0x45U
 
#define FTFx_PFLASH_SWAP   0x46U
 
#define FTFx_ERASE_ALL_BLOCK_UNSECURE   0x49U
 
#define FTFx_PROGRAM_PARTITION   0x80U
 
#define FTFx_SET_EERAM   0x81U
 
#define RESUME_WAIT_CNT   0x20U
 Resume wait count used in FlashResume function. More...
 
#define DFLASH_IFR_READRESOURCE_ADDRESS   0x8000FCU
 
#define GET_BIT_0_7(value)    ((uint8_t)(((uint32_t)(value)) & 0xFFU))
 
#define GET_BIT_8_15(value)   ((uint8_t)((((uint32_t)(value)) >> 8) & 0xFFU))
 
#define GET_BIT_16_23(value)   ((uint8_t)((((uint32_t)(value)) >> 16) & 0xFFU))
 
#define GET_BIT_24_31(value)   ((uint8_t)(((uint32_t)(value)) >> 24))
 
#define FLASH_SECURITY_STATE_KEYEN   0x80U
 
#define FLASH_SECURITY_STATE_UNSECURED   0x02U
 
#define CSE_KEY_SIZE_CODE_MAX   0x03U
 
#define FLASH_CALLBACK_CS   0x0AU
 Callback period count for FlashCheckSum. More...
 
PFlash swap control codes
#define FTFx_SWAP_SET_INDICATOR_ADDR   0x01U
 Initialize Swap System control code. More...
 
#define FTFx_SWAP_SET_IN_PREPARE   0x02U
 Set Swap in Update State. More...
 
#define FTFx_SWAP_SET_IN_COMPLETE   0x04U
 Set Swap in Complete State. More...
 
#define FTFx_SWAP_REPORT_STATUS   0x08U
 Report Swap Status. More...
 
PFlash swap states
#define FTFx_SWAP_UNINIT   0x00U
 Uninitialized swap mode. More...
 
#define FTFx_SWAP_READY   0x01U
 Ready swap mode. More...
 
#define FTFx_SWAP_UPDATE   0x02U
 Update swap mode. More...
 
#define FTFx_SWAP_UPDATE_ERASED   0x03U
 Update-Erased swap mode. More...
 
#define FTFx_SWAP_COMPLETE   0x04U
 Complete swap mode. More...
 
Flash security status
#define FLASH_NOT_SECURE   0x01U
 Flash currently not in secure state. More...
 
#define FLASH_SECURE_BACKDOOR_ENABLED   0x02U
 Flash is secured and backdoor key access enabled. More...
 
#define FLASH_SECURE_BACKDOOR_DISABLED   0x04U
 Flash is secured and backdoor key access disabled. More...
 
Null Callback function definition
#define NULL_CALLBACK   ((flash_callback_t)0xFFFFFFFFU)
 Null callback. More...
 

Typedefs

typedef void(* flash_callback_t) (void)
 Call back function pointer data type. More...
 

Enumerations

enum  flash_flexRam_function_control_code_t {
  EEE_ENABLE = 0x00U, EEE_QUICK_WRITE = 0x55U, EEE_STATUS_QUERY = 0x77U, EEE_COMPLETE_INTERRUPT_QUICK_WRITE = 0xAAU,
  EEE_DISABLE = 0xFFU
}
 FlexRAM Function control Code. More...
 

Functions

Flash driver APIs
status_t FLASH_DRV_Init (const flash_user_config_t *const pUserConf, flash_ssd_config_t *const pSSDConfig)
 Initializes Flash. More...
 
void FLASH_DRV_GetPFlashProtection (uint32_t *protectStatus)
 P-Flash get protection. More...
 
status_t FLASH_DRV_SetPFlashProtection (uint32_t protectStatus)
 P-Flash set protection. More...
 
void FLASH_DRV_GetSecurityState (uint8_t *securityState)
 Flash get security state. More...
 
status_t FLASH_DRV_SecurityBypass (const flash_ssd_config_t *pSSDConfig, const uint8_t *keyBuffer)
 Flash security bypass. More...
 
status_t FLASH_DRV_EraseAllBlock (const flash_ssd_config_t *pSSDConfig)
 Flash erase all blocks. More...
 
status_t FLASH_DRV_VerifyAllBlock (const flash_ssd_config_t *pSSDConfig, uint8_t marginLevel)
 Flash verify all blocks. More...
 
status_t FLASH_DRV_EraseSector (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size)
 Flash erase sector. More...
 
status_t FLASH_DRV_VerifySection (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint16_t number, uint8_t marginLevel)
 Flash verify section. More...
 
void FLASH_DRV_EraseSuspend (void)
 Flash erase suspend. More...
 
void FLASH_DRV_EraseResume (void)
 Flash erase resume. More...
 
status_t FLASH_DRV_ReadOnce (const flash_ssd_config_t *pSSDConfig, uint8_t recordIndex, uint8_t *pDataArray)
 Flash read once. More...
 
status_t FLASH_DRV_ProgramOnce (const flash_ssd_config_t *pSSDConfig, uint8_t recordIndex, const uint8_t *pDataArray)
 Flash program once. More...
 
status_t FLASH_DRV_Program (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size, const uint8_t *pData)
 Flash program. More...
 
status_t FLASH_DRV_ProgramCheck (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size, const uint8_t *pExpectedData, uint32_t *pFailAddr, uint8_t marginLevel)
 Flash program check. More...
 
status_t FLASH_DRV_CheckSum (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size, uint32_t *pSum)
 Calculates check sum. More...
 
status_t FLASH_DRV_ProgramSection (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint16_t number)
 Flash program section. More...
 
status_t FLASH_DRV_EraseBlock (const flash_ssd_config_t *pSSDConfig, uint32_t dest)
 Flash erase block. More...
 
status_t FLASH_DRV_VerifyBlock (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint8_t marginLevel)
 Flash verify block. More...
 
status_t FLASH_DRV_GetEERAMProtection (uint8_t *protectStatus)
 EERAM get protection. More...
 
status_t FLASH_DRV_SetEERAMProtection (uint8_t protectStatus)
 EERAM set protection. More...
 
status_t FLASH_DRV_SetFlexRamFunction (const flash_ssd_config_t *pSSDConfig, flash_flexRam_function_control_code_t flexRamFuncCode, uint16_t byteOfQuickWrite, flash_eeprom_status_t *const pEEPROMStatus)
 Set FlexRAM function. More...
 
status_t FLASH_DRV_EEEWrite (const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size, const uint8_t *pData)
 EEPROM Emulator Write. More...
 
status_t FLASH_DRV_DEFlashPartition (const flash_ssd_config_t *pSSDConfig, uint8_t uEEEDataSizeCode, uint8_t uDEPartitionCode, uint8_t uCSEcKeySize, bool uSFE)
 Flash D/E-Flash Partition. More...
 
status_t FLASH_DRV_GetDFlashProtection (const flash_ssd_config_t *pSSDConfig, uint8_t *protectStatus)
 D-Flash get protection. More...
 
status_t FLASH_DRV_SetDFlashProtection (const flash_ssd_config_t *pSSDConfig, uint8_t protectStatus)
 D-Flash set protection. More...
 
status_t FLASH_DRV_EraseAllBlockUnsecure (const flash_ssd_config_t *pSSDConfig)
 Flash erase all blocks unsecure. More...