docs: clarify 7-pin ST7789 (SDA/SCL) mapping to shared SPI bus in hw_pins.h and README wiring

This commit is contained in:
2026-09-10 06:01:10 +02:00
parent 686b8d1f6f
commit 663fb0643f
2 changed files with 28 additions and 16 deletions

View File

@@ -52,10 +52,12 @@ All code is **pure ESP-IDF v5.x (C) / FreeRTOS** — no Arduino.
| **MFRC522** | SDA (CS) | **5** | dedicated chip select |
| | RST | **22** | hard reset |
| | 3.3V / GND | — | feed from board 3.3V rail |
| **ST7789** | CS | **15** | dedicated chip select |
| | DC (A0) | **2** | data/command |
| **ST7789** (7-pin) | CS | **15** | dedicated chip select |
| | DC | **2** | data/command |
| | RST | **4** | panel reset |
| | LED | 3.3V or 5V | optional backlight pin |
| | SDA | **23** | shared MOSI (data) |
| | SCL | **18** | shared SCK (clock) |
| | VCC / GND | 3.3V / GND | panel power (no separate LED pin) |
| **EC11** | CLK | **32** | interrupt input, pull-up |
| | DT | **33** | quadrature B |
| | SW | **25** | button, active low, pull-up |
@@ -67,17 +69,24 @@ All code is **pure ESP-IDF v5.x (C) / FreeRTOS** — no Arduino.
```
ESP32-WROOM-32
┌────────────────────────────┐
│ 3V3 18 ──── SCK ───────┤ MFRC522 5 ── SDA(CS) 22 ── RST
│ GND 23 ──── MOSI ──────┤ (SPI) 3V3/GND
│ 19 ──── MISO ─────┤
│ 15 ──── CS ───────┤ ST7789 2 ── DC 4 ── RST
│ 4 ─────────────────┤ (SPI)
│ 32 ── CLK ─────────┤ EC11 33 ── DT 25 ── SW/GND
│ 27 ── Din ─────────┤ WS2812B (5V + GND)
│ 14 ── SIG ─────────┤ Buzzer (GND)
│ 3V3 18 ── SCK ──┐ │
│ GND 23 ── MOSI ─┼─────┐ │
│ 19 ── MISO ─┘ │ │
│ 5 ── SDA ───────┤ MFRC522 22 ── RST
│ 22 ── RST ───────┤ 3V3/GND
│ 15 ── CS ────────┤ ST7789 (7-pin)
│ 2 ── DC ────────┤ SDA <-> MOSI, SCL <-> SCK
│ 4 ── RST ───────┤ VCC = 3V3, GND = GND
│ 32 ── CLK ────────┤ EC11 33 ── DT 25 ── SW/GND
│ 27 ── Din ────────┤ WS2812B (5V + GND)
│ 14 ── SIG ────────┤ Buzzer (GND)
└────────────────────────────┘
```
> **7-pin ST7789 wiring recap:** connect the display's **SCL → ESP32 GPIO 18**,
> **SDA → GPIO 23**, **CS → 15**, **DC → 2**, **RST → 4**, **VCC → 3.3V**,
> **GND → GND**. The MFRC522 taps the same SCL/SDA lines (its own CS is GPIO 5).
- Keep SPI signal runs short (< 10 cm) for reliable 20 MHz display transfers.
- NTAG213/215 FPC stickers need to sit flat and close to the MFRC522 antenna.
- The **WS2812B** draws up to ~60 mA; power it from the 5V rail, never from a GPIO.

View File

@@ -11,17 +11,20 @@
#include "hal/gpio_types.h"
#include "driver/spi_master.h"
/* Shared SPI2_HOST (VSPI) bus */
/* Shared SPI2_HOST (VSPI) bus.
* NOTE: on 7-pin ST7789 modules, the display labels these SDA (MOSI) and
* SCL (SCK) - they tap the SAME shared bus as the MFRC522. */
#define HW_SPI_HOST (SPI2_HOST)
#define HW_SPI_SCK_GPIO (GPIO_NUM_18)
#define HW_SPI_MOSI_GPIO (GPIO_NUM_23)
#define HW_SPI_MISO_GPIO (GPIO_NUM_19)
#define HW_SPI_SCK_GPIO (GPIO_NUM_18) /* display SCL + MFRC522 SCK */
#define HW_SPI_MOSI_GPIO (GPIO_NUM_23) /* display SDA + MFRC522 MOSI */
#define HW_SPI_MISO_GPIO (GPIO_NUM_19) /* MFRC522 MISO only */
/* MFRC522 RFID reader */
#define HW_RC522_CS_GPIO (GPIO_NUM_5)
#define HW_RC522_RST_GPIO (GPIO_NUM_22)
/* ST7789 display */
/* ST7789 display - 7-pin breakout: CS / DC / RST / SDA / SCL / GND / VCC.
* SDA and SCL share the SPI bus above (SCL=HW_SPI_SCK, SDA=HW_SPI_MOSI). */
#define HW_LCD_CS_GPIO (GPIO_NUM_15)
#define HW_LCD_DC_GPIO (GPIO_NUM_2)
#define HW_LCD_RST_GPIO (GPIO_NUM_4)