Exemple #1
0
int main()
{

	Xint16 audio_data[128];
	int i;
	u8 *oled_equalizer_buf=(u8 *)malloc(128*sizeof(u8));
	Xil_Out32(OLED_BASE_ADDR,0xff);
	OLED_Init();			//oled init
	IicConfig(XPAR_XIICPS_0_DEVICE_ID);
	AudioPllConfig(); //enable core clock for ADAU1761
	AudioConfigure();

	xil_printf("ADAU1761 configured\n\r");

	/*
	 * perform continuous read and writes from the codec that result in a loopback
	 * from Line in to Line out
	 */

	while(1)
	{
		get_audio(audio_data);
		for(i=0;i<128;i++)
		{
			oled_equalizer_buf[i]=audio_data[i]>>18;
		}
		OLED_Clear();
		OLED_Equalizer_128(oled_equalizer_buf);
	}
    return 0;
}
/* \brief LED and AUDIO initialization
 *
 */
void system_init()
{
	Xil_Out32(OLED_BASE_ADDR,0xff);
	OLED_Init();							   //OLED initialization
	IicConfig(XPAR_XIICPS_0_DEVICE_ID);
	AudioPllConfig(); 						   //enable core clock for ADAU1761
	AudioConfigure();
	DMA_Congfig(DMA_DEV_ID);
	//Disable cache on OCM
	Xil_SetTlbAttributes(0x00000000,0x14de2);

}
int main()
{
    //init_platform();
	u32 i;
	u32 ret[128];

	Xint16 audio_data[128];
	u8 *oled_equalizer_buf=(u8 *)malloc(128*sizeof(u8));//WARNING bro...: -Wimplicit-function-declaration

	/* -------- LED and HW related -------- */
	Xil_Out32(OLED_BASE_ADDR,0xff);
	OLED_Init();			//oled init
	IicConfig(XPAR_XIICPS_0_DEVICE_ID);
	AudioPllConfig(); //enable core clock for ADAU1761
	AudioConfigure();

	xil_printf("ADAU1761 configured\n\r");
while(1) {
	//DEBUG: xil_printf("*");

    // capture audio data
    get_audio(audio_data);

#if (MEASURE_TIME==1)
    // Your total latency (FFT + Magnitude + Noise cancellation + Averaging + to & fro  PS-PL communication) ...
    // should be less than 103us.
	init_timer(timer_ctrl, timer_counter_l, timer_counter_h);
	start_timer(timer_ctrl);
#endif

    for(i=0;i<128;i++)
    {
    	Xil_Out32(XPAR_AXI4BURST_PS2PL_0_S_AXI_MEM0_BASEADDR, audio_data[i]);
    	//DEBUG: xil_printf("sent data %0x\n\r", audio_data[i]);
    }

    //TODO: find more elegant way, checking some "completed status" signal maybe...
    usleep(10);// less than 10usec doesn't work

    for(i=0;i<128;i++)
    {
    	ret[i] = Xil_In32(XPAR_AXI4BURST_PS2PL_0_S_AXI_MEM0_BASEADDR);

    	//TODO: put these post-process in FPGA
    	oled_equalizer_buf[i] = (u8)(ret[i] >> 4);
    	//DEBUG: xil_printf("oled[%d]=%d\n\r", i, oled_equalizer_buf[i]);

    	if (oled_equalizer_buf[i] >= 40) {
    		oled_equalizer_buf[i] = 40;
    	}
    }

#if (MEASURE_TIME==1)
	stop_timer(timer_ctrl);
	//Calculate the time for the operation
	xil_printf("Communication time %d us\n\r", (*timer_counter_l) / 333);
#endif

    OLED_Clear();
    OLED_Equalizer_128(oled_equalizer_buf);
}
    return 0;
}