pub trait OneWire {
type Status: OneWireStatus;
type BusError;
// Required methods
fn reset(&mut self) -> OneWireResult<Self::Status, Self::BusError>;
fn write_byte(&mut self, byte: u8) -> OneWireResult<(), Self::BusError>;
fn read_byte(&mut self) -> OneWireResult<u8, Self::BusError>;
fn write_bit(&mut self, bit: bool) -> OneWireResult<(), Self::BusError>;
fn read_bit(&mut self) -> OneWireResult<bool, Self::BusError>;
fn get_overdrive_mode(&mut self) -> OneWireResult<bool, Self::BusError>;
// Provided methods
fn set_overdrive_mode(
&mut self,
_enable: bool,
) -> OneWireResult<(), Self::BusError> { ... }
fn addrss(&mut self, rom: Option<u64>) -> OneWireResult<(), Self::BusError> { ... }
}Expand description
Trait for 1-Wire communication. This trait defines the basic operations required for 1-Wire communication, such as resetting the bus, writing and reading bytes, and writing and reading bits.
Required Associated Types§
Sourcetype Status: OneWireStatus
type Status: OneWireStatus
The status type returned by the reset operation. This type must implement the OneWireStatus trait.
Required Methods§
Sourcefn reset(&mut self) -> OneWireResult<Self::Status, Self::BusError>
fn reset(&mut self) -> OneWireResult<Self::Status, Self::BusError>
Sourcefn write_byte(&mut self, byte: u8) -> OneWireResult<(), Self::BusError>
fn write_byte(&mut self, byte: u8) -> OneWireResult<(), Self::BusError>
Sourcefn read_byte(&mut self) -> OneWireResult<u8, Self::BusError>
fn read_byte(&mut self) -> OneWireResult<u8, Self::BusError>
Sourcefn read_bit(&mut self) -> OneWireResult<bool, Self::BusError>
fn read_bit(&mut self) -> OneWireResult<bool, Self::BusError>
Sourcefn get_overdrive_mode(&mut self) -> OneWireResult<bool, Self::BusError>
fn get_overdrive_mode(&mut self) -> OneWireResult<bool, Self::BusError>
Check if the 1-Wire bus is in overdrive mode.
§Returns
A result containing a boolean indicating whether the bus is in overdrive mode.
Provided Methods§
Sourcefn set_overdrive_mode(
&mut self,
_enable: bool,
) -> OneWireResult<(), Self::BusError>
fn set_overdrive_mode( &mut self, _enable: bool, ) -> OneWireResult<(), Self::BusError>
Sourcefn addrss(&mut self, rom: Option<u64>) -> OneWireResult<(), Self::BusError>
fn addrss(&mut self, rom: Option<u64>) -> OneWireResult<(), Self::BusError>
Addresses devices on the 1-Wire bus.
The first OneWire::read_byte, OneWire::read_bit, OneWire::write_byte, OneWire::write_bit operation should be preceded by this method to address devices on the bus.
Note: A OneWire::read_byte or OneWire::read_bit call will return garbage data if this method is called without specifying a ROM address on a bus with multiple devices.
§Arguments
rom- The ROM address of the device to address. PassNoneto skip ROM addressing and address all devices on the bus.
§Returns
A result indicating the success or failure of the operation.
If the device is successfully addressed, the method returns Ok(()).