XilinxProcessorIPLib/drivers/i2stx/examples/xi2stx_intr_example.c
int I2sTxIntrExample(INTC* IntcInstancePtr,
		XI2s_Tx* I2sTxInstancePtr,
		u16 DeviceId,
		u16 IntrId)
{
	int Status;
	XI2stx_Config *Config;
	u32 IntrCount = 0;
	/*
	 * Lookup and Initialize the I2s Transmitter so that it's ready to use.
	 */
	Config = XI2s_Tx_LookupConfig(DeviceId);
	if (Config == NULL) {
		return XST_FAILURE;
	}

	Status = XI2s_Tx_CfgInitialize(I2sTxInstancePtr, Config,
		       	Config->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	/*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */
	Status = XI2s_Tx_SelfTest(I2sTxInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	/*
	 * Connect the I2s Transmitter counter to the interrupt
	 * subsystem such that interrupts can occur.
	 * This function is application specific.
	 */
	Status = I2sTxSetupIntrSystem(IntcInstancePtr,
			I2sTxInstancePtr,
			DeviceId,
			IntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	/*
	 * Setup the handler for the I2s Transmitter that will be called from
	 * the interrupt context when the I2s Transmitter receives a block
	 * complete interrupt, AES Block Sync Error interrupt, AES Channel
	 * Status Updated interrupt, Underflow interrupt or Global interrupt.
	 */
	XI2s_Tx_SetHandler(I2sTxInstancePtr, XI2S_TX_HANDLER_AES_BLKCMPLT,
			&I2sTxAesBlockCmplIntrHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetHandler(I2sTxInstancePtr, XI2S_TX_HANDLER_AES_BLKSYNCERR,
			&I2sTxAesBlockErrIntrHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetHandler(I2sTxInstancePtr,XI2S_TX_HANDLER_AES_CHSTSUPD,
			&I2sTxAesGetChStsHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetHandler(I2sTxInstancePtr, XI2S_TX_HANDLER_AUD_UNDRFLW,
			&I2sTxUnderflowIntrHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetSclkOutDiv(I2sTxInstancePtr,I2S_TX_MCLK,I2S_TX_FS);
	XI2s_Tx_SetChMux(I2sTxInstancePtr, 0, XI2S_TX_CHMUX_AXIS_01);
	XI2s_Tx_IntrEnable(I2sTxInstancePtr, XI2S_TX_GINTR_EN_MASK);
	XI2s_Tx_IntrEnable(I2sTxInstancePtr, XI2S_TX_INTR_AES_BLKCMPLT_MASK);
	XI2s_Tx_IntrEnable(I2sTxInstancePtr, XI2S_TX_INTR_AUDUNDRFLW_MASK);
	XI2s_Tx_Enable(I2sTxInstancePtr, 0x1);
	Xil_ExceptionEnable();
	while (IntrCount < I2S_TX_TIME_OUT) {
		/* Wait until an interrupt has been received. */
		if (IntrReceived == 1) {
			break;
		}

		IntrCount++;
	}
	return XST_SUCCESS;
}
/*****************************************************************************/
/**
 * This function does a minimal test on the I2s Transmitter device and driver
 * as a  design example.  The purpose of this function is to illustrate how
 * to use the XI2S_Tx component.  It initializes a I2s Transmitter and then
 * sets it up such that a periodic interrupt is generated.
 *
 * This function uses interrupt driven mode of the I2s Transmitter.
 *
 * @param	IntcInstancePtr is a pointer to the Interrupt Controller
 *		driver Instance
 * @param	I2sTxInstancePtr is a pointer to the XI2s_Tx driver Instance
 * @param	DeviceId is the XPAR_<i2s_tx_instance>_DEVICE_ID value from
 *		xparameters.h
 * @param	IntrId is XPAR_<INTC_instance>_<i2s_tx_instance>_INTERRUPT_INTR
 *		value from xparameters.h
 *
 * @return	XST_SUCCESS if the Test is 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 I2s Transmitter device and driver
as a  design example.  The purpose of this function is to illustrate how
to use the XI2S_Tx component.  It initializes a I2s Transmitter and then
sets it up such that a periodic interrupt is generated.

This function uses interrupt driven mode of the I2s Transmitter.

@param       IntcInstancePtr is a pointer to the Interrupt Controller
driver Instance
@param       I2sTxInstancePtr is a pointer to the XI2s_Tx driver Instance
@param       DeviceId is the XPAR__DEVICE_ID value from
xparameters.h
@param       IntrId is XPAR___INTERRUPT_INTR
value from xparameters.h

@return      XST_SUCCESS if the Test is 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 I2s Transmitter device and driver as a design example . The purpose of this function is to illustrate how to use the XI2S_Tx component . It initializes a I2s Transmitter and then sets it up such that a periodic interrupt is generated . This function uses interrupt driven mode of the I2s Transmitter . @param IntcInstancePtr is a pointer to the Interrupt Controller driver Instance @param I2sTxInstancePtr is a pointer to the XI2s_Tx driver Instance @param DeviceId is the XPAR__DEVICE_ID value from xparameters . h @param IntrId is XPAR___INTERRUPT_INTR value from xparameters . h @return XST_SUCCESS if the Test is successful otherwise XST_FAILURE @note This function contains an infinite loop such that if interrupts are not working it may never return .
int I2sTxIntrExample(INTC* IntcInstancePtr,
		XI2s_Tx* I2sTxInstancePtr,
		u16 DeviceId,
		u16 IntrId)
{
	int Status;
	XI2stx_Config *Config;
	u32 IntrCount = 0;
	Config = XI2s_Tx_LookupConfig(DeviceId);
	if (Config == NULL) {
		return XST_FAILURE;
	}
	Status = XI2s_Tx_CfgInitialize(I2sTxInstancePtr, Config,
		       	Config->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = XI2s_Tx_SelfTest(I2sTxInstancePtr);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	Status = I2sTxSetupIntrSystem(IntcInstancePtr,
			I2sTxInstancePtr,
			DeviceId,
			IntrId);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XI2s_Tx_SetHandler(I2sTxInstancePtr, XI2S_TX_HANDLER_AES_BLKCMPLT,
			&I2sTxAesBlockCmplIntrHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetHandler(I2sTxInstancePtr, XI2S_TX_HANDLER_AES_BLKSYNCERR,
			&I2sTxAesBlockErrIntrHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetHandler(I2sTxInstancePtr,XI2S_TX_HANDLER_AES_CHSTSUPD,
			&I2sTxAesGetChStsHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetHandler(I2sTxInstancePtr, XI2S_TX_HANDLER_AUD_UNDRFLW,
			&I2sTxUnderflowIntrHandler,
			(void *)I2sTxInstancePtr);
	XI2s_Tx_SetSclkOutDiv(I2sTxInstancePtr,I2S_TX_MCLK,I2S_TX_FS);
	XI2s_Tx_SetChMux(I2sTxInstancePtr, 0, XI2S_TX_CHMUX_AXIS_01);
	XI2s_Tx_IntrEnable(I2sTxInstancePtr, XI2S_TX_GINTR_EN_MASK);
	XI2s_Tx_IntrEnable(I2sTxInstancePtr, XI2S_TX_INTR_AES_BLKCMPLT_MASK);
	XI2s_Tx_IntrEnable(I2sTxInstancePtr, XI2S_TX_INTR_AUDUNDRFLW_MASK);
	XI2s_Tx_Enable(I2sTxInstancePtr, 0x1);
	Xil_ExceptionEnable();
	while (IntrCount < I2S_TX_TIME_OUT) {
		if (IntrReceived == 1) {
			break;
		}
		IntrCount++;
	}
	return XST_SUCCESS;
}
int I2sTxIntrExample ( INTC * IntcInstancePtr , XI2s_Tx * I2sTxInstancePtr , u16 DeviceId , u16 IntrId ) { int Status ; XI2stx_Config * Config ; u32 IntrCount = 0 ; Config = XI2s_Tx_LookupConfig ( DeviceId ) ; if ( Config == NULL ) { return XST_FAILURE ; } Status = XI2s_Tx_CfgInitialize ( I2sTxInstancePtr , Config , Config -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = XI2s_Tx_SelfTest ( I2sTxInstancePtr ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } Status = I2sTxSetupIntrSystem ( IntcInstancePtr , I2sTxInstancePtr , DeviceId , IntrId ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XI2s_Tx_SetHandler ( I2sTxInstancePtr , XI2S_TX_HANDLER_AES_BLKCMPLT , & I2sTxAesBlockCmplIntrHandler , ( void * ) I2sTxInstancePtr ) ; XI2s_Tx_SetHandler ( I2sTxInstancePtr , XI2S_TX_HANDLER_AES_BLKSYNCERR , & I2sTxAesBlockErrIntrHandler , ( void * ) I2sTxInstancePtr ) ; XI2s_Tx_SetHandler ( I2sTxInstancePtr , XI2S_TX_HANDLER_AES_CHSTSUPD , & I2sTxAesGetChStsHandler , ( void * ) I2sTxInstancePtr ) ; XI2s_Tx_SetHandler ( I2sTxInstancePtr , XI2S_TX_HANDLER_AUD_UNDRFLW , & I2sTxUnderflowIntrHandler , ( void * ) I2sTxInstancePtr ) ; XI2s_Tx_SetSclkOutDiv ( I2sTxInstancePtr , I2S_TX_MCLK , I2S_TX_FS ) ; XI2s_Tx_SetChMux ( I2sTxInstancePtr , 0 , XI2S_TX_CHMUX_AXIS_01 ) ; XI2s_Tx_IntrEnable ( I2sTxInstancePtr , XI2S_TX_GINTR_EN_MASK ) ; XI2s_Tx_IntrEnable ( I2sTxInstancePtr , XI2S_TX_INTR_AES_BLKCMPLT_MASK ) ; XI2s_Tx_IntrEnable ( I2sTxInstancePtr , XI2S_TX_INTR_AUDUNDRFLW_MASK ) ; XI2s_Tx_Enable ( I2sTxInstancePtr , 0x1 ) ; Xil_ExceptionEnable ( ) ; while ( IntrCount < I2S_TX_TIME_OUT ) { if ( IntrReceived == 1 ) { break ; } IntrCount ++ ; } return XST_SUCCESS ; }
This function does a minimal test on the I2s Transmitter device and driver
 as a  design example.
This function does a minimal test on the I2s Transmitter device and driver as a design example .
/*
	 * Lookup and Initialize the I2s Transmitter so that it's ready to use.
	 */ /*
	 * Perform a self-test to ensure that the hardware was built correctly.
	 */ /*
	 * Connect the I2s Transmitter counter to the interrupt
	 * subsystem such that interrupts can occur.
	 * This function is application specific.
	 */ /*
	 * Setup the handler for the I2s Transmitter that will be called from
	 * the interrupt context when the I2s Transmitter receives a block
	 * complete interrupt, AES Block Sync Error interrupt, AES Channel
	 * Status Updated interrupt, Underflow interrupt or Global interrupt.
	 */ /* Wait until an interrupt has been received. */