mcu/drv/fsl_flash_driver_c90tfs.c
/*FUNCTION**********************************************************************
 *
 * Function Name : EEEWrite
 * Description   : Write data to FlexRAM section which is partitioned
 * as EEPROM use for EEPROM operation. After data has been written to EEPROM
 * use section of FlexRAM, the EEPROM file system will create new data record
 * in EEPROM back-up area of FlexNVM in round-robin fashion.
 * There is no alignment constraint for destination and size parameters
 * provided by user. However, according to user's input provided, this
 * API will set priority to write to FlexRAM with following rules:
 * 32-bit writing is invoked if destination is 32 bit aligned and size
 * is not less than 32 bits.
 * 16-bit writing is invoked if destination is 16 bit aligned and size
 * is not less than 16 bits.
 * 8-bit writing is invoked if destination is 8 bit aligned and size
 * is not less than 8 bits.
 *
 * Implements    : EEEWrite_Activity
 *END**************************************************************************/
FUNCTION

Function Name : EEEWrite
Description   : Write data to FlexRAM section which is partitioned
as EEPROM use for EEPROM operation. After data has been written to EEPROM
use section of FlexRAM, the EEPROM file system will create new data record
in EEPROM back-up area of FlexNVM in round-robin fashion.
There is no alignment constraint for destination and size parameters
provided by user. However, according to user's input provided, this
API will set priority to write to FlexRAM with following rules:
32-bit writing is invoked if destination is 32 bit aligned and size
is not less than 32 bits.
16-bit writing is invoked if destination is 16 bit aligned and size
is not less than 16 bits.
8-bit writing is invoked if destination is 8 bit aligned and size
is not less than 8 bits.

Implements    : EEEWrite_Activity
END
FUNCTION Function Name : EEEWrite Description : Write data to FlexRAM section which is partitioned as EEPROM use for EEPROM operation . After data has been written to EEPROM use section of FlexRAM the EEPROM file system will create new data record in EEPROM back - up area of FlexNVM in round - robin fashion . There is no alignment constraint for destination and size parameters provided by user . However according to user ' s input provided this API will set priority to write to FlexRAM with following rules : 32 - bit writing is invoked if destination is 32 bit aligned and size is not less than 32 bits . 16 - bit writing is invoked if destination is 16 bit aligned and size is not less than 16 bits . 8 - bit writing is invoked if destination is 8 bit aligned and size is not less than 8 bits . Implements : EEEWrite_Activity END
flash_drv_status_t EEEWrite(const flash_ssd_config_t * pSSDConfig, \
                            uint32_t dest, \
                            uint32_t size, \
                            const uint8_t* pData)
{
#ifdef DEV_ERROR_DETECT
    DEV_ASSERT(pSSDConfig != NULL);
    DEV_ASSERT(pData != NULL);
#endif
    flash_drv_status_t ret = FTFx_OK;    
    uint8_t i;
    if ((FTFx_FCNFG & FTFx_FCNFG_EEERDY_MASK) == FTFx_FCNFG_EEERDY_MASK)
    {
        if ((dest < pSSDConfig->EERAMBase) || \
                ((dest + size) > (pSSDConfig->EERAMBase + pSSDConfig->EEESize)))
        {
            ret = FTFx_ERR_RANGE;
        }
        while ((size > 0U) && (ret == FTFx_OK))
        {
            if ((0U == (dest & 3U)) && (size >= 4U))
            {
                i = 4U;
            }
            else if ((0U == (dest & 1U)) && (size >= 2U))
            {
                i = 2U;
            }
            else
            {
                i = 1U;
            }
            ret = WaitEEWriteToFinish(dest, pData, i);
            dest += i;
            size -= i;
            pData += i;
        }
    }
    else
    {
        ret = FTFx_ERR_NOEEE;
    }
    return (ret);
}
flash_drv_status_t EEEWrite ( const flash_ssd_config_t * pSSDConfig , uint32_t dest , uint32_t size , const uint8_t * pData ) { #ifdef DEV_ERROR_DETECT DEV_ASSERT ( pSSDConfig != NULL ) ; DEV_ASSERT ( pData != NULL ) ; #endif flash_drv_status_t ret = FTFx_OK ; uint8_t i ; if ( ( FTFx_FCNFG & FTFx_FCNFG_EEERDY_MASK ) == FTFx_FCNFG_EEERDY_MASK ) { if ( ( dest < pSSDConfig -> EERAMBase ) || ( ( dest + size ) > ( pSSDConfig -> EERAMBase + pSSDConfig -> EEESize ) ) ) { ret = FTFx_ERR_RANGE ; } while ( ( size > 0U ) && ( ret == FTFx_OK ) ) { if ( ( 0U == ( dest & 3U ) ) && ( size >= 4U ) ) { i = 4U ; } else if ( ( 0U == ( dest & 1U ) ) && ( size >= 2U ) ) { i = 2U ; } else { i = 1U ; } ret = WaitEEWriteToFinish ( dest , pData , i ) ; dest += i ; size -= i ; pData += i ; } } else { ret = FTFx_ERR_NOEEE ; } return ( ret ) ; }
FUNCTION
FUNCTION
/* Return code variable */ /* Check if EEE is enabled */ /* Check range */ /* Dest is 32bit-aligned and size is not less than 4 */ /* Update destination address for next iteration */ /* Update size for next iteration */ /* Update data for next iteration */