Nucleo stm32f746zg USB wave player

Dependencies:   mbed wave_player USBHost

Fork of USBHostMSD_HelloWorld by Samuel Mokrani

main.cpp

Committer:
vsolonar
Date:
2018-12-29
Revision:
10:c3614ed19126
Parent:
9:d0a3b4c7b261

File content as of revision 10:c3614ed19126:

/*
Big green ugly test. Free for use bla bla bla. Do not eat.
Tested on stm32f746zg

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

AnalogOut dac(PA_5);
//DigitalOut enb(PA_12);
wave_player player(&dac);

int main() {

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.wav", "rb");
        
            if (fp != NULL) {
                pc.printf("File opened, reading...\r\n");

                    player.play(fp);
               
            fclose(fp);
            pc.printf("File closed\r\n");


            } else {
                pc.printf("FILE == NULL\r\n");
            }
                    
            if (!msd.connected())
                break;
        }
}