Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use both VSPI & HSPI SPI buses simultaneously? #790

Closed
neilpanchal opened this issue Oct 30, 2017 · 5 comments
Closed

How to use both VSPI & HSPI SPI buses simultaneously? #790

neilpanchal opened this issue Oct 30, 2017 · 5 comments

Comments

@neilpanchal
Copy link

Hardware:

Board: ESP32-DevKit-C
Core Installation/update date: Latest
IDE name: IDF Component

Description:

Trying to use both VPSI & HSPI busses simultaneously to drive two OLED displays. By default, SPIBegin() works with VSPI pinouts.

Sketch:

I've tried the suggested code here: olikraus/u8g2#377 (comment)

Is the usage of HSPI + VSPI through arduino API possible currently? If so, what is the best way to achieve this?

@me-no-dev
Copy link
Member

SPIClass SPI2(HSPI);

void setup(){
  SPI2.begin(...);
  //... your code
}

In order to use the OLED with the other SPI you might need to alter the lib to take SPIClass &spi`` as argument and use that instead of SPI```

@neilpanchal
Copy link
Author

neilpanchal commented Nov 5, 2017

@me-no-dev

I tried replacing all references to SPI and replaced them to SPI2 in this file:
https://github.com/olikraus/U8g2_Arduino/blob/master/src/U8x8lib.cpp#L394
That's the only place SPIClass object is called. I still have the OLED display connected to the following pins. The code compiles fine and I made sure the SPI2 is instantiated in SPI.cpp in the ESP32-Arduino Library.

SDA = IO 23
SCLK = IO 18
D/C = IO 21
RST = IO 22
CS = IO 5

and oled works fine. It didn't switch to HSPI pins.

So, looks like the VSPI (3) and HSPI (2) #defines are not being executed? I need to debug more.

@theMubashir919
Copy link
Contributor

theMubashir919 commented Nov 1, 2020

That's the only place SPIClass object is called. I still have the OLED display connected to the following pins. The code compiles fine and I made sure the SPI2 is instantiated in SPI.cpp in the ESP32-Arduino Library.

Hello @neilpanchal ,
I am having some difficulty on how to instantiate SPI2 in SPI.cpp.
Can you please explain or give an example?
Much appreciated.
Thanks

@chegewara
Copy link
Contributor

https://github.com/espressif/arduino-esp32/tree/master/libraries/SPI/examples/SPI_Multiple_Buses

@theMubashir919
Copy link
Contributor

thanks. My issue is resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants