1
1
/* *
2
2
* @file AudioSPDIF.h
3
3
* @author amedes / Phil Schatzmann
4
- * @brief S/PDIF output via I2S
4
+ * @brief S/PDIF output
5
5
6
6
This example code is in the Public Domain (or CC0 licensed, at your option.)
7
7
Unless required by applicable law or agreed to in writing, this
8
8
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
9
9
CONDITIONS OF ANY KIND, either express or implied.
10
10
11
11
12
- * @date 2022-01-23
12
+ * @date 2022-01-30
13
13
*
14
14
* @copyright (C) 2020 AMEDES, 2022 Phil Schatzmann
15
15
*
23
23
// Set USE_ESP32_I2S to 1 if you want to use the explicit ESP32 implementation.
24
24
// 0 for generic implementation
25
25
#ifndef USE_ESP32_I2S
26
- #define USE_ESP32_I2S 1
26
+ #define USE_ESP32_I2S 0
27
27
#endif
28
28
29
29
// Default Data Pin
@@ -150,9 +150,10 @@ class SPDIFOutI2S : public SPDIFOut {
150
150
i2s_cfg.pin_ws = -1 ;
151
151
i2s_cfg.pin_bck = -1 ;
152
152
i2s_cfg.pin_data = cfg.pin_data ;
153
+ #ifdef ESP32
153
154
i2s_cfg.use_apll = true ;
154
155
i2s_cfg.fixed_mclk = mclk;
155
-
156
+ # endif
156
157
i2s.begin (i2s_cfg);
157
158
}
158
159
@@ -169,6 +170,7 @@ class SPDIFOutI2S : public SPDIFOut {
169
170
I2SStream i2s;
170
171
};
171
172
173
+ #ifdef ESP32
172
174
/* *
173
175
* @brief ESP32 specific Output
174
176
*
@@ -219,6 +221,8 @@ class SPDFOutI2SESP32 : public SPDIFOut {
219
221
}
220
222
};
221
223
224
+ #endif
225
+
222
226
/* *
223
227
* @brief Generic output of SPDIF to Arduino Stream
224
228
*
@@ -381,7 +385,7 @@ class SPDIFStream : public AudioStreamX {
381
385
}
382
386
383
387
// / start SPDIF with default configuration
384
- bool begin () { spdif.begin (); }
388
+ bool begin () { return spdif.begin (); }
385
389
// / start SPDIF with the indicated configuration
386
390
bool begin (SPDIFConfig cfg) {
387
391
this ->cfg = cfg;
@@ -398,7 +402,8 @@ class SPDIFStream : public AudioStreamX {
398
402
targetSpdifConfig.channels = 2 ;
399
403
targetSpdifConfig.bits_per_sample = 16 ;
400
404
targetSpdifConfig.sample_rate = cfg.sample_rate ;
401
- spdif.begin (targetSpdifConfig);
405
+ return spdif.begin (targetSpdifConfig);
406
+
402
407
}
403
408
404
409
// / Close the SPDIF processing
0 commit comments