Skip to content

Commit 1887a4c

Browse files
authored
Fix PR #208 review-thread findings
1 parent 82c5e11 commit 1887a4c

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/sdcard/sdcard.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "fatfs/ff.h"
1010
#include "fatfs/ffconf.h"
1111
#include "sd_spi.h"
12+
#include "sdcard.h"
1213

1314
#define SFN_MAX 8
1415
#define SFN_SUFFIX_LEN 4 // Period + at most three chars.
@@ -18,6 +19,7 @@
1819
#define CONFIG_FILENAME "PSLAB.CFG"
1920

2021
static bool s_mounted = false;
22+
static FATFS s_standalone_drive;
2123
static TCHAR s_sector_buf[BUF_MAX];
2224
_Static_assert(
2325
sizeof(s_sector_buf) == 512,
@@ -172,8 +174,7 @@ response_t SDCARD_standalone_check(void) {
172174
return FAILED;
173175
}
174176

175-
FATFS drive;
176-
if (f_mount(&drive, SDCARD_DRIVE, 1) != FR_OK) {
177+
if (f_mount(&s_standalone_drive, SDCARD_DRIVE, 1) != FR_OK) {
177178
return FAILED;
178179
}
179180
s_mounted = true;

src/sdcard/sdcard.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,12 @@ response_t SDCARD_get_file_info(void);
102102
*
103103
* @details Checks if the SD-card can be mounted and if the configuration file is present and valid.
104104
* If the configuration file is not present or invalid, or if the SD-card is not mounted, the function returns FAILED.
105-
* The configuration file is expected to be named "PSLAB.CFG" and contain a magic header of 5 bytes with a null terminator.
105+
* The configuration file is expected to be named "PSLAB.CFG" and
106+
* contain the 5-byte magic header "PSLAB".
106107
*
107-
* @return SUCCESS
108+
* @return SUCCESS or FAILED
108109
*/
109110
response_t SDCARD_standalone_check(void);
111+
void SDCARD_standalone_unmount(void);
110112

111113
#endif // _SDCARD_H

src/states.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ state_t Standalone(void) {
4545
return STATE_RUNCOMMAND;
4646
}
4747

48+
WATCHDOG_TimerClear();
4849
return STATE_STANDALONE;
4950
}
5051

0 commit comments

Comments
 (0)