Skip to content

Commit

Permalink
Added a parameter for max files in SD (#2563)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbernstone authored and me-no-dev committed Apr 9, 2019
1 parent 7df50a9 commit d5f71ce
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions libraries/SD/src/SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using namespace fs;

SDFS::SDFS(FSImplPtr impl): FS(impl), _pdrv(0xFF) {}

bool SDFS::begin(uint8_t ssPin, SPIClass &spi, uint32_t frequency, const char * mountpoint)
bool SDFS::begin(uint8_t ssPin, SPIClass &spi, uint32_t frequency, const char * mountpoint, uint8_t max_files)
{
if(_pdrv != 0xFF) {
return true;
Expand All @@ -35,7 +35,7 @@ bool SDFS::begin(uint8_t ssPin, SPIClass &spi, uint32_t frequency, const char *
return false;
}

if(!sdcard_mount(_pdrv, mountpoint)){
if(!sdcard_mount(_pdrv, mountpoint, max_files)){
sdcard_unmount(_pdrv);
sdcard_uninit(_pdrv);
_pdrv = 0xFF;
Expand Down
2 changes: 1 addition & 1 deletion libraries/SD/src/SD.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SDFS : public FS

public:
SDFS(FSImplPtr impl);
bool begin(uint8_t ssPin=SS, SPIClass &spi=SPI, uint32_t frequency=4000000, const char * mountpoint="/sd");
bool begin(uint8_t ssPin=SS, SPIClass &spi=SPI, uint32_t frequency=4000000, const char * mountpoint="/sd", uint8_t max_files=5);
void end();
sdcard_type_t cardType();
uint64_t cardSize();
Expand Down
4 changes: 2 additions & 2 deletions libraries/SD/src/sd_diskio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ uint8_t sdcard_unmount(uint8_t pdrv)
return 0;
}

bool sdcard_mount(uint8_t pdrv, const char* path)
bool sdcard_mount(uint8_t pdrv, const char* path, uint8_t max_files)
{
ardu_sdcard_t * card = s_cards[pdrv];
if(pdrv >= FF_VOLUMES || card == NULL){
Expand All @@ -725,7 +725,7 @@ bool sdcard_mount(uint8_t pdrv, const char* path)

FATFS* fs;
char drv[3] = {(char)('0' + pdrv), ':', 0};
esp_err_t err = esp_vfs_fat_register(path, drv, 5, &fs);
esp_err_t err = esp_vfs_fat_register(path, drv, max_files, &fs);
if (err == ESP_ERR_INVALID_STATE) {
log_e("esp_vfs_fat_register failed 0x(%x): SD is registered.", err);
return false;
Expand Down
2 changes: 1 addition & 1 deletion libraries/SD/src/sd_diskio.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
uint8_t sdcard_init(uint8_t cs, SPIClass * spi, int hz);
uint8_t sdcard_uninit(uint8_t pdrv);

bool sdcard_mount(uint8_t pdrv, const char* path);
bool sdcard_mount(uint8_t pdrv, const char* path, uint8_t max_files);
uint8_t sdcard_unmount(uint8_t pdrv);

sdcard_type_t sdcard_type(uint8_t pdrv);
Expand Down

0 comments on commit d5f71ce

Please sign in to comment.