A very basic WAV player for FRDM boards. Does not work with MBED RTOS however.
Dependencies: SDFileSystem mbed wave_player
Diff: main.cpp
- Revision:
- 0:bdadf0052e87
diff -r 000000000000 -r bdadf0052e87 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Apr 30 12:42:55 2018 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" +#include "SDFileSystem.h" +#include <wave_player.h> + +#define PC_BAUD 9600 + +SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd", PTE6, SDFileSystem::SWITCH_POS_NO, 25000000); +Serial pc(USBTX,USBRX); + +AnalogOut DACout(DAC0_OUT); +wave_player waver(&DACout); + + +int main() +{ + //Configure CRC, small frames, and write validation + sd.crc(true); + sd.large_frames(false); // SPI 16 bits not supported ??? + sd.write_validation(true); + + //waver.set_verbosity(1); + FILE *wave_file; + pc.baud(PC_BAUD); + printf("\n\r\n\rGoing to open a file...\n\r"); + wave_file=fopen("/sd/sp.wav","r"); + printf("Opened a file. Will now play.\n\r"); + waver.play(wave_file); + printf("Did it play?\n\r"); + fclose(wave_file); +} + \ No newline at end of file