mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-02 16:11:41 +01:00
spi: refactor spi_common dma allocator
This commit is contained in:
@@ -74,11 +74,7 @@ TEST_CASE("SPI Master clockdiv calculation routines", "[spi]")
|
||||
.quadhd_io_num=-1
|
||||
};
|
||||
esp_err_t ret;
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
ret = spi_bus_initialize(TEST_SPI_HOST, &buscfg, 1);
|
||||
#else
|
||||
ret = spi_bus_initialize(TEST_SPI_HOST, &buscfg, -1);
|
||||
#endif
|
||||
ret = spi_bus_initialize(TEST_SPI_HOST, &buscfg, DMA_AUTO_CHAN);
|
||||
TEST_ASSERT(ret==ESP_OK);
|
||||
|
||||
check_spi_pre_n_for(26000000, 1, 3);
|
||||
@@ -116,11 +112,7 @@ static spi_device_handle_t setup_spi_bus_loopback(int clkspeed, bool dma) {
|
||||
};
|
||||
spi_device_handle_t handle;
|
||||
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, dma ? 1 : 0));
|
||||
#else
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, dma ? -1 : 0));
|
||||
#endif
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, dma ? DMA_AUTO_CHAN : 0));
|
||||
TEST_ESP_OK(spi_bus_add_device(TEST_SPI_HOST, &devcfg, &handle));
|
||||
//connect MOSI to two devices breaks the output, fix it.
|
||||
spitest_gpio_output_sel(PIN_NUM_MOSI, FUNC_GPIO, spi_periph_signal[TEST_SPI_HOST].spid_out);
|
||||
@@ -281,11 +273,7 @@ static esp_err_t test_master_pins(int mosi, int miso, int sclk, int cs)
|
||||
spi_device_interface_config_t master_cfg = SPI_DEVICE_TEST_DEFAULT_CONFIG();
|
||||
master_cfg.spics_io_num = cs;
|
||||
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
ret = spi_bus_initialize(TEST_SPI_HOST, &cfg, 1);
|
||||
#else
|
||||
ret = spi_bus_initialize(TEST_SPI_HOST, &cfg, -1);
|
||||
#endif
|
||||
ret = spi_bus_initialize(TEST_SPI_HOST, &cfg, DMA_AUTO_CHAN);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -312,11 +300,7 @@ static esp_err_t test_slave_pins(int mosi, int miso, int sclk, int cs)
|
||||
spi_slave_interface_config_t slave_cfg = SPI_SLAVE_TEST_DEFAULT_CONFIG();
|
||||
slave_cfg.spics_io_num = cs;
|
||||
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
ret = spi_slave_initialize(TEST_SLAVE_HOST, &cfg, &slave_cfg, TEST_DMA_CHAN_SLAVE);
|
||||
#else
|
||||
ret = spi_slave_initialize(TEST_SLAVE_HOST, &cfg, &slave_cfg, -1);
|
||||
#endif
|
||||
ret = spi_slave_initialize(TEST_SLAVE_HOST, &cfg, &slave_cfg, DMA_AUTO_CHAN);
|
||||
if (ret != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -523,11 +507,7 @@ TEST_CASE("SPI Master no response when switch from host1 (HSPI) to host2 (VSPI)"
|
||||
//initialize for first host
|
||||
host = TEST_SPI_HOST;
|
||||
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
TEST_ESP_OK(spi_bus_initialize(host, &bus_config, host));
|
||||
#else
|
||||
TEST_ESP_OK(spi_bus_initialize(host, &bus_config, -1));
|
||||
#endif
|
||||
TEST_ESP_OK(spi_bus_initialize(host, &bus_config, DMA_AUTO_CHAN));
|
||||
TEST_ESP_OK(spi_bus_add_device(host, &device_config, &spi));
|
||||
|
||||
printf("before first xmit\n");
|
||||
@@ -539,12 +519,7 @@ TEST_CASE("SPI Master no response when switch from host1 (HSPI) to host2 (VSPI)"
|
||||
|
||||
//for second host and failed before
|
||||
host = TEST_SLAVE_HOST;
|
||||
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
TEST_ESP_OK(spi_bus_initialize(host, &bus_config, host));
|
||||
#else
|
||||
TEST_ESP_OK(spi_bus_initialize(host, &bus_config, -1));
|
||||
#endif
|
||||
TEST_ESP_OK(spi_bus_initialize(host, &bus_config, DMA_AUTO_CHAN));
|
||||
TEST_ESP_OK(spi_bus_add_device(host, &device_config, &spi));
|
||||
|
||||
printf("before second xmit\n");
|
||||
@@ -612,11 +587,7 @@ TEST_CASE("SPI Master DMA test, TX and RX in different regions", "[spi]")
|
||||
spi_device_interface_config_t devcfg=SPI_DEVICE_TEST_DEFAULT_CONFIG();
|
||||
|
||||
//Initialize the SPI bus
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, 1));
|
||||
#else
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, -1));
|
||||
#endif
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, DMA_AUTO_CHAN));
|
||||
//Attach the LCD to the SPI bus
|
||||
TEST_ESP_OK(spi_bus_add_device(TEST_SPI_HOST, &devcfg, &spi));
|
||||
//connect MOSI to two devices breaks the output, fix it.
|
||||
@@ -700,11 +671,7 @@ TEST_CASE("SPI Master DMA test: length, start, not aligned", "[spi]")
|
||||
.pre_cb=NULL,
|
||||
};
|
||||
//Initialize the SPI bus
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, 1));
|
||||
#else
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, -1));
|
||||
#endif
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, DMA_AUTO_CHAN));
|
||||
//Attach the LCD to the SPI bus
|
||||
TEST_ESP_OK(spi_bus_add_device(TEST_SPI_HOST, &devcfg, &spi));
|
||||
|
||||
@@ -773,11 +740,7 @@ void test_cmd_addr(spi_slave_task_context_t *slave_context, bool lsb_first)
|
||||
//initial master, mode 0, 1MHz
|
||||
spi_bus_config_t buscfg=SPI_BUS_TEST_DEFAULT_CONFIG();
|
||||
buscfg.quadhd_io_num = UNCONNECTED_PIN;
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, 1));
|
||||
#else
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, -1));
|
||||
#endif
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, DMA_AUTO_CHAN));
|
||||
spi_device_interface_config_t devcfg=SPI_DEVICE_TEST_DEFAULT_CONFIG();
|
||||
devcfg.clock_speed_hz = 1*1000*1000;
|
||||
if (lsb_first) devcfg.flags |= SPI_DEVICE_BIT_LSBFIRST;
|
||||
@@ -1112,11 +1075,7 @@ static void speed_setup(spi_device_handle_t* spi, bool use_dma)
|
||||
devcfg.queue_size=8; //We want to be able to queue 7 transactions at a time
|
||||
|
||||
//Initialize the SPI bus and the device to test
|
||||
#if !SOC_GDMA_SUPPORTED
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, (use_dma? GET_DMA_CHAN(TEST_SPI_HOST): 0)));
|
||||
#else
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, (use_dma? -1 : 0)));
|
||||
#endif
|
||||
TEST_ESP_OK(spi_bus_initialize(TEST_SPI_HOST, &buscfg, (use_dma ? DMA_AUTO_CHAN : 0)));
|
||||
TEST_ESP_OK(spi_bus_add_device(TEST_SPI_HOST, &devcfg, spi));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user