Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't try and call any sd functions unless mounting was successful. #22

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion player/src/SDCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ SDCard::SDCard(gpio_num_t clk, gpio_num_t cmd, gpio_num_t d0, gpio_num_t d1, gpi
Serial.printf("SDCard mounted at: %s\n", MOUNT_POINT);
// Card has been initialized, print its properties
sdmmc_card_print_info(stdout, m_card);
sd_card_init_success = true;
#endif
}

Expand Down Expand Up @@ -123,6 +124,7 @@ SDCard::SDCard(gpio_num_t miso, gpio_num_t mosi, gpio_num_t clk, gpio_num_t cs)
Serial.printf("SDCard mounted at: %s\n", MOUNT_POINT);
// Card has been initialized, print its properties
sdmmc_card_print_info(stdout, m_card);
sd_card_init_success = true;
}

SDCard::~SDCard()
Expand All @@ -135,7 +137,10 @@ SDCard::~SDCard()


bool SDCard::isMounted() {
return sdmmc_get_status(m_card) == ESP_OK;
if (sd_card_init_success) {
return sdmmc_get_status(m_card) == ESP_OK;
}
return false;
}

std::vector<std::string> SDCard::listFiles(const char *folder, const char *extension)
Expand Down
1 change: 1 addition & 0 deletions player/src/SDCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SDCard
#else
sdmmc_host_t m_host = SDSPI_HOST_DEFAULT();
#endif
bool sd_card_init_success = false;
public:
SDCard(gpio_num_t miso, gpio_num_t mosi, gpio_num_t clk, gpio_num_t cs);
SDCard(gpio_num_t clk, gpio_num_t cmd, gpio_num_t d0, gpio_num_t d1, gpio_num_t d2, gpio_num_t d3);
Expand Down
Loading