Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FTPClient javakysSDFileSystem2 WIZnetInterface mbed
Prerequisite
This example is for playing MP3 file stored in SD card on WIZwiki-W7500 and updating MP3 files from server to SD card via FTP protocol.
To implement this function, you need a Platform board, network Interface board, MP3 decoder board and SD card. Below are what we used.
- WIZwiki-W7500 from WIZnet (Platform board and Ethernet I/F board)
- Music shield from Seeed Studio
- SD card
Hardware Configuration
WIZwiki-W7500 Pin map

SPI1 for SD Card
SPI1 on WIZwiki-W7100 is for reading from or writing to SD card and pins for SPI1 are PB_0, PB_1, PB_2 and PB_3.
SPI0 and other control pins for MP3 decoder
WIZwiki-W7500 communicates to MP3 decoder on Music Shield via SPI0 pins of which consists of PC_12, D11, D12 and D13.
And PC_13, PC_14 and PC-15 are used for DCS, DREQ and RST, respectively.
InterruptIn pins for 5-Way Navigation Switch
D3, D4, D5, D6 and D7 are connected to 5 way navigation switch on Music Shield.
When user pushes the switch to one way, a relevant pin is grounded so that he or she should make it set high at the beginning.
Software
SPI Initialization
//Declaration in VS1002.cpp
VS1002::VS1002(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)
: _DREQ(dreq), _RST(rst), _spi(mosi, miso, sck), _CS(cs), _DCS(dcs), _sd(mmosi, mmiso, ssck, ccs, name) {
}
//Initialization in main.cpp
VS1002 mp3(PB_3, PB_2, PB_1, PB_0,"sdc",D11, D12 ,D13, PC_12, PC_15, PC_14, PC_13);
Mapping 5-Way Navigation Switch into InterruptIn pins
main.cpp
InterruptIn K_VU(D3); // Volume UP Key InterruptIn K_VD(D7); // Volume Down Key InterruptIn K_FW(D4); // Foward Key InterruptIn K_BW(D6); // Backward Key InterruptIn K_ONOFF(D5); //Play/Resume or Pause Key
Additional codes due to mbed library bug of WIZwiki-W7500
main.cpp
//Operating Clock Frequency Set *(volatile uint32_t *)(0x41001014) = 0x0060100; //Set all InterruptIn pins to Internal PullUp *(volatile uint32_t *)(0x41003000) = 0x00000002; //D6 *(volatile uint32_t *)(0x41003004) = 0x00000002; //D5 *(volatile uint32_t *)(0x41003008) = 0x00000002; //D4 *(volatile uint32_t *)(0x41003080) = 0x00000002; //D3 *(volatile uint32_t *)(0x41003098) = 0x00000002; //D7
Caution
This example can play only MP3 files with up to 192KHz sample rate//
Revision 2:cea9f6564641, committed 2017-03-30
- Comitter:
- javakys
- Date:
- Thu Mar 30 10:29:51 2017 +0000
- Parent:
- 1:fc4e0c572992
- Commit message:
- Function Description Update
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r fc4e0c572992 -r cea9f6564641 main.cpp
--- a/main.cpp Thu Mar 30 06:29:49 2017 +0000
+++ b/main.cpp Thu Mar 30 10:29:51 2017 +0000
@@ -27,11 +27,11 @@
//SDFileSystem sd(PB_3, PB_2, PB_1, PB_0, "sd"); // WIZwiki-W7500
EthernetInterface eth;
-InterruptIn K_VU(D3); // Create the interrupt receiver object on pin 26
-InterruptIn K_VD(D7); // Create the interrupt receiver object on pin 26
+InterruptIn K_VU(D3); // Volume UP Key
+InterruptIn K_VD(D7); // Volume Down Key
InterruptIn K_FW(D4); // Foward Key
InterruptIn K_BW(D6); // Backward Key
-InterruptIn K_ONOFF(D5); //Play / Pause Key
+InterruptIn K_ONOFF(D5); //Play/Resume or Pause Key
VS1002 mp3(PB_3, PB_2, PB_1, PB_0,"sdc",D11, D12 ,D13, PC_12, PC_15, PC_14, PC_13); //Setup Audio decoder. Name is VS1002 even though VS1053 is used.
FTPClient myFTP("/sdc"); // mountname in MySeeedStudioTFTv2
@@ -60,13 +60,22 @@
if(ftp_time_1s++ > _FTP_UPDATE_TIME_) ftp_time_1s = 0;
}
}*/
+
+/** Volume UP
+ *
+ * @param
+ */
void Volume_Up()
{
volume_set+=3; // Volume Up
if(volume_set>=0)
volume_set=0;
}
-
+
+/** Volume Down
+ *
+ * @param
+ */
void Volume_Down()
{
volume_set-=3; //Volume Down
@@ -74,6 +83,10 @@
volume_set=-55;
}
+/** Song_Forward
+ *
+ * @param
+ */
void Song_Forward()
{
new_song_number += 1;
@@ -81,6 +94,10 @@
new_song_number = 1;
}
+/** Song_Backward
+ *
+ * @param
+ */
void Song_Backward()
{
if(new_song_number == 1)
@@ -89,6 +106,10 @@
new_song_number -= 1;
}
+/** Play_Pressed
+ *
+ * @param
+ */
void Play_Pressed()
{
pause = !pause;
@@ -141,27 +162,11 @@
uart.printf("SD Card Root Directory Not Found\r\n");
}
- uint32_t tmp;
- tmp = *(volatile uint32_t *)(0x41003000); //D6
- uart.printf("Before set, D6 : %08X\r\n", tmp);
- tmp = 0x00000002;
- *(volatile uint32_t *)(0x41003000) = tmp;
- tmp = *(volatile uint32_t *)(0x41003004); //D5
- uart.printf("Before set, D5 : %08X\r\n", tmp);
- tmp = 0x00000002;
- *(volatile uint32_t *)(0x41003004) = tmp;
- tmp = *(volatile uint32_t *)(0x41003008); //D4
- uart.printf("Before set, D4 : %08X\r\n", tmp);
- tmp = 0x00000002;
- *(volatile uint32_t *)(0x41003008) = tmp;
- tmp = *(volatile uint32_t *)(0x41003080); //D3
- uart.printf("Before set, D3 : %08X\r\n", tmp);
- tmp = 0x00000002;
- *(volatile uint32_t *)(0x41003080) = tmp;
- tmp = *(volatile uint32_t *)(0x41003098); //D7
- uart.printf("Before set, D5 : %08X\r\n", tmp);
- tmp = 0x00000002;
- *(volatile uint32_t *)(0x41003098) = tmp;
+ *(volatile uint32_t *)(0x41003000) = 0x00000002; //D6
+ *(volatile uint32_t *)(0x41003004) = 0x00000002; //D5
+ *(volatile uint32_t *)(0x41003008) = 0x00000002; //D4
+ *(volatile uint32_t *)(0x41003080) = 0x00000002; //D3
+ *(volatile uint32_t *)(0x41003098) = 0x00000002; //D7
//ledTick.attach(&ledTickfunc,2);
@@ -177,16 +182,6 @@
K_BW.fall(&Song_Backward);
// K_BW.mode(PullUp);
- tmp = *(volatile uint32_t *)(0x41003000); //D6
- uart.printf("After set, D6 : %08X\r\n", tmp);
- tmp = *(volatile uint32_t *)(0x41003004); //D5
- uart.printf("After set, D5 : %08X\r\n", tmp);
- tmp = *(volatile uint32_t *)(0x41003008); //D4
- uart.printf("After set, D4 : %08X\r\n", tmp);
- tmp = *(volatile uint32_t *)(0x41003080); //D3
- uart.printf("After set, D3 : %08X\r\n", tmp);
- tmp = *(volatile uint32_t *)(0x41003098); //D7
- uart.printf("After set, D5 : %08X\r\n", tmp);
while(1)
{