新聞中心

S3C2440-DMA

作者: 時(shí)間:2016-12-02 來(lái)源:網(wǎng)絡(luò) 收藏
void PlayMusic(unsigned char buffer[], unsigned int length){
result = (length>>1)/0x100000;
remain = (length>>1)&0xfffff;
//UDA1341
//STATUS模式
rGPBDAT = rGPBDAT & "(L3MODE|L3DATA|L3CLOCK)|(L3CLOCK|L3MODE);
WriteL3(0x14+2,0);
//復(fù)位
WriteL3(0x60,1);
WriteL3(0x14+2,0);
//00010000 系統(tǒng)時(shí)鐘頻率384fs
WriteL3(0x10,1);
WriteL3(0x14+2,0);
//11000001 輸出增益,ADC關(guān),DAC開(kāi)
WriteL3(0xc1,1);
//IIS
//DMA開(kāi)啟,在接受空閑狀態(tài),不產(chǎn)生IISLRCK信號(hào),IIS預(yù)分頻使能
rIISCON = (1<<5)|(0<<4)|(0<<3)|(1<<2)|(1<<1);
//主設(shè)備時(shí)鐘PCLK,主設(shè)備模式,發(fā)送模式,串行數(shù)據(jù)16位,主時(shí)鐘是384fs,串行位時(shí)鐘32fs
rIISMOD = (0<<9)|(0<<8)|(2<<6)|(0<<5)|(0<<4)|(1<<3)|(1<<2)|(1<<0);
//預(yù)分頻都是N=3
rIISPSR = (3<<5)|3;
//發(fā)送FIFO用DMA模式,發(fā)送FIFO使能
rIISFCON = (1<<15)|(1<<13);
//DMA
rDISRC2 = (U32)buffer; //DMA2初始源地址
rDISRCC2 = (0<<1)|(0<<0); //源在系統(tǒng)總線上,地址增加
rDIDST2 = (U32)IISFIFO; //DMA2初始目的地址
rDIDSTC2 = (0<<2)|(1<<1)|(1<<0); //當(dāng)TC為0時(shí),中斷發(fā)生,源在外圍總線上,地址固定,一直為IISFIFO的0x55000010(小端)
if(result == 0){
flag = 0;
//握手模式,與APB時(shí)鐘同步,當(dāng)所有的傳輸結(jié)束,中斷請(qǐng)求生成,單元傳送,單服務(wù)模式,當(dāng)傳輸計(jì)數(shù)器為0時(shí),DMA通道關(guān)閉
rDCON2 = (1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(0<<24)|(1<<23)|(1<<22)|(1<<20)|(remain<<0);
}
else{
flag = 1;
rDCON2 = (1<<31)|(0<<30)|(1<<29)|(0<<28)|(0<<27)|(0<<24)|(1<<23)|(1<<22)|(1<<20)|(0xfffff<<0);
}
rDMASKTRIG2 = (0<<2)|(1<<1)|(0<<0); //DMA通道開(kāi)啟
rIISCON |= 0x1; //IIS開(kāi)啟
}
void __irq DMA2_ISR(void){
rSRCPND |= 1<<19;
rINTPND |= 1<<19;
if(flag == 0){
rIISCON = 0x0; //關(guān)閉IIS
rIISFCON = 0x0; //關(guān)閉IISFIFO的DMA模式
rDMASKTRIG2 = 1<<2; //關(guān)閉DMA
}
else{
result--;
rDISRC2 += 0x200000; //因?yàn)槭前胱?
if(result == 0){
flag = 0;
rDCON2 = (rDCON2 & ("0xfffff)) | (remain);
}
rDMASKTRIG2 = (0<<2)|(1<<1)|(0<<0);
}
}
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);
rSRCPND |= 1<<19;
rINTPND |= 1<<19;
rINTMSK &= "(1<<19);
rGPFCON = 0xd57f;
rGPFUP = 0x87;
pISR_DMA2 = (U32)DMA2_ISR;
PlayMusic(music, sizeof(music));
while(1){
Led(); //占用CPU
}
return 0;
}
上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: S3C2440DMA控制

評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