Easy playback library for AUDIO_GRBoard.

Dependents:   GR-PEACH_Audio_WAV_PwmOut GR-Boards_Audio_WAV

Revision:
2:6c46c61630b3
Parent:
1:fdd79b99ba73
--- a/EasyPlayback.cpp	Tue Jul 03 05:12:29 2018 +0000
+++ b/EasyPlayback.cpp	Tue Jul 24 08:45:30 2018 +0000
@@ -18,14 +18,19 @@
 #include "dcache-control.h"
 #include "EasyPlayback.h"
 
-EasyPlayback::EasyPlayback(audio_type_t type) : 
+EasyPlayback::EasyPlayback(audio_type_t type, PinName pin1, PinName pin2) : 
      _buff_index(0), _type(type), _skip(false), _pause(false), _init_end(false)
 {
     _audio_ssif = NULL;
+    _audio_pwm = NULL;
     if (_type == AUDIO_TPYE_SSIF) {
         _audio_buff_size = 4096;
         _audio_ssif = new AUDIO_GRBoard(0x80, (AUDIO_WRITE_BUFF_NUM - 1), 0);
         _audio = _audio_ssif;
+    } else if (_type == AUDIO_TPYE_PWM) {
+        _audio_buff_size = 4096;
+        _audio_pwm = new PwmOutSpeaker(pin1, pin2);
+        _audio = _audio_pwm;
     } else if (_type == AUDIO_TPYE_SPDIF) {
         MBED_ASSERT(false);
     } else {
@@ -40,11 +45,9 @@
     if (_audio_ssif != NULL) {
         delete _audio_ssif;
     }
-#if (R_BSP_SPDIF_ENABLE == 1)
-    if (_audio_spdif != NULL) {
-        delete _audio_spdif;
+    if (_audio_pwm != NULL) {
+        delete _audio_pwm;
     }
-#endif
     delete [] _heap_buf;
 }