mcu/drv/fsl_flash_driver_c90tfs.c
/*FUNCTION**********************************************************************
 *
 * Function Name : SetFlexRamFunction
 * Description   : This function is used to change the function of the FlexRAM. When not partitioned for
 * emulated EEPROM, the FlexRAM is typically used as traditional RAM.
 * Otherwise, the FlexRam is typically used to store EEPROM data, the writing to EEPROM is normal write or
 * quick write.
 * In addition, this function may be used to get EEPROM status or complete interrupted EEPROM quick write process.
 * For example, after partitioning to have EEPROM backup, FlexRAM is used for EEPROM
 * use accordingly and if want to change FlexRAM to traditional RAM for FlashProgramSection() use, call this API
 * with the function control code is 0xFFU.
 *
 * Implements    : SetFlexRamFunction_Activity
 *END**************************************************************************/
FUNCTION

Function Name : SetFlexRamFunction
Description   : This function is used to change the function of the FlexRAM. When not partitioned for
emulated EEPROM, the FlexRAM is typically used as traditional RAM.
Otherwise, the FlexRam is typically used to store EEPROM data, the writing to EEPROM is normal write or
quick write.
In addition, this function may be used to get EEPROM status or complete interrupted EEPROM quick write process.
For example, after partitioning to have EEPROM backup, FlexRAM is used for EEPROM
use accordingly and if want to change FlexRAM to traditional RAM for FlashProgramSection() use, call this API
with the function control code is 0xFFU.

Implements    : SetFlexRamFunction_Activity
END
FUNCTION Function Name : SetFlexRamFunction Description : This function is used to change the function of the FlexRAM . When not partitioned for emulated EEPROM the FlexRAM is typically used as traditional RAM . Otherwise the FlexRam is typically used to store EEPROM data the writing to EEPROM is normal write or quick write . In addition this function may be used to get EEPROM status or complete interrupted EEPROM quick write process . For example after partitioning to have EEPROM backup FlexRAM is used for EEPROM use accordingly and if want to change FlexRAM to traditional RAM for FlashProgramSection () use call this API with the function control code is 0xFFU . Implements : SetFlexRamFunction_Activity END
flash_drv_status_t SetFlexRamFunction(const flash_ssd_config_t * pSSDConfig, \
                                      flash_flexRam_function_control_code_t flexRamFuncCode, \
                                      uint16_t byteOfQuickWrite, \
                                      flash_eeprom_status_t * const pEEPROMStatus, \
                                      flash_command_sequence_t pFlashCommandSequence)
{
#ifdef DEV_ERROR_DETECT
    DEV_ASSERT(pSSDConfig != NULL);
    DEV_ASSERT(pFlashCommandSequence != NULL);
#endif
    flash_drv_status_t ret;    
    CLEAR_FTFx_FSTAT_ERROR_BITS;
    FTFx_FCCOB0 = FTFx_SET_EERAM;
    FTFx_FCCOB1 = (uint8_t)flexRamFuncCode;
    if (flexRamFuncCode == EEE_QUICK_WRITE)
    {
        FTFx_FCCOB4 = (uint8_t)(byteOfQuickWrite >> 0x8U);
        FTFx_FCCOB5 = (uint8_t)(byteOfQuickWrite & 0xFFU);
    }
    ret = pFlashCommandSequence(pSSDConfig);
    if ((flexRamFuncCode == EEE_STATUS_QUERY) && (ret == FTFx_OK))
    {
        if (pEEPROMStatus == NULL)
        {
            ret = FTFx_ERR_PARAM;
        }
        else
        {
            pEEPROMStatus->brownOutCode = FTFx_FCCOB5;
            pEEPROMStatus->sectorEraseCount = (uint16_t)FTFx_FCCOB8 << 8U;
            pEEPROMStatus->sectorEraseCount |= (uint16_t)FTFx_FCCOB9;
            pEEPROMStatus->numOfRecordReqMaintain = (uint16_t)FTFx_FCCOB6 << 8U;
            pEEPROMStatus->numOfRecordReqMaintain |= (uint16_t)FTFx_FCCOB7;
        }
    }
    return (ret);
}
flash_drv_status_t SetFlexRamFunction ( const flash_ssd_config_t * pSSDConfig , flash_flexRam_function_control_code_t flexRamFuncCode , uint16_t byteOfQuickWrite , flash_eeprom_status_t * const pEEPROMStatus , flash_command_sequence_t pFlashCommandSequence ) { #ifdef DEV_ERROR_DETECT DEV_ASSERT ( pSSDConfig != NULL ) ; DEV_ASSERT ( pFlashCommandSequence != NULL ) ; #endif flash_drv_status_t ret ; CLEAR_FTFx_FSTAT_ERROR_BITS ; FTFx_FCCOB0 = FTFx_SET_EERAM ; FTFx_FCCOB1 = ( uint8_t ) flexRamFuncCode ; if ( flexRamFuncCode == EEE_QUICK_WRITE ) { FTFx_FCCOB4 = ( uint8_t ) ( byteOfQuickWrite >> 0x8U ) ; FTFx_FCCOB5 = ( uint8_t ) ( byteOfQuickWrite & 0xFFU ) ; } ret = pFlashCommandSequence ( pSSDConfig ) ; if ( ( flexRamFuncCode == EEE_STATUS_QUERY ) && ( ret == FTFx_OK ) ) { if ( pEEPROMStatus == NULL ) { ret = FTFx_ERR_PARAM ; } else { pEEPROMStatus -> brownOutCode = FTFx_FCCOB5 ; pEEPROMStatus -> sectorEraseCount = ( uint16_t ) FTFx_FCCOB8 << 8U ; pEEPROMStatus -> sectorEraseCount |= ( uint16_t ) FTFx_FCCOB9 ; pEEPROMStatus -> numOfRecordReqMaintain = ( uint16_t ) FTFx_FCCOB6 << 8U ; pEEPROMStatus -> numOfRecordReqMaintain |= ( uint16_t ) FTFx_FCCOB7 ; } } return ( ret ) ; }
FUNCTION
FUNCTION
/* Return code variable */ /* Clear RDCOLERR & ACCERR & FPVIOL flag in flash status register. Write 1 to clear */ /* Passing parameter to the command */ /* Calling flash command sequence function to execute the command */