pub struct OneWire<'a, P: InputPin + OutputPin> { /* private fields */ }Expand description
Represents the OneWire bus.
Further information: https://www.analog.com/media/en/technical-documentation/data-sheets/DS18B20.pdf
Implementations§
Source§impl<'a, P: InputPin + OutputPin> OneWire<'a, P>
impl<'a, P: InputPin + OutputPin> OneWire<'a, P>
Sourcepub fn initialize_bus(
&mut self,
delay: &mut impl DelayNs,
) -> Result<bool, P::Error>
pub fn initialize_bus( &mut self, delay: &mut impl DelayNs, ) -> Result<bool, P::Error>
Sends a RESET pulse and listens for a PRESENCE pulse.
Retrurns Ok(true), if a PRESENCE pulse is received, Ok(false) if not.
delay must be able to accurately handle delays in the range of 1-480 us.
Sourcepub fn write_bit(
&mut self,
bit: bool,
delay: &mut impl DelayNs,
) -> Result<(), P::Error>
pub fn write_bit( &mut self, bit: bool, delay: &mut impl DelayNs, ) -> Result<(), P::Error>
Writes a single bit to the OneWire bus.
delay must be able to accurately handle delays in the range of 5-65 us.
Sourcepub fn read_bit(&mut self, delay: &mut impl DelayNs) -> Result<bool, P::Error>
pub fn read_bit(&mut self, delay: &mut impl DelayNs) -> Result<bool, P::Error>
Reads a single bit from the OneWire bus.
delay must be able to accurately handle delays in the range of 3-53 us.
Sourcepub fn write_byte(
&mut self,
byte: u8,
delay: &mut impl DelayNs,
) -> Result<(), P::Error>
pub fn write_byte( &mut self, byte: u8, delay: &mut impl DelayNs, ) -> Result<(), P::Error>
Writes a byte to the OneWire bus, least significant bit first.
For requirements on delay, see OneWire::write_bit.
Sourcepub fn read_byte(&mut self, delay: &mut impl DelayNs) -> Result<u8, P::Error>
pub fn read_byte(&mut self, delay: &mut impl DelayNs) -> Result<u8, P::Error>
Reads a byte from the OneWire bus, least significant bit first.
For requirements on delay, see OneWire::read_bit.
Sourcepub fn read_rom(
&mut self,
delay: &mut impl DelayNs,
) -> Result<RomCode, OneWireError<P::Error>>
pub fn read_rom( &mut self, delay: &mut impl DelayNs, ) -> Result<RomCode, OneWireError<P::Error>>
Issues a Read Rom command to the OneWire bus.
Only yields valid data, if exactly one other device is connected to the OneWire bus. Since all devices connected to the OneWire bus will respond, the data will be corrupt if multiple do so.
Sourcepub fn match_rom(
&mut self,
rom_code: RomCode,
delay: &mut impl DelayNs,
) -> Result<(), OneWireError<P::Error>>
pub fn match_rom( &mut self, rom_code: RomCode, delay: &mut impl DelayNs, ) -> Result<(), OneWireError<P::Error>>
Issues a Match Rom command to the OneWire bus.
Sourcepub fn skip_rom(
&mut self,
delay: &mut impl DelayNs,
) -> Result<(), OneWireError<P::Error>>
pub fn skip_rom( &mut self, delay: &mut impl DelayNs, ) -> Result<(), OneWireError<P::Error>>
Issues a Skip Rom command to the OneWire bus.
Sourcepub fn search_rom_iter<'b, D: DelayNs>(
&'b mut self,
delay: &'b mut D,
) -> OneWireRomIter<'a, 'b, P, D, false> ⓘ
pub fn search_rom_iter<'b, D: DelayNs>( &'b mut self, delay: &'b mut D, ) -> OneWireRomIter<'a, 'b, P, D, false> ⓘ
The iterator performs a Search Rom procedure.
Sourcepub fn alarm_search_iter<'b, D: DelayNs>(
&'b mut self,
delay: &'b mut D,
) -> OneWireRomIter<'a, 'b, P, D, true> ⓘ
pub fn alarm_search_iter<'b, D: DelayNs>( &'b mut self, delay: &'b mut D, ) -> OneWireRomIter<'a, 'b, P, D, true> ⓘ
The iterator performs an Alarm Search procedure.