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.
| 247 | // other mishap. |
| 248 | // |
| 249 | void 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 | |
| 263 | void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0 */) { |
| 264 | for (uint16_t i = 0 ; i < count ; i++) |
no outgoing calls
no test coverage detected