Skip to content

Commit b34cced

Browse files
committed
extend and document ds2450, ds2502, ds2506 and ds2890
1 parent 49918bd commit b34cced

20 files changed

Lines changed: 116 additions & 86 deletions

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ project(OneWireHub)
33

44
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
55

6-
add_subdirectory(src)
7-
include_directories(./src)
6+
#add_subdirectory(src)
7+
#include_directories(./src)
88

99
set(SOURCE_FILES
1010
main.cpp

main.cpp

Lines changed: 70 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,69 +5,102 @@
55

66
using namespace std;
77

8-
#include "OneWireHub.h"
8+
#include "src/OneWireHub.h"
99

1010
// include all libs to find errors
11-
#include "DS2401.h" // Serial Number
12-
#include "DS18B20.h" // Digital Thermometer
13-
#include "DS2405.h" // Single adress switch
14-
#include "DS2408.h" // 8-Channel Addressable Switch
15-
#include "DS2413.h" // Dual channel addressable switch
16-
#include "DS2423.h" // 4kb 1-Wire RAM with Counter
17-
#include "DS2431.h" // 1kb 1-Wire EEPROM
18-
#include "DS2433.h" // 4Kb 1-Wire EEPROM
19-
#include "DS2438.h" // Smart Battery Monitor
20-
#include "DS2450.h" // 4 channel A/D
21-
#include "DS2502.h" // 1kb EEPROM
22-
#include "DS2890.h" // Single channel digital potentiometer
11+
#include "src/BAE910.h"
12+
#include "src/DS18B20.h" // Digital Thermometer
13+
#include "src/DS2401.h" // Serial Number
14+
#include "src/DS2405.h" // Single adress switch
15+
#include "src/DS2408.h" // 8-Channel Addressable Switch
16+
#include "src/DS2413.h" // Dual channel addressable switch
17+
#include "src/DS2423.h" // 4kb 1-Wire RAM with Counter
18+
#include "src/DS2431.h" // 1kb 1-Wire EEPROM
19+
#include "src/DS2433.h" // 4Kb 1-Wire EEPROM
20+
#include "src/DS2438.h" // Smart Battery Monitor
21+
#include "src/DS2450.h" // 4 channel A/D
22+
#include "src/DS2502.h" // 1kb EEPROM
23+
#include "src/DS2506.h" // 64kb EEPROM
24+
#include "src/DS2890.h" // Single channel digital potentiometer
2325

2426

2527

2628
// taken from OneWireHubTest.ino
2729

2830
const uint8_t OneWire_PIN = 8;
2931

30-
auto hub = OneWireHub(OneWire_PIN);
32+
auto hubA = OneWireHub(OneWire_PIN);
33+
auto hubB = OneWireHub(OneWire_PIN);
34+
auto hubC = OneWireHub(OneWire_PIN);
35+
3136
auto ds1822 = DS18B20(0x22, 0x0D, 0x01, 0x08, 0x02, 0x00, 0x00);
3237
auto ds18B20 = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x00); // Work - Digital Thermometer
3338
auto ds18S20 = DS18B20(0x10, 0x0D, 0x01, 0x08, 0x0F, 0x02, 0x00);
3439
auto ds2401a = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A ); // Work - Serial Number
3540
auto ds2401b = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B ); // Work - Serial Number
36-
// auto ds2405 = DS2405( 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - Single address switch
37-
// auto ds2408 = DS2408( 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 8-Channel Addressable Switch
41+
auto ds2405 = DS2405( 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - Single address switch
42+
auto ds2408 = DS2408( 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 8-Channel Addressable Switch
3843
auto ds2413 = DS2413( 0x3A, 0x0D, 0x02, 0x04, 0x01, 0x03, 0x00 ); // Work - Dual channel addressable switch
39-
// auto ds2423 = DS2423( 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4kb 1-Wire RAM with Counter
44+
45+
auto ds2423 = DS2423( 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4kb 1-Wire RAM with Counter
4046
auto ds2431 = DS2431( 0x2D, 0xE8, 0x9F, 0x90, 0x0E, 0x00, 0x00 ); // Work - 1kb 1-Wire EEPROM
41-
// auto ds2433 = DS2433( 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4Kb 1-Wire EEPROM
47+
auto ds2433 = DS2433( 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4Kb 1-Wire EEPROM
4248
auto ds2438 = DS2438( 0x26, 0x0D, 0x02, 0x04, 0x03, 0x08, 0x00 ); // - Smart Battery Monitor
43-
auto ds2450 = DS2450( 0x20, 0x0D, 0x0A, 0x02, 0x04, 0x05, 0x00 ); // - 4 channel A/D
49+
auto ds2450 = DS2450( DS2450::family_code, 0x00, 0x00, 0x50, 0x24, 0xDA, 0x00 ); // - 4 channel A/D
50+
auto ds2502 = DS2502( DS2502::family_code, 0x00, 0xA0, 0x02, 0x25, 0xDA, 0x00 );
51+
auto ds2501a = DS2502( 0x91, 0x00, 0xA0, 0x01, 0x25, 0xDA, 0x00 );
52+
auto ds2501b = DS2502( 0x11, 0x00, 0xB0, 0x02, 0x25, 0xDA, 0x00 );
53+
54+
auto ds2503 = DS2506( 0x13, 0x00, 0x00, 0x03, 0x25, 0xDA, 0x00 );
55+
auto ds2505 = DS2506( 0x0B, 0x00, 0x00, 0x05, 0x25, 0xDA, 0x00 );
56+
auto ds2506 = DS2506( 0x0F, 0x00, 0x00, 0x06, 0x25, 0xDA, 0x00 );
4457
auto ds2890A = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0A ); // Work - Single channel digital potentiometer
4558
auto ds2890B = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0B );
4659
auto ds2890C = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0C );
60+
auto bae910 = BAE910(BAE910::family_code, 0x00, 0x00, 0x10, 0xE9, 0xBA, 0x00);
4761

4862
int main()
4963
{
5064
cout << "Hello, World!" << endl;
5165

5266
// Setup OneWire
53-
ds1822.setTemp(static_cast<int16_t>(21));
54-
ds18S20.setTemp(static_cast<int16_t>(10));
55-
hub.attach(ds1822);
56-
hub.attach(ds18B20);
57-
hub.attach(ds18S20);
58-
hub.attach(ds2401a);
59-
hub.attach(ds2401b);
60-
hub.attach(ds2413);
61-
hub.attach(ds2431);
62-
hub.attach(ds2438);
63-
//hub.attach(ds2450);
64-
hub.attach(ds2890A);
65-
hub.attach(ds2890B);
66-
hub.attach(ds2890C);
67-
68-
hub.poll();
69-
70-
if (hub.getError()) hub.printError();
67+
hubA.attach(ds1822);
68+
hubA.attach(ds18B20);
69+
hubA.attach(ds18S20);
70+
hubA.attach(ds2401a);
71+
hubA.attach(ds2401b);
72+
hubA.attach(ds2405);
73+
hubA.attach(ds2408);
74+
hubA.attach(ds2413);
75+
76+
hubB.attach(ds2423);
77+
hubB.attach(ds2431);
78+
hubB.attach(ds2433);
79+
hubB.attach(ds2438);
80+
hubB.attach(ds2450);
81+
hubB.attach(ds2502);
82+
hubB.attach(ds2501a);
83+
hubB.attach(ds2501b);
84+
85+
hubC.attach(ds2503);
86+
hubC.attach(ds2505);
87+
hubC.attach(ds2506);
88+
hubC.attach(ds2890A);
89+
hubC.attach(ds2890B);
90+
hubC.attach(ds2890C);
91+
hubC.attach(bae910);
92+
93+
94+
ds1822.setTemperature(static_cast<int8_t>(21));
95+
ds18S20.setTemperature(static_cast<int8_t>(10));
96+
97+
hubA.poll();
98+
hubB.poll();
99+
hubC.poll();
100+
101+
if (hubA.hasError()) hubA.printError();
102+
if (hubB.hasError()) hubB.printError();
103+
if (hubC.hasError()) hubC.printError();
71104

72105
return 0;
73106
};

src/BAE910.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Multifunction 1-wire slave device @@@
22
// works, basic functionality
3-
// native features: unknown
3+
// native bus-features: unknown
44

55
#ifndef ONEWIRE_BAE910_H
66
#define ONEWIRE_BAE910_H

src/DS18B20.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// DS18B20: 9-12bit, -55 - +85 degC
44
// DS18S20: 9 bit, -55 - +85 degC
55
// DS1822: 9-12bit, -55 - +125 degC
6-
// native features: alarm search
6+
// native bus-features: alarm search
77

88
#ifndef ONEWIRE_DS18B20_H
99
#define ONEWIRE_DS18B20_H

src/DS2401.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Serial Number
22
// Works
3-
// native features: none
3+
// native bus-features: none
44

55
#ifndef ONEWIRE_DS2401_H
66
#define ONEWIRE_DS2401_H

src/DS2405.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Single address switch @@@
22
// works, but reading back the value is not supported, because alarm search is not implemented yet
33
// this IC is not using standard protocol - it sends data after searchRom and alarmSearch
4-
// native features: alarm search
4+
// native bus-features: alarm search
55

66
#ifndef ONEWIRE_DS2405_H
77
#define ONEWIRE_DS2405_H

src/DS2408.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// 8-Channel Addressable Switch @@@
22
// works, but no alarm search and higher logic / output / control register-action
3-
// native features: Overdrive capable, alarm search
3+
// native bus-features: Overdrive capable, alarm search
44

55
#ifndef ONEWIRE_DS2408_H
66
#define ONEWIRE_DS2408_H

src/DS2413.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Dual channel addressable switch
22
// Works, master can latch the pin and pull it thereby down
3-
// native features: Overdrive capable
3+
// native bus-features: Overdrive capable
44

55
#ifndef ONEWIRE_DS2413_H
66
#define ONEWIRE_DS2413_H

src/DS2423.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// 4kb 1-Wire RAM with Counter
22
// works
3-
// native features: Overdrive capable
3+
// native bus-features: Overdrive capable
44

55
#ifndef ONEWIRE_DS2423_H
66
#define ONEWIRE_DS2423_H

src/DS2431.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// 1Kb 1-Wire EEPROM
22
// works,
33
// note: datasheet is fuzzy, but device is similar to ds2433
4-
// native features: Overdrive capable
4+
// native bus-features: Overdrive capable
55

66
#ifndef ONEWIRE_DS2431_H
77
#define ONEWIRE_DS2431_H

0 commit comments

Comments
 (0)