usbsid-pico
Rust driver for the USBSID-Pico board — a Raspberry Pi Pico (RP2040 / RP2350) based device for interfacing one or more MOS SID chips (6581/8580) and hardware SID emulators over USB.
Features
- Synchronous and asynchronous (threaded) write modes
- Ring-buffer backed background writer for low-latency streaming
- Cycle-accurate writes for emulator integration
- Up to 4 SID chips (stereo / 3SID / 4SID)
- Clock rate configuration (PAL / NTSC)
- C FFI layer for integration with existing C/C++ applications
- Cross-platform: Linux, macOS, Windows
Requirements
- Rust 1.70+ (2021 edition)
- libusb 1.0 development headers:
| Platform | Install |
|---|---|
| Debian/Ubuntu | sudo apt install libusb-1.0-0-dev |
| Fedora | sudo dnf install libusb1-devel |
| macOS | brew install libusb |
| Windows | vcpkg or pre-built libs |
Quick start
use UsbSid;
Examples
Run with a connected USBSID-Pico:
# Simple register test
# Generate a tone
# Play a .sid file (mono)
# Play a .sid file (2SID/3SID auto-detected, or force stereo mirror)
On macOS you may need sudo for USB access (see SIGNING.md).
Architecture
| Module | Description |
|---|---|
constants |
Protocol opcodes, USB IDs, clock/timing tables, SID address helpers |
device |
Core UsbSid struct — USB setup, I/O, threading, timing |
ringbuffer |
Lock-free SPSC ring buffer for the writer thread |
error |
UsbSidError enum and Result alias |
ffi |
extern "C" functions for C/C++ consumers |
Write modes
| Mode | Function | Use case |
|---|---|---|
| Synchronous | single_write / single_read |
Direct bulk transfers |
| Async direct | write / write_cycled |
Non-threaded bulk writes |
| Async threaded | write_ring / write_ring_cycled |
Background thread drains ring buffer |
USBSID-Pico register layout
Each SID chip occupies 32 registers (0x20 bytes):
| SID | USBSID registers |
|---|---|
| SID1 | $00–$1F |
| SID2 | $20–$3F |
| SID3 | $40–$5F |
| SID4 | $60–$7F |
C FFI
The crate exposes a C-compatible interface. Build as a shared library:
[]
= ["cdylib", "rlib"]
# → target/release/libusbsid_pico.{so,dylib,dll}
To auto-generate the C header:
License
Licensed under either of
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Acknowledgments
The USBSID-Pico hardware and firmware are created by LouDnl. This driver is an independent implementation targeting the USBSID-Pico USB protocol.