Skip to content

Commit aeddbd3

Browse files
wmarkowbaldram
authored andcommitted
Introduce isChipConnected() method. (#27)
1 parent fc49833 commit aeddbd3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/VS1053.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,15 @@ void VS1053::switchToMp3Mode() {
279279
delay(100);
280280
LOG("Switched to mp3 mode\n");
281281
softReset();
282-
}
282+
}
283+
284+
/**
285+
* A lightweight method to check if VS1053 is correctly wired up (power supply and connection to SPI interface).
286+
*
287+
* @return true if the chip is wired up correctly
288+
*/
289+
bool VS1053::isChipConnected() {
290+
uint16_t status = read_register(SCI_STATUS);
291+
292+
return !(status == 0 || status == 0xFFFF);
293+
}

src/VS1053.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class VS1053 {
4747
const uint8_t vs1053_chunk_size = 32;
4848
// SCI Register
4949
const uint8_t SCI_MODE = 0x0;
50+
const uint8_t SCI_STATUS = 0x1;
5051
const uint8_t SCI_BASS = 0x2;
5152
const uint8_t SCI_CLOCKF = 0x3;
5253
const uint8_t SCI_AUDATA = 0x5;
@@ -132,6 +133,8 @@ class VS1053 {
132133
}
133134

134135
void switchToMp3Mode();
136+
137+
bool isChipConnected();
135138
};
136139

137140
#endif

0 commit comments

Comments
 (0)