20
20
#ifndef TESTING
21
21
#include "driver_init.h"
22
22
#include "sd_mmc.h"
23
+ #include "sd_mmc/sd_mmc_start.h"
23
24
#endif
24
25
25
26
#include "flags.h"
@@ -107,7 +108,14 @@ static bool _mount(void)
107
108
sd_mmc_resume_clock ();
108
109
#endif
109
110
memset (& fs , 0 , sizeof (FATFS ));
110
- if (f_mount (& fs , "SD" , 1 ) == FR_INVALID_DRIVE ) {
111
+ int res = f_mount (& fs , "" , 1 );
112
+ if (res == FR_DISK_ERR ) {
113
+ #ifndef TESTING
114
+ sd_mmc_start ();
115
+ #endif
116
+ res = f_mount (& fs , "" , 1 );
117
+ }
118
+ if (res == FR_INVALID_DRIVE ) {
111
119
#ifndef TESTING
112
120
sd_mmc_pause_clock ();
113
121
#endif
@@ -117,11 +125,11 @@ static bool _mount(void)
117
125
}
118
126
119
127
/**
120
- * Unmunts an SD card and pauses the bus clock.
128
+ * Unmounts an SD card and pauses the bus clock.
121
129
*/
122
130
static void _unmount (void )
123
131
{
124
- f_mount ( NULL , "SD" , 1 );
132
+ f_unmount ( "" );
125
133
#ifndef TESTING
126
134
sd_mmc_pause_clock ();
127
135
#endif
@@ -268,7 +276,8 @@ bool sd_list_subdir(sd_list_t* list_out, const char* subdir)
268
276
if (list_out -> num_files == allocated_files ) {
269
277
char * * new_list_out_files ;
270
278
allocated_files *= 2 ;
271
- new_list_out_files = (char * * )realloc (list_out -> files , sizeof (char * ) * allocated_files );
279
+ new_list_out_files =
280
+ (char * * )realloc ((void * )list_out -> files , sizeof (char * ) * allocated_files );
272
281
if (new_list_out_files == NULL ) {
273
282
sd_free_list (list_out );
274
283
Abort ("Error: realloc sd_list_subdir" );
@@ -295,7 +304,7 @@ void sd_free_list(sd_list_t* list)
295
304
util_zero (list -> files [i ], strlen (list -> files [i ]));
296
305
free (list -> files [i ]);
297
306
}
298
- free (list -> files );
307
+ free (( void * ) list -> files );
299
308
list -> files = NULL ;
300
309
}
301
310
0 commit comments