pub trait OneWireBus {
type Error;
// Required methods
fn reset(&mut self) -> Result<bool, Self::Error>;
fn write_bit(&mut self, bit: bool) -> Result<(), Self::Error>;
fn read_bit(&mut self) -> Result<bool, Self::Error>;
// Provided methods
fn write_byte(&mut self, byte: u8) -> Result<(), Self::Error> { ... }
fn read_byte(&mut self) -> Result<u8, Self::Error> { ... }
fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), Self::Error> { ... }
fn read_bytes(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error> { ... }
fn skip_rom(&mut self) -> Result<(), OneWireError<Self::Error>> { ... }
fn match_rom(
&mut self,
rom: &RomCode,
) -> Result<(), OneWireError<Self::Error>> { ... }
fn read_rom(&mut self) -> Result<RomCode, OneWireError<Self::Error>> { ... }
}Expand description
A 1-Wire bus: the three signaling primitives, and the byte and ROM operations built on them.
Implement reset, write_bit, and read_bit for a controller; everything else has
a default built on those. BitBang is the implementation over a bare pin.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn skip_rom(&mut self) -> Result<(), OneWireError<Self::Error>>
fn skip_rom(&mut self) -> Result<(), OneWireError<Self::Error>>
Resets the bus and addresses every device at once with SKIP_ROM.
The next function command reaches every device, which is what a bus with a single device, or a broadcast such as a temperature conversion, wants.
§Errors
Returns OneWireError::NoDevice if nothing answered the reset, or the
controller’s error.
Sourcefn match_rom(&mut self, rom: &RomCode) -> Result<(), OneWireError<Self::Error>>
fn match_rom(&mut self, rom: &RomCode) -> Result<(), OneWireError<Self::Error>>
Resets the bus and addresses one device by its ROM code with MATCH_ROM.
§Arguments
rom- the device to address; the next function command goes to it alone.
§Errors
Returns OneWireError::NoDevice if nothing answered the reset, or the
controller’s error.
Sourcefn read_rom(&mut self) -> Result<RomCode, OneWireError<Self::Error>>
fn read_rom(&mut self) -> Result<RomCode, OneWireError<Self::Error>>
Resets the bus and reads the ROM code of the only device on it.
With more than one device the answers collide and the CRC fails; use
Search instead.
§Returns
The device’s ROM code.
§Errors
Returns OneWireError::NoDevice if nothing answered the reset,
OneWireError::Crc if the code read does not check, or the controller’s
error.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".