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

Method write

Arduino/libraries/OneWire/OneWire.cpp:249–261  ·  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

247// other mishap.
248//
249void OneWire::write(uint8_t v, uint8_t power /* = 0 */) {
250 uint8_t bitMask;
251
252 for (bitMask = 0x01; bitMask; bitMask <<= 1) {
253 OneWire::write_bit( (bitMask & v)?1:0);
254 }
255 if ( !power) {
256 noInterrupts();
257 DIRECT_MODE_INPUT(baseReg, bitmask);
258 DIRECT_WRITE_LOW(baseReg, bitmask);
259 interrupts();
260 }
261}
262
263void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) {
264 for (uint16_t i = 0 ; i < count ; i++)

Callers 7

shieldSetLEDMethod · 0.45
readScratchPadMethod · 0.45
writeScratchPadMethod · 0.45
readPowerSupplyMethod · 0.45
requestTemperaturesMethod · 0.45
alarmSearchMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected