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

Committer:
silis
Date:
Thu Nov 26 14:21:36 2015 +0000
Revision:
8:5ad25d480d5f
Parent:
7:97a8edd44fe9
Added setVolume function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
silis 7:97a8edd44fe9 1 /**
silis 7:97a8edd44fe9 2 * ==================================================== Dec 21 2013, kayeks ==
silis 7:97a8edd44fe9 3 * VS1053.cpp
silis 7:97a8edd44fe9 4 * ===========================================================================
silis 7:97a8edd44fe9 5 * Just a simple library for VLSI's mp3/midi codec chip
silis 7:97a8edd44fe9 6 * - Minimal and simple implementation (and dirty too)
silis 7:97a8edd44fe9 7 *
silis 7:97a8edd44fe9 8 * Modified on 05 September 2015 by Vassilis Serasidis.
silis 7:97a8edd44fe9 9 * - Added a patch for playing MP3 files on some "LC Technology" VS1053 boards.
silis 7:97a8edd44fe9 10 *
silis 7:97a8edd44fe9 11 *
silis 7:97a8edd44fe9 12 */
silis 7:97a8edd44fe9 13
kayekss 0:708868399033 14 #ifndef KAYX_VS1053_H_
kayekss 0:708868399033 15 #define KAYX_VS1053_H_
kayekss 0:708868399033 16
kayekss 2:47ba7e2259cd 17 /** Class VS1053. Drives VLSI's mp3/midi codec chip. */
kayekss 0:708868399033 18 class VS1053 {
kayekss 0:708868399033 19 private:
kayekss 4:6e0fb5342efa 20 SPI spi;
kayekss 0:708868399033 21 DigitalOut cs;
silis 8:5ad25d480d5f 22 DigitalOut bsync; //dcs pin
kayekss 4:6e0fb5342efa 23 DigitalIn dreq;
kayekss 0:708868399033 24 DigitalOut rst;
kayekss 0:708868399033 25
kayekss 0:708868399033 26 public:
kayekss 0:708868399033 27 static const uint8_t SCI_MODE = 0x00;
kayekss 0:708868399033 28 static const uint8_t SCI_STATUS = 0x01;
kayekss 0:708868399033 29 static const uint8_t SCI_BASS = 0x02;
kayekss 0:708868399033 30 static const uint8_t SCI_CLOCKF = 0x03;
kayekss 0:708868399033 31 static const uint8_t SCI_DECODE_TIME = 0x04;
kayekss 0:708868399033 32 static const uint8_t SCI_AUDATA = 0x05;
kayekss 0:708868399033 33 static const uint8_t SCI_WRAM = 0x06;
kayekss 0:708868399033 34 static const uint8_t SCI_WRAMADDR = 0x07;
kayekss 0:708868399033 35 static const uint8_t SCI_HDAT0 = 0x08;
kayekss 0:708868399033 36 static const uint8_t SCI_HDAT1 = 0x09;
kayekss 0:708868399033 37 static const uint8_t SCI_AIADDR = 0x0a;
kayekss 0:708868399033 38 static const uint8_t SCI_VOL = 0x0b;
kayekss 0:708868399033 39 static const uint8_t SCI_AICTRL0 = 0x0c;
kayekss 0:708868399033 40 static const uint8_t SCI_AICTRL1 = 0x0d;
kayekss 0:708868399033 41 static const uint8_t SCI_AICTRL2 = 0x0e;
kayekss 0:708868399033 42 static const uint8_t SCI_AICTRL3 = 0x0f;
kayekss 0:708868399033 43
silis 7:97a8edd44fe9 44 static const uint8_t SM_RESET = 2;
silis 7:97a8edd44fe9 45 static const uint8_t SM_SDINEW = 11;
silis 7:97a8edd44fe9 46
kayekss 0:708868399033 47 VS1053(PinName mosiPin, PinName misoPin, PinName sckPin,
kayekss 6:1f57fbd3aeb5 48 PinName csPin, PinName bsyncPin, PinName dreqPin, PinName rstPin,
kayekss 0:708868399033 49 uint32_t spiFrequency=1000000);
kayekss 0:708868399033 50 ~VS1053();
kayekss 0:708868399033 51 void hardwareReset();
silis 7:97a8edd44fe9 52 void modeSwitch(void);
kayekss 2:47ba7e2259cd 53 void sendDataByte(uint8_t data);
silis 8:5ad25d480d5f 54 size_t sendDataBlock(char* data, size_t length);
kayekss 0:708868399033 55 void clockUp();
kayekss 0:708868399033 56 bool sendCancel();
kayekss 0:708868399033 57 bool stop();
silis 8:5ad25d480d5f 58 void setVolume(uint8_t vol);
kayekss 0:708868399033 59
kayekss 0:708868399033 60 private:
kayekss 0:708868399033 61 void writeReg(uint8_t, uint16_t);
kayekss 0:708868399033 62 uint16_t readReg(uint8_t);
kayekss 0:708868399033 63 };
kayekss 0:708868399033 64
kayekss 0:708868399033 65 #endif