sxa

Dependents:   MP3333 B18_MP3_PLAYER B18_MP3_PLAYER B18_MP3_PLAYER

Committer:
PKnevermind
Date:
Wed Dec 09 08:32:13 2015 +0000
Revision:
3:934d5e72990a
Parent:
0:928e5b21896c
VS1053

Who changed what in which revision?

UserRevisionLine numberNew contents of line
PKnevermind 0:928e5b21896c 1 /** file vs10xx.h
PKnevermind 0:928e5b21896c 2 * Headers for interfacing with the mp3 player chip.
PKnevermind 0:928e5b21896c 3 * Interfacing the New Way, not handling BSYNC -> not compatible with VS1001.
PKnevermind 0:928e5b21896c 4 */
PKnevermind 0:928e5b21896c 5
PKnevermind 0:928e5b21896c 6 #ifndef VS10XX_H
PKnevermind 0:928e5b21896c 7 #define VS10XX_H
PKnevermind 0:928e5b21896c 8
PKnevermind 0:928e5b21896c 9 #include "mbed.h"
PKnevermind 0:928e5b21896c 10
PKnevermind 0:928e5b21896c 11 /** VS10xx SCI Write Command byte is 0x02 */
PKnevermind 0:928e5b21896c 12 #define VS_WRITE_COMMAND 0x02
PKnevermind 0:928e5b21896c 13 /** VS10xx SCI Read Command byte is 0x03 */
PKnevermind 0:928e5b21896c 14 #define VS_READ_COMMAND 0x03
PKnevermind 0:928e5b21896c 15
PKnevermind 0:928e5b21896c 16 #define SPI_MODE 0x0 /**< VS10xx register */
PKnevermind 0:928e5b21896c 17 #define SPI_STATUS 0x1 /**< VS10xx register */
PKnevermind 0:928e5b21896c 18 #define SPI_BASS 0x2 /**< VS10xx register */
PKnevermind 0:928e5b21896c 19 #define SPI_CLOCKF 0x3 /**< VS10xx register */
PKnevermind 0:928e5b21896c 20 #define SPI_DECODE_TIME 0x4 /**< VS10xx register */
PKnevermind 0:928e5b21896c 21 #define SPI_AUDATA 0x5 /**< VS10xx register */
PKnevermind 0:928e5b21896c 22 #define SPI_WRAM 0x6 /**< VS10xx register */
PKnevermind 0:928e5b21896c 23 #define SPI_WRAMADDR 0x7 /**< VS10xx register */
PKnevermind 0:928e5b21896c 24 #define SPI_HDAT0 0x8 /**< VS10xx register */
PKnevermind 0:928e5b21896c 25 #define SPI_HDAT1 0x9 /**< VS10xx register */
PKnevermind 0:928e5b21896c 26 #define SPI_AIADDR 0xa /**< VS10xx register */
PKnevermind 0:928e5b21896c 27 #define SPI_VOL 0xb /**< VS10xx register */
PKnevermind 0:928e5b21896c 28 #define SPI_AICTRL0 0xc /**< VS10xx register */
PKnevermind 0:928e5b21896c 29 #define SPI_AICTRL1 0xd /**< VS10xx register */
PKnevermind 0:928e5b21896c 30 #define SPI_AICTRL2 0xe /**< VS10xx register */
PKnevermind 0:928e5b21896c 31 #define SPI_AICTRL3 0xf /**< VS10xx register */
PKnevermind 0:928e5b21896c 32
PKnevermind 0:928e5b21896c 33 #define SM_DIFF (1<< 0)
PKnevermind 0:928e5b21896c 34 #define SM_LAYER12 (1<< 1) /* VS1063, VS1053, VS1033, VS1011 */
PKnevermind 0:928e5b21896c 35 #define SM_RECORD_PATH (1<< 1) /* VS1103 */
PKnevermind 0:928e5b21896c 36 #define SM_RESET (1<< 2)
PKnevermind 0:928e5b21896c 37 #define SM_CANCEL (1<< 3) /* VS1063, VS1053 */
PKnevermind 0:928e5b21896c 38 #define SM_OUTOFWAV (1<< 3) /* VS1033, VS1003, VS1011 */
PKnevermind 0:928e5b21896c 39 #define SM_OUTOFMIDI (1<< 3) /* VS1103 */
PKnevermind 0:928e5b21896c 40 #define SM_EARSPEAKER_LO (1<< 4) /* VS1053, VS1033 */
PKnevermind 0:928e5b21896c 41 #define SM_PDOWN (1<< 4) /* VS1003, VS1103 */
PKnevermind 0:928e5b21896c 42 #define SM_TESTS (1<< 5)
PKnevermind 0:928e5b21896c 43 #define SM_STREAM (1<< 6) /* VS1053, VS1033, VS1003, VS1011 */
PKnevermind 0:928e5b21896c 44 #define SM_ICONF (1<< 6) /* VS1103 */
PKnevermind 0:928e5b21896c 45 #define SM_EARSPEAKER_HI (1<< 7) /* VS1053, VS1033 */
PKnevermind 0:928e5b21896c 46 #define SM_DACT (1<< 8)
PKnevermind 0:928e5b21896c 47 #define SM_SDIORD (1<< 9)
PKnevermind 0:928e5b21896c 48 #define SM_SDISHARE (1<<10)
PKnevermind 0:928e5b21896c 49 #define SM_SDINEW (1<<11)
PKnevermind 0:928e5b21896c 50 #define SM_ENCODE (1<<12) /* VS1063 */
PKnevermind 0:928e5b21896c 51 #define SM_ADPCM (1<<12) /* VS1053, VS1033, VS1003 */
PKnevermind 0:928e5b21896c 52 #define SM_EARSPEAKER1103 (1<<12) /* VS1103 */
PKnevermind 0:928e5b21896c 53 #define SM_ADPCM_HP (1<<13) /* VS1033, VS1003 */
PKnevermind 0:928e5b21896c 54 #define SM_LINE1 (1<<14) /* VS1063, VS1053 */
PKnevermind 0:928e5b21896c 55 #define SM_LINE_IN (1<<14) /* VS1033, VS1003, VS1103 */
PKnevermind 0:928e5b21896c 56 #define SM_CLK_RANGE (1<<15) /* VS1063, VS1053, VS1033 */
PKnevermind 0:928e5b21896c 57 #define SM_ADPCM_1103 (1<<15) /* VS1103 */
PKnevermind 0:928e5b21896c 58
PKnevermind 0:928e5b21896c 59 class vs10xx
PKnevermind 0:928e5b21896c 60 {
PKnevermind 0:928e5b21896c 61 public:
PKnevermind 0:928e5b21896c 62 vs10xx(PinName MOSI, PinName MISO, PinName SCLK, PinName XCS,
PKnevermind 0:928e5b21896c 63 PinName XDCS,PinName DREQ, PinName XRESET);
PKnevermind 0:928e5b21896c 64 void writeRegister(unsigned char addressbyte, unsigned int value);
PKnevermind 0:928e5b21896c 65 unsigned int readRegister(unsigned char addressbyte); /** Read the 16-bit value of a VS10xx register */
PKnevermind 0:928e5b21896c 66 void writeData(unsigned char *databuf, unsigned char = 32); //write 32 bytes to vs1053
PKnevermind 0:928e5b21896c 67
PKnevermind 0:928e5b21896c 68 void reset(void); //reset for vs10xx
PKnevermind 0:928e5b21896c 69 void softReset(void); /* Soft Reset of VS10xx (Between songs) */
PKnevermind 0:928e5b21896c 70 void setFreq(int freq);
PKnevermind 0:928e5b21896c 71 void setVolume(unsigned char vol);
PKnevermind 0:928e5b21896c 72 void loadPlugin(const unsigned short *plugin,int length);
PKnevermind 0:928e5b21896c 73 private:
PKnevermind 0:928e5b21896c 74 SPI _spi;
PKnevermind 0:928e5b21896c 75 DigitalOut _XCS;
PKnevermind 0:928e5b21896c 76 DigitalOut _XDCS;
PKnevermind 0:928e5b21896c 77 DigitalIn _DREQ;
PKnevermind 0:928e5b21896c 78 DigitalOut _XRESET;
PKnevermind 0:928e5b21896c 79
PKnevermind 0:928e5b21896c 80 };
PKnevermind 0:928e5b21896c 81
PKnevermind 0:928e5b21896c 82 #endif