📄 mcbsp_ad.c
字号:
/******************************************************************************/
/* Copyright 2004 by SEED Electronic Technology LTD. */
/* All rights reserved. SEED Electronic Technology LTD. */
/* Restricted rights to use, duplicate or disclose this code are */
/* granted through contract. */
/******************************************************************************/
/********************************************************************************\
\*DEC6713_CODEC.c -Codec AIC23B test programme.
\********************************************************************************/
#include <csl.h>
#include <csl_mcasp.h>
#include <csl_mcbsp.h>
#include <csl_i2c.h>
#include <DEC6713.h>
#include <codec.h>
#include <IIC.h>
#include <comm.h>
/////////////////////
volatile unsigned int* p_DECCTL=(volatile unsigned int *)0xB0000000;
///////////////////
#define ADSAMPL8K 0x0c
#define ADSAMPL44K 0x22
#define ADSAMPL96K 0x1c
PMcbspForDec6713 psend;
PMcbspForDec6713 preceive;
Uint32 Com_state;
Uint32 m;
unsigned short DDataBuffer[1280]={0};
/********************************************************************************/
unsigned short SampleRate,SampleLong=500;//采样长度通过SampleLong来修改
#define SAMPLERATE 2 //可以通过修改SAMPLERATE的值来改采样频率
/*******************************************************************************/
/********************************************************************************/
extern far void vectors();
void DEC6713_AIC23_Config(Uint32 SampleRate);
void AD_sample(unsigned short ADlen,unsigned short *AD_data);
/********************************************************************************/
void main()
{
#if SAMPLERATE==1
SampleRate =ADSAMPL8K;
#endif
#if SAMPLERATE==2
SampleRate =ADSAMPL44K;
#endif
#if SAMPLERATE==3
SampleRate =ADSAMPL96K;
#endif
/* Initialize CSL. */
CSL_init();
/* Initialize DEC6713 board. */
DEC6713_init();
//Open McASP
*p_DECCTL=0x00;
//Initialize AIC23
DEC6713_AIC23_Config(SampleRate);
//Open McBASP
*p_DECCTL=0x40;
//initiallize McBSP
McBSP_int();
//Open interrupt
interrupt_init();
inti_Com();
psend=(PMcbspForDec6713)(&mcbspx[0]);
AD_sample(SampleLong,&DDataBuffer[0]);
for(m=0;m<2000;m++);
/*通知主机,系统准备好*/
Com_Datareq(SampleLong,NUM_DATASEND);
for(;;)
{
Com_state=Com_Staterev(&mcbspr[0]);
if(Com_state==2)
{
}
if((Com_state == 0xffff)||(Com_state == 3))
{
//通知主机程序通讯出错,准备重发
Com_Checkerr(CHECK_ERR);
}
if(Com_state == 0)
{
preceive=(PMcbspForDec6713)(&mcbspr[0]);
if(preceive->Data[0]==CHECK_ERR)
Com_Dataagin(SampleLong);
}
//数据发送
if(preceive->Data[0] == DATA_RECEIVE)
Com_Datasend( SampleLong,&DDataBuffer[0]);
preceive->Data[0] = 0;
}
}
/********************************************************************************/
/* no more */
/********************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -