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 strong_pull_up(&mut self, duration: Duration) -> Result<(), Error>
pub async fn strong_pull_up(&mut self, duration: Duration) -> Result<(), Error>
Hold the bus HIGH for duration, then release it.
This is the parasite-power path. A device whose Vdd is tied to GND draws its conversion current – up to 1.5 mA – from the data line, and a 4.7 kOhm pull-up cannot supply that: it sources 0.7 mA at 3.3 V, so the line sags and the device’s internal cap cannot carry the conversion. The pad sources tens of mA instead, so no external strong pull-up is needed.
Mechanically: the RMT is told to drive its idle output (which the TX inverter turns into a HIGH pad), and the pad is switched to push-pull so that “high” is driven rather than released. Both are undone afterwards.
The bus MUST NOT be touched while this runs: a parasite device cannot answer a read slot during its conversion, and the datasheet forbids trying.
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.