XilinxProcessorIPLib/drivers/rfdc/examples/xrfdc_gen2_or_below_clocked_example.c
int ClockedExample(u16 RFdcDeviceId)
{

	int Status;
	u16 Tile;
	u16 Block;
	XRFdc_Config *ConfigPtr;
	XRFdc *RFdcInstPtr = &RFdcInst;
	u32 ADCSetFabricRate[4];
	u32 DACSetFabricRate[4];
	u32 GetFabricRate;

	struct metal_init_params init_param = METAL_INIT_DEFAULTS;

	if (metal_init(&init_param)) {
		printf("ERROR: Failed to run metal initialization\n");
		return XRFDC_FAILURE;
	}

	/* Initialize the RFdc driver. */
	ConfigPtr = XRFdc_LookupConfig(RFdcDeviceId);
	if (ConfigPtr == NULL) {
		return XRFDC_FAILURE;
	}

	/* Register & MAP RFDC to Libmetal */
#ifdef __BAREMETAL__
	deviceptr = &CustomDev;
#endif
	Status = XRFdc_RegisterMetal(RFdcInstPtr, RFdcDeviceId, &deviceptr);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}

	/* Initializes the controller */
	Status = XRFdc_CfgInitialize(RFdcInstPtr, ConfigPtr);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}

	if(RFdcInstPtr->RFdc_Config.IPType >= XRFDC_GEN3){
		printf("ERROR: Running a Gen 1/2 example on a higher Gen board\n");
		return XRFDC_FAILURE;
	}

#ifdef XPS_BOARD_ZCU111
printf("\n Configuring the Clock \r\n");
	LMK04208ClockConfig(I2CBUS, LMK04208_CKin);
	LMX2594ClockConfig(I2CBUS, 245760);
#endif
	Tile = 0x0;
	for (Block = 0; Block <4; Block++) {
		if (XRFdc_IsDACBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabWrVldWords(RFdcInstPtr, XRFDC_DAC_TILE,
							Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if(GetFabricRate > 0) {
				DACSetFabricRate[Block] = GetFabricRate - 1;
			}
			else {
				DACSetFabricRate[Block] = GetFabricRate + 1;
			}
			Status = XRFdc_SetFabWrVldWords(RFdcInstPtr, Tile, Block, DACSetFabricRate[Block]);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = XRFdc_GetFabWrVldWords(RFdcInstPtr, XRFDC_DAC_TILE,
							Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = CompareFabricRate(DACSetFabricRate[Block], GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
		}
		if (XRFdc_IsADCBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabRdVldWords(RFdcInstPtr, XRFDC_ADC_TILE,
									Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if(GetFabricRate > 0) {
				ADCSetFabricRate[Block] = GetFabricRate - 1;
			} else {
				ADCSetFabricRate[Block] = GetFabricRate + 1;
			}
			Status = XRFdc_SetFabRdVldWords(RFdcInstPtr, Tile, Block, ADCSetFabricRate[Block]);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = XRFdc_GetFabRdVldWords(RFdcInstPtr, XRFDC_ADC_TILE,
									Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = CompareFabricRate(ADCSetFabricRate[Block], GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
		}
	}

	Status = XRFdc_Reset(RFdcInstPtr, XRFDC_ADC_TILE, Tile);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}
	Status = XRFdc_Reset(RFdcInstPtr, XRFDC_DAC_TILE, Tile);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}

	for (Block = 0; Block <4; Block++) {
		if (XRFdc_IsDACBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabWrVldWords(RFdcInstPtr, XRFDC_DAC_TILE,
							Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if (GetFabricRate == DACSetFabricRate[Block]) {
				return XRFDC_FAILURE;
			}
		}
		if (XRFdc_IsADCBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabRdVldWords(RFdcInstPtr, XRFDC_ADC_TILE,
									Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if (GetFabricRate == ADCSetFabricRate[Block]) {
				return XRFDC_FAILURE;
			}
		}
	}

	return XRFDC_SUCCESS;
}
/****************************************************************************/
/**
*
* This function runs a test on the RFSoC data converter device using the
* driver APIs.
* This function does the following tasks:
*	- Initialize the RFdc device driver instance
*	- Set the fabric width.
*	- Get the fabric width
*	- Compare Set and Get fabric widths.
*
* @param	RFdcDeviceId is the XPAR_<XRFDC_instance>_DEVICE_ID value
*		from xparameters.h.
*
* @return
*		- XRFDC_SUCCESS if the example has completed successfully.
*		- XRFDC_FAILURE if the example has failed.
*
* @note   	None
*
****************************************************************************/
This function runs a test on the RFSoC data converter device using the
driver APIs.
This function does the following tasks:
Initialize the RFdc device driver instance
Set the fabric width.
Get the fabric width
Compare Set and Get fabric widths.
This function runs a test on the RFSoC data converter device using the driver APIs . This function does the following tasks : Initialize the RFdc device driver instance Set the fabric width . Get the fabric width Compare Set and Get fabric widths .
int ClockedExample(u16 RFdcDeviceId)
{
	int Status;
	u16 Tile;
	u16 Block;
	XRFdc_Config *ConfigPtr;
	XRFdc *RFdcInstPtr = &RFdcInst;
	u32 ADCSetFabricRate[4];
	u32 DACSetFabricRate[4];
	u32 GetFabricRate;
	struct metal_init_params init_param = METAL_INIT_DEFAULTS;
	if (metal_init(&init_param)) {
		printf("ERROR: Failed to run metal initialization\n");
		return XRFDC_FAILURE;
	}
	ConfigPtr = XRFdc_LookupConfig(RFdcDeviceId);
	if (ConfigPtr == NULL) {
		return XRFDC_FAILURE;
	}
#ifdef __BAREMETAL__
	deviceptr = &CustomDev;
#endif
	Status = XRFdc_RegisterMetal(RFdcInstPtr, RFdcDeviceId, &deviceptr);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}
	Status = XRFdc_CfgInitialize(RFdcInstPtr, ConfigPtr);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}
	if(RFdcInstPtr->RFdc_Config.IPType >= XRFDC_GEN3){
		printf("ERROR: Running a Gen 1/2 example on a higher Gen board\n");
		return XRFDC_FAILURE;
	}
#ifdef XPS_BOARD_ZCU111
printf("\n Configuring the Clock \r\n");
	LMK04208ClockConfig(I2CBUS, LMK04208_CKin);
	LMX2594ClockConfig(I2CBUS, 245760);
#endif
	Tile = 0x0;
	for (Block = 0; Block <4; Block++) {
		if (XRFdc_IsDACBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabWrVldWords(RFdcInstPtr, XRFDC_DAC_TILE,
							Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if(GetFabricRate > 0) {
				DACSetFabricRate[Block] = GetFabricRate - 1;
			}
			else {
				DACSetFabricRate[Block] = GetFabricRate + 1;
			}
			Status = XRFdc_SetFabWrVldWords(RFdcInstPtr, Tile, Block, DACSetFabricRate[Block]);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = XRFdc_GetFabWrVldWords(RFdcInstPtr, XRFDC_DAC_TILE,
							Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = CompareFabricRate(DACSetFabricRate[Block], GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
		}
		if (XRFdc_IsADCBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabRdVldWords(RFdcInstPtr, XRFDC_ADC_TILE,
									Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if(GetFabricRate > 0) {
				ADCSetFabricRate[Block] = GetFabricRate - 1;
			} else {
				ADCSetFabricRate[Block] = GetFabricRate + 1;
			}
			Status = XRFdc_SetFabRdVldWords(RFdcInstPtr, Tile, Block, ADCSetFabricRate[Block]);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = XRFdc_GetFabRdVldWords(RFdcInstPtr, XRFDC_ADC_TILE,
									Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			Status = CompareFabricRate(ADCSetFabricRate[Block], GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
		}
	}
	Status = XRFdc_Reset(RFdcInstPtr, XRFDC_ADC_TILE, Tile);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}
	Status = XRFdc_Reset(RFdcInstPtr, XRFDC_DAC_TILE, Tile);
	if (Status != XRFDC_SUCCESS) {
		return XRFDC_FAILURE;
	}
	for (Block = 0; Block <4; Block++) {
		if (XRFdc_IsDACBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabWrVldWords(RFdcInstPtr, XRFDC_DAC_TILE,
							Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if (GetFabricRate == DACSetFabricRate[Block]) {
				return XRFDC_FAILURE;
			}
		}
		if (XRFdc_IsADCBlockEnabled(RFdcInstPtr, Tile, Block)) {
			Status = XRFdc_GetFabRdVldWords(RFdcInstPtr, XRFDC_ADC_TILE,
									Tile, Block, &GetFabricRate);
			if (Status != XRFDC_SUCCESS) {
				return XRFDC_FAILURE;
			}
			if (GetFabricRate == ADCSetFabricRate[Block]) {
				return XRFDC_FAILURE;
			}
		}
	}
	return XRFDC_SUCCESS;
}
int ClockedExample ( u16 RFdcDeviceId ) { int Status ; u16 Tile ; u16 Block ; XRFdc_Config * ConfigPtr ; XRFdc * RFdcInstPtr = & RFdcInst ; u32 ADCSetFabricRate [ 4 ] ; u32 DACSetFabricRate [ 4 ] ; u32 GetFabricRate ; struct metal_init_params init_param = METAL_INIT_DEFAULTS ; if ( metal_init ( & init_param ) ) { printf ( " \n " ) ; return XRFDC_FAILURE ; } ConfigPtr = XRFdc_LookupConfig ( RFdcDeviceId ) ; if ( ConfigPtr == NULL ) { return XRFDC_FAILURE ; } #ifdef __BAREMETAL__ deviceptr = & CustomDev ; #endif Status = XRFdc_RegisterMetal ( RFdcInstPtr , RFdcDeviceId , & deviceptr ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } Status = XRFdc_CfgInitialize ( RFdcInstPtr , ConfigPtr ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } if ( RFdcInstPtr -> RFdc_Config . IPType >= XRFDC_GEN3 ) { printf ( " \n " ) ; return XRFDC_FAILURE ; } #ifdef XPS_BOARD_ZCU111 printf ( " \n \r \n " ) ; LMK04208ClockConfig ( I2CBUS , LMK04208_CKin ) ; LMX2594ClockConfig ( I2CBUS , 245760 ) ; #endif Tile = 0x0 ; for ( Block = 0 ; Block < 4 ; Block ++ ) { if ( XRFdc_IsDACBlockEnabled ( RFdcInstPtr , Tile , Block ) ) { Status = XRFdc_GetFabWrVldWords ( RFdcInstPtr , XRFDC_DAC_TILE , Tile , Block , & GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } if ( GetFabricRate > 0 ) { DACSetFabricRate [ Block ] = GetFabricRate - 1 ; } else { DACSetFabricRate [ Block ] = GetFabricRate + 1 ; } Status = XRFdc_SetFabWrVldWords ( RFdcInstPtr , Tile , Block , DACSetFabricRate [ Block ] ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } Status = XRFdc_GetFabWrVldWords ( RFdcInstPtr , XRFDC_DAC_TILE , Tile , Block , & GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } Status = CompareFabricRate ( DACSetFabricRate [ Block ] , GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } } if ( XRFdc_IsADCBlockEnabled ( RFdcInstPtr , Tile , Block ) ) { Status = XRFdc_GetFabRdVldWords ( RFdcInstPtr , XRFDC_ADC_TILE , Tile , Block , & GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } if ( GetFabricRate > 0 ) { ADCSetFabricRate [ Block ] = GetFabricRate - 1 ; } else { ADCSetFabricRate [ Block ] = GetFabricRate + 1 ; } Status = XRFdc_SetFabRdVldWords ( RFdcInstPtr , Tile , Block , ADCSetFabricRate [ Block ] ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } Status = XRFdc_GetFabRdVldWords ( RFdcInstPtr , XRFDC_ADC_TILE , Tile , Block , & GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } Status = CompareFabricRate ( ADCSetFabricRate [ Block ] , GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } } } Status = XRFdc_Reset ( RFdcInstPtr , XRFDC_ADC_TILE , Tile ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } Status = XRFdc_Reset ( RFdcInstPtr , XRFDC_DAC_TILE , Tile ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } for ( Block = 0 ; Block < 4 ; Block ++ ) { if ( XRFdc_IsDACBlockEnabled ( RFdcInstPtr , Tile , Block ) ) { Status = XRFdc_GetFabWrVldWords ( RFdcInstPtr , XRFDC_DAC_TILE , Tile , Block , & GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } if ( GetFabricRate == DACSetFabricRate [ Block ] ) { return XRFDC_FAILURE ; } } if ( XRFdc_IsADCBlockEnabled ( RFdcInstPtr , Tile , Block ) ) { Status = XRFdc_GetFabRdVldWords ( RFdcInstPtr , XRFDC_ADC_TILE , Tile , Block , & GetFabricRate ) ; if ( Status != XRFDC_SUCCESS ) { return XRFDC_FAILURE ; } if ( GetFabricRate == ADCSetFabricRate [ Block ] ) { return XRFDC_FAILURE ; } } } return XRFDC_SUCCESS ; }
This function runs a test on the RFSoC data converter device using the
driver APIs.
This function runs a test on the RFSoC data converter device using the driver APIs .
/* Initialize the RFdc driver. */ /* Register & MAP RFDC to Libmetal */ /* Initializes the controller */