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

UsbAEdgeConnector.tsx

import type { ChipProps } from "tscircuit"
import { EdgeContactFootprint } from "./EdgeContactFootprint"

export const usbAEdgeConnectorPinLabels = {
  pin1: ["VBUS"],
  pin2: ["DM", "D_MINUS"],
  pin3: ["DP", "D_PLUS"],
  pin4: ["GND"],
} as const

/** Millimetres, relative to the component origin at pcbRotation={0}. */
export const usbAEdgeConnectorGeometry = {
  tongueWidth: 12,
  boardThickness: 2,
  tipY: 4.8,
  shoulderY: -3.9,
  edgeProfile: [
    { x: -6, y: -3.9 },
    { x: -6, y: 4.3 },
    { x: -5.5, y: 4.8 },
    { x: 5.5, y: 4.8 },
    { x: 6, y: 4.3 },
    { x: 6, y: -3.9 },
  ],
} as const

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

/**
 * USB 2.0 Type-A male PCB contacts. Top copper, insertion toward local +Y.
 * Looking down at the contacts with the tip up: VBUS, D-, D+, GND.
 * The host board must supply the tongue outline and thickness (see README).
 */
export function UsbAEdgeConnector(props: UsbAEdgeConnectorProps) {
  return (
    <connector
      schWidth={2.2}
      schHeight={1}
      schPinArrangement={{
        rightSide: { pins: [1, 2, 3, 4], direction: "top-to-bottom" },
      }}
      showPinAliases
      {...props}
      layer="top"
      doNotPlace
      pinLabels={usbAEdgeConnectorPinLabels}
      footprint={
        <EdgeContactFootprint
          solderMaskMargin={0.05}
          // USB-A-PCB reference geometry, rounded to 0.01 mm; see README.
          pads={[
            { pin: "pin1", x: -3.5, y: 0, width: 1.5, height: 7.5, layer: "top" },
            { pin: "pin2", x: -1, y: -0.5, width: 1, height: 6.5, layer: "top" },
            { pin: "pin3", x: 1, y: -0.5, width: 1, height: 6.5, layer: "top" },
            { pin: "pin4", x: 3.5, y: 0, width: 1.5, height: 7.5, layer: "top" },
          ]}
        />
      }
    />
  )
}

export default UsbAEdgeConnector