Skip to main content

Module gs_usb

Module gs_usb 

Source
Expand description

USB GS_USB class — CAN bus adapter protocol.

Implements the Geschwister Schneider / candleLight USB-CAN protocol used by the Linux gs_usb driver (drivers/net/can/usb/gs_usb.c).

§Protocol overview

  • Interface class: vendor-specific (0xFF).
  • Bulk IN / OUT endpoints carry GsHostFrame packets.
  • Vendor control transfers handle configuration (bit timing, mode, etc.).

§Example

ⓘ
use my_hal_usb::{UsbBusAllocator, UsbDeviceBuilder};
use my_hal_usb::class::gs_usb::GsUsbClass;
use my_hal_usb::MyBus;

let alloc = UsbBusAllocator::new(MyBus::new(/* peripheral */));
let mut gs_usb = GsUsbClass::new(&alloc);
let mut dev = UsbDeviceBuilder::new(&alloc, 0x1D50, 0x606F)
    .product("candleLight RP2350")
    .build();

loop {
    if dev.poll(&mut [&mut gs_usb]) {
        // Handle CAN frames via gs_usb.try_recv() / gs_usb.try_send()
    }
}

Modules§

gs_can_flag
Per-frame flags in GsCanFrame (same bits as canfd_frame.flags).
gs_can_mode
CAN controller operational mode (GS_USB_BREQ_MODE first word).
gs_can_mode_flags
Mode flags for the second word of a GS_USB_BREQ_MODE request.
gs_usb_breq
GS_USB vendor control request codes (bRequest).

Structs§

GsDeviceBitTiming
Host→device request to set CAN bit timing.
GsDeviceBtConst
Response to GS_USB_BREQ_BT_CONST — CAN bit-timing constraints.
GsDeviceConfig
Response to GS_USB_BREQ_DEVICE_CONFIG.
GsHostFrame
A CAN frame as transmitted over USB bulk endpoints.
GsUsbClass
USB GS_USB class implementing the candleLight / Linux gs_usb protocol.