Skip to content

Commit 02c6dd4

Browse files
committed
close SD SPI only when sd_active
1 parent fe3c503 commit 02c6dd4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Driver.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ namespace audio_driver
230230
// Store default i2c address to pins
231231
setupI2CAddress();
232232

233-
p_pins->setSPIActiveForSD(codec_cfg.sd_active);
233+
AD_LOGI("sd_active: %d", codecCfg.sd_active);
234+
p_pins->setSPIActiveForSD(codecCfg.sd_active);
234235
if (!p_pins->begin())
235236
{
236237
AD_LOGE("AudioBoard::pins::begin failed");

src/DriverPins.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,16 @@ class DriverPins {
422422
}
423423

424424
void end() {
425-
// setup spi
425+
// close spi
426426
for (auto &tmp : spi) {
427+
// close SD only when sd_active
428+
if (tmp.function == PinFunction::SD) {
429+
if (sd_active) tmp.end();
430+
} else {
427431
tmp.end();
432+
}
428433
}
429-
// setup i2c
434+
// close i2c
430435
for (auto &tmp : i2c) {
431436
AD_LOGD("DriverPins::begin::I2C::end");
432437
tmp.end();

0 commit comments

Comments
 (0)