Skip to main content

Crate usbsid_pico

Crate usbsid_pico 

Source
Expand description

§usbsid-pico

§Quick start

use usbsid_pico::UsbSid;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut sid = UsbSid::new();
    sid.init(/* threaded */ true, /* with_cycles */ true)?;

    // Write register 0x01 with value 0x01
    sid.write_ring_cycled(0x01, 0x01, 0xFFFF)?;

    // Read a SID register (synchronous)
    let val = sid.single_read(0x1B)?;
    println!("OSC3 random: 0x{:02X}", val);

    // Driver is automatically closed on drop
    Ok(())
}

§C FFI

The crate also exposes a C-compatible interface through the ffi module so that existing C applications can link against this library as a drop-in replacement for the original USBSIDInterface.h/.cpp.

§Features

  • debug_memory – enable SID-memory tracking (mirrors DEBUG_USBSID_MEMORY from the C++ driver).

Re-exports§

pub use constants::sid_address;
pub use constants::ClockSpeed;
pub use constants::RasterRate;
pub use constants::RefreshRate;
pub use device::UsbSid;
pub use error::Result;
pub use error::UsbSidError;

Modules§

constants
Constants, protocol opcodes, and clock/timing definitions ported from USBSID.h.
device
Core driver struct and implementation.
error
Error types for the USBSID-Pico driver.
ffi
Usage from C
ringbuffer
Fixed-size, single-producer / single-consumer ring buffer used by the background writer thread.
transport
Transport backends for communicating with the USBSID-Pico.