Skip to content

Commit 323e942

Browse files
committed
Merge branch 'fix_c5_spi_master_slave_rx_issue' into 'master'
fix(driver_spi): fixed c5/c61/h21 rx issue and support c61 eco3 changes Closes IDF-12880 and IDF-9300 See merge request espressif/esp-idf!40026
2 parents dc51f79 + c6e1838 commit 323e942

File tree

5 files changed

+32
-15
lines changed

5 files changed

+32
-15
lines changed

components/esp_driver_spi/test_apps/master/main/test_spi_master.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ TEST_CASE("SPI Master clk_source and divider accuracy", "[spi]")
150150
spi_device_interface_config_t devcfg = SPI_DEVICE_TEST_DEFAULT_CONFIG();
151151
devcfg.clock_source = spi_clk_sour[sour_idx];
152152
devcfg.clock_speed_hz = MIN(IDF_TARGET_MAX_SPI_CLK_FREQ, clock_source_hz) >> test_time;
153+
#if CONFIG_IDF_TARGET_ESP32
153154
devcfg.flags |= SPI_DEVICE_HALFDUPLEX; //esp32 half duplex to work on high freq
155+
#endif
154156
#if SOC_SPI_SUPPORT_CLK_RC_FAST
155157
if (devcfg.clock_source == SPI_CLK_SRC_RC_FAST) {
156158
devcfg.clock_speed_hz /= 2; //rc_fast have bad accuracy, test at low speed
@@ -160,6 +162,13 @@ TEST_CASE("SPI Master clk_source and divider accuracy", "[spi]")
160162
// one trans first to trigger lazy load
161163
TEST_ESP_OK(spi_device_polling_transmit(handle, &trans));
162164

165+
// test single tx/rx under full duplex mode, refer to `TEST_CASE_MULTIPLE_DEVICES("SPI Master: FD, DMA, Master Single Direction Test"...`
166+
if (!(devcfg.flags && SPI_DEVICE_HALFDUPLEX)) {
167+
trans.tx_buffer = NULL;
168+
trans.rxlength = trans.length;
169+
trans.rx_buffer = sendbuf;
170+
}
171+
163172
// calculate theoretical transaction time by actual freq and trans length
164173
int real_freq_khz;
165174
spi_device_get_actual_freq(handle, &real_freq_khz);

components/hal/esp32c5/include/hal/spi_ll.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66

77
/*******************************************************************************
88
* NOTICE
9-
* The hal is not public api, don't use in application code.
10-
* See readme.md in soc/include/hal/readme.md
9+
* The LL layer for ESP32C5 SPI register operations
10+
* It is NOT public api, don't use in application code.
1111
******************************************************************************/
1212

13-
// The LL layer for SPI register operations
14-
1513
#pragma once
1614

1715
#include <stdlib.h> //for abs()
@@ -198,6 +196,10 @@ static inline void spi_ll_master_init(spi_dev_t *hw)
198196
hw->user.usr_miso_highpart = 0;
199197
hw->user.usr_mosi_highpart = 0;
200198

199+
//Disable unused error_end condition
200+
hw->user1.mst_wfull_err_end_en = 0;
201+
hw->user2.mst_rempty_err_end_en = 0;
202+
201203
//Disable unneeded ints
202204
hw->slave.val = 0;
203205
hw->user.val = 0;

components/hal/esp32c61/include/hal/spi_ll.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

77
/*******************************************************************************
88
* NOTICE
9-
* The hal is not public api, don't use in application code.
10-
* See readme.md in soc/include/hal/readme.md
9+
* The LL layer for ESP32C61 SPI register operations
10+
* It is NOT public api, don't use in application code.
1111
******************************************************************************/
1212

13-
// The LL layer for SPI register operations
14-
1513
#pragma once
1614

1715
#include <stdlib.h> //for abs()
@@ -199,6 +197,10 @@ static inline void spi_ll_master_init(spi_dev_t *hw)
199197
hw->user.usr_miso_highpart = 0;
200198
hw->user.usr_mosi_highpart = 0;
201199

200+
//Disable unused error_end condition
201+
hw->user1.mst_wfull_err_end_en = 0;
202+
hw->user2.mst_rempty_err_end_en = 0;
203+
202204
//Disable unneeded ints
203205
hw->slave.val = 0;
204206
hw->user.val = 0;
@@ -717,15 +719,15 @@ static inline void spi_ll_master_keep_cs(spi_dev_t *hw, int keep_active)
717719
*/
718720
static inline void spi_ll_master_set_rx_timing_mode(spi_dev_t *hw, spi_sampling_point_t sample_point)
719721
{
720-
//This is not supported
722+
hw->clock.clk_edge_sel = (sample_point == SPI_SAMPLING_POINT_PHASE_1);
721723
}
722724

723725
/**
724726
* Get if standard clock mode is supported.
725727
*/
726728
static inline bool spi_ll_master_is_rx_std_sample_supported(void)
727729
{
728-
return false;
730+
return true;
729731
}
730732

731733
/**

components/hal/esp32h21/include/hal/spi_ll.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
/*******************************************************************************
88
* NOTICE
9-
* The LL layer for SPI register operations
10-
* Not public api, don't use in application code.
9+
* The LL layer for ESP32H21 SPI register operations
10+
* It is NOT public api, don't use in application code.
1111
******************************************************************************/
1212

1313
#pragma once
@@ -162,6 +162,10 @@ static inline void spi_ll_master_init(spi_dev_t *hw)
162162
hw->user.usr_miso_highpart = 0;
163163
hw->user.usr_mosi_highpart = 0;
164164

165+
//Disable unused error_end condition
166+
hw->user1.mst_wfull_err_end_en = 0;
167+
hw->user2.mst_rempty_err_end_en = 0;
168+
165169
//Disable unneeded ints
166170
hw->slave.val = 0;
167171
hw->user.val = 0;

components/soc/esp32c61/include/soc/gpio_pins.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
extern "C" {
1111
#endif
1212

13-
#define GPIO_MATRIX_CONST_ONE_INPUT (0x20)
14-
#define GPIO_MATRIX_CONST_ZERO_INPUT (0x30)
13+
#define GPIO_MATRIX_CONST_ONE_INPUT (0x40)
14+
#define GPIO_MATRIX_CONST_ZERO_INPUT (0x60)
1515

1616
#ifdef __cplusplus
1717
}

0 commit comments

Comments
 (0)