pub struct OneWire<'a> { /* private fields */ }Expand description
Async 1-Wire bus master built on a pair of RMT TX/RX channels.
Implementations§
Source§impl<'a> OneWire<'a>
impl<'a> OneWire<'a>
Sourcepub async fn reset(&mut self) -> Result<bool, Error>
pub async fn reset(&mut self) -> Result<bool, Error>
Issue a 1-Wire reset pulse and return true if at least one device
responded with a presence pulse.
Sourcepub async fn send_and_receive(
&mut self,
indata: &mut [PulseCode],
data: &[PulseCode],
) -> Result<usize, Error>
pub async fn send_and_receive( &mut self, indata: &mut [PulseCode], data: &[PulseCode], ) -> Result<usize, Error>
Transmit data while simultaneously sampling the bus into indata,
returning the number of received RMT symbols.
Sourcepub fn encode_bit(bit: bool) -> PulseCode
pub fn encode_bit(bit: bool) -> PulseCode
Encode a single 1-Wire bit as an RMT pulse code (write/read time slot).
Sourcepub fn decode_bit(code: PulseCode) -> bool
pub fn decode_bit(code: PulseCode) -> bool
Decode a sampled RMT pulse code back into the 1-Wire bit value.
Sourcepub async fn exchange_byte(&mut self, byte: u8) -> Result<u8, Error>
pub async fn exchange_byte(&mut self, byte: u8) -> Result<u8, Error>
Write one byte (LSB first) and read the byte the bus returns in the same time slots.
Sourcepub async fn send_byte(&mut self, byte: u8) -> Result<(), Error>
pub async fn send_byte(&mut self, byte: u8) -> Result<(), Error>
Write one byte (LSB first) without reading the response.
Sourcepub async fn exchange_bits(
&mut self,
bits: &[bool],
out: &mut [bool],
) -> Result<(), Error>
pub async fn exchange_bits( &mut self, bits: &[bool], out: &mut [bool], ) -> Result<(), Error>
Write the bits in bits and read the bus response into out in the
same time slots. bits and out must have equal length, and at most
Self::MAX_EXCHANGE_BITS elements.
This replaces the original const-generic exchange_bits<const N> (which
required generic_const_exprs) with a slice-based API backed by a small
fixed-capacity buffer. The RMT framing is identical: each bit maps to one
PulseCode followed by a trailing end_marker().
Sourcepub async fn send_u64(&mut self, val: u64) -> Result<(), Error>
pub async fn send_u64(&mut self, val: u64) -> Result<(), Error>
Write a 64-bit value (typically a ROM address) least-significant byte first.
Sourcepub async fn send_address(&mut self, val: Address) -> Result<(), Error>
pub async fn send_address(&mut self, val: Address) -> Result<(), Error>
Write a 64-bit 1-Wire ROM Address.