seveibar/pedometer
This hardware setup integrates a Type-C connector, battery, display, and RF antenna connected through a microcontroller, USB interface, charging and fuel gauge ICs, along with associated passive components, enabling power management, data communication, and signal processing.
- Version
- 0.4.4
- License
- unset
- Stars
- 1
scripts/check-design.mjs
import fs from 'node:fs'
import assert from 'node:assert/strict'
const j=JSON.parse(fs.readFileSync('dist/index/circuit.json','utf8'))
const net=name=>{const n=j.find(e=>e.type==='source_net'&&e.name===name);assert(n,`Missing net ${name}`);return n.subcircuit_connectivity_map_key}
const port=(ref,pin)=>{const c=j.find(e=>e.type==='source_component'&&e.name===ref);assert(c,`Missing component ${ref}`);const p=j.find(e=>e.type==='source_port'&&e.source_component_id===c.source_component_id&&(e.name===pin||e.port_hints?.includes(pin)));assert(p,`Missing port ${ref}.${pin}`);return p.subcircuit_connectivity_map_key}
for(const [ref,pin,n] of [
['U1_MCU','VDDS1','SYS_VDD'],['U1_MCU','VDDS2','SYS_VDD'],['U1_MCU','VDDS3','SYS_VDD'],
['U2_CHARGER','IN','VBUS'],['U2_CHARGER','BAT1','VSYS'],['U2_CHARGER','BAT2','VSYS'],['U2_CHARGER','VINLS','PMID'],['U2_CHARGER','LSLDO','SYS_VDD'],['U2_CHARGER','VIO','SYS_VDD'],
['U3_GAUGE','BAT','BAT_CELL'],['U3_GAUGE','SRX','VSYS'],['J2_BATTERY','BATTERY_POS','BAT_CELL'],
['R7_LP_BOOT_PD','pin2','GND'],['U4_ACCEL','CSB','SYS_VDD'],['U4_ACCEL','SDO','GND'],
['J3_DISPLAY','BUS_CLK','DISP_SCLK'],['J3_DISPLAY','BUS_DATA','DISP_MOSI'],['J3_DISPLAY','VDD','DISP_VDD'],
['J4_SWD','pin1','SWDIO'],['J4_SWD','pin2','SWDCK'],['J4_SWD','pin3','RESET_N'],['J4_SWD','pin4','GND'],['J4_SWD','pin5','SYS_VDD'],
['U1_MCU','DIO16_SWDIO','SWDIO'],['U1_MCU','DIO17_SWDCK','SWDCK'],['U1_MCU','RSTN','RESET_N'],
['Q1_DISPLAY_SWITCH','S','SYS_VDD'],['Q1_DISPLAY_SWITCH','D','DISP_VDD']
])assert.equal(port(ref,pin),net(n),`${ref}.${pin} must connect to ${n}`)
for(const [a,b] of [['BAT_CELL','VSYS'],['SYS_VDD','PMID'],['SYS_VDD','DISP_VDD'],['DISP_SCLK','I2C_SCL'],['DISP_MOSI','I2C_SDA']])assert.notEqual(net(a),net(b),`${a} shorted to ${b}`)
assert.notEqual(port('C24_RF_DC_BLOCK','pin1'),port('C24_RF_DC_BLOCK','pin2'),'DC block must separate RF copper nets')
assert(!j.some(e=>e.type==='source_component'&&/^TP[1-5]_/.test(e.name)),'Programming pads must be replaced by J4')
// Regression: breakout discovery with delayed React symbols must not duplicate pins.
for (const [ref,count] of [['D1_VBUS_TVS',2],['Q1_DISPLAY_SWITCH',3],['Y1_48MHZ',4],['ANT1',2]]) {
const component=j.find(e=>e.type==='source_component'&&e.name===ref)
const ports=j.filter(e=>e.type==='source_port'&&e.source_component_id===component.source_component_id)
assert.equal(ports.length,count,`${ref}: unexpected or duplicate source ports`)
assert.equal(new Set(ports.map(p=>p.pin_number)).size,count,`${ref}: duplicate pin number`)
}
console.log('Design checks passed: power path, display bus isolation, sensor straps, LP pull-down and RF DC-block topology.')