Move MFRC522 to dedicated SPI3_HOST bus (SCK16/MOSI17/MISO13/CS26) separate from display SPI2

This commit is contained in:
2026-09-10 07:13:15 +02:00
parent 05d8012c8b
commit 12690657cc
3 changed files with 57 additions and 32 deletions

View File

@@ -11,17 +11,23 @@
#include "hal/gpio_types.h"
#include "driver/spi_master.h"
/* 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. */
/* SPI2_HOST (VSPI): dedicated to the ST7789 display.
* On 7-pin ST7789 modules the display labels these SDA (MOSI) and
* SCL (SCK). */
#define HW_SPI_HOST (SPI2_HOST)
#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 */
#define HW_SPI_SCK_GPIO (GPIO_NUM_18) /* display SCL */
#define HW_SPI_MOSI_GPIO (GPIO_NUM_23) /* display SDA */
#define HW_SPI_MISO_GPIO (GPIO_NUM_19) /* unused by display; kept for bus */
/* MFRC522 RFID reader */
#define HW_RC522_CS_GPIO (GPIO_NUM_5)
#define HW_RC522_RST_GPIO (GPIO_NUM_22)
/* MFRC522 RFID reader - OWN SPI3_HOST (HSPI) bus, separate from the display.
* Using a independent controller avoids any bus interference between the
* panel and the reader. */
#define HW_RFID_SPI_HOST (SPI3_HOST)
#define HW_RFID_SCK_GPIO (GPIO_NUM_16)
#define HW_RFID_MOSI_GPIO (GPIO_NUM_17)
#define HW_RFID_MISO_GPIO (GPIO_NUM_13)
#define HW_RC522_CS_GPIO (GPIO_NUM_26)
#define HW_RC522_RST_GPIO (GPIO_NUM_22)
/* 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). */