Beispiel #1
0
/*******************************************************************************
* Function Name  : Mp3SoftReset
* Description    : Soft reset the VS1003 chip
* Input          : None.
* Output         : None
* Return         : None
*******************************************************************************/
void Mp3SoftReset(void)
{

	Mp3WriteRegister (SPI_MODE, 0x08, 0x20);
	while(DREQ);
	Mp3WriteRegister(SPI_CLOCKF, 0x8b, 0xe8);
	Mp3WriteRegister(SPI_BASS, 0x00, 0x55);
	Mp3WriteRegister(SPI_AUDATA,0xAC,0x45);
	Mp3SetVolume(0x7a,0x7a);
//
    SDI_ChipSelect(SET);
	SPIPutChar(0);
	SPIPutChar(0);
	SPIPutChar(0);
	SPIPutChar(0);
	SDI_ChipSelect(RESET);

//	Mp3WriteRegister(SPI_MODE,0x00,0x04);
}
Beispiel #2
0
/*******************************************************************************
* Function Name  : VsSineTest
* Description    : VS1003 sine test
* Input          : None.
* Output         : None
* Return         : None
*******************************************************************************/
void VsSineTest(void)
{
	Mp3PutInReset();  //xReset = 0   ��Νvs1003
	Mp3Reset();
	Delay(1000);//wait(100);        //��ʹ100ms
	SPIPutChar(0xff);//����ҝ���ֽھ���Ч���ݣ�����SPI����
	SCI_ChipSelect(RESET);
	SDI_ChipSelect(RESET);
	Mp3ReleaseFromReset();

	Mp3Reset();
	Delay(500);//wait(100);

	Mp3SetVolume(50,50);//��������

 	Mp3WriteRegister(SPI_MODE,0x08,0x60);//����vs1003�IJ���ģʽ
	Delay(500);
	while(DREQ);     //�ȴ�DREQΪ��

 	SDI_ChipSelect(SET);       //xDCS = 1��ѥ��vs1003�����ݽӿ�

 	//��vs1003�������Ҳ������0x53 0xef 0x6e n 0x00 0x00 0x00 0x00
 	//����n = 0x24, �蜨vs1003�����������Ҳ���ƾ��־��������㡽����vs1003��datasheet
    SPIPutChar(0x53);
	SPIPutChar(0xef);
	SPIPutChar(0x6e);
	SPIPutChar(0x24);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	Delay(1000);
	SDI_ChipSelect(RESET);//����ִ�о������ӌ���ܴӜ�������ҝ����ҝƾ�ʾ�����

    //�˳����Ҳ���
	SDI_ChipSelect(SET);
	SPIPutChar(0x45);
	SPIPutChar(0x78);
	SPIPutChar(0x69);
	SPIPutChar(0x74);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	Delay(1000);
	SDI_ChipSelect(RESET);

    //�ٴν������Ҳ��Բ�����n־Ϊ0x44���������Ҳ���ƾ������Ϊ�����־
    SDI_ChipSelect(SET);
	SPIPutChar(0x53);
	SPIPutChar(0xef);
	SPIPutChar(0x6e);
	SPIPutChar(0x44);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	Delay(1000);
	SDI_ChipSelect(RESET);

	//�˳����Ҳ���
	SDI_ChipSelect(SET);
	SPIPutChar(0x45);
	SPIPutChar(0x78);
	SPIPutChar(0x69);
	SPIPutChar(0x74);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	Delay(1000);
	SDI_ChipSelect(RESET);

 }
Beispiel #3
0
void CheckKey()
{
  static unsigned char volume = 40;
  static unsigned int vu_cnt = 2000;//volume up interval
  static unsigned int vd_cnt = 2000;//volume down interval

  if(0 == PSKey)
  {
  	playStop = 1-playStop;
	delay(20);
	while(0 == PSKey);
	delay(20);
  }
  
  while(!playStop)
  {
	if(0 == PSKey)
    {
  	  playStop = 1-playStop;
	  delay(20);
	  while(0 == PSKey);
	  delay(20);
    }
  }

  if(0 == NTKey)
  {
  	playingState = PS_NEXT_SONG;
	delay(20);
	while(0 == NTKey);
	delay(20);
  }
  else if(0 == BKKey)
  {
    playingState = PS_PREVIOUS_SONG;
	delay(20);
	while(0 == BKKey);
	delay(20);
  }
  else if(0 == VUKey)
  {
  	if(--vu_cnt == 0)
	{
    	if (volume-- == 0) volume = 0; //Change + limit to 0 (maximum volume)
    
		Mp3SetVolume(volume,volume);		

		vu_cnt = 2000;
	 }
  }
  else if (0 == VDKey)
  {
    if(--vd_cnt == 0)
	{
      if (volume++ == 254) volume = 254; //Change + limit to 254 (minimum vol)
	
	  Mp3SetVolume(volume,volume);
	  
	  vd_cnt = 2000;
	 }
       	         
  }
}