Arduino MP3 Shield MP3Player This program comes from http://mbed.org/cookbook/VS1002-MP3-Decoder (Very small modification done to fit latest libs)
Dependencies: mbed SDFileSystem
main.cpp@0:8eab2c229d83, 2010-10-03 (annotated)
- Committer:
- xshige
- Date:
- Sun Oct 03 16:56:38 2010 +0000
- Revision:
- 0:8eab2c229d83
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
xshige | 0:8eab2c229d83 | 1 | |
xshige | 0:8eab2c229d83 | 2 | #include "mbed.h" |
xshige | 0:8eab2c229d83 | 3 | #include "VS1002.h" |
xshige | 0:8eab2c229d83 | 4 | |
xshige | 0:8eab2c229d83 | 5 | /* |
xshige | 0:8eab2c229d83 | 6 | |
xshige | 0:8eab2c229d83 | 7 | Arduino MP3 Shield MP3Player |
xshige | 0:8eab2c229d83 | 8 | 2010/10/3 |
xshige | 0:8eab2c229d83 | 9 | |
xshige | 0:8eab2c229d83 | 10 | This program comes from http://mbed.org/cookbook/VS1002-MP3-Decoder |
xshige | 0:8eab2c229d83 | 11 | (Very small modification done to fit latest libs) |
xshige | 0:8eab2c229d83 | 12 | |
xshige | 0:8eab2c229d83 | 13 | |
xshige | 0:8eab2c229d83 | 14 | Pin Assigenment for Arduino MP3 Shield |
xshige | 0:8eab2c229d83 | 15 | (VS1053 employed, issued by sparkfun.com) |
xshige | 0:8eab2c229d83 | 16 | |
xshige | 0:8eab2c229d83 | 17 | MP3 Sheild Side | mbed Side |
xshige | 0:8eab2c229d83 | 18 | --------------------------------------- |
xshige | 0:8eab2c229d83 | 19 | D2(BSYNC)------------17 |
xshige | 0:8eab2c229d83 | 20 | D3(DREQ)-------------16 |
xshige | 0:8eab2c229d83 | 21 | |
xshige | 0:8eab2c229d83 | 22 | D9(CS)---------------14 |
xshige | 0:8eab2c229d83 | 23 | |
xshige | 0:8eab2c229d83 | 24 | D11(MOSI)------------11 |
xshige | 0:8eab2c229d83 | 25 | D12(MISO)------------12 |
xshige | 0:8eab2c229d83 | 26 | D13(SCK)-------------13 |
xshige | 0:8eab2c229d83 | 27 | |
xshige | 0:8eab2c229d83 | 28 | GND------------------GND(1) |
xshige | 0:8eab2c229d83 | 29 | 5V-------------------VU(39) |
xshige | 0:8eab2c229d83 | 30 | RESET----------------15 |
xshige | 0:8eab2c229d83 | 31 | |
xshige | 0:8eab2c229d83 | 32 | Volume will not used. (pin20 will not used) |
xshige | 0:8eab2c229d83 | 33 | |
xshige | 0:8eab2c229d83 | 34 | */ |
xshige | 0:8eab2c229d83 | 35 | |
xshige | 0:8eab2c229d83 | 36 | |
xshige | 0:8eab2c229d83 | 37 | //PinName mmosi, PinName mmiso, PinName ssck, PinName ccs, const char *name, |
xshige | 0:8eab2c229d83 | 38 | // PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, |
xshige | 0:8eab2c229d83 | 39 | // PinName dreq, PinName dcs, PinName vol) |
xshige | 0:8eab2c229d83 | 40 | VS1002 mp3(p5, p6, p7, p8, "sd", |
xshige | 0:8eab2c229d83 | 41 | p11, p12, p13, p14, p15, |
xshige | 0:8eab2c229d83 | 42 | p16, p17, p20); //p14 in BoB non-functional so replace with p18 |
xshige | 0:8eab2c229d83 | 43 | |
xshige | 0:8eab2c229d83 | 44 | |
xshige | 0:8eab2c229d83 | 45 | int main () |
xshige | 0:8eab2c229d83 | 46 | { |
xshige | 0:8eab2c229d83 | 47 | // make debug port Fast |
xshige | 0:8eab2c229d83 | 48 | Serial pc(USBTX, USBRX); |
xshige | 0:8eab2c229d83 | 49 | // pc.baud(9600); |
xshige | 0:8eab2c229d83 | 50 | pc.baud(115200); |
xshige | 0:8eab2c229d83 | 51 | // pc.baud(230400); |
xshige | 0:8eab2c229d83 | 52 | |
xshige | 0:8eab2c229d83 | 53 | /*============================================================ |
xshige | 0:8eab2c229d83 | 54 | * MP3 Initialising |
xshige | 0:8eab2c229d83 | 55 | *==========================================================*/ |
xshige | 0:8eab2c229d83 | 56 | #ifndef FS_ONLY |
xshige | 0:8eab2c229d83 | 57 | mp3._RST = 1; |
xshige | 0:8eab2c229d83 | 58 | mp3.cs_high(); //chip disabled |
xshige | 0:8eab2c229d83 | 59 | mp3.sci_initialise(); //initialise MBED |
xshige | 0:8eab2c229d83 | 60 | mp3.sci_write(0x00,(SM_SDINEW+SM_STREAM+SM_DIFF)); |
xshige | 0:8eab2c229d83 | 61 | mp3.sci_write(0x03, 0x9800); |
xshige | 0:8eab2c229d83 | 62 | mp3.sdi_initialise(); |
xshige | 0:8eab2c229d83 | 63 | #endif |
xshige | 0:8eab2c229d83 | 64 | /*============================================================ |
xshige | 0:8eab2c229d83 | 65 | * This is the good part |
xshige | 0:8eab2c229d83 | 66 | *==========================================================*/ |
xshige | 0:8eab2c229d83 | 67 | |
xshige | 0:8eab2c229d83 | 68 | for(int a=1; a<24; a++) |
xshige | 0:8eab2c229d83 | 69 | { |
xshige | 0:8eab2c229d83 | 70 | printf("Song#:%d\r\n",a); |
xshige | 0:8eab2c229d83 | 71 | mp3.play_song(a); |
xshige | 0:8eab2c229d83 | 72 | wait(1); |
xshige | 0:8eab2c229d83 | 73 | } |
xshige | 0:8eab2c229d83 | 74 | printf("Done.\r\n"); |
xshige | 0:8eab2c229d83 | 75 | } |