MCPcopy Create free account
hub / github.com/PaulStoffregen/OneWire / write

Method write

OneWire.cpp:266–278  ·  view source on GitHub ↗

Write a byte. The writing code uses the active drivers to raise the pin high, if you need power after the write (e.g. DS18S20 in parasite power mode) then set 'power' to 1, otherwise the pin will go tri-state at the end of the write to avoid heating in a short or other mishap.

Source from the content-addressed store, hash-verified

264// other mishap.
265//
266void OneWire::write(uint8_t v, uint8_t power /* = 0 */) {
267 uint8_t bitMask;
268
269 for (bitMask = 0x01; bitMask; bitMask <<= 1) {
270 OneWire::write_bit( (bitMask & v)?1:0);
271 }
272 if ( !power) {
273 noInterrupts();
274 DIRECT_MODE_INPUT(baseReg, bitmask);
275 DIRECT_WRITE_LOW(baseReg, bitmask);
276 interrupts();
277 }
278}
279
280void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) {
281 for (uint16_t i = 0 ; i < count ; i++)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected