|
|
@@ -111,6 +111,7 @@ We have two bits to control the interrupt:
|
|
|
*/
|
|
|
|
|
|
#include <string.h>
|
|
|
+#include <sys/param.h>
|
|
|
#include "esp_private/spi_common_internal.h"
|
|
|
#include "driver/spi_master.h"
|
|
|
#include "esp_clk_tree.h"
|
|
|
@@ -123,9 +124,9 @@ We have two bits to control the interrupt:
|
|
|
#include "soc/soc_memory_layout.h"
|
|
|
#include "driver/gpio.h"
|
|
|
#include "hal/spi_hal.h"
|
|
|
+#include "hal/spi_ll.h"
|
|
|
#include "esp_heap_caps.h"
|
|
|
|
|
|
-
|
|
|
typedef struct spi_device_t spi_device_t;
|
|
|
|
|
|
/// struct to hold private transaction data (like tx and rx buffer for DMA).
|
|
|
@@ -803,6 +804,14 @@ static SPI_MASTER_ISR_ATTR esp_err_t check_trans_valid(spi_device_handle_t handl
|
|
|
//Dummy phase is not available when both data out and in are enabled, regardless of FD or HD mode.
|
|
|
SPI_CHECK(!tx_enabled || !rx_enabled || !dummy_enabled || !extra_dummy_enabled, "Dummy phase is not available when both data out and in are enabled", ESP_ERR_INVALID_ARG);
|
|
|
|
|
|
+ if (bus_attr->dma_enabled) {
|
|
|
+ SPI_CHECK(trans_desc->length <= SPI_LL_DMA_MAX_BIT_LEN, "txdata transfer > hardware max supported len", ESP_ERR_INVALID_ARG);
|
|
|
+ SPI_CHECK(trans_desc->rxlength <= SPI_LL_DMA_MAX_BIT_LEN, "rxdata transfer > hardware max supported len", ESP_ERR_INVALID_ARG);
|
|
|
+ } else {
|
|
|
+ SPI_CHECK(trans_desc->length <= SPI_LL_CPU_MAX_BIT_LEN, "txdata transfer > hardware max supported len", ESP_ERR_INVALID_ARG);
|
|
|
+ SPI_CHECK(trans_desc->rxlength <= SPI_LL_CPU_MAX_BIT_LEN, "rxdata transfer > hardware max supported len", ESP_ERR_INVALID_ARG);
|
|
|
+ }
|
|
|
+
|
|
|
return ESP_OK;
|
|
|
}
|
|
|
|
|
|
@@ -1102,3 +1111,20 @@ esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_transmit(spi_device_handle_t ha
|
|
|
|
|
|
return spi_device_polling_end(handle, portMAX_DELAY);
|
|
|
}
|
|
|
+
|
|
|
+esp_err_t spi_bus_get_max_transaction_len(spi_host_device_t host_id, size_t *max_bytes)
|
|
|
+{
|
|
|
+ SPI_CHECK(is_valid_host(host_id), "invalid host", ESP_ERR_INVALID_ARG);
|
|
|
+ if (bus_driver_ctx[host_id] == NULL || max_bytes == NULL) {
|
|
|
+ return ESP_ERR_INVALID_ARG;
|
|
|
+ }
|
|
|
+
|
|
|
+ spi_host_t *host = bus_driver_ctx[host_id];
|
|
|
+ if (host->bus_attr->dma_enabled) {
|
|
|
+ *max_bytes = MIN(host->bus_attr->max_transfer_sz, (SPI_LL_DMA_MAX_BIT_LEN / 8));
|
|
|
+ } else {
|
|
|
+ *max_bytes = MIN(host->bus_attr->max_transfer_sz, (SPI_LL_CPU_MAX_BIT_LEN / 8));
|
|
|
+ }
|
|
|
+
|
|
|
+ return ESP_OK;
|
|
|
+}
|