Esempio n. 1
0
/*******************************************************************************
* Function Name  : VsRamTest
* Description    : Test VS1003's register,if received value is 0x807F,then
				   indicate the VS1003 is OK.
* Input          : None.
* Output         : None
* Return         : None
*******************************************************************************/
void VsRamTest(void)
{
	u16 regvalue ;

	regvalue = 0;
	ControlReset(SET);
	Delay(100);
	SPIPutChar(0xff);										//����ҝ���ֽھ���Ч���ݣ�����SPI����
	SCI_ChipSelect(RESET);
	SDI_ChipSelect(RESET);
	ControlReset(RESET);
	Delay(100);
 	Mp3WriteRegister(SPI_MODE,0x09,0x00);					// ����vs1003�IJ���ģʽ
	while(DREQ);     	// �ȴ�DREQΪ��
 	SDI_ChipSelect(SET);       									// xDCS = 1��ѥ��vs1003�����ݽӿ�

    SPIPutChar(0x4d);
	SPIPutChar(0xea);
	SPIPutChar(0x6d);
	SPIPutChar(0x54);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	SPIPutChar(0x00);
	Delay(500);
	SDI_ChipSelect(RESET);

	regvalue = Mp3ReadRegister(SPI_HDAT0);      				// ����þ���־Ϊ0x807F���������å�

}
Esempio n. 2
0
/*******************************************************************************
* Function Name  : Mp3WriteRegister
* Description    : Write VS1003 register
* Input          : addressbyte--the vs1003 register address
				   highbyte--the hight 8 bits
				   lowbyte--the low 8 bits
* Output         : None
* Return         : None
*******************************************************************************/
void Mp3WriteRegister(unsigned char addressbyte, unsigned char highbyte, unsigned char lowbyte)
{
	SDI_ChipSelect(RESET);
	while(GPIO_ReadInputDataBit(DREQ_PORT,DREQ_PIN) == 0);
	SCI_ChipSelect(SET);
	SPIPutChar(VS_WRITE_COMMAND);
	SPIPutChar(addressbyte);
	SPIPutChar(highbyte);
	SPIPutChar(lowbyte);
	while(GPIO_ReadInputDataBit(DREQ_PORT,DREQ_PIN) == 0);
	SCI_ChipSelect(RESET);

}
Esempio n. 3
0
/*******************************************************************************
* Function Name  : Mp3ReadRegister
* Description    : Read VS1003 register
* Input          : addressbyte--the vs1003 register address
* Output         : None
* Return         : The register value
*******************************************************************************/
u16 Mp3ReadRegister(unsigned char addressbyte)
{
	u16 resultvalue = 0;
	SDI_ChipSelect(RESET);
	while(DREQ);
	SCI_ChipSelect(SET);				//XCS = 0
	SPIPutChar(VS_READ_COMMAND); 	//���͜��Ĵ�������
	SPIPutChar(addressbyte);	 	//���͟Ĵ����ľ�֡
	resultvalue = SPIGetChar() << 8;//��ȥ��8Ν����
	resultvalue |= SPIGetChar();  	//��ȥ��8Ν����
	while(DREQ);
	SCI_ChipSelect(RESET);
	return resultvalue;           	//����16Ν�Ĵ�����־

}
Esempio n. 4
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);
}
Esempio n. 5
0
unsigned char InitMMC()
{
  unsigned char c;
  //delay(100);
  SelectMSD();
  /* Allow MMC some time and clock cycles to reset */
  for (c=0; c<200; c++)
  {    
    SPIPutChar(0xff);
  }
  //Serial.println("allow mmc time over!");
  //delay(100);
  
  if(RebootMMC())
  {
    //Serial.println("Reboot MMC failed");
    return 1;//not able to power up
  }
  
  return 0;
}
Esempio n. 6
0
void VS1053_Start()
{
        ControlReset(SET);
        Delay(100);
        SPIPutChar(0xFF);
        SCI_ChipSelect(RESET);
        SDI_ChipSelect(RESET);
        ControlReset(RESET);
        Mp3SoftReset();
        Delay(100);

        while(GPIO_ReadInputDataBit(DREQ_PORT,DREQ_PIN) == 0);

        Mp3WriteRegister(SPI_MODE,0x08,0x00);
        Mp3WriteRegister(SPI_CLOCKF,0x98,0x00);
        Mp3WriteRegister(SPI_AUDATA,0xAC,0x45);
        Mp3WriteRegister(SPI_BASS,0x08,0x00);
        Mp3WriteRegister(SPI_VOL,0x0B,0x0B);
        Mp3WriteRegister(SPI_STATUS,0,0b00110011);

        while(GPIO_ReadInputDataBit(DREQ_PORT,DREQ_PIN) == 0);
}
Esempio n. 7
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);

 }