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

📄 main.c

📁 This directory contains an example ADSP-BF535 subroutine that demonstrates the initialization of t
💻 C
字号:
//--------------------------------------------------------------------------//
// Talkthrough for the ADSP-BF535											//
//																			//
// Version:		0.98														//
// Author:		MK															//
// Date:		28.05.2003													//
//																			//
// Tested with																//
// Hardware:	ADSP-BF535 EZ-KIT Lite 1.4, Chip Revision 0.2				//
// Software:	VisualDSP++ 3.1, Compiler Version 6.3.1						//
//																			//
// Description:	This program sets up SPORT0 in Descriptor Multichannel mode	//
//				and initialises the AC97 codec AD1885.						//
//				Code for audio data processing should be placed in function	//
//				Process_Audio_Data in file "Process Audio Data.c".			//
//																			//
// Note:		For Blackfin chip revisions >= 1.0, the function			//
//				Init_Interrupts needs to be modified.						//
//--------------------------------------------------------------------------//

#include "BF535 Talkthrough.h"
#include <cdefBF535.h>
#include <signal.h>
//--------------------------------------------------------------------------//
// Variables																//
//																			//
// Description:	sLeft_Channel_In, sRight_Channel_In:						//
//					Variables that contain PCM data coming from the codec.	//
//				sLeft_Channel_Out, sRight_Channel_Out:						//
//					Variables to hold the processed output data.			//
//				sCodec_Regs:												//
//					Array containg configuration registers for audio codec	//
//					AD1885. Used to initialise the codec. See data sheet	//
//					for details.											//
//--------------------------------------------------------------------------//
// PCM input data
volatile short sLeft_Channel_In, sRight_Channel_In;

// PCM output data
volatile short sLeft_Channel_Out, sRight_Channel_Out;

// array for codec registers
volatile short sCodec_Regs[SIZE_OF_CODEC_REGS] =
{
	SERIAL_CONFIGURATION,	0x9900,
	RESET,					0xffff,
	MASTER_VOLUME,			0x8000,
	HEADPHONES_VOLUME,		0x0000,
	MASTER_VOLUME_MONO,		0x8000,
	PC_BEEP,				0x8000,
	PHONE_VOLUME,			0x8008,
	MIC_VOLUME,				0x8008,
	LINE_IN_VOLUME,			0x8808,
	CD_VOLUME,				0x8808,
	VIDEO_VOLUME,			0x8808,
	AUX_VOLUME,				0x8808,
	PCM_OUT_VOLUME,			0x0808,
	RECORD_SELECT_CONTROL,	0x0404,				// 0x0404: Line In, 0x0000: Micro
	RECORD_GAIN,			0x0000,
	GENERAL_PURPOSE,		0x0000,
	THREE_D_CONTROL,		0x0000,
	SUBSECTION_READY,		0x0000,
	EXTENDED_AUDIO_ID,		0x0001,
	EXTENDED_AUDIO_CTL,		0x0001,
	JACK_SENSE,				0x0000,
	PCM_DAC_RATE_1,			0xbb80,				// 0x1b58: 7 kHz, 0xbb80: 48 kHz
	PCM_DAC_RATE_0,			0xbb80,				// PCM_DAC_RATE_0/1 must have the same value,
	VENDOR_ID_1,			0x4144,				// otherwise output will be distorted
	VENDOR_ID_2,			0x5360
};

// the following variables are used internally and don't need to be modified by the user

// variables that hold AC97 Tags
volatile short sAC97_Tag_In, sAC97_Tag_Out;

// Descriptors for SPORT0 RX/TX DMA setup
volatile short sSPORT0_RX_Descriptor[DESCRIPTOR_SIZE], sSPORT0_TX_Descriptor[DESCRIPTOR_SIZE];

// SPORT0 DMA buffers
volatile short sSPORT0_RX_Buffer[AC97_FRAME_SIZE], sSPORT0_TX_Buffer[AC97_FRAME_SIZE];

// flag that indicates that a new sample has been received
volatile short sNew_Sample_Received;

// pointer to function for SPORT0 receive interrupt handling
void (*pSPORT0_RX_ISR_Handling)(void) = SPORT0_RX_Dummy_Handler;

//--------------------------------------------------------------------------//
// Function:	main														//
//																			//
// Description:	After calling a few initalisation routines, main waits in	//
//				an endless loop and checks a flag to determine whether a	//
//				new audio sample can be processed.							//
//				The code for the data processing can be placed in function	//
//				Process_Audio_Data.											//
//--------------------------------------------------------------------------//
//PWM definitions
void Init_PWM0(void);
void Init_PWM1(void);

void main(void)
{
	Init_PWM0();
	Init_PWM1();
	Init_Flags();
	Init_SPORT0();
	Init_Interrupts();
	Init_Codec();
	
	while(1)
	{
		if(sNew_Sample_Received) pSPORT0_RX_ISR_Handling();
	}
}


void Init_PWM0(void)
{
	*pTIMER0_CONFIG = 0x0019;
	*pTIMER0_PERIOD_HI = 0x0000;
	*pTIMER0_WIDTH_HI = 0x0000;
	*pTIMER0_PERIOD_LO = 0x142;
	*pTIMER0_WIDTH_LO = 0xA1;
	*pTIMER0_STATUS = 0x0100;	
	
}
void Init_PWM1(void)
{
	*pTIMER1_CONFIG = 0x0019;
	*pTIMER1_PERIOD_HI = 0x0000;
	*pTIMER1_WIDTH_HI = 0x0000;
	*pTIMER1_PERIOD_LO = 0x142;
	*pTIMER1_WIDTH_LO = 0xA1;
	*pTIMER1_STATUS = 0x0400;
	
}


⌨️ 快捷键说明

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