XilinxProcessorIPLib/drivers/resetps/examples/xresetps_example.c
static XStatus ResetPsExample(XResetPs *ResetInstancePtr, u16 ResetDeviceId)
{
	int                Status;
	u8                 CurrPeri;
	u8                 FailCnt = 0;
	u32                RegValue;
	XResetPs_Config    *ConfigPtr;
	XResetPs_RstStatus IsAsserted;

	/* Initialize the Reset controller driver */
	ConfigPtr = XResetPs_LookupConfig(ResetDeviceId);

	Status = XResetPs_CfgInitialize(ResetInstancePtr, ConfigPtr);
	if (Status != XST_SUCCESS) {
		xil_printf("ResetPs configuration failed\n");
		return XST_FAILURE;
	}

	for (CurrPeri = 0; CurrPeri < NumPeripherals; CurrPeri++) {
		/* Modifying register value */
		Xil_Out32(PeriList[CurrPeri].RegAddr,
						   PeriList[CurrPeri].ModifVal);

		/* Validating modified value */
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ModifVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}

		/* Reset assert peripheral */
		Status = XResetPs_ResetAssert(ResetInstancePtr,
						    PeriList[CurrPeri].ResetID);
		if (Status == XST_SUCCESS) {
			Status = XResetPs_ResetStatus(ResetInstancePtr,
				       PeriList[CurrPeri].ResetID, &IsAsserted);
			if (Status != XST_SUCCESS ||
					 IsAsserted != XRESETPS_RESETASSERTED) {
				FailCnt++;
				xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
				continue;
			}
		}

		/* Reset deassert peripheral */
		Status = XResetPs_ResetDeassert(ResetInstancePtr,
						    PeriList[CurrPeri].ResetID);
		if (Status == XST_SUCCESS) {
			Status = XResetPs_ResetStatus(ResetInstancePtr,
				       PeriList[CurrPeri].ResetID, &IsAsserted);
			if (Status != XST_SUCCESS ||
					 IsAsserted != XRESETPS_RESETRELEASED) {
				FailCnt++;
				xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
				continue;
			}
		}

		/* Verify reset value */
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ResetVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}

		/* Modifying register value */
		Xil_Out32(PeriList[CurrPeri].RegAddr,
						   PeriList[CurrPeri].ModifVal);

		/* Validating modified value */
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ModifVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}

		/* Pulse reset peripheral */
		Status = XResetPs_ResetPulse(ResetInstancePtr,
						    PeriList[CurrPeri].ResetID);
		if (Status != XST_SUCCESS) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}

		/* Verify reset value */
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ResetVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}

		xil_printf("Reset passed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
	}

	if (FailCnt != 0) {
		xil_printf("Reset failed for %d peripherals\n", FailCnt);
		return XST_FAILURE;
	}

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function tests the functioning of the Reset controller driver by
* resetting peripheral blocks listed in PeriList[].
*
* This function modifies the value of peripheral's register. It then reset's
* the peripheral and validates the value of peripheral's register with reset
* value of the register.
*
* @param	ResetInstancePtr is a pointer to instance of XResetPs driver.
*
* @return	XST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function tests the functioning of the Reset controller driver by
resetting peripheral blocks listed in PeriList[].

This function modifies the value of peripheral's register. It then reset's
the peripheral and validates the value of peripheral's register with reset
value of the register.
This function tests the functioning of the Reset controller driver by resetting peripheral blocks listed in PeriList [] . This function modifies the value of peripheral ' s register . It then reset ' s the peripheral and validates the value of peripheral ' s register with reset value of the register .
static XStatus ResetPsExample(XResetPs *ResetInstancePtr, u16 ResetDeviceId)
{
	int                Status;
	u8                 CurrPeri;
	u8                 FailCnt = 0;
	u32                RegValue;
	XResetPs_Config    *ConfigPtr;
	XResetPs_RstStatus IsAsserted;
	ConfigPtr = XResetPs_LookupConfig(ResetDeviceId);
	Status = XResetPs_CfgInitialize(ResetInstancePtr, ConfigPtr);
	if (Status != XST_SUCCESS) {
		xil_printf("ResetPs configuration failed\n");
		return XST_FAILURE;
	}
	for (CurrPeri = 0; CurrPeri < NumPeripherals; CurrPeri++) {
		Xil_Out32(PeriList[CurrPeri].RegAddr,
						   PeriList[CurrPeri].ModifVal);
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ModifVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}
		Status = XResetPs_ResetAssert(ResetInstancePtr,
						    PeriList[CurrPeri].ResetID);
		if (Status == XST_SUCCESS) {
			Status = XResetPs_ResetStatus(ResetInstancePtr,
				       PeriList[CurrPeri].ResetID, &IsAsserted);
			if (Status != XST_SUCCESS ||
					 IsAsserted != XRESETPS_RESETASSERTED) {
				FailCnt++;
				xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
				continue;
			}
		}
		Status = XResetPs_ResetDeassert(ResetInstancePtr,
						    PeriList[CurrPeri].ResetID);
		if (Status == XST_SUCCESS) {
			Status = XResetPs_ResetStatus(ResetInstancePtr,
				       PeriList[CurrPeri].ResetID, &IsAsserted);
			if (Status != XST_SUCCESS ||
					 IsAsserted != XRESETPS_RESETRELEASED) {
				FailCnt++;
				xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
				continue;
			}
		}
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ResetVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}
		Xil_Out32(PeriList[CurrPeri].RegAddr,
						   PeriList[CurrPeri].ModifVal);
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ModifVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}
		Status = XResetPs_ResetPulse(ResetInstancePtr,
						    PeriList[CurrPeri].ResetID);
		if (Status != XST_SUCCESS) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}
		RegValue = Xil_In32(PeriList[CurrPeri].RegAddr);
		if (RegValue != PeriList[CurrPeri].ResetVal) {
			FailCnt++;
			xil_printf("Reset failed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
			continue;
		}
		xil_printf("Reset passed for Reset ID %d\n",
						    PeriList[CurrPeri].ResetID);
	}
	if (FailCnt != 0) {
		xil_printf("Reset failed for %d peripherals\n", FailCnt);
		return XST_FAILURE;
	}
	return XST_SUCCESS;
}
static XStatus ResetPsExample ( XResetPs * ResetInstancePtr , u16 ResetDeviceId ) { int Status ; u8 CurrPeri ; u8 FailCnt = 0 ; u32 RegValue ; XResetPs_Config * ConfigPtr ; XResetPs_RstStatus IsAsserted ; ConfigPtr = XResetPs_LookupConfig ( ResetDeviceId ) ; Status = XResetPs_CfgInitialize ( ResetInstancePtr , ConfigPtr ) ; if ( Status != XST_SUCCESS ) { xil_printf ( " \n " ) ; return XST_FAILURE ; } for ( CurrPeri = 0 ; CurrPeri < NumPeripherals ; CurrPeri ++ ) { Xil_Out32 ( PeriList [ CurrPeri ] . RegAddr , PeriList [ CurrPeri ] . ModifVal ) ; RegValue = Xil_In32 ( PeriList [ CurrPeri ] . RegAddr ) ; if ( RegValue != PeriList [ CurrPeri ] . ModifVal ) { FailCnt ++ ; xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; continue ; } Status = XResetPs_ResetAssert ( ResetInstancePtr , PeriList [ CurrPeri ] . ResetID ) ; if ( Status == XST_SUCCESS ) { Status = XResetPs_ResetStatus ( ResetInstancePtr , PeriList [ CurrPeri ] . ResetID , & IsAsserted ) ; if ( Status != XST_SUCCESS || IsAsserted != XRESETPS_RESETASSERTED ) { FailCnt ++ ; xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; continue ; } } Status = XResetPs_ResetDeassert ( ResetInstancePtr , PeriList [ CurrPeri ] . ResetID ) ; if ( Status == XST_SUCCESS ) { Status = XResetPs_ResetStatus ( ResetInstancePtr , PeriList [ CurrPeri ] . ResetID , & IsAsserted ) ; if ( Status != XST_SUCCESS || IsAsserted != XRESETPS_RESETRELEASED ) { FailCnt ++ ; xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; continue ; } } RegValue = Xil_In32 ( PeriList [ CurrPeri ] . RegAddr ) ; if ( RegValue != PeriList [ CurrPeri ] . ResetVal ) { FailCnt ++ ; xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; continue ; } Xil_Out32 ( PeriList [ CurrPeri ] . RegAddr , PeriList [ CurrPeri ] . ModifVal ) ; RegValue = Xil_In32 ( PeriList [ CurrPeri ] . RegAddr ) ; if ( RegValue != PeriList [ CurrPeri ] . ModifVal ) { FailCnt ++ ; xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; continue ; } Status = XResetPs_ResetPulse ( ResetInstancePtr , PeriList [ CurrPeri ] . ResetID ) ; if ( Status != XST_SUCCESS ) { FailCnt ++ ; xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; continue ; } RegValue = Xil_In32 ( PeriList [ CurrPeri ] . RegAddr ) ; if ( RegValue != PeriList [ CurrPeri ] . ResetVal ) { FailCnt ++ ; xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; continue ; } xil_printf ( " \n " , PeriList [ CurrPeri ] . ResetID ) ; } if ( FailCnt != 0 ) { xil_printf ( " \n " , FailCnt ) ; return XST_FAILURE ; } return XST_SUCCESS ; }
This function tests the functioning of the Reset controller driver by
resetting peripheral blocks listed in PeriList[].
This function tests the functioning of the Reset controller driver by resetting peripheral blocks listed in PeriList [] .
/* Initialize the Reset controller driver */ /* Modifying register value */ /* Validating modified value */ /* Reset assert peripheral */ /* Reset deassert peripheral */ /* Verify reset value */ /* Modifying register value */ /* Validating modified value */ /* Pulse reset peripheral */ /* Verify reset value */