Skip to content

Commit 22ba416

Browse files
fix spi names
1 parent 4afc03a commit 22ba416

File tree

5 files changed

+31
-60
lines changed

5 files changed

+31
-60
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ dkms.conf
5656

5757
# ESP-IDF build dir
5858
build
59+
60+
# Kconfig files
61+
sdkconfig
62+
sdkconfig.old

lvgl_helpers.c

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -154,52 +154,29 @@ bool lvgl_spi_driver_init(int host,
154154
int dma_channel,
155155
int quadwp_pin, int quadhd_pin)
156156
{
157-
int dma_chan = 0 /* SPI_DMA_DISABLED */;
158-
159-
#if defined (CONFIG_IDF_TARGET_ESP32)
160-
assert((SPI_HOST <= host) && (VSPI_HOST >= host));
161-
const char *spi_names[] = {
162-
"SPI_HOST", "HSPI_HOST", "VSPI_HOST"
163-
};
164-
165-
dma_chan = dma_channel;
166-
#elif defined (CONFIG_IDF_TARGET_ESP32S2)
167-
assert((SPI_HOST <= host) && (HSPI_HOST >= host));
168-
const char *spi_names[] = {
169-
"SPI_HOST", "", ""
170-
};
171-
172-
dma_chan = dma_channel;
173-
#elif defined (CONFIG_IDF_TARGET_ESP32C3)
174-
assert((SPI1_HOST <= host) && (SPI3_HOST >= host));
157+
assert((0 <= host) && (SPI_HOST_MAX > host));
175158
const char *spi_names[] = {
176159
"SPI1_HOST", "SPI2_HOST", "SPI3_HOST"
177160
};
178161

179-
dma_chan = 3 /* SPI_DMA_CH_AUTO */;
180-
#else
181-
#error "Target chip not selected"
182-
#endif
183-
184-
ESP_LOGI(TAG, "Configuring SPI host %s (%d)", spi_names[host], host);
162+
ESP_LOGI(TAG, "Configuring SPI host %s", spi_names[host]);
185163
ESP_LOGI(TAG, "MISO pin: %d, MOSI pin: %d, SCLK pin: %d, IO2/WP pin: %d, IO3/HD pin: %d",
186164
miso_pin, mosi_pin, sclk_pin, quadwp_pin, quadhd_pin);
187165

188166
ESP_LOGI(TAG, "Max transfer size: %d (bytes)", max_transfer_sz);
189167

190168
spi_bus_config_t buscfg = {
191169
.miso_io_num = miso_pin,
192-
.mosi_io_num = mosi_pin,
193-
.sclk_io_num = sclk_pin,
194-
.quadwp_io_num = quadwp_pin,
195-
.quadhd_io_num = quadhd_pin,
170+
.mosi_io_num = mosi_pin,
171+
.sclk_io_num = sclk_pin,
172+
.quadwp_io_num = quadwp_pin,
173+
.quadhd_io_num = quadhd_pin,
196174
.max_transfer_sz = max_transfer_sz
197175
};
198176

199177
ESP_LOGI(TAG, "Initializing SPI bus...");
200-
esp_err_t ret = spi_bus_initialize(host, &buscfg, dma_chan);
178+
esp_err_t ret = spi_bus_initialize(host, &buscfg, (spi_dma_chan_t)dma_channel);
201179
assert(ret == ESP_OK);
202180

203181
return ESP_OK != ret;
204182
}
205-

lvgl_spi_conf.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ extern "C" {
6464

6565
#define ENABLE_TOUCH_INPUT CONFIG_LV_ENABLE_TOUCH
6666

67-
#if defined (CONFIG_LV_TFT_DISPLAY_SPI1_HOST)
68-
#define TFT_SPI_HOST SPI1_HOST
69-
#elif defined (CONFIG_LV_TFT_DISPLAY_SPI2_HOST)
67+
#if defined (CONFIG_LV_TFT_DISPLAY_SPI2_HOST)
7068
#define TFT_SPI_HOST SPI2_HOST
7169
#elif defined (CONFIG_LV_TFT_DISPLAY_SPI3_HOST)
7270
#define TFT_SPI_HOST SPI3_HOST
@@ -86,12 +84,10 @@ extern "C" {
8684
#define DISP_SPI_TRANS_MODE_SIO
8785
#endif
8886

89-
#if defined (CONFIG_LV_TOUCH_CONTROLLER_SPI_HSPI)
90-
#define TOUCH_SPI_HOST HSPI_HOST
91-
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_SPI_VSPI)
92-
#define TOUCH_SPI_HOST VSPI_HOST
93-
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_SPI_FSPI)
94-
#define TOUCH_SPI_HOST FSPI_HOST
87+
#if defined (CONFIG_LV_TOUCH_CONTROLLER_SPI2_HOST)
88+
#define TOUCH_SPI_HOST SPI2_HOST
89+
#elif defined (CONFIG_LV_TOUCH_CONTROLLER_SPI3_HOST)
90+
#define TOUCH_SPI_HOST SPI3_HOST
9591
#endif
9692

9793
/* Handle the FT81X Special case */
@@ -107,7 +103,7 @@ extern "C" {
107103
// Detect the use of a shared SPI Bus and verify the user specified the same SPI bus for both touch and tft
108104
#if defined (CONFIG_LV_TOUCH_DRIVER_PROTOCOL_SPI) && TP_SPI_MOSI == DISP_SPI_MOSI && TP_SPI_CLK == DISP_SPI_CLK
109105
#if TFT_SPI_HOST != TOUCH_SPI_HOST
110-
#error You must specify the same SPI host (HSPI, VSPI or FSPI) for both display and touch driver
106+
#error You must specify the same SPI host (SPIx_HOST) for both display and touch driver
111107
#endif
112108

113109
#define SHARED_SPI_BUS

lvgl_tft/Kconfig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,10 @@ menu "LVGL TFT Display controller"
469469

470470
choice
471471
prompt "TFT SPI Bus." if LV_TFT_DISPLAY_PROTOCOL_SPI
472-
default LV_TFT_DISPLAY_SPI3_HOST if LV_PREDEFINED_DISPLAY_TTGO && \
473-
!IDF_TARGET_ESP32S2
472+
default LV_TFT_DISPLAY_SPI2_HOST
474473
help
475474
Select the SPI Bus the TFT Display is attached to.
476475

477-
config LV_TFT_DISPLAY_SPI1_HOST
478-
bool "SPI1_HOST"
479476
config LV_TFT_DISPLAY_SPI2_HOST
480477
bool "SPI2_HOST"
481478
config LV_TFT_DISPLAY_SPI3_HOST

lvgl_touch/Kconfig

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,14 @@ menu "LVGL Touch controller"
6767
prompt "Touch Controller SPI Bus."
6868
depends on LV_TOUCH_DRIVER_PROTOCOL_SPI
6969

70-
default LV_TOUCH_CONTROLLER_SPI_VSPI if !IDF_TARGET_ESP32S2
71-
default LV_TOUCH_CONTROLLER_SPI_FSPI if IDF_TARGET_ESP32S2
70+
default LV_TOUCH_CONTROLLER_SPI2_HOST
7271
help
73-
Select the SPI Bus the TFT Display is attached to.
74-
75-
config LV_TOUCH_CONTROLLER_SPI_HSPI
76-
bool "HSPI"
77-
config LV_TOUCH_CONTROLLER_SPI_VSPI
78-
bool "VSPI" if !IDF_TARGET_ESP32S2
79-
config LV_TOUCH_CONTROLLER_SPI_FSPI
80-
bool "FSPI" if IDF_TARGET_ESP32S2
72+
Select the SPI Bus the touch controller is attached to.
73+
74+
config LV_TOUCH_CONTROLLER_SPI2_HOST
75+
bool "SPI2_HOST"
76+
config LV_TOUCH_CONTROLLER_SPI3_HOST
77+
bool "SPI3_HOST"
8178
endchoice
8279

8380
menu "Touchpanel (XPT2046) Pin Assignments"
@@ -86,7 +83,7 @@ menu "LVGL Touch controller"
8683
config LV_TOUCH_SPI_MISO
8784
int
8885
prompt "GPIO for MISO (Master In Slave Out)"
89-
86+
9087
default 35 if LV_PREDEFINED_PINS_38V1
9188
default 19
9289
help
@@ -103,7 +100,7 @@ menu "LVGL Touch controller"
103100

104101
config LV_TOUCH_SPI_CLK
105102
int "GPIO for CLK (SCK / Serial Clock)"
106-
103+
107104
default 26 if LV_PREDEFINED_PINS_38V1
108105
default 18
109106
help
@@ -119,7 +116,7 @@ menu "LVGL Touch controller"
119116

120117
config LV_TOUCH_PIN_IRQ
121118
int "GPIO for IRQ (Interrupt Request)"
122-
119+
123120
default 27 if LV_PREDEFINED_PINS_38V4
124121
default 25
125122
help
@@ -216,7 +213,7 @@ menu "LVGL Touch controller"
216213
config LV_TOUCH_SPI_MISO
217214
int
218215
prompt "GPIO for MISO (Master In Slave Out)"
219-
216+
220217
default 35 if LV_PREDEFINED_PINS_38V1
221218
default 19 if LV_PREDEFINED_DISPLAY_ADA_FEATHERWING
222219
default 19
@@ -472,14 +469,14 @@ menu "LVGL Touch controller"
472469
config LV_I2C_TOUCH_PORT_0
473470
bool
474471
prompt "I2C port 0"
475-
help
472+
help
476473
I2C is shared peripheral managed by I2C Manager. In order to configure I2C Manager (pinout, etc.) see menu
477474
Component config->I2C Port Settings.
478475

479476
config LV_I2C_TOUCH_PORT_1
480477
bool
481478
prompt "I2C port 1"
482-
help
479+
help
483480
I2C is shared peripheral managed by I2C Manager. In order to configure I2C Manager (pinout, etc.) see menu
484481
Component config->I2C Port Settings.
485482

0 commit comments

Comments
 (0)