Dependents:   MP3_player_on_Orange

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers VS1002.h Source File

VS1002.h

00001 #ifndef VS1002_H
00002 #define VS1002_H
00003 
00004 //file system only
00005 //#define FS_ONLY
00006 
00007 //no vol control
00008 //#define FIXED_VOL
00009 
00010 #include "mbed.h"
00011 #include "SDFileSystem.h"
00012 #include "string"
00013 #include "string.h"
00014 
00015 //SCI_MODE register bits as of p.26 of the datasheet
00016 #define SM_DIFF         0x0001
00017 #define SM_SETTOZERO    0x0002
00018 #define SM_RESET        0x0004
00019 #define SM_OUTOFWAV     0x0008
00020 #define SM_PDOWN        0x0010
00021 #define SM_TESTS        0x0020
00022 #define SM_STREAM       0x0040
00023 #define SM_PLUSV        0x0080
00024 #define SM_DACT         0x0100
00025 #define SM_SDIORD       0x0200
00026 #define SM_SDISHARE     0x0400
00027 #define SM_SDINEW       0x0800
00028 #define SM_ADPCM        0x1000
00029 #define SM_ADPCM_HP     0x2000
00030 
00031 
00032 class VS1002  {
00033 
00034 public:
00035 //    VS1002(int _mmosi, int _mmiso, int _ssck, int _ccs, const char* _name,
00036 // int _mosi, int _miso, int _sck, int _cs, int _rst, int _dreq, int _dcs, int _vol);
00037     VS1002(PinName _mmosi, PinName _mmiso, PinName _ssck, PinName _ccs, const char* _name, 
00038     PinName _mosi, PinName _miso, PinName _sck, PinName _cs, PinName _rst, PinName _dreq,
00039     PinName _dcs, PinName _vol);
00040     
00041     void cs_low(void); 
00042     void cs_high(void);
00043     void dcs_low(void);
00044     void dcs_high(void);
00045     void sci_en(void);
00046     void sci_dis(void);
00047     void sdi_en(void);
00048     void sdi_dis(void);
00049     
00050     void sci_initialise(void);
00051     void sdi_initialise(void);
00052     void reset(void);
00053     void power_down(void);
00054  
00055     void sci_write(unsigned char, unsigned short int);
00056     void sdi_write(unsigned char);
00057     unsigned short int read(unsigned short int);
00058     void sine_test_activate(unsigned char);
00059     void volume(void);
00060     void sine_test_deactivate(void);
00061     void play_song(int);
00062     
00063     int num_of_files;
00064     
00065     DigitalIn _DREQ;
00066     DigitalOut _RST;
00067     AnalogIn _VOL;
00068     
00069 protected:
00070 
00071     SPI _spi;
00072     DigitalOut _CS;
00073     DigitalOut _DCS;
00074     SDFileSystem _sd;
00075 
00076 };
00077 #endif