Just a simple library for VLSI's mp3/midi codec chip

Dependents:   IsuProject_LPC1768

Committer:
kayekss
Date:
Sat Nov 09 10:23:04 2013 +0000
Revision:
2:47ba7e2259cd
Parent:
1:00c19f771676
Child:
3:696c8e6744b2
Added API documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kayekss 2:47ba7e2259cd 1 // ==================================================== Nov 09 2013, kayeks ==
kayekss 0:708868399033 2 // VS1053.h
kayekss 0:708868399033 3 // ===========================================================================
kayekss 0:708868399033 4 // Just a simple library for VLSI's mp3/midi codec chip
kayekss 0:708868399033 5 // - Minimal and simple implementation (and dirty too)
kayekss 0:708868399033 6
kayekss 0:708868399033 7 #ifndef KAYX_VS1053_H_
kayekss 0:708868399033 8 #define KAYX_VS1053_H_
kayekss 0:708868399033 9
kayekss 2:47ba7e2259cd 10 /** Class VS1053. Drives VLSI's mp3/midi codec chip. */
kayekss 0:708868399033 11 class VS1053 {
kayekss 0:708868399033 12 private:
kayekss 0:708868399033 13 SPI spi;
kayekss 0:708868399033 14 DigitalOut cs;
kayekss 0:708868399033 15 DigitalOut bsync;
kayekss 0:708868399033 16 DigitalIn dreq;
kayekss 0:708868399033 17 DigitalOut rst;
kayekss 0:708868399033 18
kayekss 0:708868399033 19 public:
kayekss 0:708868399033 20 static const uint8_t SCI_MODE = 0x00;
kayekss 0:708868399033 21 static const uint8_t SCI_STATUS = 0x01;
kayekss 0:708868399033 22 static const uint8_t SCI_BASS = 0x02;
kayekss 0:708868399033 23 static const uint8_t SCI_CLOCKF = 0x03;
kayekss 0:708868399033 24 static const uint8_t SCI_DECODE_TIME = 0x04;
kayekss 0:708868399033 25 static const uint8_t SCI_AUDATA = 0x05;
kayekss 0:708868399033 26 static const uint8_t SCI_WRAM = 0x06;
kayekss 0:708868399033 27 static const uint8_t SCI_WRAMADDR = 0x07;
kayekss 0:708868399033 28 static const uint8_t SCI_HDAT0 = 0x08;
kayekss 0:708868399033 29 static const uint8_t SCI_HDAT1 = 0x09;
kayekss 0:708868399033 30 static const uint8_t SCI_AIADDR = 0x0a;
kayekss 0:708868399033 31 static const uint8_t SCI_VOL = 0x0b;
kayekss 0:708868399033 32 static const uint8_t SCI_AICTRL0 = 0x0c;
kayekss 0:708868399033 33 static const uint8_t SCI_AICTRL1 = 0x0d;
kayekss 0:708868399033 34 static const uint8_t SCI_AICTRL2 = 0x0e;
kayekss 0:708868399033 35 static const uint8_t SCI_AICTRL3 = 0x0f;
kayekss 0:708868399033 36
kayekss 2:47ba7e2259cd 37 /** Constructor of class VS1053. */
kayekss 0:708868399033 38 VS1053(PinName mosiPin, PinName misoPin, PinName sckPin,
kayekss 0:708868399033 39 PinName cs, PinName bsync, PinName dreq, PinName rstPin,
kayekss 0:708868399033 40 uint32_t spiFrequency=1000000);
kayekss 2:47ba7e2259cd 41
kayekss 2:47ba7e2259cd 42 /** Destructor of class VS1053. */
kayekss 0:708868399033 43 ~VS1053();
kayekss 2:47ba7e2259cd 44
kayekss 2:47ba7e2259cd 45 /** Make a hardware reset by hitting VS1053's RESET pin. */
kayekss 0:708868399033 46 void hardwareReset();
kayekss 2:47ba7e2259cd 47
kayekss 2:47ba7e2259cd 48 /** Send a data byte to VS1053. */
kayekss 2:47ba7e2259cd 49 void sendDataByte(uint8_t data);
kayekss 2:47ba7e2259cd 50
kayekss 2:47ba7e2259cd 51 /** Send a data block specified as a pointer to VS1053.
kayekss 2:47ba7e2259cd 52 * @return Data length successfully sent.
kayekss 2:47ba7e2259cd 53 */
kayekss 2:47ba7e2259cd 54 size_t sendDataBlock(uint8_t* pData, size_t length);
kayekss 2:47ba7e2259cd 55
kayekss 2:47ba7e2259cd 56 /** Change VS1053's PLL setting for speedup. */
kayekss 0:708868399033 57 void clockUp();
kayekss 2:47ba7e2259cd 58
kayekss 2:47ba7e2259cd 59 /** Send cancel request to VS1053.
kayekss 2:47ba7e2259cd 60 * @return 0 at failure, 1 at success.
kayekss 2:47ba7e2259cd 61 */
kayekss 0:708868399033 62 bool sendCancel();
kayekss 2:47ba7e2259cd 63
kayekss 2:47ba7e2259cd 64 /** Attempts "stop playing".
kayekss 2:47ba7e2259cd 65 * Call this repeatedly during data stream tramsission until it successes.
kayekss 2:47ba7e2259cd 66 * @return 0 at failure, 1 at success.
kayekss 2:47ba7e2259cd 67 */
kayekss 0:708868399033 68 bool stop();
kayekss 0:708868399033 69
kayekss 0:708868399033 70 private:
kayekss 0:708868399033 71 void writeReg(uint8_t, uint16_t);
kayekss 0:708868399033 72 uint16_t readReg(uint8_t);
kayekss 0:708868399033 73 };
kayekss 0:708868399033 74
kayekss 0:708868399033 75 #endif