title: ESP32 direct port manipulation
body: <p>Dear StackOverflowers,</p>
  
  <p>I am trying to use HX8357D 3.5" TFT from Adafruit (<a href="https://learn.adafruit.com/adafruit-3-5-color-320x480-tft-touchscreen-breakout/overview" rel="noreferrer">link</a>) with an esp32. The TFT driver has two interfaces: SPI and 8-bit parallel. The provided library from Adafruit (<a href="https://github.com/adafruit/TFTLCD-Library" rel="noreferrer">link</a>) only supports SPI on the esp32. I need to have higher display speeds, so I decided to try and add support for the esp32 myself. I'm not experienced at all with this kind of programming, but I liked the challenge.</p>
  
  <p>I figured out how the 8-bit interface work by reverse engineering the Arduino Uno/Mega support. To add the esp32 support I need a way to directly manipulate the registers controlling the gpio ports of the esp32. I looked around on the internet, but there are very little examples of how to do this. The technical reference manual of Espressif (<a href="https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf" rel="noreferrer">link</a>) contains all the information needed, but I'm not skilled enough to figure out how to translate this into code.</p>
  
  <p>To program the esp32 I use the esp32 Arduino core. This example (<a href="https://portal.vidadesilicio.com.br/manipulando-os-registradores-esp32/" rel="noreferrer">link</a>) shows how to set gpio pins as output and make them HIGH and LOW directly using registers. The problem is that I need to be able to set 8 pins as output, write data to them, make them input and then read data from them, all using registers instead of using the pinMode, digitalRead and digitalWrite functions.</p>
  
  <p>The way it works on the Arduino Uno/Mega is clear to me, there are three registers that control a port:</p>
  
  <ul>
  <li>DDR* to read/write</li>
  <li>PORT* to set gpio HIGH/LOW</li>
  <li>PIN* to read HIGH/LOW if the gpio is INPUT.</li>
  </ul>
  
  <p>But how does this work on the esp32 and how can I make use of the registers to create this 8-bit parallel communication?</p>
  
  <p>If there is anybody that has more know-how than me on this topic I would super be grateful for an explanation. Thanks in advance.</p>