j

Fork of wave_player by Sarthak Jaiswal

Revision:
3:fd32c0cb73b1
Parent:
2:bd0772f13bc8
--- a/wave_player.cpp	Thu Mar 13 00:22:08 2014 +0000
+++ b/wave_player.cpp	Tue Apr 18 07:48:03 2017 +0000
@@ -15,8 +15,12 @@
 #include <stdio.h>
 #include <wave_player.h>
 #include <stdlib.h>
-
+    uint16_t sampleL;
 extern int vol;  
+SPI spi(p11, p12, p13);
+unsigned short DAC_fifo[256];
+short DAC_wptr;
+volatile short DAC_rptr;
 //-----------------------------------------------------------------------------
 // constructor -- accepts an mbed pin to use for AnalogOut.  Only p18 will work
 wave_player::wave_player(AnalogOut *_dac)
@@ -60,7 +64,11 @@
         extern bool playing;
         extern int vol;
         extern bool old_playing;
-        
+  
+    // Setup the spi for 16 bit data, high steady state clock,
+    // second edge capture, with a 48 kHz clock rate
+    spi.format(16,0);
+    spi.frequency(48000);       
     
   DAC_wptr=0;
   DAC_rptr=0;
@@ -212,6 +220,16 @@
   }
 }
 
+void digital_out ()
+{
+
+
+    spi.write (DAC_fifo [DAC_rptr]);
+    
+    //sample_R [mat] = DAC_fifo [DAC_rptr + 1];
+    DAC_rptr=(DAC_rptr+1) & 0xff;
+}
+
 
 void wave_player::dac_out()
 {