astra/f1c100s

This code defines and renders a four-layer, top-mounted F1C100S module with detailed pin assignments, schematic annotations, and layout profiles, facilitating design, validation, and routing of the hardware including support for decoupling capacitors, crystal oscillators, and external connectors.

Version
0.11.0
License
unset
Stars
0

src/pin-map.ts

/** Physical pin numbers from Allwinner F1C100s datasheet Rev 1.0 pp.12-15.
 * Fixed allocation: RGB666, SPI0/PC, SDMMC0/PF, UART0/PE0:1, TWI0/PE11:12.
 */
export const PIN_NETS: Record<number, string> = {
	1: "HPL",
	2: "HPCOM",
	3: "HPCOM",
	4: "VCC_HP",
	5: "VCC_IO",
	20: "VCC_IO",
	22: "VDD_CORE",
	30: "VCC_DRAM",
	31: "VCC_DRAM",
	32: "VCC_DRAM",
	33: "SVREF",
	34: "VCC_DRAM",
	35: "VDD_CORE",
	36: "VCC_DRAM",
	37: "TWI0_SDA",
	38: "TWI0_SCL",
	39: "PE10",
	40: "PE9",
	41: "PE8",
	42: "PE7",
	43: "PE6",
	44: "PE5",
	45: "PE4",
	46: "PE3",
	47: "PE2",
	48: "UART0_TX",
	49: "UART0_RX",
	50: "VCC_IO",
	51: "HOSCI",
	52: "HOSCO",
	53: "SDMMC0_D2",
	54: "SDMMC0_D3",
	55: "SDMMC0_CMD",
	56: "SDMMC0_CLK",
	57: "SDMMC0_D0",
	58: "SDMMC0_D1",
	59: "SPI0_CLK",
	60: "SPI0_CS",
	61: "SPI0_MISO",
	62: "SPI0_MOSI",
	63: "TPY2",
	64: "TPY1",
	65: "TPX2",
	66: "TPX1",
	67: "VCC_USB",
	68: "USB_DM",
	69: "USB_DP",
	70: "RESET",
	71: "VDD_CORE",
	72: "TVOUT",
	73: "VCC_TV",
	74: "GND",
	75: "TV_VRN",
	76: "TV_VRP",
	77: "TVIN1",
	78: "TVIN0",
	79: "LRADC0",
	80: "AVCC",
	81: "VRA1",
	82: "GND",
	83: "VRA2",
	84: "FMINL",
	85: "FMINR",
	86: "LINEIN",
	87: "MICIN",
	88: "HPR",
	89: "GND",
};
const lcdData = [
	2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 23,
];
const pdPins = [
	6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 23, 24, 25,
];
pdPins.forEach((pin, i) => {
	PIN_NETS[pin] = `LCD_D${lcdData[i]}`;
});
Object.assign(PIN_NETS, {
	26: "LCD_CLK",
	27: "LCD_DE",
	28: "LCD_HSYNC",
	29: "LCD_VSYNC",
});
export const RAILS = [
	"VCC_HP",
	"VCC_IO",
	"VDD_CORE",
	"VCC_DRAM",
	"VCC_USB",
	"VCC_TV",
	"AVCC",
] as const;
export const INTERNAL_NETS = new Set([
	"HOSCI",
	"HOSCO",
	"SVREF",
	"VRA1",
	"VRA2",
	"TV_VRN",
	"TV_VRP",
]);
export const EXTERNAL_NETS = [...new Set(Object.values(PIN_NETS))].filter(
	(n) => !INTERNAL_NETS.has(n),
);

/** Imported footprint at zero rotation has pin 1 on the bottom-left. */
export function pinPosition(pin: number, rotation: number) {
	let x = 0,
		y = 0;
	if (pin <= 22) {
		x = -4.2 + (pin - 1) * 0.4;
		y = -5;
	} else if (pin <= 44) {
		x = 5;
		y = -4.2 + (pin - 23) * 0.4;
	} else if (pin <= 66) {
		x = 4.2 - (pin - 45) * 0.4;
		y = 5;
	} else if (pin <= 88) {
		x = -5;
		y = 4.2 - (pin - 67) * 0.4;
	}
	const a = (rotation * Math.PI) / 180;
	return {
		x: Math.round((x * Math.cos(a) - y * Math.sin(a)) * 1e6) / 1e6,
		y: Math.round((x * Math.sin(a) + y * Math.cos(a)) * 1e6) / 1e6,
	};
}