Skip to content

Commit 0017c71

Browse files
committed
Cleanup
1 parent c149b8d commit 0017c71

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ Version: 1.8
1717
* [Hardware One-Wire Bus Manager, DS2482, Hardware::OWI](./src/Hardware/OWI.h)
1818
* [Software One-Wire Slave Device, Slave::OWI](./src/Slave/OWI.h)
1919
* [Programmable Resolution 1-Wire Digital Thermometer, DS18B20](./src/Driver/DS18B20.h)
20-
* [One-Wire Remove Arduino, Master](./src/Driver/Arduino.h)
20+
* [One-Wire Remote Arduino, Master](./src/Driver/Arduino.h)
2121

2222
## Example Sketches
2323

2424
* [Alarm](./examples/Alarm)
25-
* [Arduino](./examples/Arduino)
26-
* [Arduino, Slave](./examples/Slave/Arduino)
2725
* [Search](./examples/Search)
2826
* [Scanner](./examples/Scanner)
29-
* [DS18B20](./examples/DS18B20)
27+
* [DS18B20, Master](./examples/DS18B20)
3028
* [DS18B20, Slave](./examples/Slave/DS18B20)
3129
* [DS1990A](./examples/DS1990A)
30+
* [Remote Arduino, Master](./examples/Arduino)
31+
* [Remote Arduino, Slave](./examples/Slave/Arduino)
3232

3333
[ATtiny](./examples/ATtiny) and [DS2482](./examples/DS2482)
3434
variants.

examples/Arduino/Arduino.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "assert.h"
66
#include "benchmark.h"
77

8-
// One-Wire Interface Remove Arduino (Master)
8+
// One-Wire Interface Remote Arduino (Master)
99
Software::OWI<BOARD::D7> owi;
1010
Arduino arduino(owi);
1111

@@ -20,7 +20,7 @@ void setup()
2020
int pins;
2121

2222
// Search for device and set short address (label)
23-
last = owi.search_rom(arduino.FAMILY, rom, last);
23+
last = owi.search_rom(arduino.FAMILY_CODE, rom, last);
2424
ASSERT(last != owi.ERROR);
2525
arduino.rom(rom);
2626
arduino.label_rom(id);

examples/Slave/Arduino/Arduino.ino

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
33
#include "Slave/OWI.h"
44
#include "Driver/Arduino.h"
55

6-
/** ROM identity code (in program memory). */
7-
const uint8_t ROM[OWI::ROM_MAX] PROGMEM = {
8-
Arduino::FAMILY, 0x21, 0x32, 0x43, 0x54, 0x65, 0x76, 0x80
9-
};
10-
116
/** One-Wire Slave Device Bus Manager. */
12-
Slave::OWI<BOARD::D7> owi(ROM);
7+
Slave::OWI<BOARD::D7> owi(Arduino::FAMILY_CODE);
138

149
/**
1510
* Setup One-Wire Remote Arduino Slave Device. Set alarm

examples/Slave/DS18B20/DS18B20.ino

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@ struct scratchpad_t {
2828
uint8_t reserved[3]; //!< Reserved.
2929
} __attribute__((packed));
3030

31-
// ROM identity for slave device
32-
const uint8_t ROM[OWI::ROM_MAX] PROGMEM = {
33-
FAMILY_CODE, 0x12, 0x34, 0x56, 0x78, 0x89, 0x9a, 0xab
34-
};
35-
36-
// Slave device one wire access
37-
Slave::OWI<BOARD::D7> owi(ROM);
31+
// Slave device one wire access; use random rom code
32+
Slave::OWI<BOARD::D7> owi(FAMILY_CODE);
3833

3934
// Scratchpad with temperature, triggers and configuration
4035
scratchpad_t scratchpad = {

src/Driver/Arduino.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
class Arduino : public OWI::Device {
3636
public:
3737
/** Family code. */
38-
static const uint8_t FAMILY = 0x10;
38+
static const uint8_t FAMILY_CODE = 0x60;
3939

4040
/**
41-
* Construct One-Wire Interface (OWI) Remove Arduino with given bus
41+
* Construct One-Wire Interface (OWI) Remote Arduino with given bus
4242
* and device address.
4343
* @param[in] owi bus manager.
4444
* @param[in] rom code (default NULL).
@@ -216,7 +216,7 @@ class Arduino : public OWI::Device {
216216
return (0);
217217
}
218218

219-
/** One-Wire Interface (OWI) Remove Arduino Device function codes. */
219+
/** One-Wire Interface (OWI) Remote Arduino Device function codes. */
220220
enum {
221221
PIN_MODE = 0x11, //!< Set pin mode: 6b pin, 2b mode
222222
DIGITAL_READ = 0x22, //!< Read digital pin: 6b pin, 1b return

src/Slave/OWI.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ class OWI {
5959
m_pin.open_drain();
6060
}
6161

62+
/**
63+
* Construct one wire bus slave device connected to the given
64+
* template pin parameter, and family code. Random identity code
65+
* is generated.
66+
* @param[in] family code
67+
*/
68+
OWI(uint8_t family) :
69+
m_timestamp(0),
70+
m_label(255),
71+
m_alarm(false)
72+
{
73+
uint8_t crc = crc_update(0, family);
74+
uint8_t* p = 0;
75+
m_rom[0] = family;
76+
for (size_t i = 1; i < ROM_MAX - 1; i++) {
77+
uint8_t data = *p++;
78+
m_rom[i] = data;
79+
crc = crc_update(crc, data);
80+
}
81+
m_rom[ROM_MAX - 1] = crc;
82+
m_pin.open_drain();
83+
}
84+
6285
/**
6386
* Get cyclic redundancy check sum. Calculated by buffer read() and
6487
* write().

0 commit comments

Comments
 (0)