/**************************************************************************************************
* Function MP3_SCI_Write()
* -------------------------------------------------------------------------------------------------
* Overview: Function writes one byte to MP3 SCI
* Input: register address in codec, data
* Output: Nothing
**************************************************************************************************/
void MP3_SCI_Write(char address, unsigned int data_in) {
  XDCS = 1;

  MP3_CS = 0;                    // select MP3 SCI
  SPI0_Write(WRITE_CODE);
  SPI0_Write(address);
  SPI0_Write(Hi(data_in));       // high byte
  SPI0_Write(Lo(data_in));       // low byte
  MP3_CS = 1;                    // deselect MP3 SCI
  while (DREQ == 0);             // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI
}
예제 #2
0
//****************************************************//
//MP3_sineTest
//Prototype: void MP3_sineTest()
//Parameters: None.
//Description: test the sine wave function of vs1011e.
//Returns: None.
//****************************************************//
void MP3_sineTest()
{
	MP3_reset();       /* Pull xRESET low -> hardware reset */
	Delay_ms(100);            /* 100 ms delay */

	deselect_MP3();  /* Pull xCS high    */
	set_BSYNC();     /* Pull xDCS high */
	//Mp3DeselectData	( 		 ) 	   {MP3_XDCS=1;}

	Delay_ms(100);             /* 100 ms delay     */


	/* VS10xx Application Notes, chapter 4.8 ---------------------------------*/
	/* As an example, let's write value 0x0820 to register 00 byte by byte    */
	select_MP3();    /* Now SPI writes go to SCI port                   */
	SPI0_Write(0x02);      /* Send SPI Byte, then wait for byte to be sent.   */
	SPI0_Write(0x00);      /* 0x02 was WRITE command, 0x00 is register number */
	SPI0_Write(0x08);      /* This byte goes to MSB                           */
	SPI0_Write(0x20);      /* ..and this is LSB. (0x20=Allow Test Mode)       */
	waitSPI();             /* Wait until Atmel MCU signals SPI write complete */
	deselect_MP3();  /* Now SPI writes don't go to SCI port             */
	while (DREQ==0) {;}     /* Wait for DREQ = 1                               */
	/* Do nothing while waiting for DREQ = 1           */

	/* Send a Sine Test Header to Data port                                   */
	/* Now SPI writes go to SDI port                   */
	UARTprintf("in sine test \n");
	while(1)
	{
		MP3_SDI_Write(0x53);//SPI0_Write(0x53);      /* - This is a special VLSI Solution test header - */
		MP3_SDI_Write(0xef);//SPI0_Write(0xef);      /* - that starts a sine sound. It's good for     - */
		MP3_SDI_Write(0x6e);//SPI0_Write(0x6e);      /* - testing your code, the chip and also for    - */
		MP3_SDI_Write(0x44);//SPI0_Write(0x44);      /* - seeing if your MP3 decoder was manufactured - */
		MP3_SDI_Write(0x00);//SPI0_Write(0x00);      /* - by VLSI Solution oy. ------------------------ */
		MP3_SDI_Write(0x00);// SPI0_Write(0x00);
		MP3_SDI_Write(0x00);//SPI0_Write(0x00);
		MP3_SDI_Write(0x00);//SPI0_Write(0x00);

		Delay_ms(500);
		/* Stop the sine test sound */
		MP3_SDI_Write(0x45); //SPI0_Write(0x45);
		MP3_SDI_Write(0x78);//SPI0_Write(0x78);
		MP3_SDI_Write(0x69);//SPI0_Write(0x69);
		MP3_SDI_Write(0x74);// SPI0_Write(0x74);
		MP3_SDI_Write(0x00);//SPI0_Write(0x00);
		MP3_SDI_Write(0x00);// SPI0_Write(0x00);
		MP3_SDI_Write(0x00);//SPI0_Write(0x00);
		MP3_SDI_Write(0x00);//SPI0_Write(0x00);

		Delay_ms(500);            /* 500 ms delay */
	}
}
unsigned int MP3_SCI_ReadSingle(char address) {
  unsigned int temp;

  MP3_CS = 0;                    // select MP3 SCI
  while (DREQ == 0);             // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI
  SPI0_Write(READ_CODE);
  SPI0_Write(address);

  temp = SPI0_Read(0);
  temp <<= 8;
  temp += SPI0_Read(0);

  MP3_CS = 1;                    // deselect MP3 SCI
  return temp;
}
/**************************************************************************************************
* Function MP3_SCI_Read()
* -------------------------------------------------------------------------------------------------
* Overview: Function reads words_count words from MP3 SCI
* Input: start address, word count to be read
* Output: words are stored to data_buffer
**************************************************************************************************/
void MP3_SCI_Read(char start_address, char words_count, unsigned int *data_buffer) {
  unsigned int temp;

  MP3_CS = 0;                    // select MP3 SCI
  SPI0_Write(READ_CODE);
  SPI0_Write(start_address);

  while (words_count--) {        // read words_count words byte per byte
    temp = SPI0_Read(0);
    temp <<= 8;
    temp += SPI0_Read(0);
    *(data_buffer++) = temp;
  }
  MP3_CS = 1;                    // deselect MP3 SCI
  while (DREQ == 0);             // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI
}
예제 #5
0
unsigned int Mp3ReadRegister	(	unsigned char 	addressbyte	 ) 	
{
	unsigned int resultvalue = 0;
	unsigned char temp1,temp2;
	select_MP3();
	SPI0_Write(READ_CODE);
	SPI0_Write((addressbyte));
	temp1 = SPI0_Read();
	resultvalue = temp1; 
	resultvalue = resultvalue<<8;
	temp2 = SPI0_Read();
	waitSPI();
	resultvalue |= (temp2);
	deselect_MP3();
	return resultvalue;
	
}
예제 #6
0
/**************************************************************************************************
* Function MP3_SCI_Write()
* -------------------------------------------------------------------------------------------------
* Overview: Function writes one byte to MP3 SCI
* Input: register address in codec, data
* Output: Nothing
**************************************************************************************************/
void MP3_SCI_Write(char address, unsigned int data_in) 
{

	unsigned char highbyte,lowbyte;
	highbyte =(unsigned char)(data_in>>8);
	lowbyte = (unsigned char)(data_in);
	set_BSYNC();	//		BSYNC = 1;
	select_MP3();		//MP3_CS = 0;  select MP3 SCI
	//Delay_ms(10);
	SPI0_Write(WRITE_CODE);
	SPI0_Write(address);
	SPI0_Write(highbyte);       // high byte
	SPI0_Write(lowbyte);       // low byte
	//waitSPI();
	deselect_MP3(); //MP3_CS = 1;// deselect MP3 SCI
	while (DREQ == 0);             // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI
}
/**************************************************************************************************
* Function MP3_SDI_Write()
* -------------------------------------------------------------------------------------------------
* Overview: Function write one byte to MP3 SDI
* Input: data to be writed
* Output: Nothing
**************************************************************************************************/
void MP3_SDI_Write(char data_) {

  MP3_CS = 1;
  XDCS = 0;

  while (DREQ == 0);             // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI

  SPI0_Write(data_);
  XDCS = 1;
}
예제 #8
0
/**************************************************************************************************
* Function MP3_SDI_Write()
* -------------------------------------------------------------------------------------------------
* Overview: Function write one byte to MP3 SDI
* Input: data to be writed
* Output: Nothing
**************************************************************************************************/
void MP3_SDI_Write(char data_) {

	clear_BSYNC();	// BSYNC = 0;
	deselect_MP3();		// MP3_CS = 1;
	

	while (!DREQ);             // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI

	SPI0_Write(data_);
	
	set_BSYNC();					//BSYNC = 1;
}
/**************************************************************************************************
* Function MP3_SDI_Write_32
* -------------------------------------------------------------------------------------------------
* Overview: Function Write 32 bytes to MP3 SDI
* Input: data buffer
* Output: Nothing
**************************************************************************************************/
void MP3_SDI_Write_32(char *data_) {
  char i;

  MP3_CS = 1;
  XDCS = 0;

  while (DREQ == 0);             // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI

  for (i=0; i<32; i++)
     SPI0_Write(data_[i]);
     
  XDCS = 1;
}
예제 #10
0
/**************************************************************************************************
* Function MP3_SDI_Write_32
* -------------------------------------------------------------------------------------------------
* Overview: Function Write 32 bytes to MP3 SDI
* Input: data buffer
* Output: Nothing
**************************************************************************************************/
void MP3_SDI_Write_32(char *data_) {
	char i;

	deselect_MP3();
	clear_BSYNC();

	while (!DREQ) // wait until DREQ becomes 1, see MP3 codec datasheet, Serial Protocol for SCI
	{
		//other stuff ?
	}            

	for (i=0; i<32; i++)
	SPI0_Write(data_[i]);
	waitSPI();
	set_BSYNC();
}
예제 #11
0
파일: ssp.c 프로젝트: david2004kang/CODE
void SPITestWrite2()
{
	uint8 Buffer[1] = {0xE3};
	SPI0_Write(Buffer, 1);
}
예제 #12
0
파일: ssp.c 프로젝트: david2004kang/CODE
void SPITestWrite()
{
	uint8 Buffer[3];
	memset(Buffer, 0x81, 3);
	SPI0_Write(Buffer, 3);
}