How to handle ESP32 concurrent SPI bus access?
Posted: Mon Jan 24, 2022 8:53 am
Hi,
I try to understand how the ESP32 SPI library manages concurrent SPI access on the same bus and more specifically when a transaction is initiated by an Interrupt.
For interrupts, the Arduino SPI library manages that type of conflict using the SPI_HAS_TRANSACTION flag allowing the use usingInterrupt() functions that saves the SREG (Status Register) and disable the Interrupts before any SPI transaction (and restore it after).
The architecture of the ESP32 is quite different, but I don't see a similar configuration in the SPI and esp-hal-spi libraries beside one flag , the _inTransaction, that I can't hardly see its purposes.
I note that the SPI_HAS_TRANSACTION is defined in the esp-hal-spi.c, but again I don't see its purposes, ... beside compatibility with the Arduino one.
So is it somewhere and clear explanation of how to handle concurrent SPI access on the same bus or alternatively, shall I state that to ensure no conflict with concurrent SPI access on the same bus (typically when one is initiated by interrupt), that a semaphore mechanism handling SPI transaction is to be implemented in the script ensuring synchronized access.
Thanks in advance
Robert
I try to understand how the ESP32 SPI library manages concurrent SPI access on the same bus and more specifically when a transaction is initiated by an Interrupt.
For interrupts, the Arduino SPI library manages that type of conflict using the SPI_HAS_TRANSACTION flag allowing the use usingInterrupt() functions that saves the SREG (Status Register) and disable the Interrupts before any SPI transaction (and restore it after).
The architecture of the ESP32 is quite different, but I don't see a similar configuration in the SPI and esp-hal-spi libraries beside one flag , the _inTransaction, that I can't hardly see its purposes.
I note that the SPI_HAS_TRANSACTION is defined in the esp-hal-spi.c, but again I don't see its purposes, ... beside compatibility with the Arduino one.
So is it somewhere and clear explanation of how to handle concurrent SPI access on the same bus or alternatively, shall I state that to ensure no conflict with concurrent SPI access on the same bus (typically when one is initiated by interrupt), that a semaphore mechanism handling SPI transaction is to be implemented in the script ensuring synchronized access.
Thanks in advance
Robert