From 907b5d9e7fd0cb2779aaa5f1c5dc31f439bdc88e Mon Sep 17 00:00:00 2001 From: Sylvio Alves Date: Thu, 12 Aug 2021 09:35:38 -0300 Subject: [PATCH] drivers: spi: set max chunk len for esp32 Max SPI chunk len was missing from the implementation, causing SPI to hang up in some conditions. Signed-off-by: Sylvio Alves --- drivers/spi/spi_esp32_spim.c | 1 + soc/xtensa/esp32/soc.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/spi/spi_esp32_spim.c b/drivers/spi/spi_esp32_spim.c index e8481367580..f283d7d9424 100644 --- a/drivers/spi/spi_esp32_spim.c +++ b/drivers/spi/spi_esp32_spim.c @@ -63,6 +63,7 @@ static int IRAM_ATTR spi_esp32_transfer(const struct device *dev) spi_hal_dev_config_t *hal_dev = &data->dev_config; spi_hal_trans_config_t *hal_trans = &data->trans_config; size_t chunk_len = spi_context_max_continuous_chunk(&data->ctx); + chunk_len = MIN(chunk_len, SOC_SPI_MAXIMUM_BUFFER_SIZE); /* clean up and prepare SPI hal */ memset((uint32_t *) hal->hw->data_buf, 0, sizeof(hal->hw->data_buf)); diff --git a/soc/xtensa/esp32/soc.h b/soc/xtensa/esp32/soc.h index 686dd5558cf..9d488fb4611 100644 --- a/soc/xtensa/esp32/soc.h +++ b/soc/xtensa/esp32/soc.h @@ -8,6 +8,7 @@ #define __SOC_H__ #include #include +#include #include #include