55
66using 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
2830const 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+
3136auto ds1822 = DS18B20 (0x22 , 0x0D , 0x01 , 0x08 , 0x02 , 0x00 , 0x00 );
3237auto ds18B20 = DS18B20 (0x28 , 0x0D , 0x01 , 0x08 , 0x0B , 0x02 , 0x00 ); // Work - Digital Thermometer
3338auto ds18S20 = DS18B20 (0x10 , 0x0D , 0x01 , 0x08 , 0x0F , 0x02 , 0x00 );
3439auto ds2401a = DS2401 ( 0x01 , 0x00 , 0x0D , 0x24 , 0x01 , 0x00 , 0x0A ); // Work - Serial Number
3540auto 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
3843auto 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
4046auto 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
4248auto 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 );
4457auto ds2890A = DS2890 ( 0x2C , 0x0D , 0x02 , 0x08 , 0x09 , 0x00 , 0x0A ); // Work - Single channel digital potentiometer
4558auto ds2890B = DS2890 ( 0x2C , 0x0D , 0x02 , 0x08 , 0x09 , 0x00 , 0x0B );
4659auto ds2890C = DS2890 ( 0x2C , 0x0D , 0x02 , 0x08 , 0x09 , 0x00 , 0x0C );
60+ auto bae910 = BAE910 (BAE910 ::family_code, 0x00 , 0x00 , 0x10 , 0xE9 , 0xBA , 0x00 );
4761
4862int 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};
0 commit comments