modm API documentation
modm::platform::BitBangOneWireMaster< Pin > Class Template Reference

#include <modm/platform/1-wire/bitbang_master.hpp>

Static Public Member Functions

template<class... Signals>
static void connect ()
 
template<class SystemClock >
static void initialize ()
 
static bool touchReset ()
 
static void writeBit (bool bit)
 
static bool readBit ()
 
static void writeByte (uint8_t data)
 Write 1-Wire data byte.
 
static uint8_t readByte ()
 Read 1-Wire data byte and return it.
 
static uint8_t touchByte (uint8_t data)
 Write a 1-Wire data byte and return the sampled result.
 
static bool verifyDevice (const uint8_t *rom)
 
static void resetSearch ()
 
static void resetSearch (uint8_t familyCode)
 
static bool searchNext (uint8_t *rom)
 
static void searchSkipCurrentFamily ()
 

Static Protected Member Functions

static uint8_t crcUpdate (uint8_t crc, uint8_t data)
 
static bool performSearch ()
 Perform the actual search algorithm.
 

Static Protected Attributes

static constexpr std::chrono::microseconds A {6}
 
static constexpr std::chrono::microseconds B {64}
 
static constexpr std::chrono::microseconds C {60}
 
static constexpr std::chrono::microseconds D {10}
 
static constexpr std::chrono::microseconds E {9}
 
static constexpr std::chrono::microseconds F {55}
 
static constexpr std::chrono::microseconds G {0}
 
static constexpr std::chrono::microseconds H {480}
 
static constexpr std::chrono::microseconds I {70}
 
static constexpr std::chrono::microseconds J {410}
 
static uint8_t lastDiscrepancy
 
static uint8_t lastFamilyDiscrepancy
 
static bool lastDeviceFlag
 
static uint8_t crc8
 
static uint8_t romBuffer [8]
 

Detailed Description

template<typename Pin>
class modm::platform::BitBangOneWireMaster< Pin >

Software emulation of a 1-wire master

1-Wire is extremely timing critical. This implementation relies on simple delay loops to achieve this timing. Any interrupt during the operation can disturb the timing.

You should make sure that no interrupt occurs during the 1-Wire transmissions, for example by disabling interrupts.

Based on the Maxim 1-Wire AppNote at http://www.maxim-ic.com/appnotes.cfm/appnote_number/126

1-Wire Search Algorithm based on AppNote 187 at http://www.maxim-ic.com/appnotes.cfm/appnote_number/187

Member Function Documentation

template<typename Pin >
static bool modm::platform::BitBangOneWireMaster< Pin >::readBit ( )
static

Read a bit from the 1-wire bus and return it.

Provides 10us recovery time.

template<typename Pin >
static void modm::platform::BitBangOneWireMaster< Pin >::resetSearch ( )
static

Reset search state

See also
searchNext()
template<typename Pin >
static void modm::platform::BitBangOneWireMaster< Pin >::resetSearch ( uint8_t  familyCode)
static

Reset search state and setup it to find the device type 'familyCode' on the next call to searchNext().

This will accelerate the search because only devices of the given type will be considered.

template<typename Pin >
static bool modm::platform::BitBangOneWireMaster< Pin >::searchNext ( uint8_t *  rom)
static

Perform the 1-Wire search algorithm on the 1-Wire bus using the existing search state.

Parameters
[out]rom8 byte array which will be filled with ROM number of the device found.
Returns
true is a device is found. rom will contain the ROM number. false if no device found. This also marks the end of the search.
See also
resetSearch()
template<typename Pin >
static void modm::platform::BitBangOneWireMaster< Pin >::searchSkipCurrentFamily ( )
static

Setup the search to skip the current device type on the next call to searchNext()

template<typename Pin >
static bool modm::platform::BitBangOneWireMaster< Pin >::touchReset ( )
static

Generate a 1-wire reset

Returns
true devices detected,
false failed to detect devices
template<typename Pin >
static bool modm::platform::BitBangOneWireMaster< Pin >::verifyDevice ( const uint8_t *  rom)
static

Verify that the with the given ROM number is present

Parameters
rom8-byte ROM number
Returns
true device presens verified,
false device not present
template<typename Pin >
static void modm::platform::BitBangOneWireMaster< Pin >::writeBit ( bool  bit)
static

Send a 1-wire write bit.

Provides 10us recovery time.


The documentation for this class was generated from the following file: