mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'fix/ff_sdmmc_status_check_optional' into 'master'
fatfs: Add option to mock ff_sdmmc_status output to increase IO speed Closes IDF-4788 See merge request espressif/esp-idf!18300
This commit is contained in:
commit
7f884dc966
@ -12,6 +12,7 @@
|
||||
#include "esp_compiler.h"
|
||||
|
||||
static sdmmc_card_t* s_cards[FF_VOLUMES] = { NULL };
|
||||
static bool s_disk_status_check_en[FF_VOLUMES] = { };
|
||||
|
||||
static const char* TAG = "diskio_sdmmc";
|
||||
|
||||
@ -40,8 +41,11 @@ DSTATUS ff_sdmmc_initialize (BYTE pdrv)
|
||||
|
||||
DSTATUS ff_sdmmc_status(BYTE pdrv)
|
||||
{
|
||||
if (s_disk_status_check_en[pdrv]) {
|
||||
return ff_sdmmc_card_available(pdrv);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DRESULT ff_sdmmc_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count)
|
||||
{
|
||||
@ -108,6 +112,11 @@ DRESULT ff_sdmmc_ioctl (BYTE pdrv, BYTE cmd, void* buff)
|
||||
return RES_ERROR;
|
||||
}
|
||||
|
||||
void ff_sdmmc_set_disk_status_check(BYTE pdrv, bool enable)
|
||||
{
|
||||
s_disk_status_check_en[pdrv] = enable;
|
||||
}
|
||||
|
||||
void ff_diskio_register_sdmmc(BYTE pdrv, sdmmc_card_t* card)
|
||||
{
|
||||
static const ff_diskio_impl_t sdmmc_impl = {
|
||||
@ -118,6 +127,7 @@ void ff_diskio_register_sdmmc(BYTE pdrv, sdmmc_card_t* card)
|
||||
.ioctl = &ff_sdmmc_ioctl
|
||||
};
|
||||
s_cards[pdrv] = card;
|
||||
s_disk_status_check_en[pdrv] = false;
|
||||
ff_diskio_register(pdrv, &sdmmc_impl);
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,8 @@
|
||||
// Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -21,6 +13,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable/disable SD card status checking
|
||||
*
|
||||
* @param pdrv drive number
|
||||
* @param enable mock ff_sdmmc_status function (return 0)
|
||||
*/
|
||||
void ff_sdmmc_set_disk_status_check(BYTE pdrv, bool enable);
|
||||
|
||||
/**
|
||||
* Register SD/MMC diskio driver
|
||||
*
|
||||
|
@ -85,6 +85,17 @@ typedef struct {
|
||||
* sector size.
|
||||
*/
|
||||
size_t allocation_unit_size;
|
||||
/**
|
||||
* Enables real ff_disk_status function implementation for SD cards
|
||||
* (ff_sdmmc_status). Possibly slows down IO performance.
|
||||
*
|
||||
* Try to enable if you need to handle situations when SD cards
|
||||
* are not unmounted properly before physical removal
|
||||
* or you are experiencing issues with SD cards.
|
||||
*
|
||||
* Doesn't do anything for other memory storage media.
|
||||
*/
|
||||
bool disk_status_check_enable;
|
||||
} esp_vfs_fat_mount_config_t;
|
||||
|
||||
// Compatibility definition
|
||||
|
@ -85,6 +85,7 @@ static esp_err_t mount_to_vfs_fat(const esp_vfs_fat_mount_config_t *mount_config
|
||||
FATFS* fs = NULL;
|
||||
esp_err_t err;
|
||||
ff_diskio_register_sdmmc(pdrv, card);
|
||||
ff_sdmmc_set_disk_status_check(pdrv, mount_config->disk_status_check_enable);
|
||||
ESP_LOGD(TAG, "using pdrv=%i", pdrv);
|
||||
char drv[3] = {(char)('0' + pdrv), ':', 0};
|
||||
|
||||
|
@ -38,3 +38,5 @@ wear-levelling.rst:line: WARNING: Duplicate C++ declaration, also defined at api
|
||||
Declaration is '.. cpp:member:: int max_files'.
|
||||
wear-levelling.rst:line: WARNING: Duplicate C++ declaration, also defined at api-reference/storage/fatfs:line.
|
||||
Declaration is '.. cpp:member:: size_t allocation_unit_size'.
|
||||
wear-levelling.rst:line: WARNING: Duplicate C++ declaration, also defined at api-reference/storage/fatfs:line.
|
||||
Declaration is '.. cpp:member:: bool disk_status_check_enable'.
|
||||
|
@ -727,7 +727,6 @@ components/fatfs/diskio/diskio.c
|
||||
components/fatfs/diskio/diskio_impl.h
|
||||
components/fatfs/diskio/diskio_rawflash.c
|
||||
components/fatfs/diskio/diskio_rawflash.h
|
||||
components/fatfs/diskio/diskio_sdmmc.h
|
||||
components/fatfs/diskio/diskio_wl.h
|
||||
components/fatfs/port/freertos/ffsystem.c
|
||||
components/fatfs/port/linux/ffsystem.c
|
||||
|
Loading…
Reference in New Issue
Block a user