microSDカードからWaveファイルを再生するサンプルです。

Dependencies:   mbed FATFileSystem

Fork of JBB_WavePlayer_test by Jksoft Blue mbed Board Developer

Committer:
jksoft
Date:
Fri May 23 09:41:26 2014 +0000
Revision:
1:9681a1526ecb
Parent:
0:e9f196d85a46
???????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:e9f196d85a46 1 #include "mbed.h"
jksoft 0:e9f196d85a46 2 #include "wave_player.h"
jksoft 0:e9f196d85a46 3 #include "SDFileSystem.h"
jksoft 0:e9f196d85a46 4
jksoft 0:e9f196d85a46 5 DigitalOut myled(LED1);
jksoft 0:e9f196d85a46 6 AnalogOut DACout(p18);
jksoft 0:e9f196d85a46 7 DigitalOut AMPEnable(p12);
jksoft 0:e9f196d85a46 8 DigitalIn SW1(p25);
jksoft 0:e9f196d85a46 9
jksoft 0:e9f196d85a46 10 wave_player waver(&DACout,&AMPEnable);
jksoft 0:e9f196d85a46 11 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
jksoft 0:e9f196d85a46 12
jksoft 0:e9f196d85a46 13 Ticker flipper;
jksoft 0:e9f196d85a46 14
jksoft 0:e9f196d85a46 15
jksoft 0:e9f196d85a46 16 void flip() {
jksoft 0:e9f196d85a46 17 static int old_sw = 1;
jksoft 0:e9f196d85a46 18 if((SW1 == 0)&&(old_sw == 1))
jksoft 0:e9f196d85a46 19 {
jksoft 0:e9f196d85a46 20 waver.set_s_stop();
jksoft 0:e9f196d85a46 21 }
jksoft 0:e9f196d85a46 22 old_sw = SW1;
jksoft 0:e9f196d85a46 23 }
jksoft 0:e9f196d85a46 24
jksoft 0:e9f196d85a46 25 void player(char* file_path)
jksoft 0:e9f196d85a46 26 {
jksoft 0:e9f196d85a46 27 FILE *wave_file;
jksoft 0:e9f196d85a46 28
jksoft 0:e9f196d85a46 29 wave_file=fopen(file_path,"r");
jksoft 0:e9f196d85a46 30 waver.play(wave_file);
jksoft 0:e9f196d85a46 31 fclose(wave_file);
jksoft 0:e9f196d85a46 32 }
jksoft 0:e9f196d85a46 33
jksoft 0:e9f196d85a46 34 int main() {
jksoft 0:e9f196d85a46 35 SW1.mode(PullUp);
jksoft 0:e9f196d85a46 36 flipper.attach(&flip, 0.1);
jksoft 1:9681a1526ecb 37
jksoft 0:e9f196d85a46 38 player("/sd/1.wav");
jksoft 0:e9f196d85a46 39 wait(0.5);
jksoft 1:9681a1526ecb 40
jksoft 0:e9f196d85a46 41 while(1) {
jksoft 0:e9f196d85a46 42 myled = 1;
jksoft 0:e9f196d85a46 43 wait(0.2);
jksoft 0:e9f196d85a46 44 myled = 0;
jksoft 0:e9f196d85a46 45 wait(0.2);
jksoft 0:e9f196d85a46 46 }
jksoft 0:e9f196d85a46 47 }