基于LD3320芯片的声电密码门设计

LD3320_write_byte(add); for(i = 0;i<8;i++) {

date_temp = (date_temp <<1); delay_nop; delay_nop;

if((LD3320_SDO&0x02)==0x02) {

date_temp |= 0x01; }

LD3320_SDCK_OFF; delay_nop; delay_nop;

LD3320_SDCK_ON; delay_nop; delay_nop; }

LD3320_SCS_ON; return date_temp; }

/**************************LD3320初始化*************************************/ //mode=0 MP3播放模式。mode=1 语音识别模式。 void ld3320_init(unsigned char mode) {

LD3320_read(0x06); //激活芯片 delayus(5);

LD3320_write(0x17, 0x35); //软件复位。 delayus(5);

LD3320_read(0x06); //激活芯片 delayus(5);

LD3320_write(0x89, 0x03); //进入芯片初始化状态。 LD3320_write(0xCF, 0x43); //进入芯片初始化状态。 LD3320_write(0xCB, 0x02); //?

26

delayus(2);

LD3320_write(0x11, LD_PLL_11); delayus(2);

if(mode == 0) //MP3模式下晶振配置。 {

LD3320_write(0x1E, 0x00);

LD3320_write(0x19, LD_PLL_MP3_19); LD3320_write(0x1B, LD_PLL_MP3_1B); LD3320_write(0x1D, LD_PLL_MP3_1D); } else {

LD3320_write(0x1E,0x00);

LD3320_write(0x19, LD_PLL_ASR_19); LD3320_write(0x1B, LD_PLL_ASR_1B); LD3320_write(0x1D, LD_PLL_ASR_1D); } delayus(5);

LD3320_write(0xCD, 0x04); //初始化时候设置。允许芯片休眠。 LD3320_write(0x17, 0x4c); //进入省电模式。 LD3320_write(0xB9, 0x00); //初始化设置 LD3320_write(0xCF, 0x4F); //内部省电模式。 LD3320_write(0x6F, 0xFF); //初始化设置 delayus(2); }

void ASR_mode_init(void) {

ld3320_init(1); //识别模式初始化。

LD3320_write(0xBD, 0x00); //启动ASR模块。 delayus(5);

LD3320_write(0x17, 0x48); //激活内部DSP

27

delayus(5);

LD3320_write(0x3C, 0x80); LD3320_write(0x3E, 0x07); LD3320_write(0x38, 0xff); LD3320_write(0x3A, 0x07);

LD3320_write(0x40, 0); LD3320_write(0x42, 8); LD3320_write(0x44, 0);

LD3320_write(0x46, 8); //配置数据口。 delayus( 1 ); }

// Return 1: success.

unsigned char Check_ASR_Busy(void) {

unsigned char j; unsigned char flag = 0; for (j=0; j<10; j++) {

if (LD3320_read(0xb2) == 0x21) {

flag = 1; break; }

delayus(10); }

return flag; }

//写入识别列表。返回 0 写入失败。 返回 1 写入成功 。 unsigned char LD3320_add_list(void)

28

{

unsigned char k= 0, flag= 0; unsigned char nAsrAddLength = 0; /*

const unsigned char sRecog[19][20] = {\ \deng mie\\deng mie\\bu mie\bu liang\deng niang\

\deng niang\deng niang\deng liang\deng liang\

,\

const unsigned char pCode[19] = {CODE_RL, CODE_YL, CODE_RC, CODE_YC, CODE_AC,CODE_AL,CODE_RL,CODE_RL,CODE_RL,CODE_RL

,CODE_YL,CODE_YL,CODE_AL,CODE_AC,CODE_NOP,CODE_NOP,CODE_NOP,CODE_NOP,CODE_NOP}; */

const unsigned char sRecog[11][20] = {\bao\

\ const

unsigned

char

pCode[11]

=

{CODE_RL,CODE_RL,CODE_RL,CODE_RL,CODE_RL,CODE_YL,CODE_YL,CODE_YL,CODE_AC,CODE_AC,CODE_AC}; flag = 1;

for (k=0; k<11; k++) {

if(Check_ASR_Busy() == 0) {

flag = 0; break; }

LD3320_write(0xc1, pCode[k] ); //写入识别字序号。 LD3320_write(0xc3, 0 );

LD3320_write(0x08, 0x04); //清除 FIFO_EXT delayus(1);

LD3320_write(0x08, 0x00);

29

联系客服:779662525#qq.com(#替换为@)