← index #12124Issue #7663
Related · high · value 2.000
QUERY · ISSUE

Support for ESP32 Quad and Octal SPI on SPI2 and SPI3

openby shantzis62opened 2023-07-30updated 2024-08-22

I have an ESP32S3 project that requires a high bandwidth between the MCU and an external device. The only feature blocking the use of micropython is its lack of support for ESP32's multi-line SPI (Quad and Octal). I looked over the SPI code in ports/esp32 and it looks pretty doable. I'm considering adding it and sending a PR. Before I do so, though, I'm wondering how I should expose it in a module. I think the most sensible thing would be to create a separate esp32.QSPI class (and perhaps an esp32.OctalSPI class).

I'd be interested in hearing what people think.

Thanks!

CANDIDATE · ISSUE

ESP32 SPI - request support for hardware-managed devices

openby oclykeopened 2021-08-14updated 2022-06-21
port-esp32

The ESP32 SPI peripherals support limited management of attached devices in their abstraction layer (I am not sure whether this is a software feature of their HAL or a hardware capability of the actual peripheral though).

The hardware SPI interface common to microcontroller boards in MicroPython does not support this capability - and neither should it. However it would be advantageous to add an additional API which allows ESP32 users to take advantage of these features for both speed and convenience.

Additional capabilities:

  • hardware management of CS lines
  • independent clock frequency settings
  • independent phase and polarity settings

Proposed API:

# import from esp32 module because these features are ESP32 specific
from esp32 import SPIHost, SPIDev

# construct a SPIHost for the peripheral you want to use.
# similar to machine.SPI syntax except that device-specific properties are removed
vspi = SPIHost(2, sck=Pin(18), mosi=Pin(23), miso=Pin(19))

# add devices to the host with independent settings
# optionally allow HAL-controlled cs pin
dev1 = SPIDev(vspi, baudrate=80000000, cs=Pin(25), polarity=0, phase=0, bits=8, firstbit=0)
dev2 = SPIDev(vspi, baudrate=5000000, bits=8)

# note: the esp-idf drivers allow many (untested total) spi devices, but only 3 per host may 
# use a hw controlled cs pin. one may use a Pin to select additional spi devices

# do transactions on devices
devn.write(b'12345')     # write 5 bytes on MOSI
devn.read(10)            # read 10 bytes on MISO

This is also a different solution to #6340 (as opposed to calling spi.init(baudrate) to reconfigure)

I'd be willing to make a PR for this. Please let me know thoughts.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied