XilinxProcessorIPLib/drivers/hwicap/examples/xhwicap_intr_example.c
int HwIcapIntrExample(XIntc *IntcInstancePtr, XHwIcap *HwIcapInstancePtr,
			u16 HwIcapDeviceId, u16 HwIcapIntrId)
{
	int Status;
	u32 Count;
	u8 Test;
	XHwIcap_Config *ConfigPtr;

	/*
	 * Initialize the HwIcap driver.
	 */
	ConfigPtr = XHwIcap_LookupConfig(HwIcapDeviceId);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}
	Status = XHwIcap_CfgInitialize(HwIcapInstancePtr,
					ConfigPtr,
					ConfigPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */
	Status = XHwIcap_SelfTest(HwIcapInstancePtr);

	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Connect the HwIcap device to the interrupt subsystem such that
	 * interrupts can occur. This function is application specific.
	 */
	Status = HwIcapSetupInterruptSystem(IntcInstancePtr,
					HwIcapInstancePtr,
					HwIcapIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Setup the handler for the HwIcap that will be called from the
	 * interrupt context when an HwIcap status occurs, specify a pointer
	 * to the HwIcap driver instance as the callback reference so the
	 * handler is able to access the instance data.
	 */
	XHwIcap_SetInterruptHandler(HwIcapInstancePtr, HwIcapInstancePtr,
			 (XHwIcap_StatusHandler)HwIcapIntrHandler);

	/*
	 * Initialize the write buffer with pattern to write.
	 */
	for (Count = 0; Count < TEST_WRITE_BUFFER_SIZE;) {

		WriteBuffer[Count++] = XHI_DUMMY_PACKET;
		WriteBuffer[Count++] = XHI_SYNC_PACKET;
		WriteBuffer[Count++] = XHwIcap_Type1Read(XHI_IDCODE) | 1;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
		WriteBuffer[Count++] = XHI_DUMMY_PACKET;
		WriteBuffer[Count++] = XHI_SYNC_PACKET;
		WriteBuffer[Count++] = XHwIcap_Type1Read(XHI_COR) | 1;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
	}

	/*
	 * Enable the Write FIFO Half Full Interrupt.
	 */
	XHwIcap_IntrEnable(HwIcapInstancePtr, XHI_IPIXR_WRP_MASK);

	/*
	 * Write the the data to the device.
	 */
	TransferInProgress = TRUE;
	Status = XHwIcap_DeviceWrite(HwIcapInstancePtr,
					(u32 *) &WriteBuffer[0],
					TEST_WRITE_BUFFER_SIZE);
	if (Status != XST_SUCCESS)  {
		return XST_FAILURE;
	}

	/*
	 * Wait for the data to be written to the device.
	 */
	while (TransferInProgress);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function does a minimal test on the HwIcap device and driver as a
* design example. The purpose of this function is to illustrate how to use
* the XHwIcap component using the interrupt mode.
*
* This function sends data and expects to receive the same data.
*
*
* @param	IntcInstancePtr is a pointer to the instance of the INTC component.
* @param	HwIcapInstancePtr is a pointer to the instance of HwIcap component.
* @param	HwIcapDeviceId is the Device ID of the HwIcap Device and is the
*		XPAR_<HWICAP_instance>_DEVICE_ID value from xparameters.h.
* @param	HwIcapIntrId is the interrupt Id and is typically
*		XPAR_<INTC_instance>_<HWICAP_instance>_IP2INTC_IRPT_INTR
*		value from xparameters.h .
*
* @return	XST_SUCCESS if successful, otherwise XST_FAILURE.
*
* @note
*
* This function contains an infinite loop such that if interrupts are not
* working it may never return.
*
******************************************************************************/
This function does a minimal test on the HwIcap device and driver as a
design example. The purpose of this function is to illustrate how to use
the XHwIcap component using the interrupt mode.

This function sends data and expects to receive the same data.
This function does a minimal test on the HwIcap device and driver as a design example . The purpose of this function is to illustrate how to use the XHwIcap component using the interrupt mode . This function sends data and expects to receive the same data .
int HwIcapIntrExample(XIntc *IntcInstancePtr, XHwIcap *HwIcapInstancePtr,
			u16 HwIcapDeviceId, u16 HwIcapIntrId)
{
	int Status;
	u32 Count;
	u8 Test;
	XHwIcap_Config *ConfigPtr;
	ConfigPtr = XHwIcap_LookupConfig(HwIcapDeviceId);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}
	Status = XHwIcap_CfgInitialize(HwIcapInstancePtr,
					ConfigPtr,
					ConfigPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XHwIcap_SelfTest(HwIcapInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = HwIcapSetupInterruptSystem(IntcInstancePtr,
					HwIcapInstancePtr,
					HwIcapIntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XHwIcap_SetInterruptHandler(HwIcapInstancePtr, HwIcapInstancePtr,
			 (XHwIcap_StatusHandler)HwIcapIntrHandler);
	for (Count = 0; Count < TEST_WRITE_BUFFER_SIZE;) {
		WriteBuffer[Count++] = XHI_DUMMY_PACKET;
		WriteBuffer[Count++] = XHI_SYNC_PACKET;
		WriteBuffer[Count++] = XHwIcap_Type1Read(XHI_IDCODE) | 1;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
		WriteBuffer[Count++] = XHI_DUMMY_PACKET;
		WriteBuffer[Count++] = XHI_SYNC_PACKET;
		WriteBuffer[Count++] = XHwIcap_Type1Read(XHI_COR) | 1;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
		WriteBuffer[Count++] = XHI_NOOP_PACKET;
	}
	XHwIcap_IntrEnable(HwIcapInstancePtr, XHI_IPIXR_WRP_MASK);
	TransferInProgress = TRUE;
	Status = XHwIcap_DeviceWrite(HwIcapInstancePtr,
					(u32 *) &WriteBuffer[0],
					TEST_WRITE_BUFFER_SIZE);
	if (Status != XST_SUCCESS)  {
		return XST_FAILURE;
	}
	while (TransferInProgress);
	return XST_SUCCESS;
}
int HwIcapIntrExample ( XIntc * IntcInstancePtr , XHwIcap * HwIcapInstancePtr , u16 HwIcapDeviceId , u16 HwIcapIntrId ) { int Status ; u32 Count ; u8 Test ; XHwIcap_Config * ConfigPtr ; ConfigPtr = XHwIcap_LookupConfig ( HwIcapDeviceId ) ; if ( ConfigPtr == NULL ) { return XST_FAILURE ; } Status = XHwIcap_CfgInitialize ( HwIcapInstancePtr , ConfigPtr , ConfigPtr -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XHwIcap_SelfTest ( HwIcapInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = HwIcapSetupInterruptSystem ( IntcInstancePtr , HwIcapInstancePtr , HwIcapIntrId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XHwIcap_SetInterruptHandler ( HwIcapInstancePtr , HwIcapInstancePtr , ( XHwIcap_StatusHandler ) HwIcapIntrHandler ) ; for ( Count = 0 ; Count < TEST_WRITE_BUFFER_SIZE ; ) { WriteBuffer [ Count ++ ] = XHI_DUMMY_PACKET ; WriteBuffer [ Count ++ ] = XHI_SYNC_PACKET ; WriteBuffer [ Count ++ ] = XHwIcap_Type1Read ( XHI_IDCODE ) | 1 ; WriteBuffer [ Count ++ ] = XHI_NOOP_PACKET ; WriteBuffer [ Count ++ ] = XHI_NOOP_PACKET ; WriteBuffer [ Count ++ ] = XHI_DUMMY_PACKET ; WriteBuffer [ Count ++ ] = XHI_SYNC_PACKET ; WriteBuffer [ Count ++ ] = XHwIcap_Type1Read ( XHI_COR ) | 1 ; WriteBuffer [ Count ++ ] = XHI_NOOP_PACKET ; WriteBuffer [ Count ++ ] = XHI_NOOP_PACKET ; } XHwIcap_IntrEnable ( HwIcapInstancePtr , XHI_IPIXR_WRP_MASK ) ; TransferInProgress = TRUE ; Status = XHwIcap_DeviceWrite ( HwIcapInstancePtr , ( u32 * ) & WriteBuffer [ 0 ] , TEST_WRITE_BUFFER_SIZE ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } while ( TransferInProgress ) ; return XST_SUCCESS ; }
This function does a minimal test on the HwIcap device and driver as a
design example.
This function does a minimal test on the HwIcap device and driver as a design example .
/*
	 * Initialize the HwIcap driver.
	 */ /*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */ /*
	 * Connect the HwIcap device to the interrupt subsystem such that
	 * interrupts can occur. This function is application specific.
	 */ /*
	 * Setup the handler for the HwIcap that will be called from the
	 * interrupt context when an HwIcap status occurs, specify a pointer
	 * to the HwIcap driver instance as the callback reference so the
	 * handler is able to access the instance data.
	 */ /*
	 * Initialize the write buffer with pattern to write.
	 */ /*
	 * Enable the Write FIFO Half Full Interrupt.
	 */ /*
	 * Write the the data to the device.
	 */ /*
	 * Wait for the data to be written to the device.
	 */