whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.18k stars 222 forks source link

Feature request: support for SPI with no CS #384

Open xopxe opened 3 years ago

xopxe commented 3 years ago

There are devices that can be run in "Arduino ICSP mode", this is SPI but no CS signal. This also makes sense if you only have one SPI device and want to save a gpio pin. esp-idf supports this setup in spi_bus_add_device setting cs as -1, but there are several checks in whitecat's SPI driver that do not allow for this.

the0ne commented 2 years ago

I can confirm from spi_master.h where what you say is documented: int spics_io_num; ///< CS GPIO pin for this device, or -1 if not used

But actually in components/sys/drivers/spi.c this seems to be supported properly. Everywhere it seems the flags are checked against SPI_FLAG_CS_AUTO. Especially, if SPI_FLAG_CS_AUTO is not set, then the spics_io_num is explicitly set to -1 in case SPI_FLAG_NO_DMA is not set: .spics_io_num = ((flags & SPI_FLAG_CS_AUTO)?spi_bus[spi_idx(unit)].device[device].cs:-1), which seems to be the only possible case, as that flag is removed at the beginning of the function: flags &= ~SPI_FLAG_NO_DMA;

the0ne commented 2 years ago

Please try out #400 and let us know if that fixes your issue. Either way, #400 will need to be redone before pulling to trunk, as git-cola unintentionally had added the websocket submodule.

the0ne commented 2 years ago

Please try out https://github.com/whitecatboard/Lua-RTOS-ESP32/pull/410 and let us know if that fixes your issue.