It bloody plays

Dependencies:   mbed wave_player wavfile

Committer:
uhclem
Date:
Mon Apr 30 12:42:55 2018 +0000
Revision:
0:bdadf0052e87
Child:
1:804c1daa860b
A working SD card WAV player for the FRDM-K64F

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uhclem 0:bdadf0052e87 1 #include "mbed.h"
uhclem 0:bdadf0052e87 2 #include "SDFileSystem.h"
uhclem 0:bdadf0052e87 3 #include <wave_player.h>
uhclem 0:bdadf0052e87 4
uhclem 0:bdadf0052e87 5 #define PC_BAUD 9600
uhclem 0:bdadf0052e87 6
uhclem 0:bdadf0052e87 7 SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd", PTE6, SDFileSystem::SWITCH_POS_NO, 25000000);
uhclem 0:bdadf0052e87 8 Serial pc(USBTX,USBRX);
uhclem 0:bdadf0052e87 9
uhclem 0:bdadf0052e87 10 AnalogOut DACout(DAC0_OUT);
uhclem 0:bdadf0052e87 11 wave_player waver(&DACout);
uhclem 0:bdadf0052e87 12
uhclem 0:bdadf0052e87 13
uhclem 0:bdadf0052e87 14 int main()
uhclem 0:bdadf0052e87 15 {
uhclem 0:bdadf0052e87 16 //Configure CRC, small frames, and write validation
uhclem 0:bdadf0052e87 17 sd.crc(true);
uhclem 0:bdadf0052e87 18 sd.large_frames(false); // SPI 16 bits not supported ???
uhclem 0:bdadf0052e87 19 sd.write_validation(true);
uhclem 0:bdadf0052e87 20
uhclem 0:bdadf0052e87 21 //waver.set_verbosity(1);
uhclem 0:bdadf0052e87 22 FILE *wave_file;
uhclem 0:bdadf0052e87 23 pc.baud(PC_BAUD);
uhclem 0:bdadf0052e87 24 printf("\n\r\n\rGoing to open a file...\n\r");
uhclem 0:bdadf0052e87 25 wave_file=fopen("/sd/sp.wav","r");
uhclem 0:bdadf0052e87 26 printf("Opened a file. Will now play.\n\r");
uhclem 0:bdadf0052e87 27 waver.play(wave_file);
uhclem 0:bdadf0052e87 28 printf("Did it play?\n\r");
uhclem 0:bdadf0052e87 29 fclose(wave_file);
uhclem 0:bdadf0052e87 30 }
uhclem 0:bdadf0052e87 31