Пример #1
0
// reset for vs10xx
void VS10XX::reset()
{
  putInReset();
  delay(100);//it is a must
  /* Send dummy SPI byte to initialize atmel SPI */
  ////SPIPutCharWithoutWaiting(0xFF);  
  deselectControlBus();
  deselectDataBus();
  releaseFromReset();
  while (!readDREQ());
  /* Set clock register, doubler etc. */
  writeRegister(SPI_CLOCKF, 0xc0, 0x00); 
  Serial.print("\r\nClockF:");
  Serial.println(readRegister(SPI_CLOCKF),HEX);
  /* Wait for DREQ */
  while (!readDREQ());
  softReset();//comment this, as it will be executed everytime playing a music file.

  writeRegister(SPI_WRAMADDR, 0xc0, 0x13);
  
  /* Switch on the analog parts */
  setVolume(40,40);
  //setVolume(0xff,0xff);
  //SPISetFastClock();
}
Пример #2
0
void VS10XX::writeRegister(unsigned char addressbyte,unsigned char highbyte,unsigned char lowbyte)
{ 
 // while (!readDREQ());
  deselectDataBus();
  selectControlBus(); 
  newSPI.transmit(VS_WRITE_COMMAND); 
  newSPI.transmit((addressbyte)); 
  newSPI.transmit((highbyte)); 
  newSPI.transmit((lowbyte));
  deselectControlBus();
}
Пример #3
0
unsigned int VS10XX::readRegister (unsigned char addressbyte)
{
  unsigned int result = 0;
  unsigned char highbyte = 0;
  unsigned char lowbyte = 0;
  deselectDataBus();
  selectControlBus();//XCS = 0
  newSPI.transmit(VS_READ_COMMAND); //send read command
  newSPI.transmit(addressbyte);    //send register address     
    //be careful: when read 0xff,dump it,and read agin
    //while((h = SPIGetChar())== 0xff);
  highbyte = newSPI.receive();    
  //while((l = VsReadByte())== 0xff);
  lowbyte = newSPI.receive();

  result = (((unsigned int) highbyte << 8) | lowbyte);
  deselectControlBus();
  return result;
}