From 0aa52057ed9cc33a5b1d2d72b72894b8ded7a19e Mon Sep 17 00:00:00 2001 From: "Michael (XIAO Xufeng)" Date: Mon, 23 Jul 2018 18:47:57 +0800 Subject: [PATCH] spi_master: enable 2 tests in CI The test is previously disabled for the requirement of external connection. Now the signals are connected by internal connections. Also change the failure logic of the test. --- components/driver/test/test_spi_master.c | 74 +++++++++++++----------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/components/driver/test/test_spi_master.c b/components/driver/test/test_spi_master.c index 2037afd372..8887d5cefc 100644 --- a/components/driver/test/test_spi_master.c +++ b/components/driver/test/test_spi_master.c @@ -119,7 +119,7 @@ TEST_CASE("SPI Master clockdiv calculation routines", "[spi]") static spi_device_handle_t setup_spi_bus(int clkspeed, bool dma) { spi_bus_config_t buscfg={ - .mosi_io_num=4, + .mosi_io_num=26, .miso_io_num=26, .sclk_io_num=25, .quadwp_io_num=-1, @@ -138,22 +138,24 @@ static spi_device_handle_t setup_spi_bus(int clkspeed, bool dma) { }; esp_err_t ret; spi_device_handle_t handle; - printf("THIS TEST NEEDS A JUMPER BETWEEN IO4 AND IO26\n"); ret=spi_bus_initialize(HSPI_HOST, &buscfg, dma?1:0); TEST_ASSERT(ret==ESP_OK); ret=spi_bus_add_device(HSPI_HOST, &devcfg, &handle); TEST_ASSERT(ret==ESP_OK); + //connect MOSI to two devices breaks the output, fix it. + gpio_output_sel(26, FUNC_GPIO, HSPID_OUT_IDX); printf("Bus/dev inited.\n"); return handle; } -static void spi_test(spi_device_handle_t handle, int num_bytes) { +static int spi_test(spi_device_handle_t handle, int num_bytes) { esp_err_t ret; int x; + bool success = true; srand(num_bytes); - char *sendbuf=heap_caps_malloc(num_bytes, MALLOC_CAP_DMA); - char *recvbuf=heap_caps_malloc(num_bytes, MALLOC_CAP_DMA); + char *sendbuf=heap_caps_malloc((num_bytes+3)&(~3), MALLOC_CAP_DMA); + char *recvbuf=heap_caps_malloc((num_bytes+3)&(~3), MALLOC_CAP_DMA); for (x=0; x