mcu/drv/fsl_flash_driver_c90tfs.c
/*FUNCTION**********************************************************************
 *
 * Function Name : PFlashSwapCtl
 * Description   : Performs swap control command corresponding with the swap
 * control code provided via the swapcmd parameter.
 *
 * Implements    : PFlashSwapCtl_Activity
 *END**************************************************************************/
FUNCTION

Function Name : PFlashSwapCtl
Description   : Performs swap control command corresponding with the swap
control code provided via the swapcmd parameter.

Implements    : PFlashSwapCtl_Activity
END
FUNCTION Function Name : PFlashSwapCtl Description : Performs swap control command corresponding with the swap control code provided via the swapcmd parameter . Implements : PFlashSwapCtl_Activity END
flash_drv_status_t PFlashSwapCtl(const flash_ssd_config_t * pSSDConfig, \
                                 uint32_t addr, \
                                 uint8_t swapcmd, \
                                 uint8_t* pCurrentSwapMode, \
                                 uint8_t* pCurrentSwapBlockStatus, \
                                 uint8_t* pNextSwapBlockStatus, \
                                 flash_command_sequence_t pFlashCommandSequence)
{
#ifdef DEV_ERROR_DETECT
    DEV_ASSERT(pSSDConfig != NULL);
    DEV_ASSERT(pCurrentSwapMode != NULL);
    DEV_ASSERT(pCurrentSwapBlockStatus != NULL);
    DEV_ASSERT(pNextSwapBlockStatus != NULL);
    DEV_ASSERT(pFlashCommandSequence != NULL);
#endif
    flash_drv_status_t ret;    
    CLEAR_FTFx_FSTAT_ERROR_BITS;
    FTFx_FCCOB0 = FTFx_PFLASH_SWAP;
    FTFx_FCCOB1 = GET_BIT_16_23(addr);
    FTFx_FCCOB2 = GET_BIT_8_15(addr);
    FTFx_FCCOB3 = GET_BIT_0_7(addr);
    FTFx_FCCOB4 = swapcmd;
    FTFx_FCCOB5 = 0xFFU;
    FTFx_FCCOB6 = 0xFFU;
    FTFx_FCCOB7 = 0xFFU;
    ret = pFlashCommandSequence(pSSDConfig);
    if (FTFx_OK == ret)
    {
        *pCurrentSwapMode = FTFx_FCCOB5;
        *pCurrentSwapBlockStatus = FTFx_FCCOB6;
        *pNextSwapBlockStatus = FTFx_FCCOB7;
    }
    return (ret);
}
flash_drv_status_t PFlashSwapCtl ( const flash_ssd_config_t * pSSDConfig , uint32_t addr , uint8_t swapcmd , uint8_t * pCurrentSwapMode , uint8_t * pCurrentSwapBlockStatus , uint8_t * pNextSwapBlockStatus , flash_command_sequence_t pFlashCommandSequence ) { #ifdef DEV_ERROR_DETECT DEV_ASSERT ( pSSDConfig != NULL ) ; DEV_ASSERT ( pCurrentSwapMode != NULL ) ; DEV_ASSERT ( pCurrentSwapBlockStatus != NULL ) ; DEV_ASSERT ( pNextSwapBlockStatus != NULL ) ; DEV_ASSERT ( pFlashCommandSequence != NULL ) ; #endif flash_drv_status_t ret ; CLEAR_FTFx_FSTAT_ERROR_BITS ; FTFx_FCCOB0 = FTFx_PFLASH_SWAP ; FTFx_FCCOB1 = GET_BIT_16_23 ( addr ) ; FTFx_FCCOB2 = GET_BIT_8_15 ( addr ) ; FTFx_FCCOB3 = GET_BIT_0_7 ( addr ) ; FTFx_FCCOB4 = swapcmd ; FTFx_FCCOB5 = 0xFFU ; FTFx_FCCOB6 = 0xFFU ; FTFx_FCCOB7 = 0xFFU ; ret = pFlashCommandSequence ( pSSDConfig ) ; if ( FTFx_OK == ret ) { * pCurrentSwapMode = FTFx_FCCOB5 ; * pCurrentSwapBlockStatus = FTFx_FCCOB6 ; * pNextSwapBlockStatus = 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 */