en 129 / Mbed 2 deprecated MP3_player_on_Orange

Dependencies:   TextLCD mbed VS1002_controler SDFileSystem

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "VS1002.h"
00003 
00004 /*
00005  VS1002 MP3Player
00006  2012/03/14
00007  
00008  このプログラムは以下のURLのソースコードを元に作成しています
00009  http://mbed.org/cookbook/VS1002-MP3-Decoder
00010  
00011 接続方法 
00012  VS1002      |        mbed
00013  ---------------------------------------
00014   D2(BSYNC)------------17
00015   D3(DREQ)-------------16
00016 
00017   D9(CS)---------------14
00018 
00019   D11(MOSI)------------11
00020   D12(MISO)------------12
00021   D13(SCK)-------------13
00022 
00023   GND------------------GND(1)
00024   5V-------------------VU(39)
00025   RESET----------------15
00026 
00027 ボリュームはp20の電圧によって制御しますが、Arduino_MP3_Shield_MP3Playerライブラリの
00028 VS1002.hファイル内の#define FIXED_VOLのコメントを外すことによってp20の電圧に関係なく最大の音量となります
00029 */
00030 
00031 
00032 //PinName mmosi, PinName mmiso, PinName ssck, PinName ccs, const char *name,
00033 //         PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst,
00034 //         PinName dreq, PinName dcs, PinName vol)
00035 VS1002 mp3(p5, p6, p7, p8, "sd",
00036         p11, p12, p13, p14, p15,
00037         p16, p17, p20);     //p14 in BoB non-functional so replace with p18
00038 
00039 
00040 int main ()
00041 {
00042   // make debug port Fast
00043    Serial pc(USBTX, USBRX);
00044 //    pc.baud(9600);
00045     pc.baud(115200);
00046 //  pc.baud(230400);
00047     printf("Power ON\r\n"); 
00048 
00049     /*============================================================
00050      * MP3 Initialising
00051      *==========================================================*/
00052 #ifndef FS_ONLY    
00053     mp3._RST = 1;
00054     mp3.cs_high();                                   //chip disabled
00055     mp3.sci_initialise();                            //initialise MBED
00056     mp3.sci_write(0x00,(SM_SDINEW+SM_STREAM+SM_DIFF));
00057     mp3.sci_write(0x03, 0x9800);
00058     mp3.sdi_initialise();    
00059 #endif        
00060     /*============================================================
00061      * This is the good part
00062      *==========================================================*/
00063     printf("MP3 init OK\r\n"); 
00064     
00065     for(int a=1; a<24; a++)
00066     {
00067         printf("Song#:%d\r\n",a); 
00068         mp3.play_song(a);
00069         wait(1);
00070     }
00071     printf("Done.\r\n");
00072 }