S3C2410 IIS总线sample code 分析
rGPBDAT=rGPBDAT&~(L3D|L3M|L3C)|(L3C|L3M);//L3M=H(indatatransfermode)
for(j=0;j<4;j++);//tsu(L3)D>190ns
//GPB[4:2]=L3C3D3M
for(i=0;i<8;i++)
{
if(data&0x1)//ifdatasLSBisH
{
rGPBDAT&=~L3C;//L3C=L
rGPBDAT|=L3D;//L3D=H
for(j=0;j<4;j++);//tcy(L3)>500ns
rGPBDAT|=(L3C|L3D);//L3C=H,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;//Forchecknextbit
}
rGPBDAT=rGPBDAT&~(L3D|L3M|L3C)|(L3C|L3M);//L3M=H,L3C=H
}
//==========================================================
staticvoidInit1341(charmode)
{
U16FsIdx;
//PortInitialize
//----------------------------------------------------------
//PORTBGROUP
//Ports:GPB4GPB3GPB2
//Signal:L3CLOCKL3DATAL3MODE
//Setting:OUTPUTOUTPUTOUTPUT
//[9:8][7:6}[5:4]
//Binary:01,0101
//----------------------------------------------------------
rGPBDAT=rGPBDAT&~(L3M|L3C|L3D)|(L3M|L3C);//Startcondition:L3M=H,L3C=H
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)
//L3Interface
_WrL3Addr(0x14+2);//STATUS(000101xx+10)
_WrL3Data(0x60,0);//0,1,10,000,0:Status0,Reset,256fs,IIS-bus,noDC-filtering
_WrL3Addr(0x14+2);//STATUS(000101xx+10)
FsIdx=mode?RecStatus.FsIdxlayStatus.FsIdx;
if(CodecPara[FsIdx].ofs)
_WrL3Data(0x18,0);//0,0,01,000,0:Status0,Noreset,384fs,IIS-bus,noDC-filtering
else
_WrL3Data(0x28,0);//0,0,10,000,0:Status0,Noreset,256fs,IIS-bus,noDC-filtering
_WrL3Addr(0x14+2);//STATUS(000101xx+10)
_WrL3Data(0xc1,0);//1,0,0,0,0,0,01
//Status1,GainofDAC6dB,GainofADC0dB,ADCnon-inverting,DACnon-inverting
//,Singlespeedplayback,ADC-OffDAC-On
//Record
if(mode){
_WrL3Addr(0x14+2);//STATUS(000101xx+10)
//_WrL3Data(0xa2,0);//1,0,1,0,0,0,10
//Status1,GainofDAC0dB,GainofADC6dB,ADCnon-inverting,DACnon-inverting
//,Singlespeedplayback,ADC-OnDAC-Off
_WrL3Data(0xe3,0);//1,1,1,0,0,0,11
//Status1,GainofDAC6dB,GainofADC6dB,ADCnon-inverting,DACnon-inverting
//,Singlespeedplayback,ADC-OnDAC-On,DAC打开使录音时可从耳机听到声音
//_WrL3Addr(0x14+0);//DATA0(000101xx+00)
//_WrL3Data(0x3f,0);//00,111111:Volumecontrol(6bits)
//_WrL3Data(0x00,0);//00,000000:Volumecontrol(6bits)0dB
_WrL3Addr(0x14+0);//DATA0(000101xx+00)
_WrL3Data(0x7b,0);//01,1110,11:Data0,BassBoost18~24dB,Treble6dB
//_WrL3Addr(0x14+0);//DATA0(000101xx+00)
_WrL3Data(0xc4,0);//11000,100:Extendedaddr(3bits),100
//_WrL3Data(0x90,0);//100,100,00:DATA0,EnableAGC,00,inputamplifiergainchannel2(2bits)
_WrL3Data(0xf0,0);//111,100,00:DATA0,EnableAGC,00,inputamplifiergainchannel2(2bits)
//_WrL3Addr(0x14+0);//DATA0(000101xx+00)
_WrL3Data(0xc0,0);//11000,000:Extendedaddr(3bits),000
_WrL3Data(0xe4,0);//111,00000:MA=0dB
_WrL3Data(0xc1,0);//11000,001:Extendedaddr(3bits),001
_WrL3Data(0xe4,0);//111,00000:MB=0dB
//_WrL3Addr(0x14+0);//DATA0(000101xx+00)
_WrL3Data(0xc2,0);//11000,010:Extendedaddr(3bits),010
//_WrL3Data(0x59,0);//010,110,01:DATA0,MICAmplifierGain27dB,inputchannel1select(inputchannel2off)
_WrL3Data(0xf9,0);//111,110,11:DATA0,MICAmplifierGain27dB,input1XMA+input2XMB
}
}
//==========================================================
staticvoidPlayPause(U8mode)
{
if(mode)
rIISCON&=~1;//stopiis
else
rIISCON|=1;//startiis
}
#defineMAX_VOLUME61
staticvoidAdjVolume(U16volume)
{
rGPBDAT=rGPBDAT&~(L3M|L3C|L3D)|(L3M|L3C);//Startcondition:L3M=H,L3C=H
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)
volume=(volume*MAX_VOLUME)/0xffff;
_WrL3Addr(0x14+0);//DATA0(000101xx+00)
_WrL3Data(MAX_VOLUME-volume,0);
}
/*
staticvoidMuting(void)
{
if(mute)//Mute
{
_WrL3Addr(0x14+0);//DATA0(000101xx+00)
_WrL3Data(0xa4,0);//10,1,00,1,00:after,node-emp,mute,flat
mute=0;
}
else//Nomute
{
_WrL3Addr(0x14+0);//DATA0(000101xx+00)
_WrL3Data(0xa0,0);//10,1,00,0,00:after,node-emp,nomute,flat
mute=1;
}
}
*/
S3C2410IIS总线samplecod 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)