Skip to content

224 USB Device Port ​

224-usb-device-port.mc describes a USB Micro-B device-side port.

J_USB is the physical connector. Pin 1 is VBUS_5V, pin 5 is GND, pin 2 is the USB data-minus line, and pin 3 is the data-plus line. USB_DEVICE represents the device controller. The USB_DM and USB_DP lines connect from the connector to U_DEV.DATA.DM and U_DEV.DATA.DP, and each line also has an ESD diode to ground. C_VBUS bypasses the USB VBUS rail.

The binding USB.DATA(Peripheral) gives the controller the device-side role defined by the current USB interface library; the opposite role is Host.

Parse 224-usb-device-port.mc:

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 22-interface-recipes/224-usb-device-port.mc --lib mcode --pass1 --pass2

Generate HTML for 224-usb-device-port.mc:

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 22-interface-recipes/224-usb-device-port.mc --lib mcode --viz -o 22-interface-recipes/224-usb-device-port.html

Source ​

text
// Example: USB Device Port
// Goal: Model a USB device connector and its signals.
// Library focus: USB, DIO.ESD, CAP, DC.

component USB_DEVICE
{
    name = "USB Device Controller"
    pins = [
        // USB.DATA b3810 face: first lane positive (1=D+, 2=D-)
        [1,2] = DATA{DP, DM}::USB.DATA(DEVICE)
        3 = VBUS
        4 = GND
    ]
}

module main
{
    io GND
    io USB_DM
    io USB_DP
    io VBUS_5V

    USB.SOCK_MICROB J_USB
    USB_DEVICE U_DEV
    DIO.ESD D_DM(5V)    // partno "USBLC6" is BOM metadata; only core electrical formals are constructor params
    DIO.ESD D_DP(5V)
    CAP.MLCC C_VBUS(1uF, 10V)

    J_USB.1 -> VBUS_5V
    J_USB.5 -> GND

    VBUS_5V -> U_DEV.VBUS
    U_DEV.GND -> GND
    VBUS_5V -> C_VBUS -> GND

    J_USB.2 -> USB_DM
    J_USB.3 -> USB_DP
    USB_DM -> U_DEV.DATA.DM
    USB_DP -> U_DEV.DATA.DP

    USB_DM -> D_DM.K
    USB_DP -> D_DP.K
    D_DM.A -> GND
    D_DP.A -> GND
}

MCode Bench is the public face of the MCode stack. Closed capabilities are served through the MCode gateway.