mcu/drv/fsl_flash_driver_c90tfs.c
/*FUNCTION**********************************************************************
 *
 * Function Name : PFlashSetProtection
 * Description   : Sets the P-Flash protection to the intended protection status.
 * Setting P-Flash protection status is subject to a protection transition
 * restriction. If there is a setting violation, it returns an error code
 * and the current protection status will not be changed.
 *
 * Implements    : PFlashSetProtection_Activity
 *END**************************************************************************/
FUNCTION

Function Name : PFlashSetProtection
Description   : Sets the P-Flash protection to the intended protection status.
Setting P-Flash protection status is subject to a protection transition
restriction. If there is a setting violation, it returns an error code
and the current protection status will not be changed.

Implements    : PFlashSetProtection_Activity
END
FUNCTION Function Name : PFlashSetProtection Description : Sets the P - Flash protection to the intended protection status . Setting P - Flash protection status is subject to a protection transition restriction . If there is a setting violation it returns an error code and the current protection status will not be changed . Implements : PFlashSetProtection_Activity END
flash_drv_status_t PFlashSetProtection(uint32_t protectStatus)
{
    flash_drv_status_t ret = FTFx_OK;
    uint8_t reg0, reg1, reg2, reg3;
    bool flag0, flag1, flag2, flag3;
    reg0 = GET_BIT_24_31(protectStatus);
    reg1 = GET_BIT_16_23(protectStatus);
    reg2 = GET_BIT_8_15(protectStatus);
    reg3 = GET_BIT_0_7(protectStatus);
    FTFx_FPROT0 = reg0;
    FTFx_FPROT1 = reg1;
    FTFx_FPROT2 = reg2;
    FTFx_FPROT3 = reg3;
    flag0 = (FTFx_FPROT0 != reg0);
    flag1 = (FTFx_FPROT1 != reg1);
    flag2 = (FTFx_FPROT2 != reg2);
    flag3 = (FTFx_FPROT3 != reg3);
    if (flag0 || flag1 || flag2 || flag3)
    {
        ret = FTFx_ERR_CHANGEPROT;
    }
    return (ret);
}
flash_drv_status_t PFlashSetProtection ( uint32_t protectStatus ) { flash_drv_status_t ret = FTFx_OK ; uint8_t reg0 , reg1 , reg2 , reg3 ; bool flag0 , flag1 , flag2 , flag3 ; reg0 = GET_BIT_24_31 ( protectStatus ) ; reg1 = GET_BIT_16_23 ( protectStatus ) ; reg2 = GET_BIT_8_15 ( protectStatus ) ; reg3 = GET_BIT_0_7 ( protectStatus ) ; FTFx_FPROT0 = reg0 ; FTFx_FPROT1 = reg1 ; FTFx_FPROT2 = reg2 ; FTFx_FPROT3 = reg3 ; flag0 = ( FTFx_FPROT0 != reg0 ) ; flag1 = ( FTFx_FPROT1 != reg1 ) ; flag2 = ( FTFx_FPROT2 != reg2 ) ; flag3 = ( FTFx_FPROT3 != reg3 ) ; if ( flag0 || flag1 || flag2 || flag3 ) { ret = FTFx_ERR_CHANGEPROT ; } return ( ret ) ; }
FUNCTION
FUNCTION
/* Get register */ /* Write to register */ /* Compare changes */ /* Read the value of FPPROT registers */