MP3Player use 11U68 and VS1033
Dependencies: SDFileSystem mbed
Fork of MP3_player_on_Orange by
Revision 1:371e02d5b03a, committed 2015-07-11
- Comitter:
- nameless129
- Date:
- Sat Jul 11 19:42:51 2015 +0000
- Parent:
- 0:1152f41f7f73
- Child:
- 2:e64114d458e5
- Commit message:
- first commit;
Changed in this revision
--- a/FATFileSystem.lib Wed Mar 14 14:09:26 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_unsupported/code/fatfilesystem/ \ No newline at end of file
--- a/SDFileSystem.lib Wed Mar 14 14:09:26 2012 +0000 +++ b/SDFileSystem.lib Sat Jul 11 19:42:51 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/simon/code/SDFileSystem/#b1ddfc9a9b25 +http://mbed.org/users/neilt6/code/SDFileSystem/#a47f74caa04e
--- a/TextLCD.lib Wed Mar 14 14:09:26 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- a/VS1002_controler.lib Wed Mar 14 14:09:26 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/nameless129/code/VS1002_controler/#9abce67c084e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VS1053.lib Sat Jul 11 19:42:51 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/kayekss/code/VS1053/#b61cd12eabc5
--- a/main.cpp Wed Mar 14 14:09:26 2012 +0000 +++ b/main.cpp Sat Jul 11 19:42:51 2015 +0000 @@ -1,6 +1,7 @@ +#include <stdio.h> #include "mbed.h" -#include "VS1002.h" - +#include "SDFileSystem.h" +#include "VS1053.h" /* VS1002 MP3Player 2012/03/14 @@ -11,62 +12,93 @@ 接続方法 VS1002 | mbed --------------------------------------- - D2(BSYNC)------------17 - D3(DREQ)-------------16 + RESET----------------P1_25 + + D2(BSYNC)------------P1_28 + D3(DREQ)-------------P2_3 - D9(CS)---------------14 - - D11(MOSI)------------11 - D12(MISO)------------12 - D13(SCK)-------------13 + D9(CS)---------------P0_2 + D11(MOSI)------------P0_9 + D12(MISO)------------P0_8 + D13(SCK)-------------P1_29 GND------------------GND(1) - 5V-------------------VU(39) - RESET----------------15 + 3.3V-----------------VU(39) -ボリュームはp20の電圧によって制御しますが、Arduino_MP3_Shield_MP3Playerライブラリの -VS1002.hファイル内の#define FIXED_VOLのコメントを外すことによってp20の電圧に関係なく最大の音量となります */ +SDFileSystem sd(/*MOSI*/ P1_22, /*MISO*/ P1_21, /*SCK*/ P1_20, /*CS*/ P1_23, /*Mountpoint*/ "sd"); +VS1053 mp3(/*MOSI*/ P0_9, /*MISO*/ P0_8, /*SCK*/ P1_29, + /*CS*/ P0_2, /*BSYNC*/ P1_28, /*DREQ*/ P2_3, /*RST*/ P1_25, /*SPI freq.*/ 10000000); -//PinName mmosi, PinName mmiso, PinName ssck, PinName ccs, const char *name, -// PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, -// PinName dreq, PinName dcs, PinName vol) -VS1002 mp3(p5, p6, p7, p8, "sd", - p11, p12, p13, p14, p15, - p16, p17, p20); //p14 in BoB non-functional so replace with p18 +//Serial pc(P1_27,P1_26); +const char *fileNameList[] = { + "/sd/1.mp3", + "/sd/2.mp3", +}; + +#define BLOCK_SIZE (1024) int main () { - // make debug port Fast - Serial pc(USBTX, USBRX); // pc.baud(9600); - pc.baud(115200); -// pc.baud(230400); - printf("Power ON\r\n"); - + printf("Power ON\r\n"); /*============================================================ * MP3 Initialising *==========================================================*/ -#ifndef FS_ONLY - mp3._RST = 1; - mp3.cs_high(); //chip disabled - mp3.sci_initialise(); //initialise MBED - mp3.sci_write(0x00,(SM_SDINEW+SM_STREAM+SM_DIFF)); - mp3.sci_write(0x03, 0x9800); - mp3.sdi_initialise(); -#endif + // Initialize VS1053 + +/* for sine test mode */ +// mp3.sine_test_activate(SineWave_1k); +// while(1); + + mp3.hardwareReset(); + mp3.sci_init(); + mp3.sdi_init(); + + + wait(0.1); /*============================================================ * This is the good part *==========================================================*/ printf("MP3 init OK\r\n"); - - for(int a=1; a<24; a++) + + static FILE *fp = NULL; + size_t sizeRead = 0; + size_t totalSizeSent=0; + size_t fileSize=0; + uint8_t buf[BLOCK_SIZE]; + + fp = fopen("/sd/3.mp3", "rb"); + + fseek( fp, 0, SEEK_END ); + fileSize = ftell( fp ); + printf("file size:%d\r\n",fileSize); + + rewind(fp); + + if (fp) { + clearerr(fp); + totalSizeSent = 0; + } + while(1) { - printf("Song#:%d\r\n",a); - mp3.play_song(a); - wait(1); + if(totalSizeSent>=fileSize) + { // Close when the track reaches the end + mp3.stop(); + fclose(fp); + fp = NULL; + printf("stop\r\n"); + while(1) + { + } + } + else + { + sizeRead = fread(buf, sizeof(uint8_t), BLOCK_SIZE, fp); + totalSizeSent += mp3.sendDataBlock(buf, sizeRead); + //printf("total %d Send %d\r\n",totalSizeSent,sizeRead); + } } - printf("Done.\r\n"); } \ No newline at end of file
--- a/mbed.bld Wed Mar 14 14:09:26 2012 +0000 +++ b/mbed.bld Sat Jul 11 19:42:51 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/4c0c40fd0593 +http://mbed.org/users/mbed_official/code/mbed/builds/da0ca467f8b5 \ No newline at end of file