wave player pwm & covox

Dependencies:   wave_player_pwm_and_covox mbed USBHost

Committer:
vsolonar
Date:
Sat Dec 29 09:48:31 2018 +0000
Revision:
10:c3614ed19126
Parent:
9:d0a3b4c7b261
Child:
11:d2099045bdc9
All done, worked.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vsolonar 9:d0a3b4c7b261 1 /*
vsolonar 9:d0a3b4c7b261 2 Big green ugly test. Free for use bla bla bla. Do not eat.
vsolonar 9:d0a3b4c7b261 3 Tested on stm32f746zg
vsolonar 10:c3614ed19126 4
vsolonar 10:c3614ed19126 5 Based on Vladimir Berzin SDFileSystem wave player
vsolonar 10:c3614ed19126 6 https://os.mbed.com/users/berzin11295/code/wav_player/
vsolonar 9:d0a3b4c7b261 7 */
vsolonar 9:d0a3b4c7b261 8
samux 0:0d68fe822228 9 #include "mbed.h"
samux 0:0d68fe822228 10 #include "USBHostMSD.h"
vsolonar 10:c3614ed19126 11 #include "wave_player.h"
samux 0:0d68fe822228 12
vsolonar 9:d0a3b4c7b261 13 Serial pc(USBTX, USBRX, 115200); // tx, rx, baud rate to avoid terminal glitches
vsolonar 9:d0a3b4c7b261 14
vsolonar 10:c3614ed19126 15 AnalogOut dac(PA_5);
vsolonar 10:c3614ed19126 16 //DigitalOut enb(PA_12);
vsolonar 10:c3614ed19126 17 wave_player player(&dac);
vsolonar 9:d0a3b4c7b261 18
vsolonar 9:d0a3b4c7b261 19 int main() {
vsolonar 9:d0a3b4c7b261 20
vsolonar 10:c3614ed19126 21 USBHostMSD msd("usb");
vsolonar 9:d0a3b4c7b261 22
vsolonar 9:d0a3b4c7b261 23 while(1) {
samux 1:473f339c54c1 24 while(!msd.connect()) {
vsolonar 9:d0a3b4c7b261 25 pc.printf("Waiting for USB\r\n");
vsolonar 9:d0a3b4c7b261 26 wait_ms(500);
samux 1:473f339c54c1 27 }
vsolonar 10:c3614ed19126 28
vsolonar 9:d0a3b4c7b261 29 pc.printf("Flash mounted\r\n");
vsolonar 9:d0a3b4c7b261 30
vsolonar 10:c3614ed19126 31 FILE * fp = fopen("/usb/test1.wav", "rb");
samux 1:473f339c54c1 32
samux 1:473f339c54c1 33 if (fp != NULL) {
vsolonar 9:d0a3b4c7b261 34 pc.printf("File opened, reading...\r\n");
vsolonar 9:d0a3b4c7b261 35
vsolonar 10:c3614ed19126 36 player.play(fp);
vsolonar 9:d0a3b4c7b261 37
vsolonar 9:d0a3b4c7b261 38 fclose(fp);
vsolonar 9:d0a3b4c7b261 39 pc.printf("File closed\r\n");
vsolonar 9:d0a3b4c7b261 40
vsolonar 9:d0a3b4c7b261 41
samux 1:473f339c54c1 42 } else {
vsolonar 9:d0a3b4c7b261 43 pc.printf("FILE == NULL\r\n");
samux 1:473f339c54c1 44 }
vsolonar 9:d0a3b4c7b261 45
samux 1:473f339c54c1 46 if (!msd.connected())
samux 1:473f339c54c1 47 break;
samux 0:0d68fe822228 48 }
samux 0:0d68fe822228 49 }