Skip to content

Commit

Permalink
test(m5stack): [WIP] full-duplex SPI and no init
Browse files Browse the repository at this point in the history
Try modifiying the pure/hybrid ili9341 driver to work with a
pre-initialized SPI bus (e.g., interfaced to an SD card). These
changes aim to replicate [this workaround](e0f4a56)
which resolves the issue when using the ILI9341 C module.
  • Loading branch information
ryanfobel committed Feb 14, 2020
1 parent 70db61b commit 686e42b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions driver/esp32/ili9341.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def disp_spi_init(self):
self.finalizer = lvesp32.cb_finalizer(self.deinit)
lvesp32.init()

"""
buscfg = esp.spi_bus_config_t({
"miso_io_num": self.miso,
"mosi_io_num": self.mosi,
Expand All @@ -158,13 +159,14 @@ def disp_spi_init(self):
"quadhd_io_num": -1,
"max_transfer_sz": self.buf_size,
})
"""

devcfg = esp.spi_device_interface_config_t({
"clock_speed_hz": self.mhz*1000*1000, # Clock out at DISP_SPI_MHZ MHz
"mode": 0, # SPI mode 0
"spics_io_num": self.cs, # CS pin
"queue_size": 2,
"flags": esp.SPI_DEVICE.HALFDUPLEX,
"queue_size": 1,
#"flags": esp.SPI_DEVICE.HALFDUPLEX,
"duty_cycle_pos": 128,
})

Expand All @@ -175,10 +177,11 @@ def disp_spi_init(self):
devcfg.pre_cb = esp.spi_pre_cb_isr
devcfg.post_cb = esp.spi_post_cb_isr

esp.gpio_pad_select_gpio(self.cs)
#esp.gpio_pad_select_gpio(self.cs)

# Initialize the SPI bus, if needed.

"""
if buscfg.miso_io_num >= 0 and \
buscfg.mosi_io_num >= 0 and \
buscfg.sclk_io_num >= 0:
Expand All @@ -194,7 +197,8 @@ def disp_spi_init(self):
ret = esp.spi_bus_initialize(self.spihost, buscfg, 1)
if ret != 0: raise RuntimeError("Failed initializing SPI bus")

"""

self.trans_buffer = esp.heap_caps_malloc(TRANS_BUFFER_LEN, esp.MALLOC_CAP.DMA)
self.cmd_trans_data = self.trans_buffer.__dereference__(1)
self.word_trans_data = self.trans_buffer.__dereference__(4)
Expand Down

0 comments on commit 686e42b

Please sign in to comment.