seveibar/am3352-dev-board

A 324-ball TI AM3352 ARM processor with DDR3, LCD, USB, Ethernet, storage, serial, analog, clock, reset, power, and JTAG interfaces, paired with configurable JST-GH board connectors and constrained PCB routing.

Version
1.0.2
License
unset
Stars
0

design/replay-router.ts

import copper from './routed-copper.json'
// Replay copper produced by Freerouting, through tscircuit's documented custom-router interface.
// tscircuit still runs its ordinary copper connectivity and DRC checks on these results.
export async function replayRouter(input:any) {
 const handlers:Record<string,(event:any)=>void>={}
 return {
  stop(){},
  on(event:string,fn:(event:any)=>void){handlers[event]=fn;return this},
  start(){
   try {
    const traces:any[]=[]
    for (const connection of input.connections) {
     const key=connection.name as keyof typeof copper.nets
     const routes=copper.nets[key]
     if (!routes?.length) throw new Error(`No saved copper for ${connection.name}; route this phase before building`)
     const expected=copper.endpoints[key as keyof typeof copper.endpoints]
     for (const p of connection.pointsToConnect) {
      if (!expected.some(([x,y])=>Math.hypot(p.x-x,p.y-y)<0.002)) throw new Error(`Placement changed for ${connection.name}; reroute before building`)
     }
     for (let i=0;i<routes.length;i++) traces.push({type:'pcb_trace',pcb_trace_id:`fr_${key}_${i}`,connection_name:connection.name,source_trace_id:copper.sourceTraceIds[key as keyof typeof copper.sourceTraceIds],route:routes[i]})
    }
    handlers.complete?.({traces})
   } catch(error){handlers.error?.({error})}
  },
 }
}