87 uint8_t DEPartitionCode)
109 #if (FEATURE_FLS_IS_FTFC == 0U)
117 uint8_t EEEDataSetSize)
154 #if FEATURE_FLS_HAS_FLEX_NVM
155 uint8_t DEPartitionCode;
164 #if FEATURE_FLS_HAS_FLEX_NVM
169 FLASH_DRV_GetDEPartitionCode(pSSDConfig, DEPartitionCode);
241 uint32_t reg0, reg1, reg2, reg3;
248 *protectStatus = (uint32_t)((reg0 << 24U) | (reg1 << 16U) | (reg2 << 8U) | reg3);
264 uint8_t reg0, reg1, reg2, reg3;
265 bool flag0, flag1, flag2, flag3;
286 if (flag0 || flag1 || flag2 || flag3)
345 const uint8_t * keyBuffer)
358 for (i = 0U; i < 8U; i++)
361 *(uint8_t *)temp = keyBuffer[i];
439 uint32_t tempSize = size;
441 #if FEATURE_FLS_HAS_FLEX_NVM
443 if ((dest >= temp) && (dest < (temp + pSSDConfig->
DFlashSize)))
445 dest += 0x800000U - temp;
452 if ((dest >= temp) && (dest < (temp + pSSDConfig->
PFlashSize)))
466 if ((tempSize & (sectorSize - 1U)) != 0U)
487 tempSize -= sectorSize;
512 #if FEATURE_FLS_HAS_FLEX_NVM
514 if ((dest >= temp) && (dest < (temp + pSSDConfig->
DFlashSize)))
516 dest += 0x800000U - temp;
522 if ((dest >= temp) && (dest < (temp + pSSDConfig->
PFlashSize)))
564 if ((
FTFx_FSTAT & FTFx_FSTAT_CCIF_MASK) == 0U)
568 while ((
FTFx_FSTAT & FTFx_FSTAT_CCIF_MASK) == 0U)
611 uint8_t * pDataArray)
636 pDataArray[i] = *(uint8_t *)temp;
654 const uint8_t * pDataArray)
672 *(uint8_t *)temp = pDataArray[i];
681 #if FEATURE_FLS_HAS_READ_RESOURCE_CMD
691 uint8_t * pDataArray,
692 uint8_t resourceSelectCode)
701 #if FEATURE_FLS_HAS_FLEX_NVM
703 if ((dest >= temp) && (dest < (temp + pSSDConfig->
DFlashSize)))
705 dest += 0x800000U - temp;
711 if ((dest >= temp) && (dest < (temp + pSSDConfig->
PFlashSize)))
740 pDataArray[i] = *(uint8_t *)temp;
762 const uint8_t * pData)
776 #if FEATURE_FLS_HAS_FLEX_NVM
778 if ((dest >= temp) && (dest < (temp + pSSDConfig->
DFlashSize)))
780 dest += 0x800000U - temp;
786 if ((dest >= temp) && (dest < (temp + pSSDConfig->
PFlashSize)))
802 #if (FEATURE_FLS_DF_BLOCK_WRITE_UNIT_SIZE == FTFx_PHRASE_SIZE)
814 *(uint8_t *)(temp) = pData[i];
845 const uint8_t * pExpectedData,
846 uint32_t * pFailAddr,
855 uint32_t tempSize = size;
865 #if FEATURE_FLS_HAS_FLEX_NVM
867 if ((dest >= offsetAddr) && (dest < (offsetAddr + pSSDConfig->
DFlashSize)))
869 dest += 0x800000U - offsetAddr;
875 if ((dest >= offsetAddr) && (dest < (offsetAddr + pSSDConfig->
PFlashSize)))
886 while (tempSize > 0U)
901 *(uint8_t *)(temp) = pExpectedData[i];
910 #if FEATURE_FLS_HAS_FLEX_NVM
911 if (dest >= 0x800000U)
913 *pFailAddr = dest + offsetAddr - 0x800000U;
918 *pFailAddr = dest + offsetAddr;
958 uint32_t counter = 0U;
961 uint32_t tempSize = size;
964 endAddress = dest + tempSize;
967 if ((dest < pSSDConfig->PFlashBase) || (endAddress > (pSSDConfig->
PFlashBase + pSSDConfig->
PFlashSize)))
969 #if FEATURE_FLS_HAS_FLEX_NVM
970 if ((dest < pSSDConfig->DFlashBase) || (endAddress > (pSSDConfig->
DFlashBase + pSSDConfig->
DFlashSize)))
975 #if FEATURE_FLS_HAS_FLEX_NVM
982 while (tempSize > 0U)
984 data = *(uint8_t *)(dest);
1007 #if FEATURE_FLS_HAS_PROGRAM_SECTION_CMD
1040 #if FEATURE_FLS_HAS_FLEX_NVM
1042 if ((dest >= temp) && (dest < (temp + pSSDConfig->
DFlashSize)))
1044 dest += 0x800000U - temp;
1050 if ((dest >= temp) && (dest < (temp + pSSDConfig->
PFlashSize)))
1083 #if FEATURE_FLS_HAS_ERASE_BLOCK_CMD
1101 #if FEATURE_FLS_HAS_FLEX_NVM
1103 if ((dest >= temp) && (dest < (temp + pSSDConfig->
DFlashSize)))
1105 dest += 0x800000U - temp;
1111 if ((dest >= temp) && (dest < (temp + pSSDConfig->
PFlashSize)))
1140 #if FEATURE_FLS_HAS_READ_1S_BLOCK_CMD
1152 uint8_t marginLevel)
1159 #if FEATURE_FLS_HAS_FLEX_NVM
1161 if ((dest >= temp) && (dest < (temp + pSSDConfig->
DFlashSize)))
1163 dest += 0x800000U - temp;
1169 if ((dest >= temp) && (dest < (temp + pSSDConfig->
PFlashSize)))
1199 #if FEATURE_FLS_HAS_FLEX_NVM
1280 uint16_t byteOfQuickWrite,
1295 FTFx_FCCOB4 = (uint8_t)(byteOfQuickWrite >> 0x8U);
1296 FTFx_FCCOB5 = (uint8_t)(byteOfQuickWrite & 0xFFU);
1304 if (pEEPROMStatus == NULL)
1327 static status_t FLASH_DRV_WaitEEWriteToFinish(uint32_t dest,
1328 const uint8_t * pData,
1337 *(uint8_t *)dest = *pData;
1342 temp = (uint32_t)(pData[1]) << 8U;
1343 temp |= (uint32_t)(pData[0]);
1344 *(
volatile uint16_t *)dest = (uint16_t)temp;
1349 temp = (uint32_t)(pData[3]) << 24U;
1350 temp |= (uint32_t)(pData[2]) << 16U;
1351 temp |= (uint32_t)(pData[1]) << 8U;
1352 temp |= (uint32_t)(pData[0]);
1353 *(
volatile uint32_t *)dest = temp;
1356 while (0U == (
FTFx_FCNFG & FTFx_FCNFG_EEERDY_MASK))
1392 const uint8_t * pData)
1400 if ((
FTFx_FCNFG & FTFx_FCNFG_EEERDY_MASK) == FTFx_FCNFG_EEERDY_MASK)
1403 if ((dest < pSSDConfig->EERAMBase) || ((dest + size) > (pSSDConfig->
EERAMBase + pSSDConfig->
EEESize)))
1411 if ((0U == (dest & 3U)) && (size >= 4U))
1415 else if ((0U == (dest & 1U)) && (size >= 2U))
1424 ret = FLASH_DRV_WaitEEWriteToFinish(dest, pData, i);
1452 uint8_t uEEEDataSizeCode,
1453 uint8_t uDEPartitionCode,
1454 uint8_t uCSEcKeySize,
1487 uint8_t * protectStatus)
1517 uint8_t protectStatus)
1544 #if FEATURE_FLS_HAS_PF_BLOCK_SWAP
1572 flash_swap_callback_t pSwapCallback)
1577 uint8_t currentSwapMode, currentSwapBlockStatus, nextSwapBlockStatus;
1579 currentSwapMode = 0xFFU;
1580 currentSwapBlockStatus = 0xFFU;
1581 nextSwapBlockStatus = 0xFFU;
1582 swapContinue =
false;
1585 ret = FLASH_DRV_PFlashSwapCtl(pSSDConfig, addr,
FTFx_SWAP_REPORT_STATUS, ¤tSwapMode, ¤tSwapBlockStatus, &nextSwapBlockStatus);
1595 ret = FLASH_DRV_PFlashSwapCtl(pSSDConfig,
1599 ¤tSwapBlockStatus,
1600 &nextSwapBlockStatus);
1606 ret = FLASH_DRV_PFlashSwapCtl(pSSDConfig,
1610 ¤tSwapBlockStatus,
1611 &nextSwapBlockStatus);
1621 if ((NULL_SWAP_CALLBACK != pSwapCallback) && (
STATUS_SUCCESS == ret))
1623 swapContinue = pSwapCallback(currentSwapMode);
1625 if (swapContinue ==
true)
1628 ret = FLASH_DRV_PFlashSwapCtl(pSSDConfig,
1632 ¤tSwapBlockStatus,
1633 &nextSwapBlockStatus);
1642 if ((NULL_SWAP_CALLBACK == pSwapCallback) && (
FTFx_SWAP_UPDATE == currentSwapMode))
1649 ret = FLASH_DRV_PFlashSwapCtl(pSSDConfig,
1653 ¤tSwapBlockStatus,
1654 &nextSwapBlockStatus);
1661 if (NULL_SWAP_CALLBACK == pSwapCallback)
1663 swapContinue =
true;
1667 swapContinue = pSwapCallback(currentSwapMode);
1670 if (swapContinue ==
true)
1673 ret = FLASH_DRV_PFlashSwapCtl(pSSDConfig,
1677 ¤tSwapBlockStatus,
1678 &nextSwapBlockStatus);
1696 uint8_t * pCurrentSwapMode,
1697 uint8_t * pCurrentSwapBlockStatus,
1698 uint8_t * pNextSwapBlockStatus)
1733 #if FEATURE_FLS_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD
#define FTFx_FCNFG_RAMRDY_MASK
#define FEATURE_FLS_PF_CHECK_CMD_ADDRESS_ALIGMENT
status_t FLASH_DRV_GetDFlashProtection(const flash_ssd_config_t *pSSDConfig, uint8_t *protectStatus)
D-Flash get protection.
#define FTFx_SWAP_SET_IN_COMPLETE
Set Swap in Complete State.
status_t FLASH_DRV_VerifyAllBlock(const flash_ssd_config_t *pSSDConfig, uint8_t marginLevel)
Flash verify all blocks.
#define NULL_CALLBACK
Null callback.
#define FTFx_FSEC_SEC_MASK
#define FEATURE_FLS_DF_SIZE_0010
#define FTFx_FSTAT_ACCERR_MASK
#define FTFx_VERIFY_BLOCK
#define FTFx_VERIFY_SECTION
uint16_t sectorEraseCount
#define FEATURE_FLS_PF_BLOCK_WRITE_UNIT_SIZE
#define FTFx_FCNFG_EEERDY_MASK
#define FEATURE_FLS_PF_BLOCK_SECTOR_SIZE
void FLASH_DRV_EraseResume(void)
Flash erase resume.
status_t FLASH_DRV_SetEERAMProtection(uint8_t protectStatus)
EERAM set protection.
flash_callback_t CallBack
#define FEATURE_FLS_EE_SIZE_1000
#define FEATURE_FLS_EE_SIZE_1010
#define FEATURE_FLS_DF_SIZE_0111
#define CLEAR_FTFx_FSTAT_ERROR_BITS
status_t FLASH_DRV_GetEERAMProtection(uint8_t *protectStatus)
EERAM get protection.
#define FTFx_SWAP_SET_IN_PREPARE
Set Swap in Update State.
#define FLASH_NOT_SECURE
Flash currently not in secure state.
void FLASH_DRV_EraseSuspend(void)
Flash erase suspend.
status_t FLASH_DRV_EEEWrite(const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size, const uint8_t *pData)
EEPROM Emulator Write.
#define FEATURE_FLS_EE_SIZE_1110
#define FTFx_PROGRAM_ONCE
#define FLASH_SECURE_BACKDOOR_DISABLED
Flash is secured and backdoor key access disabled.
status_t FLASH_DRV_EraseSector(const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size)
Flash erase sector.
#define GET_BIT_0_7(value)
#define FEATURE_FLS_EE_SIZE_0100
#define END_FUNCTION_DECLARATION_RAMSECTION
#define FTFx_FSTAT_RDCOLERR_MASK
#define FTFx_SWAP_UPDATE
Update swap mode.
#define FEATURE_FLS_EE_SIZE_1111
#define FLASH_CALLBACK_CS
Callback period count for FlashCheckSum.
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.
#define FTFx_PROGRAM_CHECK
#define FEATURE_FLS_EE_SIZE_0000
status_t FLASH_DRV_Init(const flash_user_config_t *const pUserConf, flash_ssd_config_t *const pSSDConfig)
Initializes Flash.
#define FTFx_SECURITY_BY_PASS
#define FEATURE_FLS_EE_SIZE_1001
#define FTFx_ERASE_ALL_BLOCK
#define FEATURE_FLS_EE_SIZE_0111
status_t FLASH_DRV_Program(const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size, const uint8_t *pData)
Flash program.
#define FTFx_ERASE_ALL_BLOCK_UNSECURE
#define FTFx_SWAP_REPORT_STATUS
Report Swap Status.
#define FTFx_SWAP_READY
Ready swap mode.
#define CSE_KEY_SIZE_CODE_MAX
status_t FLASH_DRV_VerifyBlock(const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint8_t marginLevel)
Flash verify block.
flash_flexRam_function_control_code_t
FlexRAM Function control Code.
#define FEATURE_FLS_EE_SIZE_0110
#define FEATURE_FLS_EE_SIZE_1100
#define FEATURE_FLS_DF_SIZE_1111
#define SIM_FCFG1_DEPART_SHIFT
#define FTFx_RSRC_CODE_REG
#define FEATURE_FLS_DF_SIZE_0011
#define FEATURE_FLS_DF_SIZE_0000
static START_FUNCTION_DECLARATION_RAMSECTION status_t FLASH_DRV_CommandSequence(const flash_ssd_config_t *pSSDConfig) END_FUNCTION_DECLARATION_RAMSECTION static void FLASH_DRV_GetDEPartitionCode(flash_ssd_config_t *const pSSDConfig
#define GET_BIT_8_15(value)
void FLASH_DRV_GetPFlashProtection(uint32_t *protectStatus)
P-Flash get protection.
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.
#define ENABLE_CHECK_RAMSECTION_FUNCTION_CALL
#define END_FUNCTION_DEFINITION_RAMSECTION
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.
#define FEATURE_FLS_DF_SIZE_0100
#define FEATURE_FLS_DF_SIZE_1101
#define FTFx_SWAP_SET_INDICATOR_ADDR
Initialize Swap System control code.
status_t FLASH_DRV_CheckSum(const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint32_t size, uint32_t *pSum)
Calculates check sum.
#define FTFx_FSTAT_FPVIOL_MASK
#define FEATURE_FLS_DF_SIZE_0101
#define FEATURE_FLS_FLEX_RAM_SIZE
#define FTFx_PROGRAM_LONGWORD
#define GET_BIT_24_31(value)
#define START_FUNCTION_DECLARATION_RAMSECTION
Places a function in RAM.
status_t FLASH_DRV_SetDFlashProtection(const flash_ssd_config_t *pSSDConfig, uint8_t protectStatus)
D-Flash set protection.
status_t FLASH_DRV_EraseBlock(const flash_ssd_config_t *pSSDConfig, uint32_t dest)
Flash erase block.
#define FEATURE_FLS_DF_BLOCK_SECTOR_SIZE
#define FLASH_SECURITY_STATE_UNSECURED
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
status_t FLASH_DRV_ProgramSection(const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint16_t number)
Flash program section.
#define FEATURE_FLS_DF_SIZE_0110
#define FTFx_FSEC_KEYEN_MASK
#define FTFx_FSTAT_CCIF_MASK
#define START_FUNCTION_DEFINITION_RAMSECTION
#define FEATURE_FLS_DF_SIZE_1011
uint16_t numOfRecordReqMaintain
status_t FLASH_DRV_SetPFlashProtection(uint32_t protectStatus)
P-Flash set protection.
#define DISABLE_CHECK_RAMSECTION_FUNCTION_CALL
#define FTFx_SWAP_UPDATE_ERASED
Update-Erased swap mode.
#define FTFx_PROGRAM_PHRASE
#define FTFx_READ_RESOURCE
status_t FLASH_DRV_VerifySection(const flash_ssd_config_t *pSSDConfig, uint32_t dest, uint16_t number, uint8_t marginLevel)
Flash verify section.
#define FTFx_FSTAT_MGSTAT0_MASK
status_t FLASH_DRV_ReadOnce(const flash_ssd_config_t *pSSDConfig, uint8_t recordIndex, uint8_t *pDataArray)
Flash read once.
#define FTFx_VERIFY_ALL_BLOCK
#define FEATURE_FLS_DF_SIZE_1001
#define FTFx_PROGRAM_SECTION
Flash SSD Configuration Structure.
#define FTFx_FCNFG_ERSSUSP_MASK
#define FEATURE_FLS_DF_SIZE_0001
status_t FLASH_DRV_EraseAllBlock(const flash_ssd_config_t *pSSDConfig)
Flash erase all blocks.
#define FEATURE_FLS_EE_SIZE_0001
#define FTFx_ERASE_SECTOR
#define SIM_FCFG1_DEPART_MASK
#define FEATURE_FLS_DF_SIZE_1000
#define FEATURE_FLS_EE_SIZE_1101
#define FLASH_SECURE_BACKDOOR_ENABLED
Flash is secured and backdoor key access enabled.
#define FEATURE_FLS_EE_SIZE_1011
#define FEATURE_FLS_DF_BLOCK_SIZE
#define GET_BIT_16_23(value)
#define RESUME_WAIT_CNT
Resume wait count used in FlashResume function.
#define FTFx_SWAP_UNINIT
Uninitialized swap mode.
status_t FLASH_DRV_EraseAllBlockUnsecure(const flash_ssd_config_t *pSSDConfig)
Flash erase all blocks unsecure.
Flash User Configuration Structure.
#define FEATURE_FLS_EE_SIZE_0011
#define FEATURE_FLS_DF_SIZE_1110
status_t FLASH_DRV_SecurityBypass(const flash_ssd_config_t *pSSDConfig, const uint8_t *keyBuffer)
Flash security bypass.
#define FEATURE_FLS_EE_SIZE_0010
#define FEATURE_FLS_DF_SIZE_1010
#define FTFx_PROGRAM_PARTITION
status_t FLASH_DRV_ProgramOnce(const flash_ssd_config_t *pSSDConfig, uint8_t recordIndex, const uint8_t *pDataArray)
Flash program once.
#define FEATURE_FLS_DF_SIZE_1100
void FLASH_DRV_GetSecurityState(uint8_t *securityState)
Flash get security state.
#define FEATURE_FLS_EE_SIZE_0101