Commit d5f71ce5 authored by lbernstone's avatar lbernstone Committed by Me No Dev

Added a parameter for max files in SD (#2563)

parent 7df50a97
......@@ -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;
......@@ -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;
......
......@@ -28,7 +28,7 @@ protected:
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();
......
......@@ -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){
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment