j
Fork of wave_player by
Revision 3:fd32c0cb73b1, committed 2017-04-18
- Comitter:
- EspenSorlie
- Date:
- Tue Apr 18 07:48:03 2017 +0000
- Parent:
- 2:bd0772f13bc8
- Commit message:
- bhj
Changed in this revision
wave_player.cpp | Show annotated file Show diff for this revision Revisions of this file |
wave_player.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r bd0772f13bc8 -r fd32c0cb73b1 wave_player.cpp --- 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() {
diff -r bd0772f13bc8 -r fd32c0cb73b1 wave_player.h --- a/wave_player.h Thu Mar 13 00:22:08 2014 +0000 +++ b/wave_player.h Tue Apr 18 07:48:03 2017 +0000 @@ -57,16 +57,13 @@ * @param v the verbosity level */ void set_verbosity(int v); - private: void dac_out(void); int verbosity; AnalogOut *wave_DAC; Ticker tick; -unsigned short DAC_fifo[256]; -short DAC_wptr; -volatile short DAC_rptr; + short DAC_on; }; - +void digital_out ();