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
}
示例#3
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;
	
}