微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > S3C2410 IIS总线sample code 分析

S3C2410 IIS总线sample code 分析

时间:11-11 来源:互联网 点击:
MMRESULTwaveInClose(HWAVEOUThwi)

{

if((RecStatus.handle!=hwi)||(RecStatus.Status!=DEVICE_REC))

returnMMSYSERR_INVALHANDLE;

rIISCON=0x0;//IISInterfacestop

rIISFCON=0x0;//ForFIFOflush

rCLKCON&=~0x20000;//disableIIScolock

//rMPLLCON=save_MPLLCON;//restoreMPLLCONvalue

SetSysFclk(save_MPLLCON);

RecStatus.Status=DEVICE_FREE;

ReleaseDMA(RecStatus.DevReq);

if((RecStatus.DevReq&0xff)==0x12)

DisableIrq(BIT_DMA1);

if((RecStatus.DevReq&0xff)==0x21)

DisableIrq(BIT_DMA2);

returnMMSYSERR_NOERROR;

}

MMRESULTwaveInStart(HWAVEINhwi)

{

if((RecStatus.handle!=hwi)||(RecStatus.Status!=DEVICE_REC))

returnMMSYSERR_INVALHANDLE;

if(!RecTotBlks)

returnMMSYSERR_NOMEM;

SetRecDma();

//{48000,(123<12)|(6<4)|0,(3<5)|3,0}};

rIISPSR=CodecPara[RecStatus.FsIdx].PreScaler;

rIISCON=(0<5)+(1<4)+(1<3)+(0<2)+(1<1);//TxDMAdisable,RxDMAenable,Txidle,Rxnotidle,prescalerenable,stop

rIISMOD=(0<8)+(1<6)+(0<5)+(1<4)+((RecStatus.wBitsPerSample>>4)<3)+(CodecPara[RecStatus.FsIdx].ofs<2)+(1<0);

//Mastermode[8],Rxmode[7:6],LowforLeftChannel[5],IISformat[4],16/8bit[3],256/384fs[2],IISCLK32fs[1:0]

rIISFCON=(1<14)+(1<12);//RxDMA,RxFIFO-->startpiling....

rIISCON|=0x1;//startIIS

returnMMSYSERR_NOERROR;

}

MMRESULTwaveInStop(HWAVEINhwi)

{

if((RecStatus.handle!=hwi)||(RecStatus.Status!=DEVICE_REC))

returnMMSYSERR_INVALHANDLE;

rIISCON=0x0;//IISInterfacestop

rIISFCON=0x0;//ForFIFOflush

StopDMA(RecStatus.DevReq);

returnMMSYSERR_NOERROR;

}

MMRESULTwaveInPrepareHeader(HWAVEINhwi,LPWAVEHDRpwh,UINTcbwh)

{

if((RecStatus.handle!=hwi)||(RecStatus.Status!=DEVICE_REC))

returnMMSYSERR_INVALHANDLE;

pwh->lpNext=0;

pwh->dwBytesRecorded=0;

pwh->dwUser=0;

pwh->dwFlags=0;

returnMMSYSERR_NOERROR;

}

MMRESULTwaveInUnprepareHeader(HWAVEINhwi,LPWAVEHDRpwh,UINTcbwh)

{

if((RecStatus.handle!=hwi)||(RecStatus.Status!=DEVICE_REC))

returnMMSYSERR_INVALHANDLE;

returnMMSYSERR_NOERROR;

}

//每次循环指针pwh值都不一样他们是个连续的数组,这个函数的作用就是将数组中的数据组成一个链表

MMRESULTwaveInAddBuffer(HWAVEINhwi,LPWAVEHDRpwh,UINTcbwh)

{

if((RecStatus.handle!=hwi)||(RecStatus.Status!=DEVICE_REC))

returnMMSYSERR_INVALHANDLE;

if(!RecTotBlks)

{

lpRecFstBlk=pwh;

lpRecCurBlk=lpRecFstBlk;//最开始播放的数据

}

else

{

lpRecLstBlk->lpNext=pwh;

}

lpRecLstBlk=pwh;

pwh->lpNext=0;

RecTotBlks++;

returnMMSYSERR_NOERROR;

}

MMRESULTwaveInReset(HWAVEOUThwi)

{

returnMMSYSERR_NOERROR;

}

/*************************ControlFunction*********************/

staticvoidIIS_PortSetting(void)

{

//----------------------------------------------------------

//PORTBGROUP

//Ports:GPB4GPB3GPB2

//Signal:L3CLOCKL3DATAL3MODE

//Setting:OUTPUTOUTPUTOUTPUT

//[9:8][7:6}[5:4]

//Binary:01,0101

//----------------------------------------------------------

rGPBUP=rGPBUP&~(0x7<2)|(0x7<2);//ThepullupfunctionisdisabledGPB[4:2]11100

rGPBCON=rGPBCON&~(0x3f<4)|(0x15<4);//GPB[4:2]=Output(L3CLOCK):Output(L3DATA):Output(L3MODE)

//----------------------------------------------------------

//PORTEGROUP

//Ports:GPE4GPE3GPE2GPE1GPE0

//Signal:I2SSDOI2SSDICDCLKI2SSCLKI2SLRCK

//Binary:10,1010,1010

//----------------------------------------------------------

rGPEUP=rGPEUP&~(0x1f)|0x1f;//ThepullupfunctionisdisabledGPE[4:0]11111

rGPECON=rGPECON&~(0x3ff)|0x2aa;//GPE[4:0]=I2SSDO:I2SSDI:CDCLK:I2SSCLK:I2SLRCK

}

//==========================================================

#defineL3C(1<4)//GPB4=L3CLOCK

#defineL3D(1<3)//GPB3=L3DATA

#defineL3M(1<2)//GPB2=L3MODE

staticvoid_WrL3Addr(U8data)

{

S32i,j;

rGPBDAT=rGPBDAT&~(L3D|L3M|L3C)|L3C;//L3D=L,L3M=L(inaddressmode),L3C=H

for(j=0;j<4;j++);//tsu(L3)>190ns

//GPB[4:2]=L3C3D3M

for(i=0;i<8;i++)//LSBfirst

{

if(data&0x1)//IfdatasLSBisH

{

rGPBDAT&=~L3C;//L3C=L

rGPBDAT|=L3D;//L3D=H

for(j=0;j<4;j++);//tcy(L3)>500ns

rGPBDAT|=L3C;//L3C=H

rGPBDAT|=L3D;//L3D=H

for(j=0;j<4;j++);//tcy(L3)>500ns

}

else//IfdatasLSBisL

{

rGPBDAT&=~L3C;//L3C=L

rGPBDAT&=~L3D;//L3D=L

for(j=0;j<4;j++);//tcy(L3)>500ns

rGPBDAT|=L3C;//L3C=H

rGPBDAT&=~L3D;//L3D=L

for(j=0;j<4;j++);//tcy(L3)>500ns

}

data>>=1;

}

rGPBDAT=rGPBDAT&~(L3D|L3M|L3C)|(L3C|L3M);//L3M=H,L3C=H

}

//==========================================================

staticvoid_WrL3Data(U8data,inthalt)

{

S32i,j;

if(halt)

{

rGPBDAT=rGPBDAT&~(L3D|L3M|L3C)|L3C;//L3C=H(whiletstp,L3interfacehaltcondition)

for(j=0;j<4;j++);//tstp(L3)>190ns

}

rGPBDAT=rGPBDAT&~(L3D|L3M|L3C)|(L3C|L3M);//L3M=H(indata

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top