⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 process audio data.c

📁 This directory contains an example ADSP-BF535 subroutine that demonstrates the initialization of t
💻 C
字号:
#include "BF535 Talkthrough.h"

//--------------------------------------------------------------------------//
// Function:	Process_Audio_Data											//
//																			//
// Parameters:	None														//
//																			//
// Return:		None														//
//																			//
// Description:	This function is called every time a valid data sample has	//
//				been received.												//
//				The PCM input data can be found in the variables			//
//				sLeft_Channel_In and sRight_Channel_In. The processed		//
//				output data should be written into variables				//
//				sLeft_Channel_Out and sRight_Channel_Out respectively; they	//
//				will be placed into the SPORT0 transmit buffer in the		//
//				SPORT0 TX ISR.												//
//--------------------------------------------------------------------------//

void Process_Audio_Data(void)
{
	unsigned int temp_sLeft_Channel_In;
	unsigned int temp_sRight_Channel_In;
	//-----------------------------------------------------------------------------
	// code for data processing should be placed here
	sAC97_Tag_Out		= sAC97_Tag_In;
	sLeft_Channel_Out	= sLeft_Channel_In;
	sRight_Channel_Out	= sRight_Channel_In;
	
	//====================================================
	//Process PWM 
	temp_sLeft_Channel_In = sLeft_Channel_In + 0x7fff;
	temp_sLeft_Channel_In = temp_sLeft_Channel_In >> 8; 
	*pTIMER0_WIDTH_LO = temp_sLeft_Channel_In;
	
	temp_sRight_Channel_In = sRight_Channel_In + 0x7fff;
	temp_sRight_Channel_In = temp_sRight_Channel_In >> 8; 
	*pTIMER1_WIDTH_LO = temp_sRight_Channel_In;	

	//-----------------------------------------------------------------------------

	// confirm SPORT0 RX interrupt handling
	sNew_Sample_Received = 0;
}


//--------------------------------------------------------------------------//
// Function:	Wait_For_Codec_Init											//
//																			//
// Parameters:	None														//
//																			//
// Return:		None														//
//																			//
// Description:	This function places a new codec register into the SPORT0	//
//				transmit buffer every time a SPORT0 RX interrupt occurs.	//
//--------------------------------------------------------------------------//
void Wait_For_Codec_Init(void)
{
	static volatile int iCodec_Regs_Counter = 0;

	// place new address and register for codec into SPORT0 transmit buffer
	sAC97_Tag_Out							= 0xe000;
	sSPORT0_TX_Buffer[SLOT_COMMAND_ADDRESS]	= sCodec_Regs[iCodec_Regs_Counter++];
	sSPORT0_TX_Buffer[SLOT_COMMAND_DATA]	= sCodec_Regs[iCodec_Regs_Counter++];

	// confirm SPORT0 TX interrupt handling
	sNew_Sample_Received = 0;

	// check whether complete array has been transferred
	if(iCodec_Regs_Counter >= SIZE_OF_CODEC_REGS)
	{
		// clear address and register data slot
		sAC97_Tag_Out							= 0x8000;
		sSPORT0_TX_Buffer[SLOT_COMMAND_ADDRESS]	= 0x0000;
		sSPORT0_TX_Buffer[SLOT_COMMAND_DATA]	= 0x0000;

		// from now on Process_Audio_Data will serve as data handler
		pSPORT0_RX_ISR_Handling = Process_Audio_Data;
	}
}

//--------------------------------------------------------------------------//
// Function:	SPORT0_RX_Dummy_Handler										//
//																			//
// Parameters:	None														//
//																			//
// Return:		None														//
//																			//
// Description:	This function serves as dummy for SPORT0 receive interrupt	//
//				handling until the codec is ready. After that, it will get	//
//				replaced by function Wait_For_Codec_Init.					//
//--------------------------------------------------------------------------//
void SPORT0_RX_Dummy_Handler(void)
{
	// confirm SPORT0 RX interrupt handling
	sNew_Sample_Received = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -