新聞中心

S3C2440-IIS放音

作者: 時間:2016-12-02 來源:網絡 收藏


完成音頻文件的播放。IISFIFO為16位寬,深度為32。將音頻數(shù)組中的數(shù)據(jù)裝入IISFIFO,裝滿后IIS讀取IISFIFO中的數(shù)據(jù),即放音,然后再將音頻數(shù)組中的數(shù)據(jù)讀入IISFIFO,周而復始,完成放音。

#include "2440addr.h"
#include "music.h"
#define L3MODE 1<<2
#define L3DATA 1<<3
#define L3CLOCK 1<<4
void WriteL3(unsigned char data, unsigned int mode){
//mode = 0,地址模式;mode = 1,數(shù)據(jù)傳輸模式
int i, k;
if(mode == 0){
rGPBDAT = rGPBDAT & "(L3MODE|L3DATA|L3CLOCK )|L3CLOCK;
}
else{
rGPBDAT = rGPBDAT & "(L3MODE|L3DATA|L3CLOCK)|(L3CLOCK|L3MODE);
}
for(k = 0; k < 5; k++)
;
for(i = 0; i < 8; i++){
if(data & 0x1){
rGPBDAT &= "L3CLOCK;
rGPBDAT |= L3DATA;
for(k = 0; k < 5; k++)
;
rGPBDAT |= L3CLOCK;
rGPBDAT |= L3DATA;
for(k = 0; k < 5; k++)
;
}
else{
rGPBDAT &= "L3CLOCK;
rGPBDAT &= "L3DATA;
for(k = 0; k < 5; k++)
;
rGPBDAT |= L3CLOCK;
rGPBDAT &= "L3DATA;
for(k = 0; k < 5; k++)
;
}
data >>= 1;
}
rGPBDAT = rGPBDAT & "(L3MODE|L3DATA|L3CLOCK)|(L3CLOCK|L3MODE);
}
void PlayMusic(unsigned char buffer[], unsigned int length){
int i, fifo;
//UDA1341
//STATUS模式
rGPBDAT = rGPBDAT & "(L3MODE|L3DATA|L3CLOCK)|(L3CLOCK|L3MODE);
WriteL3(0x14+2,0);
//復位
WriteL3(0x60,1);
WriteL3(0x14+2,0);
//00010000 系統(tǒng)時鐘頻率384fs
WriteL3(0x10,1);
WriteL3(0x14+2,0);
//11000001 輸出增益,ADC關,DAC開
WriteL3(0xc1,1);
//IIS
//DMA禁止,在接受空閑狀態(tài),不產生IISLRCK信號,IIS預分頻使能
rIISCON = (0<<5)|(0<<4)|(0<<3)|(1<<2)|(1<<1);
//主設備時鐘PCLK,主設備模式,發(fā)送模式,串行數(shù)據(jù)16位,主時鐘是384fs,串行位時鐘32fs
rIISMOD = (0<<9)|(0<<8)|(2<<6)|(0<<5)|(0<<4)|(1<<3)|(1<<2)|(1<<0);
//預分頻都是N=3
rIISPSR = (3<<5)|3;
//發(fā)送FIFO正常,發(fā)送FIFO使能
rIISFCON = (0<<15)|(1<<13);
//IIS start
rIISCON |= 0x1;
for(fifo = 0; fifo <= length; fifo += 64){
while(rIISCON &(1<<7));
for(i = 0; i < 32; i++)
rIISFIFO = (buffer[i*2+fifo]) + (buffer[i*2+1+fifo]<<8);
}
//IIS close
rIISCON = 0x0;
}
int Main(){
rGPBUP= rGPBUP& "(0x7<<2) | (0x7<<2); //The pull up function is disabled GPB[4:2] 1 1100
rGPBCON = rGPBCON & "(0x3f<<4) | (0x15<<4); //GPB[4:2]=Output(L3CLOCK):Output(L3DATA):Output(L3MODE)
rGPBDAT = 0x1ec;
rGPEUP= rGPEUP& "(0x1f)| 0x1f; //The pull up function is disabled GPE[4:0] 1 1111
rGPECON = rGPECON & "(0x3ff) | 0x2aa; //GPE[4:0]=I2SSDO:I2SSDI:CDCLK:I2SSCLK:I2SLRCK
rMPLLCON = (150<<12)|(5<<4)|(0<<0);
PlayMusic(music, sizeof(music));
while(1);
return 0;
}

上一頁 1 2 下一頁

關鍵詞: S3C2440IIS放

評論


技術專區(qū)

關閉