ESP32 TFT 5483 - SPI versus I2C interface

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
salasidis
 
Posts: 13
Joined: Mon Sep 27, 2021 3:40 pm

ESP32 TFT 5483 - SPI versus I2C interface

Post by salasidis »

I would like to know if the display is accessed via SPI (instead of I2C), and whether the SPI on the pins of the device can still be used (or it is reserved for the display). My guess is no based on the code below, but want to make sure. Thanks

Code: Select all

void Adafruit_ST7735::commonInit(const uint8_t *cmdList) {

  colstart  = rowstart = 0; // May be overridden in init func

  pinMode(_rs, OUTPUT);
  pinMode(_cs, OUTPUT);
  csport    = portOutputRegister(digitalPinToPort(_cs));
  cspinmask = digitalPinToBitMask(_cs);
  rsport    = portOutputRegister(digitalPinToPort(_rs));
  rspinmask = digitalPinToBitMask(_rs);

  if(hwSPI) { // Using hardware SPI
    SPI.begin();
#ifdef SPI_HAS_TRANSACTION
    spisettings = SPISettings(4000000L, MSBFIRST, SPI_MODE0);
#else
#if defined(ARDUINO_ARCH_SAM)
    SPI.setClockDivider(24); // 4 MHz (half speed)
#else
    SPI.setClockDivider(SPI_CLOCK_DIV4); // 4 MHz (half speed)
#endif
    SPI.setBitOrder(MSBFIRST);
    SPI.setDataMode(SPI_MODE0);
#endif // SPI_HAS_TRANSACTION
  } else {
    pinMode(_sclk, OUTPUT);
    pinMode(_sid , OUTPUT);
    clkport     = portOutputRegister(digitalPinToPort(_sclk));
    clkpinmask  = digitalPinToBitMask(_sclk);
    dataport    = portOutputRegister(digitalPinToPort(_sid));
    datapinmask = digitalPinToBitMask(_sid);
    *clkport   &= ~clkpinmask;
    *dataport  &= ~datapinmask;
  }

  // toggle RST low to reset; CS low so it'll listen to us
  *csport &= ~cspinmask;
  if (_rst) {
    pinMode(_rst, OUTPUT);
    digitalWrite(_rst, HIGH);
    delay(500);
    digitalWrite(_rst, LOW);
    delay(500);
    digitalWrite(_rst, HIGH);
    delay(500);
  }

  if(cmdList) commandList(cmdList);
}

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32 TFT 5483 - SPI versus I2C interface

Post by adafruit_support_mike »

The display is connected to the MOSI, MISO, and SCK pins at the edge of the board. It uses CS pins that aren't broken out to the sides of the board.

You can use the SPI pins for other devices, but you'll need to use other CS pins, and will need to manage which CS pins are pulled down when you want to talk to a given device.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”