|
#include "config.h"
extern void delay(unsigned long uldata);
extern uint8 nAsrStatus;
uint8 nLD_Mode=LD_MODE_IDLE;
uint8 ucRegVal;
void ProcessInt0(void);
void LD_Reset()
{
RSTB=1;
delay(5);
RSTB=0;
delay(5);
RSTB=1;
delay(5);
SCS=0;
delay(5);
SCS=1;
delay(5);
}
void LD_Init_Common()
{
LD_ReadReg(0x06);
LD_WriteReg(0x17, 0x35);
delay(5);
LD_ReadReg(0x06);
LD_WriteReg(0x89, 0x03);
delay(5);
LD_WriteReg(0xCF, 0x43);
delay(5);
LD_WriteReg(0xCB, 0x02);
/*PLL setting*/
LD_WriteReg(0x11, LD_PLL_11);
if (nLD_Mode == LD_MODE_MP3)
{
LD_WriteReg(0x1E,0x00);
LD_WriteReg(0x19, LD_PLL_MP3_19);
LD_WriteReg(0x1B, LD_PLL_MP3_1B);
LD_WriteReg(0x1D, LD_PLL_MP3_1D);
}
else
{
LD_WriteReg(0x1E,0x00);
LD_WriteReg(0x19, LD_PLL_ASR_19);
LD_WriteReg(0x1B, LD_PLL_ASR_1B);
LD_WriteReg(0x1D, LD_PLL_ASR_1D);
}
delay(5);
LD_WriteReg(0xCD, 0x04);
LD_WriteReg(0x17, 0x4c);
delay(5);
LD_WriteReg(0xB9, 0x00);
LD_WriteReg(0xCF, 0x4F);
LD_WriteReg(0x6F, 0xFF);
}
void LD_Init_ASR()
{
nLD_Mode=LD_MODE_ASR_RUN;
LD_Init_Common();
LD_WriteReg(0xBD, 0x00);
LD_WriteReg(0x17, 0x48);
delay( 10 );
LD_WriteReg(0x3C, 0x80);
LD_WriteReg(0x3E, 0x07);
LD_WriteReg(0x38, 0xff);
LD_WriteReg(0x3A, 0x07);
LD_WriteReg(0x40, 0);
LD_WriteReg(0x42, 8);
LD_WriteReg(0x44, 0);
LD_WriteReg(0x46, 8);
delay( 5 );
}
void ProcessInt0(void)
{
uint8 nAsrResCount=0;
EX0=0;
ucRegVal = LD_ReadReg(0x2B);
LD_WriteReg(0x29,0) ;
LD_WriteReg(0x02,0) ;
if((ucRegVal & 0x10)&&LD_ReadReg(0xb2)==0x21&&LD_ReadReg(0xbf)==0x35) /*ʶ±ð³É¹¦*/
{
nAsrResCount = LD_ReadReg(0xba);
if(nAsrResCount>0 && nAsrResCount<=4)
{
nAsrStatus=LD_ASR_FOUNDOK;
}
else
{
nAsrStatus=LD_ASR_FOUNDZERO;
}
} /*ûÓÐʶ±ð½á¹û*/
else
{
nAsrStatus=LD_ASR_FOUNDZERO;
}
LD_WriteReg(0x2b, 0);
LD_WriteReg(0x1C,0);/*д0:ADC²»¿ÉÓÃ*/
LD_WriteReg(0x29,0);
LD_WriteReg(0x02,0);
LD_WriteReg(0x2B,0);
LD_WriteReg(0xBA,0);
LD_WriteReg(0xBC,0);
LD_WriteReg(0x08,1); /*Çå³ýFIFO_DATA*/
LD_WriteReg(0x08,0); /*Çå³ýFIFO_DATAºó ÔÙ´Îд0*/
EX0=1;
}
uint8 LD_Check_ASRBusyFlag_b2()
{
uint8 j,i;
uint8 flag = 0;
for (j=0; j<5; j++)
{
i=LD_ReadReg(0xb2);
if ( i== 0x21)
{
flag = 1;
break;
}
delay(10);
}
return flag;
}
void LD_AsrStart()
{
LD_Init_ASR();
}
uint8 LD_AsrRun()
{
EX0=0;
LD_WriteReg(0x35, MIC_VOL);
LD_WriteReg(0x1C, 0x09);
LD_WriteReg(0xBD, 0x20);
LD_WriteReg(0x08, 0x01);
delay( 5 );
LD_WriteReg(0x08, 0x00);
delay( 5 );
if(LD_Check_ASRBusyFlag_b2() == 0)
{
return 0;
}
LD_WriteReg(0xB2, 0xff);
LD_WriteReg(0x37, 0x06);
delay( 10 );
LD_WriteReg(0x37, 0x06);
delay( 30 );
LD_WriteReg(0x1C, 0x0b);
LD_WriteReg(0x29, 0x10);
LD_WriteReg(0xBD, 0x00);
EX0=1;
return 1;
}
uint8 LD_AsrAddFixed()
{
uint8 k, flag;
uint8 nAsrAddLength;
#define DATE_A 14 //Êý×é¶þάÊýÖµ
#define DATE_B 20 //Êý×éһάÊýÖµ
uint8 code sRecog[DATE_A][DATE_B] = {
"xiao jie",\
"dai ma ce shi",\
"ce shi wan bi",\
"bei jing",\
"shang hai",\
"kai deng",\
"guan deng",\
"guang zhou",\
"shen zhen",\
"xiang zuo zhuan",\
"xiang you zhuan",\
"da kai kong tiao",\
"guan bi kong tiao",\
"hou tui",\
}; /*Ìí¼Ó¹Ø¼ü´Ê£¬Óû§ÐÞ¸Ä*/
uint8 code pCode[DATE_A] = {
CODE_CMD,\
CODE_DMCS,\
CODE_CSWB,\
CODE_1KL1,\
CODE_1KL2,\
CODE_1KL3,\
CODE_1KL4,\
CODE_2KL1,\
CODE_2KL2,\
CODE_2KL3,\
CODE_2KL4,\
CODE_3KL1,\
CODE_3KL2,\
CODE_5KL1,
}; /*Ìí¼Óʶ±ðÂ룬Óû§ÐÞ¸Ä*/
flag = 1;
for (k=0; k<DATE_A; k++)
{
if(LD_Check_ASRBusyFlag_b2() == 0)
{
flag = 0;
break;
}
LD_WriteReg(0xc1, pCode[k] );
LD_WriteReg(0xc3, 0 );
LD_WriteReg(0x08, 0x04);
delay(1);
LD_WriteReg(0x08, 0x00);
delay(1);
for (nAsrAddLength=0; nAsrAddLength<DATE_B; nAsrAddLength++)
{
if (sRecog[k][nAsrAddLength] == 0)
break;
LD_WriteReg(0x5, sRecog[k][nAsrAddLength]);
}
LD_WriteReg(0xb9, nAsrAddLength);
LD_WriteReg(0xb2, 0xff);
LD_WriteReg(0x37, 0x04);
}
return flag;
}
uint8 LD_GetResult()
{
return LD_ReadReg(0xc5 );
}
|
-
-
LD3320并行串行读写辅助说明.pdf
349.8 KB, 下载次数: 18, 下载积分: 黑币 -5
-
-
LD3320开发手册.pdf
771.39 KB, 下载次数: 24, 下载积分: 黑币 -5
-
-
LD3320数据手册.pdf
681.43 KB, 下载次数: 20, 下载积分: 黑币 -5
-
-
LD3320芯片简明调试步骤.pdf
135.58 KB, 下载次数: 22, 下载积分: 黑币 -5
-
-
可编辑语音识别芯片LD3320介绍.pdf
286.85 KB, 下载次数: 19, 下载积分: 黑币 -5
-
-
语音识别芯片LD3320高阶秘籍.pdf
332.02 KB, 下载次数: 17, 下载积分: 黑币 -5
|