Skip to content

Commit bad7148

Browse files
committed
SPDIFStream compile support for rp2040
1 parent 1565ee2 commit bad7148

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/AudioConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ typedef uint32_t eps32_i2s_sample_rate_type;
225225
//----------------
226226
#if defined(ARDUINO_ARCH_RP2040)
227227
//#define USE_ESP8266_AUDIO
228-
//#define USE_I2S 1
228+
#define USE_I2S 1
229229
#define USE_PWM
230230

231231
#define PWM_START_PIN 6

src/AudioExperiments/AudioSPDIF.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
/**
22
* @file AudioSPDIF.h
33
* @author amedes / Phil Schatzmann
4-
* @brief S/PDIF output via I2S
4+
* @brief S/PDIF output
55
66
This example code is in the Public Domain (or CC0 licensed, at your option.)
77
Unless required by applicable law or agreed to in writing, this
88
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
99
CONDITIONS OF ANY KIND, either express or implied.
1010
1111
12-
* @date 2022-01-23
12+
* @date 2022-01-30
1313
*
1414
* @copyright (C) 2020 AMEDES, 2022 Phil Schatzmann
1515
*
@@ -23,7 +23,7 @@
2323
// Set USE_ESP32_I2S to 1 if you want to use the explicit ESP32 implementation.
2424
// 0 for generic implementation
2525
#ifndef USE_ESP32_I2S
26-
#define USE_ESP32_I2S 1
26+
#define USE_ESP32_I2S 0
2727
#endif
2828

2929
// Default Data Pin
@@ -150,9 +150,10 @@ class SPDIFOutI2S : public SPDIFOut {
150150
i2s_cfg.pin_ws = -1;
151151
i2s_cfg.pin_bck = -1;
152152
i2s_cfg.pin_data = cfg.pin_data;
153+
#ifdef ESP32
153154
i2s_cfg.use_apll = true;
154155
i2s_cfg.fixed_mclk = mclk;
155-
156+
#endif
156157
i2s.begin(i2s_cfg);
157158
}
158159

@@ -169,6 +170,7 @@ class SPDIFOutI2S : public SPDIFOut {
169170
I2SStream i2s;
170171
};
171172

173+
#ifdef ESP32
172174
/**
173175
* @brief ESP32 specific Output
174176
*
@@ -219,6 +221,8 @@ class SPDFOutI2SESP32 : public SPDIFOut {
219221
}
220222
};
221223

224+
#endif
225+
222226
/**
223227
* @brief Generic output of SPDIF to Arduino Stream
224228
*
@@ -381,7 +385,7 @@ class SPDIFStream : public AudioStreamX {
381385
}
382386

383387
/// start SPDIF with default configuration
384-
bool begin() { spdif.begin(); }
388+
bool begin() { return spdif.begin(); }
385389
/// start SPDIF with the indicated configuration
386390
bool begin(SPDIFConfig cfg) {
387391
this->cfg = cfg;
@@ -398,7 +402,8 @@ class SPDIFStream : public AudioStreamX {
398402
targetSpdifConfig.channels = 2;
399403
targetSpdifConfig.bits_per_sample = 16;
400404
targetSpdifConfig.sample_rate = cfg.sample_rate;
401-
spdif.begin(targetSpdifConfig);
405+
return spdif.begin(targetSpdifConfig);
406+
402407
}
403408

404409
/// Close the SPDIF processing

0 commit comments

Comments
 (0)