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: TFTLCDwithFastIO FastIO SDFileSystem TouchPanel VS1033 mbed
Revision 2:0090839c8276, committed 2015-07-12
- Comitter:
- nameless129
- Date:
- Sun Jul 12 06:59:22 2015 +0000
- Parent:
- 1:fae9cad8108c
- Child:
- 3:67e97c846cec
- Commit message:
- first commit;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Sun Jul 12 06:59:22 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/neilt6/code/SDFileSystem/#a47f74caa04e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VS1033.lib Sun Jul 12 06:59:22 2015 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/nameless129/code/VS1033/#b61cd12eabc5
--- a/main.cpp Sun Jul 12 03:49:09 2015 +0000
+++ b/main.cpp Sun Jul 12 06:59:22 2015 +0000
@@ -1,25 +1,83 @@
-// include the library, this will also pull in the header for the provided fonts
#include "ili9328.h"
-
+#include <stdio.h>
+#include "mbed.h"
+#include "SDFileSystem.h"
+#include "VS1053.h"
+
// prepare the data bus for writing commands and pixel data
BusOut dataBus( P1_28,P2_3,P1_18,P1_24,P1_19,P1_26,P1_27,P1_25 ); // 16 pins
// create the lcd instance
//(PinName CS, PinName RESET, PinName RS, PinName WR, BusOut *DATA_PORT, PinName BL=NC, PinName RD=NC, backlight_t blType=Constant, float defaultBackLightLevel=1.0)
ILI9328_LCD lcd( P0_12, P0_11, P0_13, P0_14, &dataBus, NC, P1_9 ); // control pins and data bus
-
+
+SDFileSystem sd(/*MOSI*/ P0_9, /*MISO*/ P0_8, /*SCK*/ P1_29, /*CS*/ P0_2, /*Mountpoint*/ "sd");
+VS1053 mp3(/*MOSI*/ P1_22 , /*MISO*/ P1_21, /*SCK*/ P1_20, /*CS*/ P1_23,
+ /*BSYNC*/ P2_16, /*DREQ*/ P2_17, /*RST*/ P2_18, /*SPI freq.*/ 10000000);
+
+
+#define SD_READ_BLOCK_SIZE (1024)
+
int main()
{
- // initialize display - place it in standard portrait mode and set background to black and
- // foreground to white color.
+ static FILE *fp = NULL;
+ size_t sizeRead = 0;
+ size_t totalSizeSent=0;
+ size_t fileSize=0;
+ uint8_t buf[SD_READ_BLOCK_SIZE];
+
+ printf("Power ON\r\n");
+
+ //LCD Init.
lcd.Initialize(LANDSCAPE,RGB16);
- // set current font to the smallest 8x12 pixels font.
+
+/* for sine test mode */
+// mp3.sine_test_activate(SineWave_10k);
+// while(1);
+
+ //MP3 decoder Init.
+ mp3.hardwareReset();
+ mp3.sci_init();
+ mp3.sdi_init();
+ wait(0.1);
+
+ printf("init CMPL.\r\n");
+
lcd.SetBackground(COLOR_BLUE);
lcd.FillScreen(-1);
lcd.SetFont( &TerminusFont );
lcd.Print( "STOP:XXXXXXXX", CENTER, 25 ); // align text to center horizontally and use starndard colors
-
- while ( 1 )
+
+ fp = fopen("/sd/2.mp3", "rb");
+
+ //Get file size
+ fseek( fp, 0, SEEK_END );
+ fileSize = ftell( fp );
+ printf("file size:%d\r\n",fileSize);
+
+ //move file pointer to top.
+ rewind(fp);
+
+ if (fp) {
+ clearerr(fp);
+ totalSizeSent = 0;
+ }
+ while(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), SD_READ_BLOCK_SIZE, fp);
+ totalSizeSent += mp3.sendDataBlock(buf, sizeRead);
+ //printf("total %d Send %d\r\n",totalSizeSent,sizeRead);
+ }
+ }
}