Skip to main content

Bridge

Struct Bridge 

Source
pub struct Bridge<P> { /* private fields */ }
Expand description

The bridge on a USB card, reached over a port.

Implementations§

Source§

impl<P: Read + Write> Bridge<P>

Source

pub fn new(port: P) -> Bridge<P>

Wraps a port. Nothing is sent until the bridge is asked something.

§Arguments
  • port - the serial device the card enumerates as, opened raw.
§Returns

The bridge.

Source

pub fn ping(&mut self) -> Result<Identity, UsbError>

Asks the bridge who it is.

§Returns

Its unique identifier and firmware version.

§Errors

When the port fails or the bridge answers something else.

Source

pub fn status(&mut self) -> Result<Status, UsbError>

Asks the bridge for its clock and temperature.

§Returns

The status.

§Errors

When the port fails or the bridge answers something else.

Source

pub fn write_gpio(&mut self, pin: u8, high: bool) -> Result<(), UsbError>

Drives one of the card’s pins.

§Arguments
  • pin - which pin, such as PIN_RESET.
  • high - whether to drive it high.
§Errors

When the port fails or the bridge refuses.

Source

pub fn reset_card(&mut self) -> Result<(), UsbError>

Resets the card.

§Errors

When the port fails or the bridge refuses.

Source

pub fn power_up(&mut self) -> Result<(), UsbError>

Brings the card up the way the reference does before it is used.

The supply is switched on, the concentrator’s reset is pulsed, then the radio beside it has its own reset pulsed, which is active low.

§Errors

When any of those pin writes fails.

Source

pub fn bulk(&mut self, bulk: &Bulk, into: &mut [u8]) -> Result<usize, UsbError>

Sends a bulk of SPI transfers and reads back what the chip clocked.

§Arguments
  • bulk - the entries.
  • into - where the answer goes, which needs as much room as the entries took plus nothing, since the answer echoes each entry at the same length.
§Returns

How many bytes of answer were read, which Replies then walks.

§Errors

When the port fails, the bridge answers another order, or the answer does not fit.

Auto Trait Implementations§

§

impl<P> Freeze for Bridge<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for Bridge<P>
where P: RefUnwindSafe,

§

impl<P> Send for Bridge<P>
where P: Send,

§

impl<P> Sync for Bridge<P>
where P: Sync,

§

impl<P> Unpin for Bridge<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for Bridge<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for Bridge<P>
where P: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.