fix(sdspi): fixed sdspi on p4

This commit is contained in:
Armando 2024-08-08 16:23:59 +08:00
parent c13f35a7cf
commit 29bf116021
9 changed files with 46 additions and 5 deletions

View File

@ -33,6 +33,10 @@ menu "SDMMC Test Board Configuration"
bool "ESP32-P4 Function EV Board"
depends on IDF_TARGET_ESP32P4
config SDMMC_BOARD_ESP32P4_EV_BOARD_WITH_SDSPI
bool "ESP32-P4 Function EV Board with SDSPI breakout"
depends on IDF_TARGET_ESP32P4
config SDMMC_BOARD_ESP32C5_BREAKOUT
bool "ESP32-C5 breakout board"
depends on IDF_TARGET_ESP32C5

View File

@ -346,6 +346,34 @@ static const sdmmc_test_board_info_t s_board_info = {
},
};
#elif CONFIG_SDMMC_BOARD_ESP32P4_EV_BOARD_WITH_SDSPI
static const sdmmc_test_board_info_t s_board_info = {
.name = "ESP32-P4 Function EV Board with SDSPI breakout",
.slot = {
{
.slot_exists = false
},
{
.slot_exists = true,
.bus_width = 1,
.clk = 53,
.cmd_mosi = 36,
.d0_miso = 47,
.d1 = GPIO_NUM_NC,
.d2 = GPIO_NUM_NC,
.d3_cs = 33,
.d4 = GPIO_NUM_NC,
.d5 = GPIO_NUM_NC,
.d6 = GPIO_NUM_NC,
.d7 = GPIO_NUM_NC,
.cd = CONFIG_SDMMC_BOARD_CUSTOM_CD,
.wp = CONFIG_SDMMC_BOARD_CUSTOM_WP,
.unused_pin = CONFIG_SDMMC_BOARD_CUSTOM_UNUSED,
}
},
};
#elif CONFIG_SDMMC_BOARD_ESP32C5_BREAKOUT
static const sdmmc_test_board_info_t s_board_info = {

View File

@ -49,7 +49,9 @@ TEST_CASE("CD input works in SPI mode", "[sdspi]")
TEST_ESP_OK(sdspi_host_deinit());
TEST_ESP_OK(spi_bus_free(SDSPI_DEFAULT_HOST));
sdmmc_test_board_card_power_set(false);
#if SOC_SDMMC_IO_POWER_EXTERNAL
TEST_ESP_OK(sd_pwr_ctrl_del_on_chip_ldo(pwr_ctrl_handle));
#endif
}
TEST_CASE("WP input works in SPI mode", "[sdspi]")
@ -85,5 +87,7 @@ TEST_CASE("WP input works in SPI mode", "[sdspi]")
TEST_ESP_OK(sdspi_host_deinit());
TEST_ESP_OK(spi_bus_free(SDSPI_DEFAULT_HOST));
sdmmc_test_board_card_power_set(false);
#if SOC_SDMMC_IO_POWER_EXTERNAL
TEST_ESP_OK(sd_pwr_ctrl_del_on_chip_ldo(pwr_ctrl_handle));
#endif
}

View File

@ -6,6 +6,7 @@ from pytest_embedded_idf import IdfDut
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.esp32p4
@pytest.mark.esp32c5
@pytest.mark.sdcard_spimode
def test_sdspi(dut: IdfDut) -> None:

View File

@ -0,0 +1,2 @@
CONFIG_SDMMC_BOARD_ESP32P4_EV_BOARD_WITH_SDSPI=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y

View File

@ -72,7 +72,7 @@ typedef struct {
typedef struct {
spi_ll_clock_val_t clock_reg; ///< Register value used by the LL layer
spi_clock_source_t clock_source; ///< Clock source of each device used by LL layer
uint32_t source_pre_div; ///< Pre divider befor enter SPI peripheral
uint32_t source_pre_div; ///< Pre divider before enter SPI peripheral
int real_freq; ///< Output of the actual frequency
int timing_dummy; ///< Extra dummy needed to compensate the timing
int timing_miso_delay; ///< Extra miso delay clocks to compensate the timing
@ -129,7 +129,7 @@ typedef struct {
#if SOC_SPI_AS_CS_SUPPORTED
uint32_t as_cs : 1; ///< Whether to toggle the CS while the clock toggles, device specific
#endif
uint32_t positive_cs : 1; ///< Whether the postive CS feature is abled, device specific
uint32_t positive_cs : 1; ///< Whether the positive CS feature is abled, device specific
};//boolean configurations
} spi_hal_dev_config_t;

View File

@ -19,7 +19,7 @@ menu "SD SPI Example Configuration"
default 35 if IDF_TARGET_ESP32S2
default 35 if IDF_TARGET_ESP32S3
default 5 if IDF_TARGET_ESP32H2
default 48 if IDF_TARGET_ESP32P4
default 36 if IDF_TARGET_ESP32P4
default 4 # C3 and others
config EXAMPLE_PIN_MISO

View File

@ -9,6 +9,7 @@ from pytest_embedded import Dut
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.esp32p4
@pytest.mark.esp32c5
@pytest.mark.sdcard_spimode
def test_examples_sd_card_sdspi(dut: Dut) -> None:
@ -16,7 +17,7 @@ def test_examples_sd_card_sdspi(dut: Dut) -> None:
dut.expect('example: Using SPI peripheral', timeout=20)
# Provide enough time for possible SD card formatting
dut.expect('Filesystem mounted', timeout=60)
dut.expect('Filesystem mounted', timeout=180)
# These lines are matched separately because of ASCII color codes in the output
name = dut.expect(re.compile(rb'Name: (\w+)\r'), timeout=20).group(1).decode()
@ -43,4 +44,4 @@ def test_examples_sd_card_sdspi(dut: Dut) -> None:
dut.expect_exact(msg, timeout=30)
dut.expect(sd_card_format, timeout=180) # Provide enough time for SD card FATFS format operation
for msg in message_list2:
dut.expect_exact(msg, timeout=30)
dut.expect_exact(msg, timeout=180)

View File

@ -0,0 +1 @@
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y