pixalynx/edge-connector

Configures USB-A, Micro-USB, and USB-C PCB-edge connectors with exposed copper contacts and automatically shaped, positioned board tongues.

Version
1.0.0
License
GPL-3.0-only
Stars
0

UsbCEdgeConnector.tsx

// Adapted from vasya-zh/PCB-Edge-USB-connector-KiCad-library; see NOTICE.md.
import type { ChipProps } from "tscircuit"
import { EdgeContactFootprint } from "./EdgeContactFootprint"
import { usbCEdgePads, usbCEdgeProfile } from "./usbCGeometry"

// Each physical contact stays independent; aliases never short repeated signals.
export const usbCEdgeConnectorPinLabels = {
  pin1: ["A1", "GND_A1"],
  pin2: ["A2", "TX1_P"],
  pin3: ["A3", "TX1_N"],
  pin4: ["A4", "VBUS_A4"],
  pin5: ["A5", "CC1"],
  pin6: ["A6", "DP_A6"],
  pin7: ["A7", "DM_A7"],
  pin8: ["A8", "SBU1"],
  pin9: ["A9", "VBUS_A9"],
  pin10: ["A10", "RX2_N"],
  pin11: ["A11", "RX2_P"],
  pin12: ["A12", "GND_A12"],
  pin13: ["B1", "GND_B1"],
  pin14: ["B2", "TX2_P"],
  pin15: ["B3", "TX2_N"],
  pin16: ["B4", "VBUS_B4"],
  pin17: ["B5", "CC2"],
  pin18: ["B6", "DP_B6"],
  pin19: ["B7", "DM_B7"],
  pin20: ["B8", "SBU2"],
  pin21: ["B9", "VBUS_B9"],
  pin22: ["B10", "RX1_N"],
  pin23: ["B11", "RX1_P"],
  pin24: ["B12", "GND_B12"],
} as const

export const usbCEdgeConnectorGeometry = {
  boardThickness: 0.6,
  tipY: 2.55,
  // Open edge profile from left to right, including the mating reliefs.
  edgeProfile: usbCEdgeProfile,
} as const

export type UsbCEdgeConnectorProps = Omit<
  ChipProps<typeof usbCEdgeConnectorPinLabels>,
  "footprint" | "pinLabels" | "layer" | "cadModel" | "children"
>

/** 24-contact, shell-less USB-C receptacle tongue. A on top, B on bottom. */
export function UsbCEdgeConnector(props: UsbCEdgeConnectorProps) {
  return (
    <connector
      schWidth={1.7}
      schHeight={2.6}
      schPinArrangement={{
        leftSide: { pins: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], direction: "top-to-bottom" },
        rightSide: { pins: [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], direction: "top-to-bottom" },
      }}
      {...props}
      // An explicit component layer overrides every pad layer in this version
      // of tscircuit. Leave it unset to preserve A/top and B/bottom contacts.
      layer={undefined}
      doNotPlace
      pinLabels={usbCEdgeConnectorPinLabels}
      footprint={<EdgeContactFootprint pads={usbCEdgePads} />}
    />
  )
}

export default UsbCEdgeConnector