XilinxProcessorIPLib/drivers/audio_formatter/examples/xaudioformatter_intr_example.c
u32 InitializeAudioFormatter(XAudioFormatter *AFInstancePtr)
{
	u32 Status;
	u32 offset;
	XAudioFormatter_Config *AFConfig;
	/*
	 * Lookup and Initialize the audio formatter so that it's ready to use.
	 */
	Status = XAudioFormatter_Initialize(&AFInstance, AF_DEVICE_ID);
	if (Status != XST_SUCCESS)
		return XST_FAILURE;

	if (AFInstancePtr->s2mm_presence == 1) {
		Status = XScuGic_Connect(&Intc, AF_S2MM_INTERRUPT_ID,
			(XInterruptHandler)XAudioFormatterS2MMIntrHandler,
			(void *)AFInstancePtr);
		if (Status == XST_SUCCESS) {
			XScuGic_Enable(&Intc, AF_S2MM_INTERRUPT_ID);
		} else {
			xil_printf("Failed to register AF interrupt handler");
			return XST_FAILURE;
		}
		AFInstancePtr->ChannelId = XAudioFormatter_S2MM;
		XAudioFormatter_SetS2MMCallback(AFInstancePtr,
			XAudioFormatter_IOC_Handler, XS2MMAFCallback,
			(void *)AFInstancePtr);
		XAudioFormatter_InterruptEnable(AFInstancePtr,
			XAUD_CTRL_IOC_IRQ_MASK);
		XAudioFormatterSetS2MMTimeOut(AFInstancePtr, AF_S2MM_TIMEOUT);
		XAudioFormatterSetHwParams(AFInstancePtr, &af_hw_params);
		XAudioFormatterDMAStart(AFInstancePtr);
	}
	if (AFInstancePtr->mm2s_presence == 1) {
		Status = XScuGic_Connect(&Intc, AF_MM2S_INTERRUPT_ID,
			(XInterruptHandler)XAudioFormatterMM2SIntrHandler,
			(void *)AFInstancePtr);
		if (Status == XST_SUCCESS) {
			XScuGic_Enable(&Intc, AF_MM2S_INTERRUPT_ID);
		} else {
			xil_printf("Failed to register AF interrupt handler");
			return XST_FAILURE;
		}
		AFInstancePtr->ChannelId = XAudioFormatter_MM2S;
		XAudioFormatter_SetMM2SCallback(AFInstancePtr,
			XAudioFormatter_IOC_Handler, XMM2SAFCallback,
			(void *)AFInstancePtr);
		XAudioFormatter_InterruptEnable(AFInstancePtr,
			XAUD_CTRL_IOC_IRQ_MASK);
		XAudioFormatterSetFsMultiplier(AFInstancePtr, AF_MCLK, AF_FS);
		XAudioFormatterSetHwParams(AFInstancePtr, &af_hw_params);
		XAudioFormatterDMAStart(AFInstancePtr);
	}
	return Status;
}
/*****************************************************************************/
/**
 * This function does the lookup and intialization of the audio formatter.
 *
 * @param	AFInstancePtr is a pointer to audio formatter driver instance
 *
 * @return	XST_SUCCESS if the call is successful, otherwise XST_FAILURE.
 *
 * @note	None.
 *
******************************************************************************/
This function does the lookup and intialization of the audio formatter.
@param       AFInstancePtr is a pointer to audio formatter driver instance

@return      XST_SUCCESS if the call is successful, otherwise XST_FAILURE.

