MustafaMulla29/usb-pd-motherboard
4-layer USB-C PD hub motherboard with 20 V USB-C input, Linux T113-S3 computer, CH338F USB hub, four individually controlled 5–20 V PD outputs, USB data/camera ports, regulated rails, and hardware watchdog/E-stop safety interlock.
- Version
- 1.0.24
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone MustafaMulla29/usb-pd-motherboard # download the package files into ./usb-pd-motherboard
tsci add MustafaMulla29/usb-pd-motherboard # add it to your project as @tsci/MustafaMulla29.usb-pd-motherboardIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
lib/sch-pins.ts
/**
* Where each chip's pins are drawn on the schematic, per chip type.
* Grouped by what the pins do, the way the chip's datasheet draws its application circuit: inputs and control on
* the left, outputs on the right, supply pins on top, ground and "set by a resistor / capacitor" pins underneath.
* (The default is package order: pin 1.. down the left, the rest up the right, which scatters related pins.)
* tools/sch-layout.py then puts every resistor / capacitor beside the pin it belongs to.
*/
type Sides = { left?: string[]; right?: string[]; top?: string[]; bottom?: string[] }
const PITCH = 0.2 // tscircuit's pin spacing
const labelRoom = (pins: string[]) => (pins.length ? Math.max(...pins.map((p) => p.length)) * 0.11 + 0.15 : 0.1)
const span = (a: string[], b: string[]) => Math.max(0.6, (Math.max(a.length, b.length) - 1) * PITCH + 0.4)
/** Pin sides plus, when pins are on the top or bottom too, a box big enough that the pin names do not overlap. */
const arrange = ({ left = [], right = [], top = [], bottom = [] }: Sides) => ({
schPinArrangement: {
...(left.length ? { leftSide: { direction: "top-to-bottom" as const, pins: left } } : {}),
...(right.length ? { rightSide: { direction: "top-to-bottom" as const, pins: right } } : {}),
...(top.length ? { topSide: { direction: "left-to-right" as const, pins: top } } : {}),
...(bottom.length ? { bottomSide: { direction: "left-to-right" as const, pins: bottom } } : {}),
},
...(top.length || bottom.length ? {
schWidth: Math.round((span(top, bottom) + labelRoom(left) + labelRoom(right)) * 10) / 10,
schHeight: Math.round((span(left, right) + labelRoom(top) + labelRoom(bottom)) * 10) / 10,
} : {}),
})
const seq = (prefix: string, from: number, to: number) => Array.from({ length: to - from + 1 }, (_, k) => `${prefix}${from + k}`)
const USBC_SIGNALS = ["VBUS1", "VBUS2", "CC1", "CC2", "DP1", "DN1", "DP2", "DN2", "SBU1", "SBU2"]
const USBC_GROUND = ["GND1", "GND2", "SHELL"]
export const SCH_PINS = {
// TI TPS55288: input and the gate drives of the two input-side transistors on the left, the two switch nodes
// (the coil sits between them) on top, output and its current sense on the right, set-up pins underneath.
TPS55288RPMR: arrange({
left: ["VIN", "EN", "SCL", "SDA", "DR1H", "DR1L"],
top: ["BOOT1", "SW1", "SW21", "SW22", "BOOT2"],
right: ["VOUT1", "VOUT2", "ISP", "ISN", "FB", "CDC"],
bottom: ["VCC", "MODE", "FSW", "DITH", "ILIM", "COMP", "AGND", "PGND1", "PGND2"],
}),
// TI TPS25947 / TPS1663 eFuses: power in on the left, out on the right, set-up pins underneath.
TPS259470ARPWR: arrange({ left: ["IN", "EN", "OVLO"], right: ["OUT", "PG", "N_FLT"], bottom: ["ITIMER", "ILM", "DVDT", "GND"] }),
TPS16630PWPR: arrange({
left: ["IN1", "IN2", "IN3", "P_IN", "UVLO", "OVP", "N_SHDN", "MODE"],
right: ["OUT1", "OUT2", "OUT3", "PGOOD", "N_FLT"],
bottom: ["dVdT", "ILIM", "IMON", "GND", "EP", "N_C1", "N_C2", "N_C3"],
}),
// WCH CH338F: the computer side, clock, reset and set-up pins on the left, the seven ports on the right.
// (its box size is set per part in data/schematic-placements.json)
CH338F: { schPinArrangement: arrange({
left: ["DPU", "DMU", "XI", "XO", "N_RESET", "N_PWREN", "N_OVCUR", "CFG", "SMBDAT", "SMBCLK", "CC1", "CC2", "CC3", "CC3_CTL"],
right: ["DP1", "DM1", "DP2", "DM2", "DP5", "DM5", "DP4", "DM4", "DP3", "DM3", "DP6", "DM6", "DP7", "DM7"],
top: ["VDD331", "VDD332", "AVDDK", "DVDDK"],
bottom: ["EP"],
}).schPinArrangement },
// TI TPD6S300: system side on the left, connector side on the right.
TPD6S300RUKR: arrange({
left: ["CC1", "CC2", "SUB1", "SBU2", "D1", "D2", "N_FLT"],
right: ["C_CC1", "C_CC2", "RPD_G1", "RPD_G2", "C_SUB1", "C_SUB2"],
top: ["VPWR", "VBIAS"],
bottom: ["GND1", "GND2", "GND3", "PAD", "N_C1", "N_C2"],
}),
TPS54560BDDAR: arrange({ left: ["VIN", "EN", "RT", "COMP"], right: ["BOOT", "SW", "FB"], bottom: ["GND", "EP"] }),
TLV62569DBVR: arrange({ left: ["VIN", "EN"], right: ["SW", "FB"], bottom: ["GND"] }),
AP2112K_3_3TRG1: arrange({ left: ["VIN", "EN"], right: ["VOUT", "NC"], bottom: ["GND"] }),
XC6206P182MR: arrange({ left: ["VIN"], right: ["VOUT"], bottom: ["VSS"] }),
SY6280AAC: arrange({ left: ["IN", "EN"], right: ["OUT"], bottom: ["ISET", "GND"] }),
CH224Q: arrange({ left: ["VBUS", "CC1", "CC2", "DP", "DM"], right: ["PG", "CFG1", "CFG2", "CFG3"], top: ["VHV"], bottom: ["EP"] }),
// Logic: inputs left, output right, supply on top, ground underneath (set on top, reset underneath for the latch).
SN74LVC1G08DCKR: arrange({ left: ["A", "B"], right: ["Y"], top: ["VCC"], bottom: ["GND"] }),
SN74LVC1G11DBVR: arrange({ left: ["A", "B", "C"], right: ["Y"], top: ["VCC"], bottom: ["GND"] }),
A_74LVC1G74DP_Q100H: arrange({ left: ["D", "CP"], right: ["Q", "N_Q"], top: ["S_D", "VCC"], bottom: ["R_D", "GND"] }),
TPS3823_33DBVR: arrange({ left: ["VDD", "N_MR", "WDI"], right: ["N_RESET"], bottom: ["GND"] }),
TLV803SDBZR: arrange({ left: ["VDD"], right: ["N_RESET"], bottom: ["GND"] }),
// ST USBLC6-2: each data line goes in on the left and out on the right (pins 1 -> 6 and 3 -> 4).
USBLC6_2SC6: arrange({ left: ["IO1A", "IO2A"], right: ["IO1B", "IO2B"], top: ["VBUS"], bottom: ["GND"] }),
TF_01A: arrange({
left: ["DAT2_RSV", "CDDAT3_CS", "CMD_DI", "CLK_SCLK", "DAT0_D0", "DAT1_RSV", "CD"],
top: ["VDD"],
bottom: ["VSS", "GND1", "GND2", "GND3", "GND4"],
}),
HSE24M: arrange({ left: ["XIN"], right: ["XOUT"], bottom: ["GND1", "GND2"] }),
// USB-C sockets: an input socket has its pins on the right, an output socket on the left (signal runs left to right).
USBC_OUT: arrange({ left: USBC_SIGNALS, bottom: USBC_GROUND }),
USBC_IN: arrange({ right: USBC_SIGNALS, bottom: USBC_GROUND }),
// STM32G0B1 (48 pins): supply on top, ground underneath, reset / clock pins and port A on the left, ports B-D on the right.
STM32G0B1CBT6: arrange({
top: ["VBAT", "VREF_POS", "VDD"],
bottom: ["VSS"],
left: ["PF2_NRST", "PF0_OSC_IN", "PF1_OSC_OUT", "PC14_OSC32_IN", "PC15_OSC32_OUT", "PC13",
...seq("PA", 0, 10), "PA11_PA9_", "PA12_PA10_", "PA13", "PA14_BOOT0", "PA15"],
right: [...seq("PB", 0, 15), "PC6", "PC7", ...seq("PD", 0, 3)],
}),
// Allwinner T113-S3 (128 pins + pad): supplies on top, ground underneath; reset, clocks, USB, SD card (PF) and the
// PG / PB / PC ports on the left; the PD / PE ports and the unused audio / video pins on the right.
T113_S3: arrange({
top: ["VDD_CORE0", "VDD_CORE1", "VDD_SYS0", "VDD_SYS1", "VDD_SYS2", "VCC_DRAM0", "VCC_DRAM1", "VDD18_DRAM", "VCC_IO",
"VCC_PD", "VCC_PE", "VCC_PG", "VCC_PLL", "VCC_LVDS", "VCC_RTC", "VCC_TVOUT", "VCC_TVIN", "AVCC", "HPVCC",
"LDO_IN", "LDOA_OUT", "LDOB_OUT"],
bottom: ["AGND", "EPAD"],
left: ["RESET", "DXIN", "DXOUT", "X32KIN", "X32KOUT", "REFCLK_OUT", "DZQ", "VRA1", "VRA2",
"USB0_DP", "USB0_DM", "USB1_DP", "USB1_DM", ...seq("PF", 0, 6), ...seq("PG", 0, 15), ...seq("PB", 2, 7), ...seq("PC", 2, 7)],
right: [...seq("PD", 0, 22), ...seq("PE", 0, 13), "MICIN3P", "MICIN3N", "FMINR", "FMINL", "LINEINR", "LINEINL",
"HPOUTR", "HPOUTL", "HPOUTFB", "GPADC0", "TP_X1", "TP_X2", "TP_Y1", "TP_Y2", "TVOUT0", "TVIN0", "TVIN1",
"TVIN_VRP", "TVIN_VRN", "NC0"],
}),
}