Skip to content

Commit

Permalink
sd card fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 3, 2019
1 parent f34f093 commit 0c8c27f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -26853,7 +26853,7 @@
{
"type": "Text",
"style": {
"inheritFrom": "event_info",
"inheritFrom": "value_S",
"padding": 0
},
"activeStyle": {
Expand All @@ -26869,7 +26869,7 @@
{
"type": "Text",
"style": {
"inheritFrom": "value_S",
"inheritFrom": "event_error",
"padding": 0
},
"activeStyle": {
Expand Down
2 changes: 1 addition & 1 deletion src/eez/apps/psu/list_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ bool loadList(int iChannel, const char *filePath, int *err) {
return false;
}

if (!sd_card::exists(filePath, NULL)) {
if (!sd_card::exists(filePath, err)) {
if (err) {
*err = SCPI_ERROR_LIST_NOT_FOUND;
}
Expand Down
21 changes: 11 additions & 10 deletions src/eez/apps/psu/sd_card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ void unmount() {
FATFS_UnLinkDriver(SDPath);
#endif
g_mounted = false;
g_testResult = TEST_SKIPPED;
g_lastError = SCPI_ERROR_MISSING_MASS_MEDIA;
g_testResult = TEST_FAILED;
setQuesBits(QUES_MMEM, false);
}

Expand All @@ -91,7 +92,8 @@ void init() {
if (g_sdCardIsPresent) {
mount();
} else {
g_testResult = TEST_SKIPPED;
g_lastError = SCPI_ERROR_MISSING_MASS_MEDIA;
g_testResult = TEST_FAILED;
}
#endif

Expand All @@ -107,7 +109,7 @@ bool test() {
void tick() {
#if defined(EEZ_PLATFORM_STM32)
g_sdCardIsPresent = HAL_GPIO_ReadPin(SD_DETECT_GPIO_Port, SD_DETECT_Pin) == GPIO_PIN_RESET ? 1 : 0;
if (g_sdCardIsPresent && !g_mounted && g_testResult == TEST_SKIPPED) {
if (g_sdCardIsPresent && !g_mounted && g_lastError == SCPI_ERROR_MISSING_MASS_MEDIA) {
mount();
}
#endif
Expand All @@ -128,16 +130,15 @@ void onSdDetectInterruptHandler() {

bool isMounted(int *err) {
if (g_mounted) {
*err = SCPI_RES_OK;
if (err != nullptr) {
*err = SCPI_RES_OK;
}
return true;
}

if (g_testResult == TEST_SKIPPED) {
*err = SCPI_ERROR_MISSING_MASS_MEDIA;
return false;
}

*err = g_lastError;
if (err != nullptr) {
*err = g_lastError;
}
return false;
}

Expand Down

0 comments on commit 0c8c27f

Please sign in to comment.