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

Method write_bit

Arduino/libraries/OneWire/OneWire.cpp:196–218  ·  view source on GitHub ↗

Write a bit. Port and bit is used to cut lookup time and provide more certain timing.

Source from the content-addressed store, hash-verified

194// more certain timing.
195//
196void OneWire::write_bit(uint8_t v)
197{
198 IO_REG_TYPE mask=bitmask;
199 volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg;
200
201 if (v & 1) {
202 noInterrupts();
203 DIRECT_WRITE_LOW(reg, mask);
204 DIRECT_MODE_OUTPUT(reg, mask); // drive output low
205 delayMicroseconds(10);
206 DIRECT_WRITE_HIGH(reg, mask); // drive output high
207 interrupts();
208 delayMicroseconds(55);
209 } else {
210 noInterrupts();
211 DIRECT_WRITE_LOW(reg, mask);
212 DIRECT_MODE_OUTPUT(reg, mask); // drive output low
213 delayMicroseconds(65);
214 DIRECT_WRITE_HIGH(reg, mask); // drive output high
215 interrupts();
216 delayMicroseconds(5);
217 }
218}
219
220//
221// Read a bit. Port and bit is used to cut lookup time and provide

Callers 1

alarmSearchMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected