Lab4
Dependencies: USBHost mbed wave_player_appbd
Fork of AppBoard_Waveplayer by
Diff: main.cpp
- Revision:
- 11:84161ded6baf
- Parent:
- 10:c8246ac91533
- Child:
- 12:67b9ed2c6e4f
--- a/main.cpp Tue Mar 03 19:21:54 2015 +0000 +++ b/main.cpp Tue Mar 03 19:49:09 2015 +0000 @@ -1,6 +1,8 @@ #include "mbed.h" #include "USBHostMSD.h" #include "wave_player.h" +#include "rtos.h" + //mbed Application board waveplayer demo //Plays the wave file "sample.wav" on the USB flash drive //Outputs to onboard speaker (but at very low volume) @@ -14,10 +16,17 @@ wave_player waver(&DACout,&PWMout); +void playwav(void const *args) +{ + File *wave_file; + wave_file=fopen((const char *)args,"r"); + waver.play(wave_file); + fclose(wave_file); +} + int main() { USBHostMSD msd("usb"); - FILE *wave_file; //setup PWM hardware for a Class D style audio output PWMout.period(1.0/400000.0); printf("\n\n\nHello, wave world!\n"); @@ -25,12 +34,10 @@ while(!msd.connect()) { Thread::wait(500); } - - //open wav file and play it - wave_file=fopen("/usb/wav3.wav","r"); - waver.play(wave_file); - fclose(wave_file); + Thread thread(playwav,(void *)"/usb/wav3.wav"); //end of program + Thread::wait(10); + waver.stop = true; while(1) {}; } \ No newline at end of file