📄 ad_main.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. */
/* */
/* MODULE NAME... IIC and Mcbsp */
/* FILENAME...... DEC5502_MCBSP.c */
/* DESCRIPTION: */
/* This is an fuction that can sample the signal and display the sampled */
/* signal on the LCD */
/* This example is that the CODEC is controled by the IIC and Mcbsp */
/* */
/* 作者:黄林生 */
/* 版本:1.0 */
/* 日期:06.10.20 */
/******************************************************************************/
#include <csl.h>
#include <csl_chip.h>
#include <csl_i2c.h>
#include <csl_irq.h>
#include <csl_gpt.h>
#include <csl_pll.h>
#include <csl_mcbsp.h>
#include <csl_emif.h>
#include <csl_emifBhal.h>
#include <csl_std.h>
#include "check.h"
#include "type.h"
#include "protocol.h"
#include "DEC5502_MCBSP_inti.h"
#include "DEC5502_MCBSP_work.h"
#include "i_cmplx.h"
#include "math.h"
#include "E2PROM_Function.h"
#include "CODEC.h"
#undef CODEC_ADDR
#define CODEC_ADDR 0x1A
#define ADSAMPL8K 0x03
#define ADSAMPL44K 0x0
#define ADSAMPL96K 0x07
unsigned int sendcount;
short DataBuffer[1024];
int Com_state,j;
PmcbspForDec5502 preceive;
Uint16 SampleRate;
/***********************************************************************/
unsigned int SampleLong=500;
#define SAMPLERATE 2
/***********************************************************************/
extern void VECSTART();
/*----------------------------------------------------------------------*/
// MAIN FUNCTION
/*----------------------------------------------------------------------*/
void main(void)
{
#if SAMPLERATE==1
SampleRate =ADSAMPL8K;
#endif
#if SAMPLERATE==2
SampleRate =ADSAMPL44K;
#endif
#if SAMPLERATE==3
SampleRate =ADSAMPL96K;
#endif
// Initialize CSL library - This is REQUIRED !!!
CSL_init();
// Set IVPH/IVPD to start of interrupt vector table */
IRQ_setVecs((Uint32)(&VECSTART)<<1);
// The main frequency of system is 240MHz
// 该频率是为了设置IIC模块的需要设置的,为了使用I2C_setup函数
PLL_setFreq(1, 0xC, 0, 1, 3, 3, 0);
// Initialize I2C, Using parameters in I2C_Setup structure
I2c_Setup();
// Config McBSP port 1 by use previously defined structure
Mcbsp1_Config();
// 设置AIC23各部分均工作
inti_AIC(SampleRate);
//通讯初始化
inti_Com();
Com_open();
//采样数据
AD_sample(SampleLong,&DataBuffer[0]);
//要求进行数据发送
Com_Datareq(SampleLong,NUM_DATASEND);
for(;;)
{
Com_state=Com_Staterev(&mcbspr[0]);
if(Com_state==2)
{
IRQ_clear(IRQ_EVT_RINT2);
IRQ_plug(IRQ_EVT_RINT2, &McbspRevIsr);
IRQ_enable(IRQ_EVT_RINT2);
continue;
}
if((Com_state == 0xffff)||(Com_state == 3))
{
//通知主机程序通讯出错,准备重发
Com_Checkerr(CHECK_ERR);
}
if(Com_state == 0)
{
preceive=(PmcbspForDec5502)(&mcbspr[0]);
if(preceive->Data[0]==CHECK_ERR)
Com_Dataagin(SampleLong);
}
//数据发送
if(preceive->Data[0] == DATA_RECEIVE)
Com_Datasend( SampleLong,&DataBuffer[0]);
preceive->Data[0] = 0;
}
}
/**********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -