astra-abse/t113-s3

Allwinner T113-S3 / JLCPCB C5197687: native saved fanout, LCD top, storage right, 127 perimeter exits, 30 decoupling capacitors, connected GND planes; clean DRC and shorts, all 29 vias connected.

Version
1.2.0
License
MIT
Stars
0

src/terminals.ts

import { pins } from "./pins";

/** Functional aliases for the mux choices in T113-S3 datasheet v1.6, table 4-3.
 * Selecting a routing profile does not configure the processor's pin mux.
 */
export const TERMINAL_ALIASES = {
	LCD_D2: "PD0",
	LCD_D3: "PD1",
	LCD_D4: "PD2",
	LCD_D5: "PD3",
	LCD_D6: "PD4",
	LCD_D7: "PD5",
	LCD_D10: "PD6",
	LCD_D11: "PD7",
	LCD_D12: "PD8",
	LCD_D13: "PD9",
	LCD_D14: "PD10",
	LCD_D15: "PD11",
	LCD_D18: "PD12",
	LCD_D19: "PD13",
	LCD_D20: "PD14",
	LCD_D21: "PD15",
	LCD_D22: "PD16",
	LCD_D23: "PD17",
	LCD_CLK: "PD18",
	LCD_DE: "PD19",
	LCD_HSYNC: "PD20",
	LCD_VSYNC: "PD21",
	SPI0_CLK: "PC2",
	SPI0_CS: "PC3",
	SPI0_MOSI: "PC4",
	SPI0_MISO: "PC5",
	SPI0_WP: "PC6",
	SPI0_HOLD: "PC7",
	SDMMC0_D1: "PF0",
	SDMMC0_D0: "PF1",
	SDMMC0_CLK: "PF2",
	SDMMC0_CMD: "PF3",
	SDMMC0_D3: "PF4",
	SDMMC0_D2: "PF5",
	GND: "EPAD",
} as const;
export type TerminalName =
	| Exclude<(typeof pins)[number]["label"], "NC0">
	| keyof typeof TERMINAL_ALIASES;
export function resolveTerminal(terminal: string): string {
	if (terminal in TERMINAL_ALIASES)
		return TERMINAL_ALIASES[terminal as keyof typeof TERMINAL_ALIASES];
	if (pins.some((pin) => pin.label === terminal && pin.pin !== 106))
		return terminal;
	throw new Error(`Unknown T113-S3 terminal '${terminal}'`);
}