mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
refactor(sdmmc): place sdmmc driver into a new component
This commit is contained in:
parent
c4559198b8
commit
c7c38b7904
@ -18,7 +18,6 @@ set(includes "include"
|
||||
"parlio/include"
|
||||
"rmt/include"
|
||||
"sdio_slave/include"
|
||||
"sdmmc/include"
|
||||
"sdspi/include"
|
||||
"sigma_delta/include"
|
||||
"temperature_sensor/include"
|
||||
@ -127,12 +126,6 @@ if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED)
|
||||
list(APPEND srcs "sdio_slave/sdio_slave.c")
|
||||
endif()
|
||||
|
||||
# SDMMC related source files
|
||||
if(CONFIG_SOC_SDMMC_HOST_SUPPORTED)
|
||||
list(APPEND srcs "sdmmc/sdmmc_transaction.c"
|
||||
"sdmmc/sdmmc_host.c")
|
||||
endif()
|
||||
|
||||
# Sigma-Delta Modulation related source files
|
||||
if(CONFIG_SOC_SDM_SUPPORTED)
|
||||
list(APPEND srcs "sigma_delta/sdm.c"
|
||||
@ -199,6 +192,7 @@ else()
|
||||
# for backward compatibility, the driver component needs to
|
||||
# have a public dependency on other "esp_driver_foo" components
|
||||
esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm
|
||||
esp_driver_sd_common esp_driver_sdmmc
|
||||
LDFRAGMENTS ${ldfragments}
|
||||
)
|
||||
endif()
|
||||
|
6
components/esp_driver_sd_common/CMakeLists.txt
Normal file
6
components/esp_driver_sd_common/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
set(srcs)
|
||||
set(public_include "include")
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
)
|
10
components/esp_driver_sd_common/README.md
Normal file
10
components/esp_driver_sd_common/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Common Component for SD Related Drivers
|
||||
|
||||
This component contains driver layer common files:
|
||||
- `esp_sd_defs.h`
|
||||
- `esp_sd_types.h`
|
||||
|
||||
These files will be used by SD related drivers, including:
|
||||
|
||||
- `esp_driver_sdmmc`
|
||||
- `esp_driver_sdspi`
|
@ -1,24 +1,7 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: ISC
|
||||
*
|
||||
* SPDX-FileContributor: 2016-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
@ -75,7 +58,6 @@ extern "C" {
|
||||
#define SD_IO_RW_DIRECT 52 /* R5 */
|
||||
#define SD_IO_RW_EXTENDED 53 /* R5 */
|
||||
|
||||
|
||||
/* OCR bits */
|
||||
#define MMC_OCR_MEM_READY (1<<31) /* memory power-up status bit */
|
||||
#define MMC_OCR_ACCESS_MODE_MASK 0x60000000 /* bits 30:29 */
|
||||
@ -528,7 +510,6 @@ static inline uint32_t MMC_RSP_BITS(uint32_t *src, int start, int len)
|
||||
#define CISTPL_CODE_SDIO_EXT 0x92
|
||||
#define CISTPL_CODE_END 0xFF
|
||||
|
||||
|
||||
/* Timing */
|
||||
#define SDMMC_TIMING_LEGACY 0
|
||||
#define SDMMC_TIMING_HIGHSPEED 1
|
@ -1,24 +1,7 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: ISC
|
||||
*
|
||||
* SPDX-FileContributor: 2016-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2006 Uwe Stuehler <uwe@openbsd.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
15
components/esp_driver_sdmmc/CMakeLists.txt
Normal file
15
components/esp_driver_sdmmc/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
||||
set(srcs)
|
||||
|
||||
set(public_include "include")
|
||||
|
||||
# SDMMC related source files
|
||||
if(CONFIG_SOC_SDMMC_HOST_SUPPORTED)
|
||||
list(APPEND srcs "src/sdmmc_transaction.c"
|
||||
"src/sdmmc_host.c")
|
||||
endif()
|
||||
|
||||
idf_component_register(SRCS ${srcs}
|
||||
INCLUDE_DIRS ${public_include}
|
||||
REQUIRES
|
||||
PRIV_REQUIRES esp_timer esp_pm esp_mm esp_driver_gpio esp_driver_sd_common
|
||||
)
|
@ -50,8 +50,6 @@ extern "C" {
|
||||
#define SDMMC_SLOT_NO_WP GPIO_NUM_NC ///< indicates that write protect line is not used
|
||||
#define SDMMC_SLOT_WIDTH_DEFAULT 0 ///< use the maximum possible width for the slot
|
||||
|
||||
|
||||
|
||||
#if SOC_SDMMC_USE_IOMUX && !SOC_SDMMC_USE_GPIO_MATRIX
|
||||
/**
|
||||
* Macro defining default configuration of SDMMC host slot
|
9
components/esp_driver_sdmmc/include/driver/sdmmc_defs.h
Normal file
9
components/esp_driver_sdmmc/include/driver/sdmmc_defs.h
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "driver/esp_sd_defs.h"
|
9
components/esp_driver_sdmmc/include/driver/sdmmc_types.h
Normal file
9
components/esp_driver_sdmmc/include/driver/sdmmc_types.h
Normal file
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "driver/esp_sd_types.h"
|
@ -45,7 +45,6 @@
|
||||
#define SDMMC_CLK_SRC_ATOMIC()
|
||||
#endif
|
||||
|
||||
|
||||
static const char *TAG = "sdmmc_periph";
|
||||
|
||||
/**
|
||||
@ -70,7 +69,6 @@ typedef struct host_ctx_t {
|
||||
|
||||
static host_ctx_t s_host_ctx;
|
||||
|
||||
|
||||
static void sdmmc_isr(void *arg);
|
||||
static void sdmmc_host_dma_init(void);
|
||||
static esp_err_t sdmmc_host_pullup_en_internal(int slot, int width);
|
@ -18,13 +18,11 @@
|
||||
#include "driver/sdmmc_types.h"
|
||||
#include "driver/sdmmc_defs.h"
|
||||
#include "driver/sdmmc_host.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_cache.h"
|
||||
#include "esp_private/esp_cache_private.h"
|
||||
#include "sdmmc_private.h"
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
|
||||
/* Number of DMA descriptors used for transfer.
|
||||
* Increasing this value above 4 doesn't improve performance for the usual case
|
||||
* of SD memory cards (most data transfers are multiples of 512 bytes).
|
||||
@ -291,7 +289,6 @@ static esp_err_t handle_idle_state_events(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
static esp_err_t handle_event(sdmmc_command_t* cmd, sdmmc_req_state_t* state,
|
||||
sdmmc_event_t* unhandled_events)
|
||||
{
|
||||
@ -418,7 +415,8 @@ static void process_data_status(uint32_t status, sdmmc_command_t* cmd)
|
||||
|
||||
}
|
||||
|
||||
static inline bool mask_check_and_clear(uint32_t* state, uint32_t mask) {
|
||||
static inline bool mask_check_and_clear(uint32_t* state, uint32_t mask)
|
||||
{
|
||||
bool ret = ((*state) & mask) != 0;
|
||||
*state &= ~mask;
|
||||
return ret;
|
||||
@ -466,7 +464,6 @@ static esp_err_t process_events(sdmmc_event_t evt, sdmmc_command_t* cmd,
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case SDMMC_SENDING_DATA:
|
||||
if (mask_check_and_clear(&evt.sdmmc_status, SDMMC_DATA_ERR_MASK)) {
|
||||
process_data_status(orig_evt.sdmmc_status, cmd);
|
@ -98,9 +98,9 @@ INPUT = \
|
||||
$(PROJECT_PATH)/components/driver/rmt/include/driver/rmt_types.h \
|
||||
$(PROJECT_PATH)/components/driver/sdio_slave/include/driver/sdio_slave.h \
|
||||
$(PROJECT_PATH)/components/driver/sigma_delta/include/driver/sdm.h \
|
||||
$(PROJECT_PATH)/components/driver/sdmmc/include/driver/sdmmc_default_configs.h \
|
||||
$(PROJECT_PATH)/components/driver/sdmmc/include/driver/sdmmc_host.h \
|
||||
$(PROJECT_PATH)/components/driver/sdmmc/include/driver/sdmmc_types.h \
|
||||
$(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_default_configs.h \
|
||||
$(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_host.h \
|
||||
$(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_types.h \
|
||||
$(PROJECT_PATH)/components/driver/sdspi/include/driver/sdspi_host.h \
|
||||
$(PROJECT_PATH)/components/esp_driver_spi/include/driver/spi_common.h \
|
||||
$(PROJECT_PATH)/components/esp_driver_spi/include/driver/spi_master.h \
|
||||
|
@ -8,7 +8,7 @@ Overview
|
||||
|
||||
The SD/SDIO/MMC driver currently supports SD memory, SDIO cards, and eMMC chips. This is a protocol level driver built on top of SDMMC and SD SPI host drivers.
|
||||
|
||||
SDMMC and SD SPI host drivers (:component_file:`driver/sdmmc/include/driver/sdmmc_host.h` and :component_file:`driver/sdspi/include/driver/sdspi_host.h`) provide API functions for:
|
||||
SDMMC and SD SPI host drivers (:component_file:`esp_driver_sdmmc/include/driver/sdmmc_host.h` and :component_file:`driver/sdspi/include/driver/sdspi_host.h`) provide API functions for:
|
||||
|
||||
- Sending commands to slave devices
|
||||
- Sending and receiving data
|
||||
|
@ -10,6 +10,7 @@ In order to control the dependence of other components on drivers at a smaller g
|
||||
- `esp_driver_gpio` - Driver for GPIO
|
||||
- `esp_driver_spi` - Driver for GPSPI
|
||||
- `esp_driver_mcpwm` - Driver for Motor Control PWM
|
||||
- `esp_driver_sdmmc` - Driver for SDMMC
|
||||
|
||||
For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on.
|
||||
|
||||
|
@ -8,7 +8,7 @@ SD/SDIO/MMC 驱动程序
|
||||
|
||||
SD/SDIO/MMC 驱动是一种基于 SDMMC 和 SD SPI 主机驱动的协议级驱动程序,目前已支持 SD 存储器、SDIO 卡和 eMMC 芯片。
|
||||
|
||||
SDMMC 主机驱动和 SD SPI 主机驱动(:component_file:`driver/sdmmc/include/driver/sdmmc_host.h` 和 :component_file:`driver/sdspi/include/driver/sdspi_host.h`)为以下功能提供 API:
|
||||
SDMMC 主机驱动和 SD SPI 主机驱动(:component_file:`esp_driver_sdmmc/include/driver/sdmmc_host.h` 和 :component_file:`driver/sdspi/include/driver/sdspi_host.h`)为以下功能提供 API:
|
||||
|
||||
- 发送命令至从设备
|
||||
- 接收和发送数据
|
||||
|
@ -10,6 +10,7 @@
|
||||
- `esp_driver_gpio` - GPIO 驱动
|
||||
- `esp_driver_spi` - 通用 SPI 驱动
|
||||
- `esp_driver_mcpwm` - 电机控制 PWM 驱动
|
||||
- `esp_driver_sdmmc` - SDMMC 驱动
|
||||
|
||||
为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。
|
||||
|
||||
|
@ -11,9 +11,11 @@ examples/storage/custom_flash_driver:
|
||||
examples/storage/emmc:
|
||||
depends_components:
|
||||
- sdmmc
|
||||
- driver
|
||||
- driver # `driver` will be replaced with `esp_driver_sdspi`
|
||||
- fatfs
|
||||
- vfs
|
||||
- esp_driver_sdmmc
|
||||
- esp_driver_sd_common
|
||||
enable:
|
||||
- if: IDF_TARGET == "esp32s3"
|
||||
reason: only support on esp32s3
|
||||
@ -107,7 +109,8 @@ examples/storage/perf_benchmark:
|
||||
- spiffs
|
||||
- wear_levelling
|
||||
- esp_partition
|
||||
- driver
|
||||
- esp_driver_sdmmc
|
||||
- esp_driver_sd_common
|
||||
disable:
|
||||
- if: IDF_TARGET == "esp32p4" and CONFIG_NAME in ["sdmmc_1line", "sdmmc_4line", "sdspi_1line"]
|
||||
temporary: true
|
||||
@ -121,7 +124,8 @@ examples/storage/sd_card/sdmmc:
|
||||
depends_components:
|
||||
- vfs
|
||||
- sdmmc
|
||||
- driver
|
||||
- esp_driver_sdmmc
|
||||
- esp_driver_sd_common
|
||||
disable:
|
||||
- if: SOC_SDMMC_HOST_SUPPORTED != 1
|
||||
disable_test:
|
||||
@ -133,7 +137,7 @@ examples/storage/sd_card/sdspi:
|
||||
depends_components:
|
||||
- vfs
|
||||
- sdmmc
|
||||
- driver
|
||||
- driver # To be updated to `esp_driver_sdspi`
|
||||
disable:
|
||||
- if: SOC_GPSPI_SUPPORTED != 1
|
||||
disable_test:
|
||||
|
@ -121,7 +121,7 @@ spiffs:
|
||||
|
||||
sdmmc:
|
||||
include:
|
||||
- 'components/driver/sdmmc/include/driver/'
|
||||
- 'components/esp_driver_sdmmc/include/driver/'
|
||||
- 'components/sdmmc/'
|
||||
allowed_licenses:
|
||||
- Apache-2.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user