Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: PaulStoffregen/OneWire
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: maxicus/OneWire
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 6 commits
  • 3 files changed
  • 2 contributors

Commits on Nov 5, 2015

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    suzuki-shunsuke Shunsuke Suzuki
    Copy the full SHA
    59e1825 View commit details
  2. spacing

    maxicus committed Nov 5, 2015

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    suzuki-shunsuke Shunsuke Suzuki
    Copy the full SHA
    b356584 View commit details
  3. old behaviour by default

    maxicus committed Nov 5, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    25d315f View commit details

Commits on Jan 25, 2016

  1. Create README.md

    maxicus committed Jan 25, 2016

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    suzuki-shunsuke Shunsuke Suzuki
    Copy the full SHA
    75b6c57 View commit details
  2. Update README.md

    maxicus committed Jan 25, 2016

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d5c33f6 View commit details
  3. Update README.md

    maxicus committed Jan 25, 2016

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    701ee87 View commit details
Showing with 37 additions and 1 deletion.
  1. +17 −1 OneWire.cpp
  2. +8 −0 OneWire.h
  3. +12 −0 README.md
18 changes: 17 additions & 1 deletion OneWire.cpp
Original file line number Diff line number Diff line change
@@ -148,6 +148,10 @@ uint8_t OneWire::reset(void)

noInterrupts();
DIRECT_MODE_INPUT(reg, mask);
#if ONEWIRE_INTERNAL_PULLUP
DIRECT_WRITE_HIGH(reg , mask); // enable pull-up resistor
#endif

interrupts();
// wait until the wire is high... just in case
do {
@@ -162,6 +166,10 @@ uint8_t OneWire::reset(void)
delayMicroseconds(480);
noInterrupts();
DIRECT_MODE_INPUT(reg, mask); // allow it to float
#if ONEWIRE_INTERNAL_PULLUP
DIRECT_WRITE_HIGH(reg , mask); // enable pull-up resistor
#endif

delayMicroseconds(70);
r = !DIRECT_READ(reg, mask);
interrupts();
@@ -212,6 +220,9 @@ uint8_t OneWire::read_bit(void)
DIRECT_WRITE_LOW(reg, mask);
delayMicroseconds(3);
DIRECT_MODE_INPUT(reg, mask); // let pin float, pull up will raise
#if ONEWIRE_INTERNAL_PULLUP
DIRECT_WRITE_HIGH(reg , mask); // enable pull-up resistor
#endif
delayMicroseconds(10);
r = DIRECT_READ(reg, mask);
interrupts();
@@ -235,7 +246,9 @@ void OneWire::write(uint8_t v, uint8_t power /* = 0 */) {
if ( !power) {
noInterrupts();
DIRECT_MODE_INPUT(baseReg, bitmask);
DIRECT_WRITE_LOW(baseReg, bitmask);
#if !(ONEWIRE_INTERNAL_PULLUP)
DIRECT_WRITE_LOW(baseReg, bitmask); // otherwise it's left high
#endif
interrupts();
}
}
@@ -246,7 +259,9 @@ void OneWire::write_bytes(const uint8_t *buf, uint16_t count, bool power /* = 0
if (!power) {
noInterrupts();
DIRECT_MODE_INPUT(baseReg, bitmask);
#if !ONEWIRE_INTERNAL_PULLUP
DIRECT_WRITE_LOW(baseReg, bitmask);
#endif
interrupts();
}
}
@@ -293,6 +308,7 @@ void OneWire::depower()
{
noInterrupts();
DIRECT_MODE_INPUT(baseReg, bitmask);
DIRECT_WRITE_LOW(baseReg, bitmask); // disable pull-up too
interrupts();
}

8 changes: 8 additions & 0 deletions OneWire.h
Original file line number Diff line number Diff line change
@@ -45,6 +45,14 @@
#define ONEWIRE_CRC16 1
#endif

// Use internal microcontroller pull-up resistor instead of
// regular 4.7KOhms one connected externally
// http://wp.josh.com/2014/06/23/no-external-pull-up-needed-for-ds18b20-temp-sensor/
// for details
#ifndef ONEWIRE_INTERNAL_PULLUP
#define ONEWIRE_INTERNAL_PULLUP 0
#endif

#define FALSE 0
#define TRUE 1

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Fork on 1-Wire library with ability to use internal AVR (including arduino) pull-up resistor.

No external pull-up resistor required on a board for 1-wire devices as a result.

Details here
http://wp.josh.com/2014/06/23/no-external-pull-up-needed-for-ds18b20-temp-sensor/

To activate internal pull-up specify

```
#define ONEWIRE_INTERNAL_PULLUP 1
```