imrishabh18/rp2040-motor-controller

An RP2040-based NEMA17 stepper-motor controller with USB-C programming and PD motor-power negotiation, DRV8825 dual H-bridge drive, current/temperature telemetry, protected power filtering, status RGB LED, buzzer alarm, and optional magnetic encoder.

Version
1.0.41
License
unset
Stars
3

tests/pd-voltage-control.test.tsx

import {expect, test} from 'bun:test';
import {Circuit} from 'tscircuit';
import Board from '../index.circuit';
import {assertPdVoltageControl} from './helpers/assertPdVoltageControl';

test('PD selection uses the correct physical pins and isolates the USB power domains', async () => {
  const c = new Circuit({platform:{pcbDisabled:true}});
  c.add(<Board routingDisabled/>); await c.renderUntilSettled();
  const j = c.getCircuitJson();
  expect(assertPdVoltageControl(j).status).toBe('pass');
  const disconnected = structuredClone(j).filter(e => !(e.type === 'source_trace' && e.name === 'PD_CFG1_OUTPUT'));
  expect(() => assertPdVoltageControl(disconnected)).toThrow();
  const shorted = structuredClone(j) as any[];
  const cfg = shorted.find(e => e.type === 'source_trace' && e.name === 'PD_CFG1_OUTPUT');
  const mcu = shorted.find(e => e.type === 'source_trace' && e.name === 'PD_CFG1_CONTROL');
  cfg.connected_source_port_ids.push(mcu.connected_source_port_ids[0]);
  expect(() => assertPdVoltageControl(shorted)).toThrow();
}, 60000);