// 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(); }
/** Soft Reset of VS10xx (Between songs) */ void VS10XX::softReset() { /* Soft Reset of VS10xx */ writeRegister (SPI_MODE, 0x08, 0x04); /* Newmode, Reset, No L1-2 */ //Delay(1); while (!readDREQ()); /* wait for startup */ //setup I2S (see page77 of the datasheet of vs1053 ) //set GPIO0 as output writeRegister(SPI_WRAMADDR, 0xc0, 0x17); writeRegister(SPI_WRAM, 0x00, 0xf0); //enable I2S (MCLK enabled, 48kHz sample rate) writeRegister(SPI_WRAMADDR, 0xc0, 0x40); writeRegister(SPI_WRAM, 0x00, 0x0C); while (!readDREQ()); //LoadUserPatch(); }
void VS10XX::writeData(unsigned char *databuf, unsigned char datalen) { selectDataBus(); while (!readDREQ()); while(datalen --) { newSPI.transmit(*databuf ++); } deselectDataBus(); }
void VS10XX::sendZerosToVS10xx() { unsigned int i; selectDataBus(); for (i=0;i < 2048;i ++) { while (!readDREQ()); newSPI.transmit(0); } deselectDataBus(); }