Skip to content

Commit 29fa051

Browse files
committed
Fixed read_scratchpad after search_rom
1 parent 4c17f72 commit 29fa051

File tree

8 files changed

+26
-17
lines changed

8 files changed

+26
-17
lines changed

README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
# Arduino-OWI
22
The OWI library has been developed to support the implementation of
33
1-wire bus managers and device drivers. The library includes a GPIO
4-
based software and DS2482 based hardware bus manager, and device
5-
driver for DS18B20.
4+
based software and DS2482 based hardware bus manager, Slave device
5+
support class, and device driver for DS18B20.
66

77
The examples directory contains device search, bus scanner,
88
thermometer alarm search, and example sketches for DS18B20 and
99
DS1990A.
1010

11-
Version: 1.7
11+
Version: 1.8
1212

1313
## Classes
1414

1515
* [Abstract One-Wire Bus Manager and Device Interface, OWI](./src/OWI.h)
1616
* [Software One-Wire Bus Manager, GPIO, Software::OWI](./src/Software/OWI.h)
17+
* [Hardware One-Wire Bus Manager, DS2482, Hardware::OWI](./src/Hardware/OWI.h)
18+
* [Software One-Wire Slave Device, Slave::OWI](./src/Slave/OWI.h)
1719
* [Programmable Resolution 1-Wire Digital Thermometer, DS18B20](./src/Driver/DS18B20.h)
1820

1921
## Example Sketches
2022

21-
* [DS18B20](./examples/DS18B20)
22-
* [DS1990A](./examples/DS1990A)
2323
* [Alarm](./examples/Alarm)
24-
* [Scanner](./examples/Scanner)
2524
* [Search](./examples/Search)
25+
* [Scanner](./examples/Scanner)
26+
* [DS18B20](./examples/DS18B20)
27+
* [DS1990A](./examples/DS1990A)
28+
29+
[ATtiny](./examples/ATtiny) and [DS2482](./examples/DS2482)
30+
variants. And example of [Slave](./examples/Slave) device.
2631

2732
## Dependencies
2833

examples/Alarm/Alarm.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void setup()
2121
if (last == owi.ERROR) break;
2222
sensor.resolution(10);
2323
sensor.set_trigger(20, 25);
24-
ASSERT(sensor.write_scratchpad());
24+
ASSERT(sensor.write_scratchpad(false));
2525
} while (last != owi.LAST);
2626
}
2727

@@ -45,7 +45,7 @@ void loop()
4545
Serial.print('.');
4646
Serial.print(id++);
4747
Serial.print(F(":rom="));
48-
for (size_t i = 1; i < owi.ROM_MAX; i++) {
48+
for (size_t i = 0; i < owi.ROM_MAX; i++) {
4949
if (rom[i] < 0x10) Serial.print(0);
5050
Serial.print(rom[i], HEX);
5151
}

examples/DS18B20/DS18B20.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ void loop()
6060
Serial.print(sensor.resolution());
6161

6262
// Print alarm trigger threshols
63-
Serial.print(F(",trigger=["));
63+
Serial.print(F(",trigger="));
6464
Serial.print(low);
6565
Serial.print(F(".."));
6666
Serial.print(high);
6767

6868
// And temperature
69-
Serial.print(F("],temperature="));
69+
Serial.print(F(",temperature="));
7070
Serial.println(sensor.temperature());
7171
} while (last != owi.LAST);
7272

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name=Arduino-OWI
2-
version=1.7
2+
version=1.8
33
author=Mikael Patel
44
maintainer=Mikael Patel <[email protected]>
55
sentence=One-Wire Interface (OWI) library for Arduino.
6-
paragraph=The OWI library has been developed to support the implementation of 1-wire device drivers. Includes abstract OWI bus manager class, GPIO based Software::OWI bus manager, DS2482 based Hardware::OWI bus manager, and device driver for DS18B20.
6+
paragraph=The OWI library has been developed to support the implementation of 1-wire device drivers. Includes abstract OWI bus manager class, GPIO based Software::OWI bus manager, DS2482 based Hardware::OWI bus manager, support for Slave devices, and device driver for DS18B20.
77
category=Communication
88
url=https://github.com/mikaelpatel/Arduino-OWI
99
architectures=avr,sam

mainpage.dox

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
The OWI library has been developed to support the implementation of
44
1-wire device drivers. Includes abstract OWI bus manager class, GPIO
55
based Software::OWI bus manager, DS2482 based Hardware::OWI bus
6-
manager, and device driver for DS18B20.
6+
manager, Slave::OWI for slave devices, and device driver for DS18B20.
77

8-
Version: 1.7
8+
Version: 1.8
99
*/
1010

1111
/** @page License

src/Driver/DS18B20.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ class DS18B20 : public OWI::Device {
181181
* (3 bytes) to device.
182182
* @return true(1) if successful otherwise false(0).
183183
*/
184-
bool write_scratchpad()
184+
bool write_scratchpad(bool match = true)
185185
{
186-
if (!m_owi.match_rom(m_rom)) return (false);
186+
if (match && !m_owi.match_rom(m_rom)) return (false);
187187
m_owi.write(WRITE_SCRATCHPAD, &m_scratchpad.high_trigger, CONFIG_MAX);
188188
return (true);
189189
}

src/OWI.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class OWI {
138138
* calculation. Polynomial: x^8 + x^5 + x^4 + 1 (0x8C).
139139
* See http://www.maxim-ic.com/appnotes.cfm/appnote_number/27
140140
*/
141-
static uint8_t crc_update(uint8_t crc, uint8_t data)
141+
static inline uint8_t crc_update(uint8_t crc, uint8_t data)
142+
__attribute__((always_inline))
142143
{
143144
crc = crc ^ data;
144145
for (uint8_t i = 0; i < 8; i++) {

src/Software/OWI.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ class OWI : public ::OWI {
115115
}
116116
}
117117

118+
using ::OWI::read;
119+
using ::OWI::write;
120+
118121
protected:
119122
/** 1-Wire bus pin. */
120123
GPIO<PIN> m_pin;

0 commit comments

Comments
 (0)