📄 dec5502_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. */
/* */
/* MODULE NAME... IIC and Mcbsp */
/* FILENAME...... 5502_CODEC.c */
/* DESCRIPTION: */
/* This is an audio signal sample and play example for CODEC of C5502 */
/* This example is that the codec is controled by the IIC and Mcbsp */
/* */
/* 作者:艾岩 */
/* 版本:1.0 */
/* 日期:06.8.30 */
/******************************************************************************/
#include <csl.h>
#include <csl_chip.h>
#include <csl_i2c.h>
#include <csl_pll.h>
#include <csl_mcbsp.h>
#include <csl_emif.h>
#include <csl_emifBhal.h>
#include "E2PROM_Function.h"
#include "CODEC.h"
#undef CODEC_ADDR
#define CODEC_ADDR 0x1A
#define ADSAMPL8K 0x03
#define ADSAMPL48K 0x0
#define ADSAMPL96K 0x07
#define SAMPLERATE 1
#define SAMPLELONG 3
Uint16 SampleLong;
Uint16 SampleRate;
short DataBuffer[1024]={0};
//Uint16 SampleRate;
//Uint16 SampleLong;
// 定义McBSP的句柄
MCBSP_Handle hMcbsp;
/*------------------------------------------------------------------------------------*/
//
// FUNCTION: MAIN
//
/*------------------------------------------------------------------------------------*/
void main(void)
{
Uint16 i = 0;
short DataTempR = 0; // 暂存采样数据
short DataTempL = 0; // 暂存采样数据
#if SAMPLERATE==1
SampleRate =ADSAMPL8K;
#endif
#if SAMPLERATE==2
SampleRate =ADSAMPL44K;
#endif
#if SAMPLERATE==3
SampleRate =ADSAMPL96K;
#endif
#if SAMPLELONG==1
SampleLong =256;
#endif
#if SAMPLELONG==2
SampleLong =512;
#endif
#if SAMPLELONG==3
SampleLong =1024;
#endif
// Initialize CSL library - This is REQUIRED !!!
CSL_init();
// 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();
// Open McBSP port 1 and get a McBSP type handle
hMcbsp = MCBSP_open(MCBSP_PORT1,MCBSP_OPEN_RESET);
// Config McBSP port 1 by use previously defined structure
Mcbsp_Config(hMcbsp);
// Start McBSP1
MCBSP_start(hMcbsp,
MCBSP_RCV_START | MCBSP_XMIT_START,
0);
inti_AIC(hMcbsp);
for(i=0;i<SampleLong;i++)
{
DataBuffer[i] = 0;
}
for(i=0;i<SampleLong;i++)
{
while(!MCBSP_rrdy(hMcbsp)){};
DataTempL = MCBSP_read16(hMcbsp);
while(!MCBSP_rrdy(hMcbsp)){};
DataTempR = MCBSP_read16(hMcbsp);
DataBuffer[i] = DataTempR;
}
while(1){};
}
/******************************************************************************/
// No more
/******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -