MCPcopy Create free account
hub / github.com/RobTillaart/Arduino / begin

Method begin

libraries/DS18B20_INT/DS18B20_INT.cpp:37–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35
36
37bool DS18B20_INT::begin(uint8_t retries)
38{
39 _addressFound = false;
40 for (uint8_t rtr = retries; (rtr > 0) && (_addressFound == false); rtr--)
41 {
42 _oneWire->reset();
43 _oneWire->reset_search();
44 _deviceAddress[0] = 0x00;
45 _oneWire->search(_deviceAddress);
46 _addressFound = _deviceAddress[0] != 0x00 &&
47 _oneWire->crc8(_deviceAddress, 7) == _deviceAddress[7];
48 }
49
50 if (_addressFound)
51 {
52 _oneWire->reset();
53 _oneWire->select(_deviceAddress);
54 _oneWire->write(WRITESCRATCH);
55 // two dummy values for LOW & HIGH ALARM
56 _oneWire->write(0);
57 _oneWire->write(100);
58 _oneWire->write(_resolution); // lowest as we do only integer math.
59 _oneWire->reset();
60 }
61 return _addressFound;
62}
63
64
65void DS18B20_INT::requestTemperatures(void)

Callers

nothing calls this directly

Calls 4

resetMethod · 0.45
crc8Method · 0.45
selectMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected