Files
AI_Printer/docs/gpio-map.md

66 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ESP32-S3 GPIO Mapping
本文件记录当前板级 GPIO 分配来源于硬件对接表2026-02-26
## GPIO Table
| Board Pin | GPIO | Signal | Direction | Notes |
| --- | --- | --- | --- | --- |
| 1 | GND | GND | - | Ground |
| 2 | 3V3 | 3V3 | - | 3.3V Power |
| 3 | EN/RST | EN | Input | Chip enable/reset |
| 4 | IO4 | PRINT_STB5_6 | Output | Printer strobe 5/6 |
| 5 | IO5 | PRINT_STB3_4 | Output | Printer strobe 3/4 |
| 6 | IO6 | ES8311_I2C_SDA | Bidirectional | Voice codec I2C SDA |
| 7 | IO7 | ES8311_I2C_SCL | Output | Voice codec I2C SCL |
| 8 | IO15 | BATTERY_ADC | Input | Battery voltage ADC detect |
| 9 | IO16 | PRINT_STB1_2 | Output | Printer strobe 1/2 |
| 10 | IO17 | PRINT_PAPER | Input | Paper detect |
| 11 | IO18 | NTC_ADC | Input | NTC ADC |
| 12 | IO8 | PRINT_OUTA_P | Output | Printer OUTA+ |
| 13 | IO19 | PRINT_OUTA_N | Output | Printer OUTA- |
| 14 | IO20 | ES8311_PA | Output | PA control |
| 15 | IO3 | PRINT_OUTB_P | Output | Printer OUTB+ |
| 16 | IO46 | PRINT_OUTB_N | Output | Printer OUTB- |
| 17 | IO9 | SPI_SHARED_MOSI | Output | Printer/Screen shared MOSI |
| 18 | IO10 | PRINTER_MISO | Input | Printer MISO |
| 19 | IO11 | SPI_SHARED_CLK | Output | Printer/Screen shared CLK |
| 20 | IO12 | SCREEN_DC | Output | ST7789 DC |
| 21 | IO13 | SCREEN_CS1 | Output | ST7789 CS |
| 22 | IO14 | MIC_KEY | Input | Mic key (can ADC-mux 2 keys if needed) |
| 23 | IO21 | LED_G | Output | Green LED |
| 24 | IO47 | POWER_KEY | Input | Hold low for 2s to request power-off logic |
| 25 | IO48 | SCREEN_BACKLIGHT | Output | High level turns backlight on |
| 26 | IO45 | PRINT_LAT | Output | Printer LAT |
| 27 | IO0 | KEY_PRINT / BOOST_CTRL | Input/Output | Print confirm key or 7.2V boost control |
| 28 | IO35 | N/A | - | Not available |
| 29 | IO36 | N/A | - | Not available |
| 30 | IO37 | N/A | - | Not available |
| 31 | IO38 | I2S_MCLK | Output | Voice I2S MCLK |
| 32 | IO39 | I2S_BCLK | Output | Voice I2S BCLK |
| 33 | IO40 | I2S_DI | Input | Voice I2S data in |
| 34 | IO41 | I2S_WS | Output | Voice I2S WS |
| 35 | IO42 | I2S_DO | Output | Voice I2S data out |
| 36 | TXD0 | UART0_TX | Output | Serial log/program |
| 37 | RXD0 | UART0_RX | Input | Serial log/program |
| 38 | IO2 | LED_R | Output | Red LED |
| 39 | IO1 | POWER_HOLD | Output | Must drive high at boot to keep board powered |
| 40 | GND | GND | - | Ground |
| 41 | GND | GND | - | Ground |
## Firmware Mapping Notes
- `main/Kconfig.projbuild` contains board pin configs prefixed with `TQ_*`.
- `components/platform/src/platform_bootstrap.c` initializes critical GPIO on startup:
- `POWER_HOLD` asserted high early.
- `SCREEN_DC/SCREEN_CS/SCREEN_BACKLIGHT` default states.
- `KEY_PRINT` defaults to boost-enable output mode (`CONFIG_TQ_KEY_PRINT_BOOST_ENABLE_ON_BOOT=y`).
- key/sensor inputs (`POWER_KEY`, `MIC_KEY`, `PRINT_PAPER`, ADC inputs) default directions.
- `components/platform/src/display_st7789.c` provides ST7789 driver integration:
- SPI bus (`MOSI=IO9`, `CLK=IO11`) + `esp_lcd_new_panel_st7789`.
- Optional boot test pattern via `CONFIG_TQ_SCREEN_TEST_PATTERN_ON_BOOT`.
- Voice codec and I2S pin defaults are aligned to this table:
- I2C: `SDA=6`, `SCL=7`
- I2S: `MCLK=38`, `BCLK=39`, `WS=41`, `DIN=40`, `DOUT=42`
- PA: `IO20`