diff --git a/README.md b/README.md index a76074e..416e139 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL - **DS2401 Serial Number** - **DS2405 Single address switch** - DS2408 8-Channel Addressable Switch, GPIO Port-expander +- **DS2411 Serial Number** (use DS2401 with same family code 0x01) - **DS2413 Dual channel addressable switch with input-sensing** - DS2423 4kb 1-Wire RAM with Counter - DS2433 4Kb 1-Wire EEPROM @@ -70,4 +71,4 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL - original pieces seem to be adopted from [OneWireSlave](http://robocraft.ru/blog/arduino/302.html) - further development was done in [OneWireSlave](https://github.com/MarkusLange/OneWireSlave) from MarkusLange and [OneWire](https://github.com/PaulStoffregen/OneWire) - first implementation of the [OneWireHub](https://github.com/Shagrat2/OneWireHub) by Shagrat2 -- the current state of code has the concepts in common, but the codebase is a (nearly) total rewrite \ No newline at end of file +- the current state of code has the concepts in common, but the codebase is a total rewrite \ No newline at end of file diff --git a/examples/OneWireHubTest/OneWireHubTest.ino b/examples/OneWireHubTest/OneWireHubTest.ino index e767b25..0fe4252 100644 --- a/examples/OneWireHubTest/OneWireHubTest.ino +++ b/examples/OneWireHubTest/OneWireHubTest.ino @@ -72,7 +72,7 @@ void setup() hub.attach(ds2401b); hub.attach(ds2413); hub.attach(ds2438); - //hub.attach(ds2450); // still breaks the communication ? find out :-) + //hub.attach(ds2450); hub.attach(ds2890A); hub.attach(ds2890B); hub.attach(ds2890C); diff --git a/src/DS2890.cpp b/src/DS2890.cpp index 9b3c956..7db82b6 100644 --- a/src/DS2890.cpp +++ b/src/DS2890.cpp @@ -1,4 +1,3 @@ - #include "DS2890.h" DS2890::DS2890(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7) : OneWireItem(ID1, ID2, ID3, ID4, ID5, ID6, ID7) @@ -71,7 +70,6 @@ bool DS2890::duty(OneWireHub *hub) default: hub->raiseSlaveError(cmd); - break; } return true; diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index 9c8f979..8cce141 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -365,7 +365,7 @@ bool OneWireHub::search(void) bool OneWireHub::recvAndProcessCmd(void) { uint8_t address[8]; - bool flag; + bool flag = false; uint8_t cmd = recv(); switch (cmd) @@ -378,7 +378,6 @@ bool OneWireHub::recvAndProcessCmd(void) recv(address, 8); if (_error != Error::NO_ERROR) return false; - flag = false; slave_selected = 0; for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) @@ -406,7 +405,6 @@ bool OneWireHub::recvAndProcessCmd(void) if (slave_selected != nullptr) slave_selected->duty(this); return true; - case 0xCC: // SKIP ROM slave_selected = nullptr; return true; @@ -417,7 +415,6 @@ bool OneWireHub::recvAndProcessCmd(void) default: // Unknown command _error = Error::INCORRECT_ONEWIRE_CMD; - } return false; } @@ -579,7 +576,7 @@ bool OneWireHub::waitWhilePinIs(const bool value, const uint16_t timeout_us) if (micros() > time_trigger) return false; } #else - uint16_t retries = static_cast(microsecondsToClockCycles(timeout_us) >> 3); + uint16_t retries = static_cast(microsecondsToClockCycles(timeout_us)/11); while (DIRECT_READ(reg, pin_bitMask) == value) { if (--retries == 0) return false; diff --git a/src/OneWireHub.h b/src/OneWireHub.h index e2b525a..104e229 100644 --- a/src/OneWireHub.h +++ b/src/OneWireHub.h @@ -55,10 +55,10 @@ class OneWireHub static constexpr uint8_t ONEWIRE_TREE_SIZE = 2*ONEWIRESLAVE_LIMIT - 1; - /// the following TIME-values are in us and are taken from the ds2408 datasheet + /// the following TIME-values are in microseconds and are taken from the ds2408 datasheet // should be --> datasheet // was --> shagrat-legacy - static constexpr uint16_t ONEWIRE_TIME_BUS_CHANGE_MAX = 5; // + static constexpr uint16_t ONEWIRE_TIME_BUS_CHANGE_MAX = 5; // static constexpr uint16_t ONEWIRE_TIME_RESET_MIN = 380; // should be 480, and was 470 static constexpr uint16_t ONEWIRE_TIME_RESET_MAX = 960; // from ds2413 @@ -66,9 +66,9 @@ class OneWireHub static constexpr uint16_t ONEWIRE_TIME_PRESENCE_SAMPLE_MIN = 20; // probe measures 40us static constexpr uint16_t ONEWIRE_TIME_PRESENCE_LOW_STD = 140; // was 125 static constexpr uint16_t ONEWIRE_TIME_PRESENCE_LOW_MAX = 480; // should be 280, was 480 !!!! why - static constexpr uint16_t ONEWIRE_TIME_PRESENCE_HIGH_MAX = 999; // + static constexpr uint16_t ONEWIRE_TIME_PRESENCE_HIGH_MAX = 9999; // - static constexpr uint16_t ONEWIRE_TIME_SLOT_MAX = 240; // should be 120, was ~1050 + static constexpr uint16_t ONEWIRE_TIME_SLOT_MAX = 999; // should be 120, was ~1050 // read and write from the viewpoint of the slave!!!! static constexpr uint16_t ONEWIRE_TIME_READ_ONE_LOW_MAX = 60; // diff --git a/src/platform.h b/src/platform.h index 3cb65a2..cb5201c 100644 --- a/src/platform.h +++ b/src/platform.h @@ -233,7 +233,7 @@ void sei(void); #endif -#ifdef ARDUINO_attiny // Test to make it work on tiny85 +#ifdef ARDUINO_attiny // Test to make it work on aTtiny85, 8MHz #include "inttypes.h"