共2条
1/1 1 跳转至页
S3C44B0 求助:各位大大, S3C44B0 怎么播放音频,谢谢!
问
请教:
各位大哥,我买了块 44B0 的开发板,带音频输出,可是它给的测试代码只能在 RAM 里拨放拨放,我希望能在 flash 里拨放,各位大哥,那要代码要怎么写呢?还有 怎么把 *.wave 文件弄到 flash 里面去?
这是给的测试代码:
#include "44b.h"
#include "def.h"
#include "iis.h"
#include "utils.h"
typedef struct tWAVEFORMATEX{
U16 wFormatTag;
U16 nChannels;
U32 nSamplesPerSec;
U32 nAvgBytesPerSec;
U16 nBlockAlign;
U16 wBitsPerSample;
U16 cbSize;
}WAVEFORMATEX, *LPWAVEFORMATEX;
#define WAVE_FORMAT_PCM 0x0001
void __irq BDMA0_Done(void);
void Init_4334(void)
{
}
/****************************************************************************
Name : Play_SmallWave
Function: 播放1M以下的wav文件,采用DMA方式
Input : addr----------wav文件起始地址
samplesize----wav文件长度
Return :
说明 :
****************************************************************************/
void Play_SmallWave(U32 addr, U32 size)
{
unsigned char *pWave;
U32 samplesize;
U32 save_PLLCON;
// ChangePllValue(0x69,0x17,0x0); //MCLK=45.1584MHz <-- 5.6448MHz*8
save_PLLCON = rPLLCON;
rPLLCON = (0x69<<12)|(0x17<<4)|0;
SerialChgBaud(115200);
pISR_BDMA0=(unsigned)BDMA0_Done;
rINTMSK=~(BIT_GLOBAL|BIT_BDMA0);
pWave=(unsigned char *)addr;
pWave+=0x28; //指向wav采样长度
samplesize=*(pWave+0) | *(pWave+1)<<8 | *(pWave+2)<<16 | *(pWave+3)<<24;
pWave+=4; //指向wav数据
samplesize=(samplesize>>1)<<1;
printf("\nsample start:0x%x",pWave);
printf("\nsample size:0x%x",samplesize);
Init_4334();
/****** IIS Initialize ******/
rIISCON=0x22; //Tx DMA enable,Rx idle,prescaler enable
rIISMOD=0x89; //Master,Tx,L-ch=low,iis,16bit ch.,codeclk=256fs,lrck=32fs
// rIISPSR=0x11; //Prescaler_A/B enable, value=1
rIISPSR=0x33; //Prescaler_A/B enable, value=3
rIISFCON=0xa00; //Tx/Rx DMA,Tx/Rx FIFO --> start piling....
/****** BDMA0 Initialize ******/
rBDISRC0=(1<<30)+(1<<28)+(U32)pWave; //Half word,inc,pWave
rBDIDES0=(1<<30)+(3<<28)+((U32)rIISFIF); //M2IO,fix,IISFIF
rBDICNT0=(1<<30)+(1<<26)+(3<<22)+(1<<21)+(0<<20)+samplesize;
rBDICNT0 |= (1<<20);//enable
//iis,reserve,done_int,auto-reload/start,DMA enable,COUNT
rBDCON0 = 0x0<<2;
printf("\nNow play the wave file ...");
printf("\nPush any key to exit!!!");
/****** IIS Tx Start ******/
rIISCON |=0x1;
while(!getkey());
/****** IIS Tx Stop ******/
rIISCON=0x0; //IIS stop
rBDICNT0=0x0; //BDMA stop
rINTMSK=BIT_GLOBAL;
//ChangePllValue(136, 8, 1);//Fin=10MHz, Fout=72MHz
rPLLCON = save_PLLCON;
SerialChgBaud(115200);
}
void __irq BDMA0_Done(void)
{
rI_ISPC=BIT_BDMA0; //clear pending bit
WrUTXH0('#');
}
/****************************************************************************
Name : Play_BigWave
Function: 播放1M以上的wav文件,采用normal方式
Input : addr----------wav文件起始地址
samplesize----wav文件长度
Return :
说明 :
****************************************************************************/
void Play_BigWave(U32 addr, U32 size)
{
int i;
unsigned char *pWave;
unsigned short *pSteroWave;
U32 samplesize,start;
U32 save_PLLCON;
LPWAVEFORMATEX pWav;
if(!download_len)
return;
pWav = (LPWAVEFORMATEX)(addr+0x14);
if(pWav->wFormatTag!=WAVE_FORMAT_PCM) {
puts("Supported PCM format only\n");
return;
}
if(pWav->nChannels!=2) {
puts("Support stereo wave only\n");
return;
}
printf("Sample rate =%dHz\n", pWav->nSamplesPerSec);
// ChangePllValue(0x69,0x17,0x0); //MCLK=45.1584MHz <-- 5.6448MHz*8
save_PLLCON = rPLLCON;
rPLLCON = (0x69<<12)|(0x17<<4)|0;
SerialChgBaud(115200);
pWave=(unsigned char *)addr;
pWave+=0x28; //指向wav采样长度
samplesize=*(pWave+0) | *(pWave+1)<<8 | *(pWave+2)<<16 | *(pWave+3)<<24;
pWave+=4;
start=(U32)(unsigned char *)pWave; //指向wav数据
pSteroWave=(U16 *)start;
samplesize=(samplesize>>1)<<1;
printf("\nsample start:0x%x",pWave);
printf("\nsample size:0x%x",samplesize);
Init_4334();
/****** IIS Initialize ******/
rIISCON=0x02; //Tx DMA disable,Rx idle,prescaler enable
rIISMOD=0x89; //Master,Tx,L-ch=low,iis,16bit ch.,codeclk=256fs,lrck=32fs
// rIISPSR=0x11; //Prescaler_A/B enable, value=1
rIISPSR=0x33; //Prescaler_A/B enable, value=3
rIISFCON=0x200; //Tx/Rx normal,Tx FIFO enable--> start piling....
printf("\nNow play the wave file ...");
printf("\nPush ESC key to exit!!!");
/****** IIS Tx Start ******/
rIISCON |=0x1;
while(getkey()!=ESC_KEY)
{
if(IIS_FIFOREADY)
{
for(i=0;i<8;i++)
{
*rIISFIF = *pSteroWave++;
// printf("\n0x%x:0x%x",pSteroWave,*pSteroWave);
}
if( ((U32)pSteroWave-start) > samplesize )
{
// printf("\n0x%x-0x%x=0x%x:0x%x",pSteroWave,start,((U32)pSteroWave-start),samplesize);
pSteroWave=(U16 *)start;
WrUTXH0('#');
}
}
}
/****** IIS Tx Stop ******/
rIISCON=0x0; //IIS stop
SerialTxEmpty();
rPLLCON = save_PLLCON;
//ChangePllValue(0x2a,0x3,0x1);//Fin=10MHz, Fout=50MHz
SerialChgBaud(115200);
}
void IISMain(void)
{
Play_BigWave(download_addr, download_len);
}
需要怎么修改啊?
谢谢! 答 1: 期待! 答 2: 找一下我的贴子找一下我的贴子, 标题里有一个"郁闷"
C语言中这样引用:
extern int welcome;
wave_play(&welcome);
wav文件使用汇编包含, 例如welcome.s
AREA wave, data, readonly
welcome
incbin welcome.wav
end
各位大哥,我买了块 44B0 的开发板,带音频输出,可是它给的测试代码只能在 RAM 里拨放拨放,我希望能在 flash 里拨放,各位大哥,那要代码要怎么写呢?还有 怎么把 *.wave 文件弄到 flash 里面去?
这是给的测试代码:
#include "44b.h"
#include "def.h"
#include "iis.h"
#include "utils.h"
typedef struct tWAVEFORMATEX{
U16 wFormatTag;
U16 nChannels;
U32 nSamplesPerSec;
U32 nAvgBytesPerSec;
U16 nBlockAlign;
U16 wBitsPerSample;
U16 cbSize;
}WAVEFORMATEX, *LPWAVEFORMATEX;
#define WAVE_FORMAT_PCM 0x0001
void __irq BDMA0_Done(void);
void Init_4334(void)
{
}
/****************************************************************************
Name : Play_SmallWave
Function: 播放1M以下的wav文件,采用DMA方式
Input : addr----------wav文件起始地址
samplesize----wav文件长度
Return :
说明 :
****************************************************************************/
void Play_SmallWave(U32 addr, U32 size)
{
unsigned char *pWave;
U32 samplesize;
U32 save_PLLCON;
// ChangePllValue(0x69,0x17,0x0); //MCLK=45.1584MHz <-- 5.6448MHz*8
save_PLLCON = rPLLCON;
rPLLCON = (0x69<<12)|(0x17<<4)|0;
SerialChgBaud(115200);
pISR_BDMA0=(unsigned)BDMA0_Done;
rINTMSK=~(BIT_GLOBAL|BIT_BDMA0);
pWave=(unsigned char *)addr;
pWave+=0x28; //指向wav采样长度
samplesize=*(pWave+0) | *(pWave+1)<<8 | *(pWave+2)<<16 | *(pWave+3)<<24;
pWave+=4; //指向wav数据
samplesize=(samplesize>>1)<<1;
printf("\nsample start:0x%x",pWave);
printf("\nsample size:0x%x",samplesize);
Init_4334();
/****** IIS Initialize ******/
rIISCON=0x22; //Tx DMA enable,Rx idle,prescaler enable
rIISMOD=0x89; //Master,Tx,L-ch=low,iis,16bit ch.,codeclk=256fs,lrck=32fs
// rIISPSR=0x11; //Prescaler_A/B enable, value=1
rIISPSR=0x33; //Prescaler_A/B enable, value=3
rIISFCON=0xa00; //Tx/Rx DMA,Tx/Rx FIFO --> start piling....
/****** BDMA0 Initialize ******/
rBDISRC0=(1<<30)+(1<<28)+(U32)pWave; //Half word,inc,pWave
rBDIDES0=(1<<30)+(3<<28)+((U32)rIISFIF); //M2IO,fix,IISFIF
rBDICNT0=(1<<30)+(1<<26)+(3<<22)+(1<<21)+(0<<20)+samplesize;
rBDICNT0 |= (1<<20);//enable
//iis,reserve,done_int,auto-reload/start,DMA enable,COUNT
rBDCON0 = 0x0<<2;
printf("\nNow play the wave file ...");
printf("\nPush any key to exit!!!");
/****** IIS Tx Start ******/
rIISCON |=0x1;
while(!getkey());
/****** IIS Tx Stop ******/
rIISCON=0x0; //IIS stop
rBDICNT0=0x0; //BDMA stop
rINTMSK=BIT_GLOBAL;
//ChangePllValue(136, 8, 1);//Fin=10MHz, Fout=72MHz
rPLLCON = save_PLLCON;
SerialChgBaud(115200);
}
void __irq BDMA0_Done(void)
{
rI_ISPC=BIT_BDMA0; //clear pending bit
WrUTXH0('#');
}
/****************************************************************************
Name : Play_BigWave
Function: 播放1M以上的wav文件,采用normal方式
Input : addr----------wav文件起始地址
samplesize----wav文件长度
Return :
说明 :
****************************************************************************/
void Play_BigWave(U32 addr, U32 size)
{
int i;
unsigned char *pWave;
unsigned short *pSteroWave;
U32 samplesize,start;
U32 save_PLLCON;
LPWAVEFORMATEX pWav;
if(!download_len)
return;
pWav = (LPWAVEFORMATEX)(addr+0x14);
if(pWav->wFormatTag!=WAVE_FORMAT_PCM) {
puts("Supported PCM format only\n");
return;
}
if(pWav->nChannels!=2) {
puts("Support stereo wave only\n");
return;
}
printf("Sample rate =%dHz\n", pWav->nSamplesPerSec);
// ChangePllValue(0x69,0x17,0x0); //MCLK=45.1584MHz <-- 5.6448MHz*8
save_PLLCON = rPLLCON;
rPLLCON = (0x69<<12)|(0x17<<4)|0;
SerialChgBaud(115200);
pWave=(unsigned char *)addr;
pWave+=0x28; //指向wav采样长度
samplesize=*(pWave+0) | *(pWave+1)<<8 | *(pWave+2)<<16 | *(pWave+3)<<24;
pWave+=4;
start=(U32)(unsigned char *)pWave; //指向wav数据
pSteroWave=(U16 *)start;
samplesize=(samplesize>>1)<<1;
printf("\nsample start:0x%x",pWave);
printf("\nsample size:0x%x",samplesize);
Init_4334();
/****** IIS Initialize ******/
rIISCON=0x02; //Tx DMA disable,Rx idle,prescaler enable
rIISMOD=0x89; //Master,Tx,L-ch=low,iis,16bit ch.,codeclk=256fs,lrck=32fs
// rIISPSR=0x11; //Prescaler_A/B enable, value=1
rIISPSR=0x33; //Prescaler_A/B enable, value=3
rIISFCON=0x200; //Tx/Rx normal,Tx FIFO enable--> start piling....
printf("\nNow play the wave file ...");
printf("\nPush ESC key to exit!!!");
/****** IIS Tx Start ******/
rIISCON |=0x1;
while(getkey()!=ESC_KEY)
{
if(IIS_FIFOREADY)
{
for(i=0;i<8;i++)
{
*rIISFIF = *pSteroWave++;
// printf("\n0x%x:0x%x",pSteroWave,*pSteroWave);
}
if( ((U32)pSteroWave-start) > samplesize )
{
// printf("\n0x%x-0x%x=0x%x:0x%x",pSteroWave,start,((U32)pSteroWave-start),samplesize);
pSteroWave=(U16 *)start;
WrUTXH0('#');
}
}
}
/****** IIS Tx Stop ******/
rIISCON=0x0; //IIS stop
SerialTxEmpty();
rPLLCON = save_PLLCON;
//ChangePllValue(0x2a,0x3,0x1);//Fin=10MHz, Fout=50MHz
SerialChgBaud(115200);
}
void IISMain(void)
{
Play_BigWave(download_addr, download_len);
}
需要怎么修改啊?
谢谢! 答 1: 期待! 答 2: 找一下我的贴子找一下我的贴子, 标题里有一个"郁闷"
C语言中这样引用:
extern int welcome;
wave_play(&welcome);
wav文件使用汇编包含, 例如welcome.s
AREA wave, data, readonly
welcome
incbin welcome.wav
end
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 | |
【FRDM-MCXN947评测】核间通信MUTEX被打赏50分 |