adafruit / Adafruit-GFX-Library

Adafruit GFX graphics core Arduino library, this is the 'core' class that all our other graphics libraries derive from

Home Page:https://learn.adafruit.com/adafruit-gfx-graphics-library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ESP32 HSPI usage

monte-monte opened this issue · comments

  • Arduino board: ESP32 WROOM
  • Arduino IDE version: 1.8.13

I am trying to initialize display using HSPI port of ESP32. I haven't found any documentation for this in regards to Adafruit GFX. I see in code, that when you create an instance of Adafruit_SPITFT you can pass a pointer to spiClass for specific SPI device.
I created an instance of spiClass for desired port and passed a pointer to it to Adafruit_SPITFT. Problem is that ESP32 resets on spi initialization and throws an exception to console. I tried to begin spi outside of Adafruit_SPITFT but it resets anyway. Neither VSPI nor HSPI don't work. The default initialization without custom spiClass works, but I looked in source code and doesn't see any difference, it should work, except it doesn't.
The snippet of code I am working with:

#include <Adafruit_GFX.h> 
#include <Adafruit_ST7735.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>


#define TFT_CS        -1
#define TFT_RST        27
#define TFT_DC         12

SPIClass * hspi = NULL;
Adafruit_ST7789 tft = Adafruit_ST7789(hspi, TFT_CS, TFT_DC, TFT_RST);

void setup(void) {
  Serial.begin(115200);
  Serial.print(F("Hello! ST77xx TFT Test"));
  hspi = new SPIClass(VSPI);
  tft.init(240, 240, SPI_MODE3); 
  tft.setSPISpeed(40000000);
  Serial.println(F("Initialized"));

Also I've found that arduino ESP32 library is using the default pins for VSPI, but declaring default SPI device as HSPI. I wonder who and why choose to do this way, but anyway I don't think this matters to my exact problem, because I've tried both SPI and tried manually declaring it with needed pins.