diff options
| author | Your Name <you@example.com> | 2026-05-18 16:29:13 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-18 16:29:13 +0530 |
| commit | 02d699d22989fd8bda091b00657d0dd1b7406247 (patch) | |
| tree | b6308eb362d034eb55cc7a5cb008e4eb1c27b5e7 | |
| parent | bf0f22dc7510eb6d098ae2205dae008f858d8195 (diff) | |
fix: convert AXS15231B driver from SPI to QSPI
The JC3248W535 uses Quad SPI with 4 data lines (D0-D3), not standard
SPI. The previous driver only wired D0 (MOSI), causing garbled pixel
data while register writes (single SPI) worked partially.
Changes:
- Wire all 4 data pins in spi_bus_config_t (data0-data3)
- Set SPI_DEVICE_HALFDUPLEX for QSPI output mode
- Send pixel data with SPI_TRANS_MODE_QIO flag for 4-bit parallel transfer
- Register writes (init, CASET, RASET, RAMWR cmd) remain single SPI
| -rw-r--r-- | components/axs15231b/axs15231b.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/components/axs15231b/axs15231b.c b/components/axs15231b/axs15231b.c index dd7145a..50be305 100644 --- a/components/axs15231b/axs15231b.c +++ b/components/axs15231b/axs15231b.c | |||
| @@ -136,11 +136,11 @@ esp_err_t axs15231b_init(void) { | |||
| 136 | esp_err_t ret; | 136 | esp_err_t ret; |
| 137 | 137 | ||
| 138 | spi_bus_config_t buscfg = { | 138 | spi_bus_config_t buscfg = { |
| 139 | .mosi_io_num = AXS15231B_PIN_D0, | 139 | .data0_io_num = AXS15231B_PIN_D0, |
| 140 | .data1_io_num = AXS15231B_PIN_D1, | ||
| 140 | .sclk_io_num = AXS15231B_PIN_CLK, | 141 | .sclk_io_num = AXS15231B_PIN_CLK, |
| 141 | .miso_io_num = -1, | 142 | .data2_io_num = AXS15231B_PIN_D2, |
| 142 | .quadwp_io_num = -1, | 143 | .data3_io_num = AXS15231B_PIN_D3, |
| 143 | .quadhd_io_num = -1, | ||
| 144 | .max_transfer_sz = 32768, | 144 | .max_transfer_sz = 32768, |
| 145 | }; | 145 | }; |
| 146 | 146 | ||
| @@ -149,7 +149,7 @@ esp_err_t axs15231b_init(void) { | |||
| 149 | .mode = 0, | 149 | .mode = 0, |
| 150 | .spics_io_num = AXS15231B_PIN_CS, | 150 | .spics_io_num = AXS15231B_PIN_CS, |
| 151 | .queue_size = 7, | 151 | .queue_size = 7, |
| 152 | .flags = 0, | 152 | .flags = SPI_DEVICE_HALFDUPLEX, |
| 153 | }; | 153 | }; |
| 154 | 154 | ||
| 155 | ret = spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO); | 155 | ret = spi_bus_initialize(SPI2_HOST, &buscfg, SPI_DMA_CH_AUTO); |
| @@ -266,10 +266,11 @@ void axs15231b_flush(void) { | |||
| 266 | int remaining = total_bytes - offset; | 266 | int remaining = total_bytes - offset; |
| 267 | int this_chunk = remaining < chunk_size ? remaining : chunk_size; | 267 | int this_chunk = remaining < chunk_size ? remaining : chunk_size; |
| 268 | 268 | ||
| 269 | spi_transaction_t t = {0}; | 269 | spi_transaction_ext_t t = {0}; |
| 270 | t.length = this_chunk * 8; | 270 | t.base.length = this_chunk * 8; |
| 271 | t.tx_buffer = fb_bytes + offset; | 271 | t.base.tx_buffer = fb_bytes + offset; |
| 272 | esp_err_t ret = spi_device_polling_transmit(s_spi, &t); | 272 | t.base.flags = SPI_TRANS_MODE_QIO | SPI_TRANS_MULTILINE_CMD; |
| 273 | esp_err_t ret = spi_device_polling_transmit(s_spi, (spi_transaction_t *)&t); | ||
| 273 | if (ret != ESP_OK) { | 274 | if (ret != ESP_OK) { |
| 274 | ESP_LOGE(TAG, "Flush transfer failed at offset %d: %s", offset, esp_err_to_name(ret)); | 275 | ESP_LOGE(TAG, "Flush transfer failed at offset %d: %s", offset, esp_err_to_name(ret)); |
| 275 | return; | 276 | return; |