modified for VS1033
Dependents: 11U68_MP3Player with TFTLCD 11U68_MP3Player-with-TFTLCD Mp3_1
Fork of VS1033 by
VS1053.h@9:1dd0ecaac8e5, 2015-07-16 (annotated)
- Committer:
- nameless129
- Date:
- Thu Jul 16 18:17:42 2015 +0000
- Revision:
- 9:1dd0ecaac8e5
- Parent:
- 7:b61cd12eabc5
- Child:
- 10:a8594af40a50
add vol control
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kayekss | 6:1f57fbd3aeb5 | 1 | // ==================================================== Dec 21 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 | |
nameless129 | 7:b61cd12eabc5 | 10 | //SCI_MODE register bits as of p.26 of the datasheet |
nameless129 | 7:b61cd12eabc5 | 11 | #define SM_DIFF 0x0001 |
nameless129 | 7:b61cd12eabc5 | 12 | #define SM_SETTOZERO 0x0002 |
nameless129 | 7:b61cd12eabc5 | 13 | #define SM_RESET 0x0004 |
nameless129 | 7:b61cd12eabc5 | 14 | #define SM_OUTOFWAV 0x0008 |
nameless129 | 7:b61cd12eabc5 | 15 | #define SM_PDOWN 0x0010 |
nameless129 | 7:b61cd12eabc5 | 16 | #define SM_TESTS 0x0020 |
nameless129 | 7:b61cd12eabc5 | 17 | #define SM_STREAM 0x0040 |
nameless129 | 7:b61cd12eabc5 | 18 | #define SM_PLUSV 0x0080 |
nameless129 | 7:b61cd12eabc5 | 19 | #define SM_DACT 0x0100 |
nameless129 | 7:b61cd12eabc5 | 20 | #define SM_SDIORD 0x0200 |
nameless129 | 7:b61cd12eabc5 | 21 | #define SM_SDISHARE 0x0400 |
nameless129 | 7:b61cd12eabc5 | 22 | #define SM_SDINEW 0x0800 |
nameless129 | 7:b61cd12eabc5 | 23 | #define SM_ADPCM 0x1000 |
nameless129 | 7:b61cd12eabc5 | 24 | #define SM_ADPCM_HP 0x2000 |
nameless129 | 7:b61cd12eabc5 | 25 | |
nameless129 | 7:b61cd12eabc5 | 26 | #define SineWave_10k (0x1D) |
nameless129 | 7:b61cd12eabc5 | 27 | #define SineWave_1k (0xA8) |
nameless129 | 7:b61cd12eabc5 | 28 | |
nameless129 | 7:b61cd12eabc5 | 29 | |
kayekss | 2:47ba7e2259cd | 30 | /** Class VS1053. Drives VLSI's mp3/midi codec chip. */ |
kayekss | 0:708868399033 | 31 | class VS1053 { |
kayekss | 0:708868399033 | 32 | private: |
kayekss | 4:6e0fb5342efa | 33 | SPI spi; |
kayekss | 0:708868399033 | 34 | DigitalOut cs; |
kayekss | 0:708868399033 | 35 | DigitalOut bsync; |
kayekss | 4:6e0fb5342efa | 36 | DigitalIn dreq; |
kayekss | 0:708868399033 | 37 | DigitalOut rst; |
kayekss | 0:708868399033 | 38 | |
kayekss | 0:708868399033 | 39 | public: |
kayekss | 0:708868399033 | 40 | static const uint8_t SCI_MODE = 0x00; |
kayekss | 0:708868399033 | 41 | static const uint8_t SCI_STATUS = 0x01; |
kayekss | 0:708868399033 | 42 | static const uint8_t SCI_BASS = 0x02; |
kayekss | 0:708868399033 | 43 | static const uint8_t SCI_CLOCKF = 0x03; |
kayekss | 0:708868399033 | 44 | static const uint8_t SCI_DECODE_TIME = 0x04; |
kayekss | 0:708868399033 | 45 | static const uint8_t SCI_AUDATA = 0x05; |
kayekss | 0:708868399033 | 46 | static const uint8_t SCI_WRAM = 0x06; |
kayekss | 0:708868399033 | 47 | static const uint8_t SCI_WRAMADDR = 0x07; |
kayekss | 0:708868399033 | 48 | static const uint8_t SCI_HDAT0 = 0x08; |
kayekss | 0:708868399033 | 49 | static const uint8_t SCI_HDAT1 = 0x09; |
kayekss | 0:708868399033 | 50 | static const uint8_t SCI_AIADDR = 0x0a; |
kayekss | 0:708868399033 | 51 | static const uint8_t SCI_VOL = 0x0b; |
kayekss | 0:708868399033 | 52 | static const uint8_t SCI_AICTRL0 = 0x0c; |
kayekss | 0:708868399033 | 53 | static const uint8_t SCI_AICTRL1 = 0x0d; |
kayekss | 0:708868399033 | 54 | static const uint8_t SCI_AICTRL2 = 0x0e; |
kayekss | 0:708868399033 | 55 | static const uint8_t SCI_AICTRL3 = 0x0f; |
kayekss | 0:708868399033 | 56 | |
kayekss | 0:708868399033 | 57 | VS1053(PinName mosiPin, PinName misoPin, PinName sckPin, |
kayekss | 6:1f57fbd3aeb5 | 58 | PinName csPin, PinName bsyncPin, PinName dreqPin, PinName rstPin, |
nameless129 | 7:b61cd12eabc5 | 59 | uint32_t spiFrequency=7000000); |
kayekss | 0:708868399033 | 60 | ~VS1053(); |
kayekss | 0:708868399033 | 61 | void hardwareReset(); |
kayekss | 2:47ba7e2259cd | 62 | void sendDataByte(uint8_t data); |
kayekss | 4:6e0fb5342efa | 63 | size_t sendDataBlock(uint8_t* data, size_t length); |
nameless129 | 7:b61cd12eabc5 | 64 | void sci_init(); |
nameless129 | 7:b61cd12eabc5 | 65 | void sdi_init(); |
kayekss | 0:708868399033 | 66 | bool sendCancel(); |
kayekss | 0:708868399033 | 67 | bool stop(); |
nameless129 | 7:b61cd12eabc5 | 68 | void sine_test_activate(unsigned char wave); |
nameless129 | 7:b61cd12eabc5 | 69 | void sine_test_deactivate(); |
nameless129 | 9:1dd0ecaac8e5 | 70 | void VS1053::VolControl(uint16_t vol); |
nameless129 | 9:1dd0ecaac8e5 | 71 | |
kayekss | 0:708868399033 | 72 | private: |
kayekss | 0:708868399033 | 73 | void writeReg(uint8_t, uint16_t); |
kayekss | 0:708868399033 | 74 | uint16_t readReg(uint8_t); |
nameless129 | 7:b61cd12eabc5 | 75 | uint32_t useSpiFreq; |
nameless129 | 7:b61cd12eabc5 | 76 | void sci_en(); |
nameless129 | 7:b61cd12eabc5 | 77 | void sci_dis(); |
nameless129 | 7:b61cd12eabc5 | 78 | void sdi_en(); |
nameless129 | 7:b61cd12eabc5 | 79 | void sdi_dis(); |
kayekss | 0:708868399033 | 80 | }; |
kayekss | 0:708868399033 | 81 | |
kayekss | 0:708868399033 | 82 | #endif |