A wave player demo setup for the mbed application board. Reads a wave file from a USB flash drive, and outputs to the onboard speaker (very low volume) and the analog audio out jack that can be connected to a set of PC speakers for more volume. A wave file for the demo is available at http://mbed.org/media/uploads/4180_1/sample.wav. Copy it to the USB drive. See http://mbed.org/users/4180_1/notebook/application-board-waveplayer-demo/ for more details and instructions.

Dependencies:   USBHost mbed wave_player_appbd

Fork of USBHostMSD_HelloWorld by Samuel Mokrani

main.cpp

Committer:
samux
Date:
2013-03-06
Revision:
0:0d68fe822228
Child:
1:473f339c54c1

File content as of revision 0:0d68fe822228:

#include "mbed.h"
#include "USBHostMSD.h"

DigitalOut led(LED1);

void msd_task(void const *) {
    
    USBHostMSD msd("usb");
    int i = 0;
    
    while(1) {
        
        // try to connect a USB flash disk
        while(!msd.connect())
            Thread::wait(500);
        
        FILE * fp = fopen("/usb/test.txt", "a");
        
        if (fp != NULL) {
            fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++);
            printf("Goodbye World!\r\n");
            fclose(fp);
        } else {
            printf("FILE == NULL\r\n");
        }
        
        // wait until the msd disk is disconnected
        while(msd.connected())
            Thread::wait(500);
    }
}


int main() {
    Thread msdTask(msd_task, NULL, osPriorityNormal, (1024+512) * 4);
    while(1) {
        led=!led;
        Thread::wait(500);
    }
}