0hmX/tps6521401vafr-pmic
This code models and visualizes the pin configuration and electrical attributes of the TPS6521401 voltage supervisor IC in a specific WQFN-HR package.
- Version
- 1.0.1
- License
- unset
- Stars
- 0
scripts/verify-pin-attributes.ts
// @ts-nocheck -- executed by Bun; the component package intentionally omits Bun globals.
export {}
const circuit = await Bun.file("dist/index/circuit.json").json()
const recognizedAttributes = [
"requires_power",
"provides_power",
"requires_ground",
"provides_ground",
"must_be_connected",
"capabilities",
"can_use_open_drain",
"is_using_open_drain",
"can_use_push_pull",
"needs_external_pullup",
"should_have_decoupling_capacitor",
] as const
const ports = circuit
.filter((element: any) => element.type === "source_port")
.filter((port: any) => port.pin_number != null)
.sort((a: any, b: any) => Number(a.pin_number) - Number(b.pin_number))
if (ports.length !== 24) {
throw new Error(`Expected 24 physical source ports, found ${ports.length}`)
}
for (const [index, port] of ports.entries()) {
const expectedPinNumber = index + 1
if (Number(port.pin_number) !== expectedPinNumber) {
throw new Error(
`Expected pin ${expectedPinNumber}, found pin ${port.pin_number}`,
)
}
if (!recognizedAttributes.some((attribute) => attribute in port)) {
throw new Error(`Pin ${expectedPinNumber} has no recognized pin attributes`)
}
}
const warnings = circuit.filter((element: any) =>
[
"source_component_pins_underspecified_warning",
"source_no_power_pin_defined_warning",
"source_no_ground_pin_defined_warning",
].includes(element.type),
)
if (warnings.length > 0) {
throw new Error(`Found ${warnings.length} pin-attribute warning(s)`)
}
console.log("Verified datasheet attributes on all 24 physical pins")