mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi: added an API to get max transaction length and use in spi lcd driver
This commit is contained in:
parent
4943844764
commit
8702e49057
@ -111,6 +111,7 @@ We have two bits to control the interrupt:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include "esp_private/spi_common_internal.h"
|
#include "esp_private/spi_common_internal.h"
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
#include "esp_clk_tree.h"
|
#include "esp_clk_tree.h"
|
||||||
@ -126,7 +127,6 @@ We have two bits to control the interrupt:
|
|||||||
#include "hal/spi_ll.h"
|
#include "hal/spi_ll.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct spi_device_t spi_device_t;
|
typedef struct spi_device_t spi_device_t;
|
||||||
|
|
||||||
/// struct to hold private transaction data (like tx and rx buffer for DMA).
|
/// struct to hold private transaction data (like tx and rx buffer for DMA).
|
||||||
@ -1111,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);
|
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;
|
||||||
|
}
|
||||||
|
@ -391,6 +391,18 @@ void spi_get_timing(bool gpio_is_used, int input_delay_ns, int eff_clk, int *dum
|
|||||||
*/
|
*/
|
||||||
int spi_get_freq_limit(bool gpio_is_used, int input_delay_ns);
|
int spi_get_freq_limit(bool gpio_is_used, int input_delay_ns);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get max length (in bytes) of one transaction
|
||||||
|
*
|
||||||
|
* @param host_id SPI peripheral
|
||||||
|
* @param[out] max_bytes Max length of one transaction, in bytes
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_OK: On success
|
||||||
|
* - ESP_ERR_INVALID_ARG: Invalid argument
|
||||||
|
*/
|
||||||
|
esp_err_t spi_bus_get_max_transaction_len(spi_host_device_t host_id, size_t *max_bytes);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_check.h"
|
#include "esp_check.h"
|
||||||
#include "esp_lcd_common.h"
|
#include "esp_lcd_common.h"
|
||||||
#include "esp_private/spi_common_internal.h"
|
|
||||||
|
|
||||||
static const char *TAG = "lcd_panel.io.spi";
|
static const char *TAG = "lcd_panel.io.spi";
|
||||||
|
|
||||||
@ -107,9 +106,13 @@ esp_err_t esp_lcd_new_panel_io_spi(esp_lcd_spi_bus_handle_t bus, const esp_lcd_p
|
|||||||
spi_panel_io->base.tx_color = panel_io_spi_tx_color;
|
spi_panel_io->base.tx_color = panel_io_spi_tx_color;
|
||||||
spi_panel_io->base.del = panel_io_spi_del;
|
spi_panel_io->base.del = panel_io_spi_del;
|
||||||
spi_panel_io->base.register_event_callbacks = panel_io_spi_register_event_callbacks;
|
spi_panel_io->base.register_event_callbacks = panel_io_spi_register_event_callbacks;
|
||||||
spi_panel_io->spi_trans_max_bytes = spi_bus_get_attr((spi_host_device_t)bus)->max_transfer_sz;
|
|
||||||
|
size_t max_trans_bytes = 0;
|
||||||
|
ESP_GOTO_ON_ERROR(spi_bus_get_max_transaction_len((spi_host_device_t)bus, &max_trans_bytes), err, TAG, "get spi max transaction len failed");
|
||||||
|
spi_panel_io->spi_trans_max_bytes = max_trans_bytes;
|
||||||
|
|
||||||
*ret_io = &(spi_panel_io->base);
|
*ret_io = &(spi_panel_io->base);
|
||||||
ESP_LOGD(TAG, "new spi lcd panel io @%p", spi_panel_io);
|
ESP_LOGD(TAG, "new spi lcd panel io @%p, max_trans_bytes: %d", spi_panel_io, (int)max_trans_bytes);
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user