uint8 LD_GetResult()
{
	uint8 res;

	res = LD_ReadReg(0xc5);
	SendString("ASR Result = ");
	SendByteHex(res);
	SendLineEnd();

	return res;
}
void LD_Init_Common()
{
	bMp3Play = 0;

	LD_ReadReg(0x06);  
	LD_WriteReg(0x17, 0x35); 
	delay(10);
	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(10);
	
	LD_WriteReg(0xCD, 0x04);
	LD_WriteReg(0x17, 0x4C); 
	delay(5);
	LD_WriteReg(0xB9, 0x00);
	LD_WriteReg(0xCF, 0x4F); 
	LD_WriteReg(0x6F, 0xFF); 
}
Beispiel #3
0
void LD_Init_Common(void)
{
	//bMp3Play = 0;
	LD_ReadReg(0x06);
	LD_WriteReg(0x17, 0x35);
	delay(10);
	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 (myRobot.ld3320State.mode == LD_MODE_MP3)
	{
		LD_WriteReg(0x1E, 0x00);
		//!! 注意,下面三个寄存器,会随晶振频率变化而设置不同
		//!! 注意, 请根据使用的晶振频率修改参考程序中的 CLK_IN
		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);
		//!! 注意,下面三个寄存器,会随晶振频率变化而设置不同
		//!! 注意, 请根据使用的晶振频率修改参考程序中的 CLK_IN
		LD_WriteReg(0x19, LD_PLL_ASR_19);
		LD_WriteReg(0x1B, LD_PLL_ASR_1B);
		LD_WriteReg(0x1D, LD_PLL_ASR_1D);
	}
	LD_WriteReg(0xCD, 0x04);
	LD_WriteReg(0x17, 0x4c);
	delay(5);
	LD_WriteReg(0xB9, 0x00);
	LD_WriteReg(0xCF, 0x4f);
	LD_WriteReg(0x6F, 0xFF);
}	
void LD_ReloadMp3Data_2()
{
	uint32 nCurMp3Pos;
	uint8 val;
	uint8 k;

	nCurMp3Pos = nMp3StartPos + nMp3Pos;
	FLASH_CS=1;
	FLASH_CLK=0;
	FLASH_CS=0;

	 IO_Send_Byte(W25P_FastReadData);   
	 IO_Send_Byte(((nCurMp3Pos & 0xFFFFFF) >> 16));  
	 IO_Send_Byte(((nCurMp3Pos & 0xFFFF) >> 8));
	 IO_Send_Byte(nCurMp3Pos & 0xFF);
	 IO_Send_Byte(0xFF);

	ucStatus = LD_ReadReg(0x06);
	while ( !(ucStatus&MASK_FIFO_STATUS_AFULL) && (nMp3Pos<nMp3Size) )
	{
		val=0;
		for(k=0;k<8;k++)
		{
			FLASH_CLK=0;
			val<<=1;
			FLASH_CLK=1;
			val|=FLASH_DO;
		}
		LD_WriteReg(0x01,val);

		nMp3Pos++;

		ucStatus = LD_ReadReg(0x06);
	}
	
	FLASH_CS=1;
	FLASH_CLK=0;

}
// Return 1: success.
uint8 LD_Check_ASRBusyFlag_b2()
{
	uint8 j;
	uint8 flag = 0;
	for (j=0; j<10; j++)
	{
		if (LD_ReadReg(0xb2) == 0x21)
		{
			flag = 1;
			break;
		}
		delay(10);		
	}
	return flag;
}
Beispiel #6
0
static unsigned char LD_Check_ASRBusyFlag_b2(void)
{
	unsigned char j;
	unsigned char temp=0;
	unsigned char flag = 0;
	for (j=0; j<10; j++)
	{
		temp=LD_ReadReg(0xb2);
		if (temp == 0x21)
		{
			flag = 1;
			break;
		}
		delay(10);		
	}
	return flag;
}
Beispiel #7
0
void ProcessInt(void)
{
	unsigned char nAsrResCount=0;
	unsigned char ucRegVal;
	
	unsigned char ucHighInt;
	unsigned char ucLowInt;
	ucRegVal = LD_ReadReg(0x2B);

	if(myRobot.ld3320State.mode==LD_MODE_ASR_RUN)
	{
		//语音识别产生的中断
		//有声音输入,不论是别成功或失败都有中断
		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) 
				{
					myRobot.ld3320State.state=LD_ASR_FOUNDOK; 		
				}
				else
				{
					myRobot.ld3320State.state=LD_ASR_FOUNDZERO;
				}	
		}
		else
		{
			myRobot.ld3320State.state=LD_ASR_FOUNDZERO;
		}

		LD_WriteReg(0x2b,0);
		LD_WriteReg(0x1C,0);
		return;
		
	}
	
	
	
	
	
	
	
	ucHighInt = LD_ReadReg(0x29); 
	ucLowInt=LD_ReadReg(0x02); 
	LD_WriteReg(0x29,0) ;
	LD_WriteReg(0x02,0) ;
    if(LD_ReadReg(0xBA)&CAUSE_MP3_SONG_END)
    {
	// A. 声音数据全部播放完毕

			LD_WriteReg(0x2B,  0);
			LD_WriteReg(0xBA, 0);	
			LD_WriteReg(0xBC,0x0);	
			
		
			LD_WriteReg(0x08,1);

			LD_WriteReg(0x08,0);
			LD_WriteReg(0x33, 0);
		
			myRobot.ld3320State.mode=LD_MODE_ASR_RUN;
			myRobot.ld3320State.state=LD_ASR_NONE;
		
			return ;
    }

//	if(nMp3Pos>=nMp3Size)
//	{
//	// B. ÉùÒôÊý¾ÝÒÑ·¢ËÍÍê±Ï¡£

//		LD_Write(0xBC, 0x01);
//		LD_Write(0x29, 0x10);
//		f_close(&fsrc);
//		nLD_Mode = LD_MODE_ASR_RUN;
//		nAsrStatus = LD_ASR_NONE;
//		return;	
//	}
	LD_WriteReg(0x29,ucHighInt); 
	LD_WriteReg(0x02,ucLowInt) ;
}
Beispiel #8
0
static unsigned char LD_GetResult(void)
{
	unsigned char res;
	res = LD_ReadReg(0xc5);
	return res;
}
void ProcessInt0()
{
	uint8 nAsrResCount=0;

	EX0=0;
	
	ucRegVal = LD_ReadReg(0x2B);
	if(nLD_Mode == LD_MODE_ASR_RUN)
	{
		// 语音识别产生的中断
		// (有声音输入,不论识别成功或失败都有中断)
		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);
		return;
	}
	
	// 声音播放产生的中断,有三种:
	// A. 声音数据已全部播放完。
	// B. 声音数据已发送完毕。
	// C. 声音数据暂时将要用完,需要放入新的数据。	
	ucHighInt = LD_ReadReg(0x29); 
	ucLowInt=LD_ReadReg(0x02); 
	LD_WriteReg(0x29,0) ;
	LD_WriteReg(0x02,0) ;
    if(LD_ReadReg(0xBA)&CAUSE_MP3_SONG_END)
    {
	// A. 声音数据已全部播放完。

		LD_WriteReg(0x2B,  0);
      	LD_WriteReg(0xBA, 0);	
		LD_WriteReg(0xBC,0x0);	
		bMp3Play=0;					// 声音数据全部播放完后,修改bMp3Play的变量
		LD_WriteReg(0x08,1);
		delay_2(5);
      	LD_WriteReg(0x08,0);
		LD_WriteReg(0x33, 0);

		return ;
     }

	 if(nMp3Pos>=nMp3Size)
	{
	// B. 声音数据已发送完毕。

		LD_WriteReg(0xBC, 0x01);
		LD_WriteReg(0x29, 0x10);
//		bMp3Play=0;				//	此时,只是主控MCU把所有MP3数据发送到LD3320芯片内,但是还没有把送入的数据全部播放完毕
		EX0=1;

		return;	
	}

	// C. 声音数据暂时将要用完,需要放入新的数据。	

	LD_ReloadMp3Data_2();
		
	LD_WriteReg(0x29,ucHighInt); 
	LD_WriteReg(0x02,ucLowInt) ;

	delay_2(10);
	EX0=1;

}