Skip to content

Commit 3fcd4bf

Browse files
committed
sd_active support
1 parent 1969b15 commit 3fcd4bf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Driver.h

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const samplerate_t rate_code[8] = {RATE_08K, RATE_11K, RATE_16K, RATE_22K,
3030
*/
3131
class CodecConfig : public codec_config_t {
3232
public:
33+
// if sd active we setup SPI for the SD
34+
bool sd_active = true;
35+
3336
/// @brief setup default values
3437
CodecConfig() {
3538
adc_input = ADC_INPUT_LINE1;
@@ -155,6 +158,7 @@ class AudioDriver {
155158
virtual bool begin(CodecConfig codecCfg, DriverPins &pins) {
156159
codec_cfg = codecCfg;
157160
p_pins = &pins;
161+
pins.setSPIActiveForSD(codecCfg.sd_active);
158162
if (!init(codec_cfg)) {
159163
AD_LOGE("init failed");
160164
return false;

src/DriverPins.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ class DriverPins {
289289
// setup spi
290290
bool result = true;
291291
for (auto &tmp : spi) {
292-
result &= tmp.begin();
292+
if (tmp.function==SD && sd_active)
293+
result &= tmp.begin();
294+
else
295+
result &= tmp.begin();
293296
}
294297
// setup i2c
295298
for (auto &tmp : i2c) {
@@ -331,11 +334,19 @@ class DriverPins {
331334
}
332335
}
333336

337+
void setSPIActiveForSD(bool active){
338+
sd_active = active;
339+
}
340+
bool isSPIActiveForSD(){
341+
return sd_active;
342+
}
343+
334344
protected:
335345
Vector<PinsI2S> i2s{0};
336346
Vector<PinsSPI> spi{0};
337347
Vector<PinsI2C> i2c{0};
338348
Vector<PinsFunction> pins{0};
349+
bool sd_active = true;
339350
};
340351

341352
/**

0 commit comments

Comments
 (0)