Skip to main content

Cap

Enum Cap 

Source
#[non_exhaustive]
pub enum Cap { CleanFrame, CommandProtocol, Ddr3, Adio, Grounding, TtlIn, SlotHealth, FieldUpdate, RateControl, }
Expand description

A capability bit. Branch on these, NEVER on a version comparison.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

CleanFrame

this build emits the format-2 self-describing frame on the declared stream endpoints

Gates: streams samples, digital; registers quiesce, run_samples, run_digital, lanes_samples, burst_samples, burst_digital, stream_status_samples, stream_status_digital.

§

CommandProtocol

the typed request/response command channel is live (firmware-dependent: it is baked into the same .bit)

Gates: commands sys.hello, power.status, power.up, adio.mode, adio.adc, adio.fb, adio.dout, gnd.eeprom.read, sys.claim, sys.release, sys.challenge, sys.unlock, id.boards.

§

Ddr3

the DDR3 pipe buffer is present and calibrated; without it a stream’s depth is the on-chip FIFO only

§

Adio

ADIO analog/digital module I/O is present

Gates: commands adio.mode, adio.adc, adio.fb, adio.dout.

§

Grounding

the grounding/module-ID board is present

Gates: commands gnd.eeprom.read.

§

TtlIn

TTL inputs are wired to the digital stream’s lanes

§

SlotHealth

per-slot presence and rail health are readable

Gates: commands power.status.

§

FieldUpdate

gateware images can be written over the wire and selected at boot (RESERVED — no command implements this yet)

§

RateControl

the acquisition rate is host-configurable, and rhd_matrix emits NOTHING until it has been configured (#131). A device with this capability expects rate_md + rate_apply before acquisition and reports readiness on rate_ready; without it a host cannot know whether the cadence a frame declares is one the hardware was placed into.

Gates: registers rate_md, rate_apply, rate_ready.

Implementations§

Source§

impl Cap

Source

pub const fn token(self) -> &'static str

The contract token, 1:1 with contract.yaml.

Examples found in repository?
examples/usb3_handshake.rs (line 32)
7fn main() -> std::process::ExitCode {
8    let mut args = std::env::args().skip(1);
9    let serial = args.next().unwrap_or_default();
10    let driver_dir = args.next();
11
12    let opened = kdi::Device::open_usb3(&serial, driver_dir.as_deref().map(std::path::Path::new));
13
14    let mut dev = match opened {
15        Ok(d) => d,
16        Err(e) => {
17            // Naming the failure matters more than the exit code: "no board" and "the driver is
18            // present but a symbol did not resolve" are the two outcomes worth telling apart, and
19            // every entry point resolves by name at dlopen so the second one says which symbol.
20            eprintln!("could not open the board: {e}");
21            return std::process::ExitCode::FAILURE;
22        }
23    };
24
25    let (major, minor) = dev.kdi();
26    let caps = dev.caps();
27    println!("serial          {}", dev.info().serial);
28    println!("transport       {:?}", dev.info().transport);
29    println!("contract        {major}.{minor}");
30    println!("caps            0x{:08x}", caps.0);
31    for c in caps.iter() {
32        println!("                  {}", c.token());
33    }
34    println!("gateware_sha    {:08x}", dev.gateware_sha());
35    if caps.has(kdi::Cap::CommandProtocol) {
36        match dev.sys_hello() {
37            Ok(h) => println!("fw_sha          {}", h.fw),
38            Err(e) => {
39                eprintln!("sys.hello failed: {e}");
40                return std::process::ExitCode::FAILURE;
41            }
42        }
43    } else {
44        println!("fw_sha          -");
45    }
46
47    match dev.wait_ready(std::time::Duration::from_millis(kdi::READY_TIMEOUT_MS)) {
48        Ok(()) => println!("contract_ready  yes"),
49        Err(e) => {
50            // Not fatal for a handshake read: a board still calibrating is a normal transient, and
51            // the point of this program is to report what the device says.
52            println!("contract_ready  NO ({e})");
53        }
54    }
55
56    if let Err(e) = dev.close() {
57        eprintln!("close: {e}");
58        return std::process::ExitCode::FAILURE;
59    }
60    std::process::ExitCode::SUCCESS
61}
Source

pub fn from_token(s: &str) -> Option<Self>

Parse a token. None is a token this build does not know — from a device on a newer minor, which is legal and must never be a parse failure.

Source

pub const fn bit(self) -> u32

This capability’s bit position in the caps register.

Trait Implementations§

Source§

impl Clone for Cap

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Cap

Source§

impl Debug for Cap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Cap

Source§

impl Hash for Cap

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Cap

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Cap

Auto Trait Implementations§

§

impl Freeze for Cap

§

impl RefUnwindSafe for Cap

§

impl Send for Cap

§

impl Sync for Cap

§

impl Unpin for Cap

§

impl UnsafeUnpin for Cap

§

impl UnwindSafe for Cap

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.