Skip to content

Commit

Permalink
Merge branch 'test/add_spi_slave_freq_test' into 'master'
Browse files Browse the repository at this point in the history
spi: add spi multiple config test

Closes IDF-5882

See merge request espressif/esp-idf!20125
  • Loading branch information
wanckl committed Mar 3, 2023
2 parents 140e6be + e581092 commit 40ca803
Show file tree
Hide file tree
Showing 15 changed files with 1,002 additions and 201 deletions.
3 changes: 3 additions & 0 deletions components/driver/spi/gpspi/spi_slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static const char *SPI_TAG = "spi_slave";

typedef struct {
int id;
spi_bus_config_t bus_config;
spi_slave_interface_config_t cfg;
intr_handle_t intr;
spi_slave_hal_context_t hal;
Expand Down Expand Up @@ -156,6 +157,7 @@ esp_err_t spi_slave_initialize(spi_host_device_t host, const spi_bus_config_t *b
}
memset(spihost[host], 0, sizeof(spi_slave_t));
memcpy(&spihost[host]->cfg, slave_config, sizeof(spi_slave_interface_config_t));
memcpy(&spihost[host]->bus_config, bus_config, sizeof(spi_bus_config_t));
spihost[host]->id = host;

bool use_dma = (dma_chan != SPI_DMA_DISABLED);
Expand Down Expand Up @@ -301,6 +303,7 @@ esp_err_t spi_slave_free(spi_host_device_t host)
if (spihost[host]->dma_enabled) {
spicommon_dma_chan_free(host);
}
spicommon_bus_free_io_cfg(&spihost[host]->bus_config);
free(spihost[host]->hal.dmadesc_tx);
free(spihost[host]->hal.dmadesc_rx);
esp_intr_free(spihost[host]->intr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@
.flags=0,\
}

//default device config for slave hd devices
#define SPI_SLOT_TEST_DEFAULT_CONFIG() {\
.spics_io_num = PIN_NUM_CS, \
.flags = 0, \
.mode = 0, \
.command_bits = 8,\
.address_bits = 8,\
.dummy_bits = 8,\
.queue_size = 10,\
}

typedef enum {
FULL_DUPLEX = 0,
HALF_DUPLEX_MISO = 1,
Expand Down Expand Up @@ -252,8 +263,8 @@ esp_err_t spitest_check_data(int len, spi_transaction_t *master_t, slave_rxdata_
#define spitest_cmp_or_dump(expected, actual, len) ({\
int r = memcmp(expected, actual, len);\
if (r != 0) {\
ESP_LOG_BUFFER_HEXDUMP("expected", expected, len, ESP_LOG_INFO);\
ESP_LOG_BUFFER_HEXDUMP("actual", actual, len, ESP_LOG_WARN);\
ESP_LOG_BUFFER_HEXDUMP("actual ", actual, len, ESP_LOG_WARN);\
ESP_LOG_BUFFER_HEXDUMP("expecte", expected, len, ESP_LOG_INFO);\
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, len);\
}\
r;\
Expand Down
2 changes: 1 addition & 1 deletion components/driver/test_apps/spi/param/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ set(srcs
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(
SRCS ${srcs}
PRIV_REQUIRES test_utils driver test_driver_utils
PRIV_REQUIRES test_utils driver test_driver_utils esp_serial_slave_link
WHOLE_ARCHIVE
)
Loading

0 comments on commit 40ca803

Please sign in to comment.