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: SDFileSystem mbed
main.cpp
00001 #include "mbed.h" 00002 #include "SDFileSystem.h" 00003 00004 DigitalOut led1(LED1); 00005 DigitalOut led2(LED2); 00006 DigitalOut led3(LED3); 00007 DigitalOut led4(LED4); 00008 00009 DigitalIn Dreq(p26); 00010 DigitalOut XDCS(p25); 00011 DigitalOut reset(p23); 00012 DigitalOut XCS(p22); 00013 00014 SPI mp3Board(p11, p12, p13); 00015 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card 00016 00017 int killLoop = 1; 00018 int mp3Chunk; 00019 int fileSize; 00020 00021 long getFileSize(FILE *fp) { 00022 fseek(fp, 0, SEEK_END); 00023 int size = ftell(fp); 00024 fseek(fp, 0, SEEK_SET); 00025 00026 return size; 00027 } 00028 00029 int main() { 00030 led1=0; 00031 led2=0; 00032 led3=0; 00033 led4=0; 00034 00035 00036 XCS=1; 00037 XCS=0; //pull xcs low to begin sci write. Sets mode to vs1002, 00038 mp3Board.write(0x02); //0x02 is the write opcode 00039 mp3Board.write(0x00); //0x00 is the address of the sci mode register 00040 mp3Board.write(0x0A); //0x0A (11 in dec) is the SM_SDINEW bit 00041 XCS=1; //pulled high to end write sequence 00042 00043 led1=1; 00044 00045 FILE *mp3_file; 00046 //printf("\n\n\nHello, wave world!\n"); 00047 mp3_file=fopen("/sd/Putties.mp3","rb"); 00048 00049 XDCS = 1; 00050 XDCS = 0; 00051 00052 00053 /* 00054 fseek(mp3_file, 0, SEEK_END); 00055 fileSize=ftell(mp3_file); 00056 fseek(mp3_file, 0, SEEK_SET); 00057 */ 00058 00059 fileSize=getFileSize(mp3_file); 00060 00061 led2=1; 00062 00063 fread(&mp3Chunk, 1, 100, mp3_file); 00064 led3=1; 00065 mp3Board.write(mp3Chunk); 00066 00067 00068 00069 fclose(mp3_file); 00070 XDCS=1; 00071 00072 led4=1; 00073 00074 }
Generated on Tue Aug 16 2022 09:09:54 by
1.7.2