# USB-C power input ## What this builds The part of a circuit board that takes 5 V from a USB-C socket: the socket, the two resistors a charger looks for before it supplies power, protection, and a way to learn how much current is on offer. It comes as a circuit with a parts list, and a script that checks the circuit against this spec. The classic mistake is to leave out the resistors on the CC pins, or to share one between both. Such a board works from an old USB-A charger and stays dead on a USB-C one. R2 and its check exist for that. Read `spekkr.inputs.json` first. The board draws at most `max_current` amps. `detect_current`, `data_lines` and `power_led` add parts. `tool` says how the circuit is written. ## Out of scope - USB Power Delivery and anything above 5 V. - Supplying power to another device. - The board's layout. `design.md` lists what the layout must respect. - Certification. This is a design to review before it is made. The checks catch the known mistakes, not every mistake. ## Requirements Each requirement has an id. Checks name the id they cover. ### R1. The socket - A USB Type-C receptacle. With `data_lines` off, a 6-pin power-only part is enough. With it on, a 16-pin USB 2.0 part. - Every VBUS pin is on one net, `VBUS_IN`. Every GND pin and the shell are on `GND`. - `CC1` and `CC2` are two separate nets. Accept when: the netlist has `VBUS_IN`, `GND`, `CC1` and `CC2`, every VBUS and GND pin of the socket is on its net, and `CC1` and `CC2` are different nets. ### R2. Ask for power - `CC1` has its own resistor of 5.1 kilohms, 1%, to `GND`. So has `CC2`. They are two parts. - Nothing else connects `CC1` or `CC2` to `GND`, to each other or to `VBUS_IN`. Accept when: the check finds exactly one 5.1 kilohm resistor from each CC net to `GND`, two different references, both marked 1% in the parts list. ### R3. Protect - A fuse that resets itself sits between `VBUS_IN` and `VBUS`, with a hold current of at least `max_current`. - A diode that clamps surges sits from `VBUS_IN` to `GND`, with a working voltage of at least 5.5 V. - Everything downstream takes its power from `VBUS`, never from `VBUS_IN`. Accept when: the only parts on `VBUS_IN` are the socket, the fuse and the clamp, and the parts list gives the fuse's hold current and the clamp's working voltage. ### R4. Do not ask for too much at once - The capacitors on `VBUS` together are at least 1 microfarad and at most 10. A charger sees them the moment the cable goes in. - Each is rated for 16 V or more. Accept when: the check adds up every capacitor on `VBUS` and finds a total from 1 to 10 microfarads. ### R5. How much is on offer Only if `detect_current` is on. - `CC1_SENSE` and `CC2_SENSE` each reach their CC net through a resistor of at least 10 kilohms, so that a fault on the cable cannot push a harmful current into whatever reads them. - A small function, in whatever language the person's firmware uses, turns the two voltages into what the source offers, by the table in `design.md`. Accept when: every row of the table of cases in `design.md` gives the answer listed. ### R6. Data Only if `data_lines` is on. - The socket's two D+ pins are joined on `USB_DP` and its two D- pins on `USB_DN`, so the plug works either way up. - A part made to protect USB data lines sits on both, next to the socket. With `data_lines` off, the socket has no data pins, or they are marked as not connected. Accept when: the check finds both pins of each pair on its net, or with the option off finds no net on any data pin. ### R7. Power light Only if `power_led` is on. - An LED and a resistor in series from `VBUS` to `GND`. The resistor is 1.5 kilohms, for about 2 mA through a red LED. Accept when: the check finds the pair, and the resistor's value. ### R8. What comes out - A header carries `VBUS` and `GND`, and `CC1_SENSE`, `CC2_SENSE`, `USB_DP` and `USB_DN` when they exist. - A parts list as CSV: reference, value, tolerance or rating, footprint, and what the part is for. - A netlist in KiCad's format, written by one command from the source. Accept when: the command writes the netlist and the parts list, and every part in one is in the other. ### R9. The check - One script reads the netlist and the parts list and checks R1 to R8. - It fails, with a message that names the requirement, when a CC resistor is removed, when both CC pins share one resistor, and when a 22 microfarad capacitor is put on `VBUS`. - The tool's own electrical rules check reports no errors. Accept when: the script passes on the circuit as built and fails on each of the three broken copies. ## Definition of done - Every acceptance check above runs from one command, and all pass at the person's inputs. - A README says how to make the netlist, how to run the check, and lists what a person must still review before ordering boards: the layout rules in `design.md` and the choice of each part.