Skip to content

Commit c81b65e

Browse files
committed
Deactivate SPI when sd not active
1 parent 993ec2f commit c81b65e

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include "Arduino.h"
2+
3+
/**
4+
* @brief Pin Tests for AudioKit
5+
*
6+
*/
7+
8+
void setup() {
9+
Serial.begin(115200);
10+
for (int j=10;j<=36;j++){
11+
pinMode(j, INPUT_PULLUP);
12+
}
13+
}
14+
15+
void loop() {
16+
for (int j=10;j<=36;j++){
17+
int value = digitalRead(j);
18+
Serial.print(value ? "-":"+");
19+
}
20+
Serial.println();
21+
delay(1000);
22+
}

src/AudioLibs/AudioKit.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class AudioKitStreamConfig : public I2SConfig {
2323
// set dac channel
2424
audio_hal_dac_output_t output_device = AUDIOKIT_DEFAULT_OUTPUT;
2525
int masterclock_pin = 0;
26-
bool sd_active = false;
26+
bool sd_active = true;
2727
bool default_actions_active = true;
2828

2929
/// convert to config object needed by HAL
@@ -40,6 +40,7 @@ class AudioKitStreamConfig : public I2SConfig {
4040
result.sample_rate = toSampleRate();
4141
result.bits_per_sample = toBits();
4242
result.sd_active = sd_active;
43+
LOGW("sd_active = %s", sd_active ? "true" : "false" );
4344
return result;
4445
}
4546

@@ -536,8 +537,14 @@ class AudioKitStream : public AudioStreamX {
536537
/// Setup the supported default actions
537538
void setupActions() {
538539
LOGI(LOG_METHOD);
540+
// SPI might have been activated
541+
if (!cfg.sd_active){
542+
LOGW("Deactivating SPI because SD is not active");
543+
SPI.end();
544+
}
545+
539546
// pin conflicts with AIThinker A101 and headphone detection
540-
if (! (cfg.sd_active && AUDIOKIT_BOARD==6)) {
547+
if (! (cfg.sd_active && AUDIOKIT_BOARD==6)) {
541548
actions.add(kit.pinHeadphoneDetect(), actionHeadphoneDetection);
542549
} else {
543550
LOGW("Headphone detection ignored because of conflict: %d ",kit.pinHeadphoneDetect());

0 commit comments

Comments
 (0)