@note        None.
This function does the lookup and intialization of the audio formatter . @param AFInstancePtr is a pointer to audio formatter driver instance @return XST_SUCCESS if the call is successful otherwise XST_FAILURE . @note None .
u32 InitializeAudioFormatter(XAudioFormatter *AFInstancePtr)
{
	u32 Status;
	u32 offset;
	XAudioFormatter_Config *AFConfig;
	Status = XAudioFormatter_Initialize(&AFInstance, AF_DEVICE_ID);
	if (Status != XST_SUCCESS)
		return XST_FAILURE;
	if (AFInstancePtr->s2mm_presence == 1) {
		Status = XScuGic_Connect(&Intc, AF_S2MM_INTERRUPT_ID,
			(XInterruptHandler)XAudioFormatterS2MMIntrHandler,
			(void *)AFInstancePtr);
		if (Status == XST_SUCCESS) {
			XScuGic_Enable(&Intc, AF_S2MM_INTERRUPT_ID);
		} else {
			xil_printf("Failed to register AF interrupt handler");
			return XST_FAILURE;
		}
		AFInstancePtr->ChannelId = XAudioFormatter_S2MM;
		XAudioFormatter_SetS2MMCallback(AFInstancePtr,
			XAudioFormatter_IOC_Handler, XS2MMAFCallback,
			(void *)AFInstancePtr);
		XAudioFormatter_InterruptEnable(AFInstancePtr,
			XAUD_CTRL_IOC_IRQ_MASK);
		XAudioFormatterSetS2MMTimeOut(AFInstancePtr, AF_S2MM_TIMEOUT);
		XAudioFormatterSetHwParams(AFInstancePtr, &af_hw_params);
		XAudioFormatterDMAStart(AFInstancePtr);
	}
	if (AFInstancePtr->mm2s_presence == 1) {
		Status = XScuGic_Connect(&Intc, AF_MM2S_INTERRUPT_ID,
			(XInterruptHandler)XAudioFormatterMM2SIntrHandler,
			(void *)AFInstancePtr);
		if (Status == XST_SUCCESS) {
			XScuGic_Enable(&Intc, AF_MM2S_INTERRUPT_ID);
		} else {
			xil_printf("Failed to register AF interrupt handler");
			return XST_FAILURE;
		}
		AFInstancePtr->ChannelId = XAudioFormatter_MM2S;
		XAudioFormatter_SetMM2SCallback(AFInstancePtr,
			XAudioFormatter_IOC_Handler, XMM2SAFCallback,
			(void *)AFInstancePtr);
		XAudioFormatter_InterruptEnable(AFInstancePtr,
			XAUD_CTRL_IOC_IRQ_MASK);
		XAudioFormatterSetFsMultiplier(AFInstancePtr, AF_MCLK, AF_FS);
		XAudioFormatterSetHwParams(AFInstancePtr, &af_hw_params);
		XAudioFormatterDMAStart(AFInstancePtr);
	}
	return Status;
}
u32 InitializeAudioFormatter ( XAudioFormatter * AFInstancePtr ) { u32 Status ; u32 offset ; XAudioFormatter_Config * AFConfig ; Status = XAudioFormatter_Initialize ( & AFInstance , AF_DEVICE_ID ) ; if ( Status != XST_SUCCESS ) return XST_FAILURE ; if ( AFInstancePtr -> s2mm_presence == 1 ) { Status = XScuGic_Connect ( & Intc , AF_S2MM_INTERRUPT_ID , ( XInterruptHandler ) XAudioFormatterS2MMIntrHandler , ( void * ) AFInstancePtr ) ; if ( Status == XST_SUCCESS ) { XScuGic_Enable ( & Intc , AF_S2MM_INTERRUPT_ID ) ; } else { xil_printf ( " " ) ; return XST_FAILURE ; } AFInstancePtr -> ChannelId = XAudioFormatter_S2MM ; XAudioFormatter_SetS2MMCallback ( AFInstancePtr , XAudioFormatter_IOC_Handler , XS2MMAFCallback , ( void * ) AFInstancePtr ) ; XAudioFormatter_InterruptEnable ( AFInstancePtr , XAUD_CTRL_IOC_IRQ_MASK ) ; XAudioFormatterSetS2MMTimeOut ( AFInstancePtr , AF_S2MM_TIMEOUT ) ; XAudioFormatterSetHwParams ( AFInstancePtr , & af_hw_params ) ; XAudioFormatterDMAStart ( AFInstancePtr ) ; } if ( AFInstancePtr -> mm2s_presence == 1 ) { Status = XScuGic_Connect ( & Intc , AF_MM2S_INTERRUPT_ID , ( XInterruptHandler ) XAudioFormatterMM2SIntrHandler , ( void * ) AFInstancePtr ) ; if ( Status == XST_SUCCESS ) { XScuGic_Enable ( & Intc , AF_MM2S_INTERRUPT_ID ) ; } else { xil_printf ( " " ) ; return XST_FAILURE ; } AFInstancePtr -> ChannelId = XAudioFormatter_MM2S ; XAudioFormatter_SetMM2SCallback ( AFInstancePtr , XAudioFormatter_IOC_Handler , XMM2SAFCallback , ( void * ) AFInstancePtr ) ; XAudioFormatter_InterruptEnable ( AFInstancePtr , XAUD_CTRL_IOC_IRQ_MASK ) ; XAudioFormatterSetFsMultiplier ( AFInstancePtr , AF_MCLK , AF_FS ) ; XAudioFormatterSetHwParams ( AFInstancePtr , & af_hw_params ) ; XAudioFormatterDMAStart ( AFInstancePtr ) ; } return Status ; }
This function does the lookup and intialization of the audio formatter.
This function does the lookup and intialization of the audio formatter .
/*
	 * Lookup and Initialize the audio formatter so that it's ready to use.
	 */