Nucleo stm32f746zg USB wave player
Dependencies: mbed wave_player USBHost
Fork of USBHostMSD_HelloWorld by
Revision 10:c3614ed19126, committed 2018-12-29
- Comitter:
- vsolonar
- Date:
- Sat Dec 29 09:48:31 2018 +0000
- Parent:
- 9:d0a3b4c7b261
- Commit message:
- All done, worked.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
wave_player.lib | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 19 13:31:58 2018 +0000 +++ b/main.cpp Sat Dec 29 09:48:31 2018 +0000 @@ -1,67 +1,43 @@ /* Big green ugly test. Free for use bla bla bla. Do not eat. Tested on stm32f746zg -Results: 814 KB/s, to slow for my project. -No have idea how i can increase reading speed up to 4MB/s. + +Based on Vladimir Berzin SDFileSystem wave player +https://os.mbed.com/users/berzin11295/code/wav_player/ */ #include "mbed.h" #include "USBHostMSD.h" +#include "wave_player.h" Serial pc(USBTX, USBRX, 115200); // tx, rx, baud rate to avoid terminal glitches -// read block size -unsigned int bs = 65536; -// read memory buffer -char buff[65536]; - -// Binary test file, 10MB size -unsigned long fsize=1024*1024*10; -// start time, end time, delta time -unsigned long time1, time2, time3; -// speed = fsize / time3 -float speed; - - -Timer t; +AnalogOut dac(PA_5); +//DigitalOut enb(PA_12); +wave_player player(&dac); int main() { -// Mission clock on. -t.start(); - - USBHostMSD msd("usb"); +USBHostMSD msd("usb"); while(1) { while(!msd.connect()) { pc.printf("Waiting for USB\r\n"); wait_ms(500); } + pc.printf("Flash mounted\r\n"); - FILE * fp = fopen("/usb/test1.bin", "rb"); + FILE * fp = fopen("/usb/test1.wav", "rb"); if (fp != NULL) { pc.printf("File opened, reading...\r\n"); - time1=t.read_ms(); - pc.printf("Start timer value = %u \r\n",time1); - - while(!feof(fp)) - { - fread(&buff,bs,1,fp); - } - - time2 = t.read_ms(); - pc.printf("End timer value = %u\r\n",time2); + player.play(fp); fclose(fp); pc.printf("File closed\r\n"); - time3 = time2 - time1; - speed = fsize / time3; - - pc.printf ("Time to read file %u speed KB/s = %f \r\n======================\r\n", time3, speed); } else { pc.printf("FILE == NULL\r\n");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wave_player.lib Sat Dec 29 09:48:31 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ECE-2035-TA/code/wave_player/#910a7c3c9b24