求高手解决下呀,我都搞了几天了都没搞定!
#include "2440addr.h"
#define L3C (1<<4) //GPB4 = L3CLOCK
#define L3D (1<<3) //GPB3 = L3DATA
#define L3M (1<<2) //GPB2 = L3MODE
#define S32 int
#define U8 unsigned char
extern void ChangePll(int,int,int);
unsigned char *_temp;
extern void ShowMenu();
//==========================================================
#define L3C (1<<4) //GPB4 = L3CLOCK
#define L3D (1<<3) //GPB3 = L3DATA
#define L3M (1<<2) //GPB2 = L3MODE
static void _WrL3Addr(U8 data)
{
S32 i,j;
rGPBDAT = rGPBDAT & ~(L3D | L3M | L3C) | L3C; //L3D=L, L3M=L(in address mode), L3C=H
for(j=0;j<4;j++); //tsu(L3) > 190ns
//GPB[4:2]=L3C:L3D:L3M
for(i=0;i<8;i++) //LSB first
{
if(data & 0x1) //If data's LSB is 'H'
{
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 //If data's LSB is 'L'
{
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
}
//==========================================================
static void _WrL3Data(U8 data,int halt)
{
S32 i,j;
if(halt)
{
rGPBDAT = rGPBDAT & ~(L3D | L3M | L3C) | L3C; //L3C=H(while tstp, L3 interface halt condition)
for(j=0;j<4;j++); //tstp(L3) > 190ns
}
rGPBDAT = rGPBDAT & ~(L3D | L3M | L3C) | (L3C | L3M); //L3M=H(in data transfer mode)
for(j=0;j<4;j++); //tsu(L3)D > 190ns
//GPB[4:2]=L3C:L3D:L3M
for(i=0;i<8;i++)
{
if(data & 0x1) //if data's LSB is 'H'
{
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 //If data's LSB is 'L'
{
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; //For check next bit
}
rGPBDAT = rGPBDAT & ~(L3D | L3M | L3C) | (L3C | L3M); //L3M=H,L3C=H
}
void __irq DMA_0()
{
rSRCPND=BIT_DMA0;
rINTPND=BIT_DMA0;
rIISCON=0;
//rDMASKTRIG0=(1<<2);
rIISFCON=0x0;
//rINTMSK=rINTMSK|(BIT_DMA0);
rDMASKTRIG0=2;
Uart_send("GO");
}
void Play(unsigned char *buf)
{
ChangePll(229,5,1);
rCLKCON |= 0x20000;
delay(10);
//端口E初始化
rGPECON=0x628;
rGPEUP|=0x1f;//取消电阻上拉
//================================
//rPLLCON = (0x69 << 12) | (0x17 << 4) | 0;
rIISCON=(1<<5)|(1<<3)|(1<<1);
rIISMOD=(0<<8)+(3<<6)+(0<<5)+(1<<4)+(1<<3)+(1<<2)+1;
rIISPSR=(8<<5)|8;//时钟设置。CDCLK=pclk/3=11.142857;
rIISFCON=(1<<15)+(1<<13);
//dma
rDISRC0=(unsigned int)(buf+0x2c);
rDISRCC0=0;
rDIDST0=(( unsigned int)IISFIFO);
rDIDSTC0=3;
rDCON0=(1<<31)|(0<<30)|(1<<29)|(0<<28)|(1<<27)|(5<<24)|(1<<23)|(1<<22)|(1<<20)|240000;
pISR_DMA0=(unsigned)DMA_0;
rINTMSK&=~BIT_DMA0;
rGPBDAT = rGPBDAT & ~(L3M|L3C|L3D) |(L3M|L3C); //Start condition : L3M=H, L3C=H
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)
//L3 Interface
_WrL3Addr(0x14 + 2); //STATUS (000101xx+10)
_WrL3Data(0x60,0); //0,1,10, 000,0 : Status 0,Reset,256fs,IIS-bus,no DC-filtering
_WrL3Addr(0x14 + 2); //STATUS (000101xx+10)
_WrL3Data(0x18,0); //0,0,01, 000,0 : Status 0,No reset,384fs,IIS-bus,no DC-filtering
_WrL3Addr(0x14 + 2); //STATUS (000101xx+10)
_WrL3Data(0xc1,0); //1,0,0,0, 0,0,01
//Status 1,Gain of DAC 6 dB,Gain of ADC 0dB,ADC non-inverting,DAC non-inverting
//,Single speed playback,ADC-Off DAC-On
_WrL3Addr(0x14 + 0); //DATA0 (000101xx+00)
_WrL3Data(30, 0);
rIISCON|=1;
rDMASKTRIG0=2;
for(;;);
ChangePll(92,1,1);
rCLKDIVN=5;
ShowMenu();
} |