***ac97 需注意的三種Reset
1.Cold Reset:ac97 Controller Registers的值會被初始成power on reset的default值。Reset為Low,BIT_CLK會立即不見,Reset為High,SYNC和BIT_CLK會約隔355毫秒不見。
2.Register Reset:寫任何值在Codec register(0x00h)都會做Reset,當Reset完後只有Codec Register的值變回default值。BIT_CLK和SYNC都不會改變。
3.Warm Reset:會重新觸發AC-Link但不影響Codec Register的值,做法就是直接設定Codec Register(0x26h)。BIT_CLK會為Low,SYNC會High一段時間後為Low。
***對ucb1400 codec做錄放音功能。
1.先對GPIO做設定。
void ucb1400_gpio_cfg()
{
GPIO_set_dir(28,INPUT); //BitClk
GPIO_set_dir(29,INPUT); //DtatIn
GPIO_set_dir(30,OUTPUT); //DataOut
GPIO_set_dir(31,OUTPUT); //SYNC
GPIO_set_dir(113,OUTPUT); //Reset
GPIO_set_alternate(28,1);
GPIO_set_alternate(29,1);
GPIO_set_alternate(30,2);
GPIO_set_alternate(31,2);
GPIO_set_alternate(113,0);
GPIO_set_output_bit(113);
GPIO_set_dir(10,OUTPUT); //speaker enable
GPIO_set_output_bit(10);
}
2.錄音,對Codec Register做設定。
void AudioRecord(unsigned* buffer,unsigned bufferSize)
{
writecodecreg(0x2,0x0000);
readcodecreg(0x2);//read it for check
writecodecreg(0xe,0x0040);
readcodecreg(0xe);
writecodecreg(0x1a,0x0000);
readcodecreg(0x1a);
sleep(1); // have to wait a moment
writecodecreg(0x1c,0x0f0f);
readcodecreg(0x1c);
if((pac97_regs->mcsr & 0x10))
{
pac97_regs->mcsr = 0x10;
}
if((pac97_regs->pisr & 0x10))
{
pac97_regs->pisr = 0x10;
}
while(bufferSize-- > 0)
{
/*
* Wait for the start of a new frame.
* This is signified by a pulse on the SYNC line.
*/
while ((GPIO_get_level(BSP_GPIO_AC97_SYNC)!= 0));
/* Wait for it to go high */
while ((GPIO_get_level(BSP_GPIO_AC97_SYNC)!= 1));
/* Wait for it to go low */
*buffer++ = pac97_regs->pcdr;
}
}
3.放音,對Codec Register做設定。
void AudioPlay(unsigned* buffer, unsigned bufferSize)
{
writecodecreg(0x6a,0x0349);
readcodecreg(0x6a);
writecodecreg(0x2a,0x0000);
readcodecreg(0x2a);
writecodecreg(0x2c,0xbb80);
readcodecreg(0x2c);
sleep(1);
writecodecreg(0x2,0x1010);
readcodecreg(0x2);
while(bufferSize-- >0)
{
while((pac97_regs->posr & 0x10))
{
pac97_regs->posr = 0x10;
}
while ((GPIO_get_level(BSP_GPIO_AC97_SYNC)!= 0));
/* Wait for it to go high */
while ((GPIO_get_level(BSP_GPIO_AC97_SYNC)!= 1));
/* Wait for it to go low */
pac97_regs->pcdr =*buffer++;
}
}
1 則留言:
Dear Ariel:
您好.. 想請教您一些問題,是有關於(NB)ICH8[82801HBM/SLA5Q]對(CODE) ALC262SRS 的基本動作時序等..一些基本動作原理.
謝謝您的指導..
張貼留言