OneWire

class

A one-wire communication line with a sensor that has a data line with pull-up. The sensor is expected to be activated by pulling down the wire and the releasing it. The sensor is then expected to send data, distinguishing between zero bits and one bits by two different period lengths of logic-high on the wire.

Author
Jens Peter Secher

Public Functions

OneWire::OneWire(PinName wire, uint32_t usPeriodLow, uint32_t usPeriodHiZero, uint32_t usPeriodHiOne, uint32_t usFullReadTimeOut)

Setup a one-wire communication line with a sensor that has a data line with pull-up. The sensor is expected to be activated by pulling down the wire and the releasing it. The sensor is then expected to send data, distinguishing between zero bits and one bits by two different period lengths of logic-high on the wire.

...DigitalOut because they use the same pin, and the initialisation sets the pin mode.

Parameters
  • wire -

    Pin to communication through.

  • usPeriodLow -

    Expected logic-low length in µs common to all bits.

  • usPeriodHiZero -

    Expected logic-high length of a zero bit in µs.

  • usPeriodHiOne -

    Expected logic-high length of a one bit in µs.

  • usFullReadTimeOut -

    Timeout in µs for a complete read.

template <typename Class>
void mono::io::OneWire::send(uint32_t usInitialPeriodLow, size_t skipBits, uint8_t * buffer, size_t length, Class * obj, void(Class::*)() member)

Tell the sensor to start sending data. Reading from the sensor stops when the buffer is filled up or when timeout is reached, and then the buffer will contain whatever bits that have been read so far.

Parameters
  • usInitialPeriodLow -

    Period in µs that wire will be pulled low to initiate sensor.

  • skipBits -

    Number of initial handshake bits to ignore.

  • buffer -

    Buffer where the received bytes will be stored.

  • length -

    Buffer length in bytes.

  • obj -

    Object that will recieve notification when read is done.

  • member -

    Object member that will recieve notification when read is done.