A simple library for decoding MP3 files with the VS1053 CoDec chip. The initial library was written by Kaoru Onoe. The library is patched to work with some "LC Technology" VS1053 board that have some IC pins disconnected. Because of that problem, there was no sound out of that boards. Now, these board work ok !

Dependents:   W7500_and_VS1053_MP3_decoder VS1053_MP3_decoder_WIZwiki-W7500 VS1053Player Scat

Fork of VS1053 by Kaoru Onoe

Files at this revision

API Documentation at this revision

Comitter:
silis
Date:
Thu Nov 26 14:21:36 2015 +0000
Parent:
7:97a8edd44fe9
Commit message:
Added setVolume function

Changed in this revision

VS1053.cpp Show annotated file Show diff for this revision Revisions of this file
VS1053.h Show annotated file Show diff for this revision Revisions of this file
diff -r 97a8edd44fe9 -r 5ad25d480d5f VS1053.cpp
--- a/VS1053.cpp	Sat Sep 05 12:16:06 2015 +0000
+++ b/VS1053.cpp	Thu Nov 26 14:21:36 2015 +0000
@@ -21,12 +21,12 @@
 :
     spi(mosiPin, misoPin, sckPin),
     cs(csPin),
-    bsync(bsyncPin),
+    bsync(bsyncPin), //dcs pin
     dreq(dreqPin),
     rst(rstPin)
 {
-    spi.format(8, 0);
-    spi.frequency(spiFrequency);
+    //spi.format(8, 0);
+    //spi.frequency(spiFrequency);
 
     // Initialize outputs
     cs = 1;
@@ -71,7 +71,7 @@
 /** Send a data block specified as a pointer to VS1053.
  *  @return Data length successfully sent.
  */
-size_t VS1053::sendDataBlock(uint8_t* data, size_t length) {
+size_t VS1053::sendDataBlock(char* data, size_t length) {
     size_t n, sizeSent = 0;
     
     if (!data || !length) return 0;
@@ -147,6 +147,19 @@
     return readReg(SCI_HDAT0) == 0x0000 && readReg(SCI_HDAT1) == 0x0000;
 }
 
+/**
+ * Set the VS1053 volume.
+ *
+ */
+void VS1053::setVolume(uint8_t vol)
+{
+  uint16_t value = vol;
+  value <<= 8;
+  value |= vol;
+
+  writeReg(SCI_VOL,value); // VOL
+}
+
 /** Write to an SCI (Serial Control Interface) register entry. */
 void VS1053::writeReg(uint8_t addr, uint16_t word) {
     // If addr is out-of-range, do nothing
diff -r 97a8edd44fe9 -r 5ad25d480d5f VS1053.h
--- a/VS1053.h	Sat Sep 05 12:16:06 2015 +0000
+++ b/VS1053.h	Thu Nov 26 14:21:36 2015 +0000
@@ -19,7 +19,7 @@
 private:
     SPI        spi;
     DigitalOut cs;
-    DigitalOut bsync;
+    DigitalOut bsync; //dcs pin
     DigitalIn  dreq;
     DigitalOut rst;
 
@@ -51,10 +51,11 @@
     void hardwareReset();
     void modeSwitch(void);
     void sendDataByte(uint8_t data);
-    size_t sendDataBlock(uint8_t* data, size_t length);
+    size_t sendDataBlock(char* data, size_t length);
     void clockUp();
     bool sendCancel();
     bool stop();
+    void setVolume(uint8_t vol);
     
 private:
     void writeReg(uint8_t, uint16_t);