oxstack_cardputer/pins.rs
1//! Cardputer ADV pin assignment, for reference and for code that drives
2//! pins directly. The typed equivalents live in [`Board`](crate::Board).
3//!
4//! Source: M5Stack *Sch_M5CardputerAdv_v1.0* (2025-06-20), cross-checked
5//! against M5Unified/M5GFX.
6//!
7//! Avoid UART0. Its default pins on the ESP32-S3 are GPIO43/44, which this
8//! board uses for I²S word-select and the IR LED. Log over USB-Serial-JTAG.
9
10/// ST7789V2 LCD on SPI, write-only (3-wire, no MISO).
11pub mod lcd {
12 /// Reset, active low.
13 pub const RST: u8 = 33;
14 /// Data/command select.
15 pub const DC: u8 = 34;
16 /// SPI MOSI.
17 pub const MOSI: u8 = 35;
18 /// SPI clock.
19 pub const SCK: u8 = 36;
20 /// Chip select, active low.
21 pub const CS: u8 = 37;
22 /// Backlight enable / PWM. **Also gates power to the RGB LED.**
23 pub const BL: u8 = 38;
24}
25
26/// Internal I²C bus shared by the keyboard scanner, audio codec and IMU.
27pub mod sys_i2c {
28 /// SDA.
29 pub const SDA: u8 = 8;
30 /// SCL.
31 pub const SCL: u8 = 9;
32 /// TCA8418 keypad scanner.
33 pub const ADDR_TCA8418: u8 = 0x34;
34 /// ES8311 audio codec (CE tied low).
35 pub const ADDR_ES8311: u8 = 0x18;
36 /// BMI270 IMU (SDO pulled high).
37 pub const ADDR_BMI270: u8 = 0x69;
38}
39
40/// TCA8418 interrupt output, active low.
41pub const KEYBOARD_INT: u8 = 11;
42
43/// ES8311 codec I²S. There is no MCLK line; the codec clocks itself from BCLK.
44pub mod i2s {
45 /// Bit clock (codec SCLK).
46 pub const BCLK: u8 = 41;
47 /// Word select (codec LRCK).
48 pub const WS: u8 = 43;
49 /// Data to the codec DAC (codec DSDIN).
50 pub const DOUT: u8 = 42;
51 /// Data from the codec ADC (codec ASDOUT). Strapping pin, input only here.
52 pub const DIN: u8 = 46;
53}
54
55/// SPI bus shared by the microSD slot and the EXT header (e.g. LoRa cap).
56pub mod spi_bus {
57 /// Clock (SD CLK).
58 pub const SCK: u8 = 40;
59 /// MOSI (SD CMD).
60 pub const MOSI: u8 = 14;
61 /// MISO (SD D0).
62 pub const MISO: u8 = 39;
63 /// microSD chip select (SD D3).
64 pub const SD_CS: u8 = 12;
65 /// EXT header chip select.
66 pub const EXT_CS: u8 = 5;
67}
68
69/// 14-pin EXT header (besides the shared SPI bus and system I²C).
70pub mod ext {
71 /// RESET line to the module.
72 pub const RESET: u8 = 3;
73 /// Interrupt from the module.
74 pub const INT: u8 = 4;
75 /// BUSY from the module.
76 pub const BUSY: u8 = 6;
77 /// UART TX from the ESP32 (header pin labelled GPS-RX).
78 pub const UART_TX: u8 = 13;
79 /// UART RX into the ESP32 (header pin labelled GPS-TX).
80 pub const UART_RX: u8 = 15;
81}
82
83/// Grove HY2.0-4P port (5 V switchable to input).
84pub mod grove {
85 /// Yellow wire. M5Unified uses it as external-I²C SCL.
86 pub const G1: u8 = 1;
87 /// White wire. M5Unified uses it as external-I²C SDA.
88 pub const G2: u8 = 2;
89}
90
91/// WS2812-class RGB LED data. Powered only while [`lcd::BL`] is high.
92pub const RGB_LED: u8 = 21;
93/// IR LED, driven directly through 22 Ω (no carrier hardware).
94pub const IR_TX: u8 = 44;
95/// Battery voltage through a 100 k / 100 k divider (×2), ADC1.
96pub const BATTERY_ADC: u8 = 10;
97/// G0 button; hold at power-on for download mode. Active low.
98pub const BUTTON_G0: u8 = 0;
99/// Spare line on the internal 8-pin FPC connector.
100pub const FPC_IO1: u8 = 7;