main.c

来自「基于visual dsp++开发环境」· C语言 代码 · 共 116 行

C
116
字号
//--------------------------------------------------------------------------//
//																			//
//  Example BTC target application											//
//																			//
//--------------------------------------------------------------------------//
//																			//
//	(C) Copyright 2004 - Analog Devices, Inc.  All rights reserved.			//
//																			//
//	Project Name:	BF537 C Talkthrough I2S 								//
//																			//
//	Date Modified:	12/04		MT		Rev 1.0								//
//																			//
//	Software:		VisualDSP++ 4.0											//
//																			//
//	Hardware:		ADSP-BF537 EZ-KIT Board									//
//																			//
//	Connections:	Connect an input source (such as a radio) to the Audio	//
//					input jack and an output source (such as headphones) to //
//					the Audio output jack									//
//																			//
//	Purpose:		This program sets up the SPI port on the ADSP-BF537 to  //
//					configure the AD1854 codec.  The SPI port is disabled 	//
//					after initialization.  The data to/from the codec are 	//
//					transfered over SPORT0 in I2S mode						//
//																			//
//--------------------------------------------------------------------------//

#include "Talkthrough.h"
#include "sysreg.h"
#include "ccblkfn.h"
#include <btc.h>

//--------------------------------------------------------------------------//
// Prototypes																//
//--------------------------------------------------------------------------//
// in file Initialisation.asm
void Init_Flags(void);
void Audio_Reset(void);
void Init_EBIU(void);
void Init_Sport0(void);
void Init_DMA(void);
void Init_Interrupts(void);
void Enable_DMA_Sport0(void);
void Disable_DMA_Sport0(void);
void finish_up(void);

//--------------------------------------------------------------------------//
// Variables																//
//																			//
// Description:	The variables iChannelxLeftIn and iChannelxRightIn contain 	//
//				the data coming from the codec ad1854.  The (processed)		//
//				playback data are written into the variables 				//
//				iChannelxLeftOut and iChannelxRightOut respectively, which 	//
//				are then sent back to the codec in the SPORT0 ISR.  		//
//																			//
//--------------------------------------------------------------------------//
// left input data from ad1854
int iChannel0LeftIn;
// right input data from ad1854
int iChannel0RightIn;
// left ouput data for ad1854
int iChannel0LeftOut;
// right ouput data for ad1854
int iChannel0RightOut;

// SPORT0 DMA transmit buffer
volatile int tx_buf[4];
// SPORT0 DMA receive buffer
volatile int rx_buf[4];

////////////////////
// BTC Definitions
////////////////////
#define MAXBTCBUF  24000


int BTCLeft[MAXBTCBUF];
int BTCRight[MAXBTCBUF];	

int BTCLeftVolume = 0;
int BTCRightVolume = 0;

BTC_MAP_BEGIN
//             Channel Name, Starting Address, Length (bytes)
BTC_MAP_ENTRY("Audio Left Channel", (long)&BTCLeft, sizeof(BTCLeft))
BTC_MAP_ENTRY("Audio Right Channel", (long)&BTCRight, sizeof(BTCRight))
BTC_MAP_ENTRY("Audio Left Volume", (long)&BTCLeftVolume, sizeof(BTCLeftVolume))
BTC_MAP_ENTRY("Audio Right Volume", (long)&BTCRightVolume, sizeof(BTCRightVolume))
BTC_MAP_END

//--------------------------------------------------------------------------//
// Function:	main														//
//																			//
// Description:	After calling a few initalization routines, main() just 	//
//				waits in a loop forever.  The code to process the incoming  //
//				data can be placed in the function Process_Data() in the 	//
//				file "Process_Data.c".										//
//--------------------------------------------------------------------------//
void main(void)
{
	btc_init();

	Init_Flags();
	Audio_Reset();
	Init_Sport0();
	Init_DMA();
	Init_Interrupts();
	Enable_DMA_Sport0();

	while(1) {
		btc_poll();
	}

}

⌨️ 快捷键说明

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