MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / reset

Method reset

Arduino/libraries/OneWire/OneWire.cpp:162–190  ·  view source on GitHub ↗

Perform the onewire reset function. We will wait up to 250uS for the bus to come high, if it doesn't then it is broken or shorted and we return a 0; Returns 1 if a device asserted a presence pulse, 0 otherwise.

Source from the content-addressed store, hash-verified

160// Returns 1 if a device asserted a presence pulse, 0 otherwise.
161//
162uint8_t OneWire::reset(void)
163{
164 IO_REG_TYPE mask = bitmask;
165 volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
166 uint8_t r;
167 uint8_t retries = 125;
168
169 noInterrupts();
170 DIRECT_MODE_INPUT(reg, mask);
171 interrupts();
172 // wait until the wire is high... just in case
173 do {
174 if (--retries == 0) return 0;
175 delayMicroseconds(2);
176 } while ( !DIRECT_READ(reg, mask));
177
178 noInterrupts();
179 DIRECT_WRITE_LOW(reg, mask);
180 DIRECT_MODE_OUTPUT(reg, mask); // drive output low
181 interrupts();
182 delayMicroseconds(480);
183 noInterrupts();
184 DIRECT_MODE_INPUT(reg, mask); // allow it to float
185 delayMicroseconds(70);
186 r = !DIRECT_READ(reg, mask);
187 interrupts();
188 delayMicroseconds(410);
189 return r;
190}
191
192//
193// Write a bit. Port and bit is used to cut lookup time and provide

Callers 7

readScratchPadMethod · 0.45
writeScratchPadMethod · 0.45
readPowerSupplyMethod · 0.45
requestTemperaturesMethod · 0.45
alarmSearchMethod · 0.45
sendMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected