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 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_FCCOB8
 
#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 FLASH_DRV_EraseResume function. More...
 
#define SUSPEND_WAIT_CNT   0x40U
 Suspend wait count used in FLASH_DRV_EraseSuspend 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...