Buses
Three thin classes that tie bus pins together on the schematic: I2C, UART,
and USB. Construct one from the component's pins and include it with create() alongside the components.
I2C
An I2C bus — the SDA and SCL pins, tied together for the schematic.
Example first
i2c.ts
import { I2C } from '@typecad/pcb';
import { ATtiny85_20S } from './ATtiny85_20S';
let u1 = new ATtiny85_20S();
let i2c = new I2C(u1.PB0, u1.PB1); // SDA on PB0, SCL on PB1
typecad.create(u1, i2c);constructor new I2C(sda: Pin, scl: Pin): I2C
| Parameter | Type | Units / values | Description |
|---|---|---|---|
| sda | Pin | — | The data line pin |
| scl | Pin | — | The clock line pin |
UART
A UART serial port — receive and transmit pins, with optional hardware flow control.
Example first
uart.ts
import { UART } from '@typecad/pcb';
let serial = new UART(u1.PB2, u1.PB3); // rx, tx
let flow = new UART(u1.PB2, u1.PB3, u1.PB4, u1.PB5); // + rts, ctsconstructor new UART(rx: Pin, tx: Pin, rts?: Pin, cts?: Pin): UART
| Parameter | Type | Units / values | Description |
|---|---|---|---|
| rx | Pin | — | Receive pin |
| tx | Pin | — | Transmit pin |
| rts | Pin | — | Optional — request to send |
| cts | Pin | — | Optional — clear to send |
USB
A USB port — the D+ and D- differential pair.
Example first
usb.ts
import { USB } from '@typecad/pcb';
let usb = new USB(u1.DP, u1.DN); // USB D+ and D- pinsconstructor new USB(DP: Pin, DN: Pin): USB
| Parameter | Type | Units / values | Description |
|---|---|---|---|
| DP | Pin | — | USB D+ pin |
| DN | Pin | — | USB D- pin |