From 3643ffb18cddf4bd7eb90ee8a6ad514b0d7327dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Fri, 14 Oct 2022 23:44:31 +0200 Subject: [PATCH 01/29] bump version --- README.md | 2 +- library.json | 2 +- library.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 77f9142..02becb9 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### HELP - What to do if things don't work as expected? - check if your arduino software up to date (>v1.8.0) -- update this lib to the latest release (v2.2.3) +- update this lib to the latest release (v2.2.4) - if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation - check if clock-speed of the µC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical - begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the master won't switch to higher data rates diff --git a/library.json b/library.json index 68b1f57..d3e54a7 100644 --- a/library.json +++ b/library.json @@ -22,7 +22,7 @@ "type": "git", "url": "https://github.com/orgua/OneWireHub" }, - "version": "2.2.3", + "version": "2.2.4", "examples": [ "examples/*/*.ino" ] diff --git a/library.properties b/library.properties index e7e18af..113624a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=OneWireHub -version=2.2.3 +version=2.2.4 author=Ingmar Splitt, orgua, MarkusLange, Shagrat2 maintainer=orgua sentence=OneWire slave device emulator with support for up to 32 simultaneous 1wire devices. From 427bd36edefb3d67ee33b7f28f543b0047e5d10e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sat, 15 Oct 2022 00:44:23 +0200 Subject: [PATCH 02/29] fix ds2434 fix bug and emulate timings as well --- examples/DS2434_IBM701c/DS2434_IBM701c.ino | 3 +- src/DS2434.cpp | 33 ++++++++++++++++++---- src/DS2434.h | 6 ++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/examples/DS2434_IBM701c/DS2434_IBM701c.ino b/examples/DS2434_IBM701c/DS2434_IBM701c.ino index 07ad40f..1707d49 100644 --- a/examples/DS2434_IBM701c/DS2434_IBM701c.ino +++ b/examples/DS2434_IBM701c/DS2434_IBM701c.ino @@ -35,7 +35,7 @@ void setup() void loop() { - static uint8_t temp = 20; + static uint8_t temp = 20u; // following function must be called periodically hub.poll(); @@ -44,6 +44,7 @@ void loop() if (ds2434.getTemperatureRequest()) { ds2434.setTemperature(temp++); + if (temp > 25u) temp = 20u; } } \ No newline at end of file diff --git a/src/DS2434.cpp b/src/DS2434.cpp index 7a25a5c..dd7d8ee 100644 --- a/src/DS2434.cpp +++ b/src/DS2434.cpp @@ -14,6 +14,7 @@ DS2434::DS2434(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, void DS2434::duty(OneWireHub * const hub) { uint8_t start_byte, cmd, data; + uint32_t time_now; if (hub->recv(&cmd)) return; switch (cmd) @@ -44,11 +45,13 @@ void DS2434::duty(OneWireHub * const hub) if (memory[0x62] & 0b100u) return; // check LOCK-Status writeMemory(&scratchpad[PAGE1_ADDR], PAGE_SIZE, PAGE1_ADDR); // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0x25: // copy scratchpad SP2 to NV2 writeMemory(&scratchpad[PAGE2_ADDR], PAGE_SIZE, PAGE2_ADDR); // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0x28: // copy scratchpad SP3 to SRAM @@ -62,34 +65,46 @@ void DS2434::duty(OneWireHub * const hub) case 0x77: // Recall Memory, NV2 to SP2 readMemory(&scratchpad[PAGE2_ADDR], PAGE_SIZE, PAGE2_ADDR); // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0x7A: // Recall Memory, SRAM to SP3 readMemory(&scratchpad[PAGE3_ADDR], PAGE_SIZE, PAGE3_ADDR); // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0x43: // lock NV1 lockNV1(); // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0x44: // unlock NV1 unlockNV1(); // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0xD2: // trigger temperature-reading - scratchpad[0x62] |= 0b1u; + request_temp = true; + timer_temp = millis() + DURATION_TEMP_ms; break; case 0xB2: // read Page 4 and 5 if (hub->recv(&start_byte)) return; if (start_byte < PAGE4_ADDR) return; // when out of limits if (start_byte >= PAGE6_ADDR) return; + + // update status byte, TODO: done here because laptop waits -> check duration + time_now = millis(); + if (time_now >= timer_nvwr) scratchpad[0x62] &= ~0b10u; // erase busy-flag + else scratchpad[0x62] |= 0b10u; // set busy-flag + if (time_now >= timer_temp) scratchpad[0x62] &= ~0b1u; // erase busy-flag + else scratchpad[0x62] |= 0b1u; // set busy-flag + for (uint8_t nByte = start_byte; nByte < PAGE6_ADDR; ++nByte) { - if (hub->recv(&data, 1)) return; - scratchpad[nByte] = data; + if (hub->send(&scratchpad[nByte], 1)) return; } break; @@ -100,12 +115,20 @@ void DS2434::duty(OneWireHub * const hub) scratchpad[82]++; } // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0xB8: // reset Cycle scratchpad[82] = 0u; scratchpad[83] = 0u; // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0x8E: // secret command just to avoid triggering an error + break; + case 0x84: // second secret command + if (hub->recv(&data)) return; break; default: @@ -153,12 +176,12 @@ void DS2434::setTemperature(const int8_t temp_degC) memory[60] = uvalue << 1u; // reset request - scratchpad[0x62] &= ~0b1u; + request_temp = false; } bool DS2434::getTemperatureRequest() const { - return (scratchpad[0x62] & 0b1u); + return (request_temp); } void DS2434::lockNV1() diff --git a/src/DS2434.h b/src/DS2434.h index 9cbf2f5..acbf771 100644 --- a/src/DS2434.h +++ b/src/DS2434.h @@ -51,6 +51,12 @@ class DS2434 : public OneWireItem static constexpr uint8_t MEM_SIZE { 3 * PAGE_SIZE }; static constexpr uint8_t SCRATCHPAD_SIZE { PAGE_COUNT * PAGE_SIZE }; + static constexpr uint32_t DURATION_TEMP_ms { 230 }; + static constexpr uint32_t DURATION_NVWR_ms { 10 }; + uint32_t timer_temp = 0u; + uint32_t timer_nvwr = 0u; + bool request_temp = false; + uint8_t memory[MEM_SIZE]; uint8_t scratchpad[SCRATCHPAD_SIZE]; From 1c803f71ec43fd066c146981bed43f1e0d331e28 Mon Sep 17 00:00:00 2001 From: matt Date: Sun, 16 Oct 2022 14:33:04 -0700 Subject: [PATCH 03/29] Fixed int vs. hex bug & scratch vs. memory. --- src/DS2434.cpp | 30 +++++++++++++++--------------- src/DS2434.h | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/DS2434.cpp b/src/DS2434.cpp index dd7d8ee..b654bce 100644 --- a/src/DS2434.cpp +++ b/src/DS2434.cpp @@ -97,30 +97,30 @@ void DS2434::duty(OneWireHub * const hub) // update status byte, TODO: done here because laptop waits -> check duration time_now = millis(); - if (time_now >= timer_nvwr) scratchpad[0x62] &= ~0b10u; // erase busy-flag - else scratchpad[0x62] |= 0b10u; // set busy-flag - if (time_now >= timer_temp) scratchpad[0x62] &= ~0b1u; // erase busy-flag - else scratchpad[0x62] |= 0b1u; // set busy-flag + if (time_now >= timer_nvwr) memory[0x62] &= ~0b10u; // erase busy-flag + else memory[0x62] |= 0b10u; // set busy-flag + if (time_now >= timer_temp) memory[0x62] &= ~0b1u; // erase busy-flag + else memory[0x62] |= 0b1u; // set busy-flag for (uint8_t nByte = start_byte; nByte < PAGE6_ADDR; ++nByte) { - if (hub->send(&scratchpad[nByte], 1)) return; + if (hub->send(&memory[nByte], 1)) return; } break; case 0xB5: // increment Cycle - if (++scratchpad[83] == 0u) + if (++memory[0x83] == 0u) { // after overflow of LSB - scratchpad[82]++; + memory[0x82]++; } // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) timer_nvwr = millis() + DURATION_NVWR_ms; break; case 0xB8: // reset Cycle - scratchpad[82] = 0u; - scratchpad[83] = 0u; + memory[0x82] = 0u; + memory[0x83] = 0u; // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) timer_nvwr = millis() + DURATION_NVWR_ms; break; @@ -168,12 +168,12 @@ void DS2434::setTemperature(const int8_t temp_degC) if (value > 126) value = 126; if (value < -40) value = -40; - memory[61] = value; + memory[0x61] = value; if (value < 0) value = 0; uint8_t uvalue = static_cast(value); - memory[60] = uvalue << 1u; + memory[0x60] = uvalue << 1u; // reset request request_temp = false; @@ -186,20 +186,20 @@ bool DS2434::getTemperatureRequest() const void DS2434::lockNV1() { - scratchpad[0x62] |= 0b100u; + memory[0x62] |= 0b100u; } void DS2434::unlockNV1() { - scratchpad[0x62] &= ~0b100u; + memory[0x62] &= ~0b100u; } void DS2434::setBatteryCounter(uint16_t value) { - *((uint16_t *) &scratchpad[82]) = value; + *((uint16_t *) &memory[0x82]) = value; } void DS2434::setID(uint16_t value) { - *((uint16_t *) &scratchpad[80]) = value; + *((uint16_t *) &memory[0x80]) = value; } diff --git a/src/DS2434.h b/src/DS2434.h index acbf771..9ea1434 100644 --- a/src/DS2434.h +++ b/src/DS2434.h @@ -48,8 +48,8 @@ class DS2434 : public OneWireItem static constexpr uint8_t PAGE_SIZE { 32 }; static constexpr uint8_t PAGE_COUNT { 5 }; - static constexpr uint8_t MEM_SIZE { 3 * PAGE_SIZE }; - static constexpr uint8_t SCRATCHPAD_SIZE { PAGE_COUNT * PAGE_SIZE }; + static constexpr uint8_t MEM_SIZE { 4 * PAGE_SIZE + 4 }; // Limit the memory size to the working space + static constexpr uint8_t SCRATCHPAD_SIZE { 3 * PAGE_SIZE }; // Scratchpad is used for first 3 pages static constexpr uint32_t DURATION_TEMP_ms { 230 }; static constexpr uint32_t DURATION_NVWR_ms { 10 }; From 62cc59848988583a360d9f6db0c23ed677490479 Mon Sep 17 00:00:00 2001 From: matt Date: Sun, 16 Oct 2022 14:45:29 -0700 Subject: [PATCH 04/29] Fixing double-reset behavior for multidrops. --- src/OneWireHub.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index 581edaa..8e0711d 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -412,7 +412,7 @@ bool OneWireHub::recvAndProcessCmd(void) if( slave_selected->skip_multidrop ){ slave_selected->duty(this); - return (_error != Error::NO_ERROR); + return false; // TODO: Find the root-cause. This fixes the issue but may cause other problems. } } From d010513233d509594edbc2c61c011606aa8bc8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 17 Oct 2022 10:23:58 +0200 Subject: [PATCH 05/29] clean up formatting and spelling --- .codespellrc | 2 +- .github/ISSUE_TEMPLATE/bug_report.md | 4 +-- CMakeLists.txt | 2 +- LICENSE.md | 2 +- README.md | 28 +++++++++---------- examples/DS2405_switch/DS2405_switch.ino | 2 +- examples/DS2423_RAM/DS2423_RAM.ino | 2 +- examples/DS2430_EEPROM/DS2430_EEPROM.ino | 2 +- examples/DS2431_EEPROM/DS2431_EEPROM.ino | 2 +- examples/DS2433_EEPROM/DS2433_EEPROM.ino | 2 +- examples/DS2434_IBM701c/DS2434_IBM701c.ino | 2 +- examples/DS2502_DELLCHG/DS2502_DELLCHG.ino | 2 +- examples/DS2502_DELLCHG/readme.md | 2 +- examples/DS2506_EEPROM/DS2506_EEPROM.ino | 2 +- examples/OneWireHubTest/OneWireHubTest.ino | 2 +- .../debug/CRC-Comparison/CRC-Comparison.ino | 2 +- .../calibrate_by_bus_timing.ino | 3 -- .../irq-driven-playground.ino | 2 +- .../programsize_documentation.ino | 2 +- keywords.txt | 2 +- library.json | 2 +- library.properties | 2 +- main.cpp | 4 +-- src/DS2430.cpp | 1 - src/DS2438.h | 4 +-- src/DS2450.cpp | 2 -- src/OneWireHub.cpp | 2 +- src/platform.cpp | 1 - 28 files changed, 40 insertions(+), 47 deletions(-) diff --git a/.codespellrc b/.codespellrc index 9416829..719c29f 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,5 +1,5 @@ [codespell] -#skip = +#skip = builtin = clear,rare,informal,usage,code,en-GB_to_en-US diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b12f850..fad775f 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -25,9 +25,9 @@ If applicable, add screenshots to help explain your problem. **Dev-Environment:** Give some information about your setup, like: - microcontroller used for the hub -- onewire-host to talk to the hub +- onewire-host to talk to the hub - software and version used to compile -- which device is emulated, what works, what doesn't +- which device is emulated, what works, what doesn't **Additional context** Add any other context about the problem here. diff --git a/CMakeLists.txt b/CMakeLists.txt index 6135636..5cfca01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,4 +30,4 @@ set(SOURCE_FILES src/platform.cpp ) # TODO: this does not have to be manual -add_executable(OneWireHub ${SOURCE_FILES}) \ No newline at end of file +add_executable(OneWireHub ${SOURCE_FILES}) diff --git a/LICENSE.md b/LICENSE.md index e587591..94a0453 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -618,4 +618,4 @@ an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. - END OF TERMS AND CONDITIONS \ No newline at end of file + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index 02becb9..0d9cb89 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ OneWireHub ========== -The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Slaves with support for various devices. The motivation is to offer a shared code base for all OneWire-Slaves. With a small overhead one µC can emulate up to 32 ICs simultaneously. +The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Slaves with support for various devices. The motivation is to offer a shared code base for all OneWire-Slaves. With a small overhead one µC can emulate up to 32 ICs simultaneously. The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iLib) or SPI interface) and transfer their measurements into one or more emulated ds2438 which have 4x16bit registers for values. This feature removes the limitations of modern house-automation-systems. Add humidity, light and other sensors easy to your home automation environment. [![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) @@ -10,7 +10,7 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL - **BAE0910 (0xFC) multi purpose device (ADC, Clock, GPIO, PWM, EEPROM)** - **DS1822 (0x22) Digital Thermometer, 12bit** -> use DS18B20 with different family code -- **DS18B20 (0x28) Digital Thermometer, 12bit** (also known as DS1820) +- **DS18B20 (0x28) Digital Thermometer, 12bit** (also known as DS1820) - **DS18S20 (0x10) Digital Thermometer, 9bit** (also known as DS1920, use DS18B20 with different family code) - **DS1990 (0x01) iButton** (DS2401 with same family code) - **DS1990A (0x81) iButton** (DS2401 with different family code) @@ -57,9 +57,9 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - hub and slaves are unit tested and run for each supported architecture through travis CI - Serial-Debug output can be enabled in src/OneWireHub_config.h: set USE_SERIAL_DEBUG to 1 (be aware! it may produce heisenbugs, timing is critical) - GPIO-Debug output - shows status by issuing high-states (activate in src/OneWireHub_config.h, is a better alternative to serial debug) - - during presence detection (after reset), + - during presence detection (after reset), - after receiving / sending a whole byte (not during SEARCH ROM) - - when duty()-subroutines of an attached slave get called + - when duty()-subroutines of an attached slave get called - during hub-startup it issues a 1ms long high-state (you can check the instruction-per-loop-value for your architecture with this) - provide documentation, numerous examples, easy interface for hub and sensors @@ -84,10 +84,10 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - Digispark tiny ([DigistumpArduino](https://github.com/digistump/DigistumpArduino)) - failing platforms - reason: current tick-counting implementation is not compatible with variable clock-speed - - Arduino Due ([Arduino SAMD Boards (32-bits ARM Cortex-M3)](https://github.com/arduino/ArduinoCore-sam)) + - Arduino Due ([Arduino SAMD Boards (32-bits ARM Cortex-M3)](https://github.com/arduino/ArduinoCore-sam)) - Arduino MKRZero ([Arduino SAMD Boards (32-bits ARM Cortex-M0+)](https://github.com/arduino/ArduinoCore-samd)) - - reason: gcc 4.8.3 is artificially limited to c++98 - - Arduino Primo ([Arduino nRF52 Boards](https://github.com/arduino-org/arduino-core-nrf52)) + - reason: gcc 4.8.3 is artificially limited to c++98 + - Arduino Primo ([Arduino nRF52 Boards](https://github.com/arduino-org/arduino-core-nrf52)) - RedBear [nRF51](https://github.com/RedBearLab/nRF51822-Arduino) - reason: value_ipl is unknown for this hardware - Arduino 101 ([Intel Curie Boards](https://github.com/01org/corelibs-arduino101)) @@ -104,7 +104,7 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - send() and recv() can process data between device and master on byte-level (and do a CRC if needed) - recvAndProcessCmd() handles basic commands of the master like: search-rom, match-rom, skip-rom, read-rom - High Level - user interaction - - attach() adds an instance of a ow-device to the hub so the master can find it on the bus. there is a lot to do here. the device ID must be integrated into the tree-structure so that the hub knows how to react during a search-rom-command + - attach() adds an instance of a ow-device to the hub so the master can find it on the bus. there is a lot to do here. the device ID must be integrated into the tree-structure so that the hub knows how to react during a search-rom-command - detach() takes the selected emulated device offline and restructures the search-tree - poll() lets the hub listen to the bus. If there is a reset within a given time-frame it will continue to handle the message (show presence and receive commands), otherwise it will exit and you can do other stuff. the user should call this function as often as possible to intercept every message and therefore stay visible on the bus - Slave Level: @@ -125,8 +125,8 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - if communication works, but is unstable please check with logic analyzer - maybe your master is slow and just needs a higher ONEWIRE_TIME_MSG_HIGH_TIMEOUT-value (see OneWireHub_config.h line 37) - make sure that serial- and gpio-debugging is disabled (see src/OneWireHub_config.h), especially when using overdrive (be aware! it may produce heisenbugs, timing is critical) -- on a slow arduino it can be helpful to disable the serial port completely to get reliable results -> at least comment out serial.begin() -- if you can provide a recording via logic-analyzer (logic 8 or similar) there should be chance we can help you +- on a slow arduino it can be helpful to disable the serial port completely to get reliable results -> at least comment out serial.begin() +- if you can provide a recording via logic-analyzer (logic 8 or similar) there should be chance we can help you - additional gpio-debug output can be enabled in src/OneWireHub_config.h: set USE_GPIO_DEBUG to 1 (it helps tracking state changes of the hub) - if you checked all these points feel free to open an issue at [Github](https://github.com/orgua/OneWireHub) and describe your troubleshooting process - please provide the following basic info: which µC and master do you use, software versions, what device do you try to emulate, what works, what doesn't @@ -148,13 +148,13 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - returns 1 if error occurred in the following functions: recv(buf[]), send(), awaitTimeslot(), sendBit(), checkReset(), showPresence(), recvAndProzessCmd() - support for ds2408 (thanks to vytautassurvila) and ds2450 - offline calibration by watching the bus (examples/debug/calibrate_by_bus_timing) - - branch for online calibration was abandoned because it took to much resources (DS18B20-Sketch compiled to 8434 // 482 bytes instead of 7026 // 426 bytes now) + - branch for online calibration was abandoned because it took to much resources (DS18B20-Sketch compiled to 8434 // 482 bytes instead of 7026 // 426 bytes now) - cleaned up timing-fn (no guessing, no micros(), no delayMicroseconds()) - debug-pin shows state by issuing high-states - see explanation in "features" - teensy3.2 tested: cleaned warnings, fixed port access, cleaned examples - added or extended the ds2431, ds2431, ds2501, ds2502 (also tested) - added ds2431 (thanks to j-langlois) and BAE910 (thanks to Giermann), Dell Power Supply (thanks to Kondi) -- prepare new timing-method which will replace the old one in the next couple of weeks (a 6µs millis() call at 8MHz is not suitable for OW) +- prepare new timing-method which will replace the old one in the next couple of weeks (a 6µs millis() call at 8MHz is not suitable for OW) - support for skipROM-cmd if only one slave is present (thanks to Giermann) - speed up atmel-crc-functions - rework of error system, switch to enum, slaves can raise errors now & and Serial interferes less with OW-timings @@ -191,6 +191,6 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### Ancestors of this Lib - 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) +- 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 code has just the concepts in common, but the codebase is a total rewrite \ No newline at end of file +- the current code has just the concepts in common, but the codebase is a total rewrite diff --git a/examples/DS2405_switch/DS2405_switch.ino b/examples/DS2405_switch/DS2405_switch.ino index a096b9f..6f220b9 100644 --- a/examples/DS2405_switch/DS2405_switch.ino +++ b/examples/DS2405_switch/DS2405_switch.ino @@ -53,4 +53,4 @@ void loop() } -} \ No newline at end of file +} diff --git a/examples/DS2423_RAM/DS2423_RAM.ino b/examples/DS2423_RAM/DS2423_RAM.ino index a343b66..decd2a1 100644 --- a/examples/DS2423_RAM/DS2423_RAM.ino +++ b/examples/DS2423_RAM/DS2423_RAM.ino @@ -69,4 +69,4 @@ void loop() { // following function must be called periodically hub.poll(); -} \ No newline at end of file +} diff --git a/examples/DS2430_EEPROM/DS2430_EEPROM.ino b/examples/DS2430_EEPROM/DS2430_EEPROM.ino index b477ccc..19f1364 100644 --- a/examples/DS2430_EEPROM/DS2430_EEPROM.ino +++ b/examples/DS2430_EEPROM/DS2430_EEPROM.ino @@ -34,4 +34,4 @@ void loop() { // following function must be called periodically hub.poll(); -} \ No newline at end of file +} diff --git a/examples/DS2431_EEPROM/DS2431_EEPROM.ino b/examples/DS2431_EEPROM/DS2431_EEPROM.ino index 8260e4f..58f82e0 100644 --- a/examples/DS2431_EEPROM/DS2431_EEPROM.ino +++ b/examples/DS2431_EEPROM/DS2431_EEPROM.ino @@ -65,4 +65,4 @@ void loop() { // following function must be called periodically hub.poll(); -} \ No newline at end of file +} diff --git a/examples/DS2433_EEPROM/DS2433_EEPROM.ino b/examples/DS2433_EEPROM/DS2433_EEPROM.ino index 1b1d354..5d3ac20 100644 --- a/examples/DS2433_EEPROM/DS2433_EEPROM.ino +++ b/examples/DS2433_EEPROM/DS2433_EEPROM.ino @@ -44,4 +44,4 @@ void loop() { // following function must be called periodically hub.poll(); -} \ No newline at end of file +} diff --git a/examples/DS2434_IBM701c/DS2434_IBM701c.ino b/examples/DS2434_IBM701c/DS2434_IBM701c.ino index 1707d49..8f3db09 100644 --- a/examples/DS2434_IBM701c/DS2434_IBM701c.ino +++ b/examples/DS2434_IBM701c/DS2434_IBM701c.ino @@ -47,4 +47,4 @@ void loop() if (temp > 25u) temp = 20u; } -} \ No newline at end of file +} diff --git a/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino b/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino index b110dab..8cced05 100644 --- a/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino +++ b/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino @@ -57,4 +57,4 @@ void loop() { // following function must be called periodically hub.poll(); -} \ No newline at end of file +} diff --git a/examples/DS2502_DELLCHG/readme.md b/examples/DS2502_DELLCHG/readme.md index 182c03b..a8ad06a 100644 --- a/examples/DS2502_DELLCHG/readme.md +++ b/examples/DS2502_DELLCHG/readme.md @@ -61,4 +61,4 @@ __Do not make up a weak power adapter to a more powerful one. Overloading may pe ## More information on the string format: 1. https://github.com/garyStofer/DS2502_DELL_PS/blob/master/DS2502_DELL_PS.ino 2. https://nickschicht.wordpress.com/2009/07/15/dell-power-supply-fault/ -3. https://github.com/KivApple/dell-charger-emulator \ No newline at end of file +3. https://github.com/KivApple/dell-charger-emulator diff --git a/examples/DS2506_EEPROM/DS2506_EEPROM.ino b/examples/DS2506_EEPROM/DS2506_EEPROM.ino index 1b8c7c5..5dc9244 100644 --- a/examples/DS2506_EEPROM/DS2506_EEPROM.ino +++ b/examples/DS2506_EEPROM/DS2506_EEPROM.ino @@ -76,4 +76,4 @@ void loop() // following function must be called periodically hub.poll(); -} \ No newline at end of file +} diff --git a/examples/OneWireHubTest/OneWireHubTest.ino b/examples/OneWireHubTest/OneWireHubTest.ino index bdf6d8c..66fbe54 100644 --- a/examples/OneWireHubTest/OneWireHubTest.ino +++ b/examples/OneWireHubTest/OneWireHubTest.ino @@ -118,4 +118,4 @@ void loop() p4 +=8; ds2450.setPotentiometer(p1,p2,p3,p4); } -} \ No newline at end of file +} diff --git a/examples/debug/CRC-Comparison/CRC-Comparison.ino b/examples/debug/CRC-Comparison/CRC-Comparison.ino index 4f96c26..63a60d7 100644 --- a/examples/debug/CRC-Comparison/CRC-Comparison.ino +++ b/examples/debug/CRC-Comparison/CRC-Comparison.ino @@ -427,4 +427,4 @@ uint16_t v3A_crc16(uint16_t crc, uint8_t value) } return crc; -} \ No newline at end of file +} diff --git a/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino b/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino index 586b0ab..08f1689 100644 --- a/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino +++ b/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino @@ -102,6 +102,3 @@ void loop() } } } - - - diff --git a/examples/debug/irq-driven-playground/irq-driven-playground.ino b/examples/debug/irq-driven-playground/irq-driven-playground.ino index fb7d4f8..ed93f66 100644 --- a/examples/debug/irq-driven-playground/irq-driven-playground.ino +++ b/examples/debug/irq-driven-playground/irq-driven-playground.ino @@ -170,4 +170,4 @@ void loop() irq_mockup(); // emulate an interrupt //Serial.println(" jump end "); } -} \ No newline at end of file +} diff --git a/examples/debug/programsize_documentation/programsize_documentation.ino b/examples/debug/programsize_documentation/programsize_documentation.ino index 187c116..ac86053 100644 --- a/examples/debug/programsize_documentation/programsize_documentation.ino +++ b/examples/debug/programsize_documentation/programsize_documentation.ino @@ -46,4 +46,4 @@ void loop() hub.poll(); // this part is just for debugging (USE_SERIAL_DEBUG in OneWire.h must be enabled for output) if (hub.hasError()) hub.printError(); -} \ No newline at end of file +} diff --git a/keywords.txt b/keywords.txt index 60c35aa..aaaf7f2 100644 --- a/keywords.txt +++ b/keywords.txt @@ -167,4 +167,4 @@ getRegFeat KEYWORD2 # Constants (LITERAL1) ####################################### -family_code LITERAL1 \ No newline at end of file +family_code LITERAL1 diff --git a/library.json b/library.json index d3e54a7..48c41d2 100644 --- a/library.json +++ b/library.json @@ -26,4 +26,4 @@ "examples": [ "examples/*/*.ino" ] -} \ No newline at end of file +} diff --git a/library.properties b/library.properties index 113624a..982ecba 100644 --- a/library.properties +++ b/library.properties @@ -6,4 +6,4 @@ sentence=OneWire slave device emulator with support for up to 32 simultaneous 1w paragraph=supported sensors: BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890 category=Sensors url=https://github.com/orgua/OneWireHub -architectures=* \ No newline at end of file +architectures=* diff --git a/main.cpp b/main.cpp index 7e92dd7..b7fceaa 100644 --- a/main.cpp +++ b/main.cpp @@ -121,7 +121,7 @@ int main() auto ds2434 = DS2434(0x1B, 0x01, 0x02, 0x12, 0x34, 0x56, 0x78); cout << "- attach devices to hubs" << endl; - + // Setup OneWire hubA.attach(ds1822); hubA.attach(ds18B20); @@ -771,4 +771,4 @@ int main() cout << "Program did run " << tests_absolved << " tests, " << tests_failed << " of them failed." << endl; return static_cast(tests_failed); -}; \ No newline at end of file +}; diff --git a/src/DS2430.cpp b/src/DS2430.cpp index 0a24beb..0274c8d 100644 --- a/src/DS2430.cpp +++ b/src/DS2430.cpp @@ -129,4 +129,3 @@ bool DS2430::syncScratchpad() memcpy(scratchpad,memory,length); return true; } - diff --git a/src/DS2438.h b/src/DS2438.h index 6a168ae..741471e 100644 --- a/src/DS2438.h +++ b/src/DS2438.h @@ -65,7 +65,7 @@ class DS2438 : public OneWireItem static constexpr uint8_t REG0_MASK_ADB { 0x40 }; // adc busy flag uint8_t memory[MEM_SIZE]; // this mem is the "scratchpad" in the datasheet., no EEPROM implemented - uint8_t crc[PAGE_COUNT+1]; // keep the matching crc for each memory-page, reading can be very timesensitive + uint8_t crc[PAGE_COUNT+1]; // keep the matching crc for each memory-page, reading can be very time-sensitive // One of the following is placed in scratchpad depending on state of REG0_MASK_AD when voltage conversion is requested uint8_t vadVoltage[2]; // unsigned 10 bit @@ -90,7 +90,7 @@ class DS2438 : public OneWireItem void setTemperature(int8_t temp_degC); int8_t getTemperature(void) const; - // setVoltage should be considered deprecated in favour of setVDDVoltage (default) & setVADVoltage + // setVoltage should be considered deprecated in favor of setVDDVoltage (default) & setVADVoltage void setVoltage(uint16_t voltage_10mV); // unsigned 10 bit void setVDDVoltage(uint16_t voltage_10mV); // unsigned 10 bit void setVADVoltage(uint16_t voltage_10mV); // unsigned 10 bit diff --git a/src/DS2450.cpp b/src/DS2450.cpp index a1caff2..8e0ed05 100644 --- a/src/DS2450.cpp +++ b/src/DS2450.cpp @@ -132,5 +132,3 @@ uint16_t DS2450::getPotentiometer(const uint8_t channel) const value |= memory[(2*channel) ]; return value; } - - diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index 8e0711d..6b9d445 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -413,7 +413,7 @@ bool OneWireHub::recvAndProcessCmd(void) if( slave_selected->skip_multidrop ){ slave_selected->duty(this); return false; // TODO: Find the root-cause. This fixes the issue but may cause other problems. - } + } } uint8_t address[8], cmd; diff --git a/src/platform.cpp b/src/platform.cpp index d3b3223..7653874 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -12,4 +12,3 @@ void noInterrupts() { }; void interrupts() { }; #endif // ONEWIREHUB_FALLBACK_BASIC_FNs - From 8198f312444cab7b5956a9831ff1184473d972be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 17 Oct 2022 12:00:50 +0200 Subject: [PATCH 06/29] update tests --- .gitignore | 1 + .pre-commit-config.yaml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d3fc9b2..45c7184 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.xml *.iml cmake-build-debug/ +build/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f9de169..8625784 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: fix-byte-order-marker - repo: https://github.com/codespell-project/codespell - rev: "v2.2.1" + rev: "v2.2.2" hooks: - id: codespell @@ -46,3 +46,4 @@ repos: - "-q" - "--max-ctu-depth=10" - "--suppress=unusedFunction" + - "--force" From 25cdae4f4da702a32a80203315027defa1fea387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 17 Oct 2022 12:01:14 +0200 Subject: [PATCH 07/29] fix testsuite --- main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.cpp b/main.cpp index b7fceaa..f66f139 100644 --- a/main.cpp +++ b/main.cpp @@ -27,6 +27,12 @@ using namespace std; #include "src/DS2506.h" // 64kb EEPROM #include "src/DS2890.h" // Single channel digital potentiometer +uint32_t millis(void) +{ + static uint32_t counter = 0; + return counter++; +} + constexpr uint8_t operator "" _u8(const unsigned long long int value) { return static_cast(value); From f58ea0b68ab7ed27117c76cb00b13421dba52d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 17 Oct 2022 12:01:17 +0200 Subject: [PATCH 08/29] Update OneWireHub.cpp --- src/OneWireHub.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index 6b9d445..7ae0c7e 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -408,11 +408,13 @@ bool OneWireHub::recvAndProcessCmd(void) slave_selected = slave_list[getIndexOfNextSensorInList()]; // TODO: this might be expensive for weak uC and OW in Overdrive and only one device emulated - // -> look into optimizations (i.e. preselect when only one device present?) + // -> look into optimizations (i.e. preselect when only one device present?, move to switch-default section below) if( slave_selected->skip_multidrop ){ slave_selected->duty(this); - return false; // TODO: Find the root-cause. This fixes the issue but may cause other problems. + return false; + // TODO: Find the root-cause. This fixes the issue but may cause other problems. + // -> correct exit would be: return (_error != Error::NO_ERROR); } } From 496d8830ed6e9b361cdc9406b61cfe47f428f9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 17 Oct 2022 12:39:52 +0200 Subject: [PATCH 09/29] fix tests --- .codespellrc | 3 ++- .pre-commit-config.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.codespellrc b/.codespellrc index 719c29f..3ccdc40 100644 --- a/.codespellrc +++ b/.codespellrc @@ -3,7 +3,8 @@ builtin = clear,rare,informal,usage,code,en-GB_to_en-US -ignore-words-list = master,masters,slave,slaves,usera,thre,OD +ignore-words-list = od,master,masters,slave,slaves,usera,thre, +# note: use lower-case! # options without argument check-filenames = diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8625784..261c2c3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,6 +41,7 @@ repos: args: - "--enable=all" - "--std=c++11" + - "--language=c++" - "--platform=unix32" - "--verbose" - "-q" From d356ece4ee232d92615a4d248d7800ab38ccb7cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 17 Oct 2022 14:29:39 +0200 Subject: [PATCH 10/29] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 261c2c3..c4a9395 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,3 +48,5 @@ repos: - "--max-ctu-depth=10" - "--suppress=unusedFunction" - "--force" + - "-I./src" + - "--check-config" From aed3d9c84ef50b29d3177f0d9f612f2a82c43f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sat, 29 Oct 2022 11:46:54 +0200 Subject: [PATCH 11/29] Update DS2434_IBM701c.ino --- examples/DS2434_IBM701c/DS2434_IBM701c.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/DS2434_IBM701c/DS2434_IBM701c.ino b/examples/DS2434_IBM701c/DS2434_IBM701c.ino index 8f3db09..6c272a2 100644 --- a/examples/DS2434_IBM701c/DS2434_IBM701c.ino +++ b/examples/DS2434_IBM701c/DS2434_IBM701c.ino @@ -2,7 +2,8 @@ * Example-Code that emulates a DS2434 with Battery Management & EEPROM * * Tested with -* - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave +* - IBM 701c - due to special non-standard onewire-usage + * - arduino uno target: 4318 byte PROG, 392 byte RAM */ #include "OneWireHub.h" From 105e1e1d39208138cfe062432305f6ac0546ec87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 7 Nov 2022 13:54:02 +0100 Subject: [PATCH 12/29] Update OneWireHub.cpp --- src/OneWireHub.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index 7ae0c7e..e5c176e 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -408,7 +408,9 @@ bool OneWireHub::recvAndProcessCmd(void) slave_selected = slave_list[getIndexOfNextSensorInList()]; // TODO: this might be expensive for weak uC and OW in Overdrive and only one device emulated - // -> look into optimizations (i.e. preselect when only one device present?, move to switch-default section below) + // -> look into optimizations, i.e.: + // - preselect when only one device present? + // - move that at the end of switch in default (less impact for all other hosts) if( slave_selected->skip_multidrop ){ slave_selected->duty(this); From e50e14a93e50a976328137c8f89ae61a74bbc62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 7 Nov 2022 14:23:18 +0100 Subject: [PATCH 13/29] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d9cb89..7da5031 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL - **DS2431 (0x2D) 1kbit protected EEPROM** (also known as DS1972 or DS28E07, same FC) - DS2432 (0x33) 1kbit protected EEPROM (basically a ds2431 with extra sha-engine) - **DS2433 (0x23) 4Kbit EEPROM** (also known as DS1973) -- DS2434 (0x1B ???) BatteryManagement used in some IBM Notebook-Batteries (similar to DS2436 (x1B), but without multidrop and one less cmd) +- DS2434 BatteryManagement used in some IBM Notebook-Batteries -> moved to [special branch of the OWHub](https://github.com/orgua/OneWireHub/tree/tiny-ds2434) - **DS2438 (0x26) Smart Battery Monitor, measures temperature, 2x voltage and current, 10bit** - **DS2450 (0x20) 4 channel A/D** - **DS2501 (0x11, 0x91) 512bit EEPROM** -> use DS2502 with different family code From c5bdf3ee940d58da7b5d83304e3510609e42260e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 12:15:16 +0200 Subject: [PATCH 14/29] reformat code, bump version, update deps --- .clang-format | 6 +- .codespellrc | 2 +- .pre-commit-config.yaml | 17 +- README.md | 2 +- examples/BAE910_device/BAE910_device.ino | 22 +- .../DS18B20_asInterface.ino | 43 +- .../DS18B20_thermometer.ino | 32 +- examples/DS2401_serial/DS2401_serial.ino | 30 +- examples/DS2405_switch/DS2405_switch.ino | 11 +- examples/DS2408_switch/DS2408_switch.ino | 38 +- examples/DS2413_switch/DS2413_switch.ino | 33 +- examples/DS2423_RAM/DS2423_RAM.ino | 19 +- examples/DS2430_EEPROM/DS2430_EEPROM.ino | 8 +- examples/DS2431_EEPROM/DS2431_EEPROM.ino | 47 +- examples/DS2433_EEPROM/DS2433_EEPROM.ino | 15 +- examples/DS2434_IBM701c/DS2434_IBM701c.ino | 20 +- examples/DS2438_battMon/DS2438_battMon.ino | 40 +- examples/DS2450_ADC/DS2450_ADC.ino | 24 +- examples/DS2502_DELLCHG/DS2502_DELLCHG.ino | 22 +- examples/DS2502_EEPROM/DS2502_EEPROM.ino | 23 +- examples/DS2506_EEPROM/DS2506_EEPROM.ino | 36 +- examples/DS2890_poti/DS2890_poti.ino | 26 +- examples/OneWireHubTest/OneWireHubTest.ino | 50 +- .../debug/CRC-Comparison/CRC-Comparison.ino | 109 ++-- .../attiny85-4slaves/attiny85-4slaves.ino | 28 +- .../calibrate_by_bus_timing.ino | 38 +- .../irq-driven-playground.ino | 26 +- .../optimize_pinAccess/optimize_pinAccess.ino | 29 +- .../programsize_documentation.ino | 9 +- library.json | 45 +- library.properties | 2 +- main.cpp | 468 +++++++++-------- src/BAE910.cpp | 60 +-- src/BAE910.h | 26 +- src/DS18B20.cpp | 40 +- src/DS18B20.h | 10 +- src/DS2401.cpp | 14 +- src/DS2401.h | 9 +- src/DS2405.cpp | 9 +- src/DS2405.h | 19 +- src/DS2408.cpp | 116 +++-- src/DS2408.h | 34 +- src/DS2413.cpp | 23 +- src/DS2413.h | 28 +- src/DS2423.cpp | 144 +++--- src/DS2423.h | 47 +- src/DS2430.cpp | 80 +-- src/DS2430.h | 33 +- src/DS2431.cpp | 173 ++++--- src/DS2431.h | 50 +- src/DS2433.cpp | 94 ++-- src/DS2433.h | 34 +- src/DS2434.cpp | 277 +++++----- src/DS2434.h | 77 +-- src/DS2438.cpp | 102 ++-- src/DS2438.h | 84 ++- src/DS2450.cpp | 54 +- src/DS2450.h | 20 +- src/DS2502.cpp | 105 ++-- src/DS2502.h | 52 +- src/DS2506.cpp | 221 ++++---- src/DS2506.h | 80 +-- src/DS2890.cpp | 70 +-- src/DS2890.h | 44 +- src/OneWireHub.cpp | 318 ++++++------ src/OneWireHub.h | 117 +++-- src/OneWireHub_config.h | 54 +- src/OneWireItem.cpp | 20 +- src/OneWireItem.h | 27 +- src/platform.cpp | 8 +- src/platform.h | 484 +++++++++--------- 71 files changed, 2326 insertions(+), 2251 deletions(-) diff --git a/.clang-format b/.clang-format index 417bce0..d34d9cd 100644 --- a/.clang-format +++ b/.clang-format @@ -3,13 +3,13 @@ BasedOnStyle: LLVM AccessModifierOffset: -4 AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: AcrossEmptyLinesAndComments +AlignConsecutiveAssignments: AcrossComments # Enabled: true # TODO: pyClangFormat fails with this style # AcrossEmptyLines: true # AcrossComments: true # AlignCompound: true -AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments -AlignConsecutiveMacros: AcrossEmptyLinesAndComments +AlignConsecutiveDeclarations: AcrossComments +AlignConsecutiveMacros: AcrossComments AlignTrailingComments: true AlignOperands: Align AllowAllArgumentsOnNextLine: false diff --git a/.codespellrc b/.codespellrc index 3ccdc40..be8dd00 100644 --- a/.codespellrc +++ b/.codespellrc @@ -3,7 +3,7 @@ builtin = clear,rare,informal,usage,code,en-GB_to_en-US -ignore-words-list = od,master,masters,slave,slaves,usera,thre, +ignore-words-list = od,usera,thre,usere # note: use lower-case! # options without argument diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c4a9395..4dcab77 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ # install pip3 install pre-commit # sudo apt install cppcheck -# run pre-commit run --all-files +# run pre-commit run -a # update pre-commit autoupdate repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-yaml - id: end-of-file-fixer @@ -22,16 +22,15 @@ repos: - id: fix-byte-order-marker - repo: https://github.com/codespell-project/codespell - rev: "v2.2.2" + rev: "v2.2.5" hooks: - id: codespell -# - repo: https://github.com/pre-commit/mirrors-clang-format -# rev: 'v14.0.6' -# hooks: -# - id: clang-format -# types_or: [c++, c] -# TODO: activate later + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: 'v15.0.7' + hooks: + - id: clang-format + #types_or: [c++, c] # cpp-check comes last! fails if uninstalled - repo: https://github.com/pocc/pre-commit-hooks diff --git a/README.md b/README.md index 7da5031..4a946c3 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### HELP - What to do if things don't work as expected? - check if your arduino software up to date (>v1.8.0) -- update this lib to the latest release (v2.2.4) +- update this lib to the latest release (v3.0.0) - if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation - check if clock-speed of the µC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical - begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the master won't switch to higher data rates diff --git a/examples/BAE910_device/BAE910_device.ino b/examples/BAE910_device/BAE910_device.ino index 540fc50..c432ccc 100644 --- a/examples/BAE910_device/BAE910_device.ino +++ b/examples/BAE910_device/BAE910_device.ino @@ -5,12 +5,12 @@ * Tested with: */ +#include "BAE910.h" // 3rd party OneWire slave device, family code 0xFC #include "OneWireHub.h" -#include "BAE910.h" // 3rd party OneWire slave device, family code 0xFC -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; -constexpr uint8_t pin_analog { 0 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; +constexpr uint8_t pin_analog{0}; auto hub = OneWireHub(pin_onewire); auto bae910 = BAE910(BAE910::family_code, 0x00, 0x00, 0x10, 0xE9, 0xBA, 0x00); @@ -26,7 +26,7 @@ void setup() // Setup OneWire hub.attach(bae910); - bae910.memory.field.SW_VER = 0x01; + bae910.memory.field.SW_VER = 0x01; bae910.memory.field.BOOTSTRAP_VER = 0x01; Serial.println("config done"); @@ -52,15 +52,15 @@ void loop() bool blinking(void) { - const uint32_t interval = 500; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 500; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS18B20_asInterface/DS18B20_asInterface.ino b/examples/DS18B20_asInterface/DS18B20_asInterface.ino index 02871b1..50a8ce3 100644 --- a/examples/DS18B20_asInterface/DS18B20_asInterface.ino +++ b/examples/DS18B20_asInterface/DS18B20_asInterface.ino @@ -11,11 +11,11 @@ constexpr bool enable_debug = 0; -#include "OneWireHub.h" #include "DS18B20.h" +#include "OneWireHub.h" -#include #include "i2c.h" +#include #include "i2c_TCS3772.h" TCS3772 tcs3772; @@ -26,18 +26,23 @@ MPL3115A2 mpl3115; #include "i2c_SI7021.h" SI7021 si7021; -constexpr uint8_t pin_led { 8 }; -constexpr uint8_t pin_onewire { 1 }; +constexpr uint8_t pin_led{8}; +constexpr uint8_t pin_onewire{1}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); -auto ds18b0 = DS18B20(0x28, 0x00, 0x55, 0x44, 0x33, 0x22, 0x11); // Light, RED, without unit, int16 from 0 to 2047 +auto ds18b0 = DS18B20(0x28, 0x00, 0x55, 0x44, 0x33, 0x22, + 0x11); // Light, RED, without unit, int16 from 0 to 2047 auto ds18b1 = DS18B20(0x28, 0x01, 0x55, 0x44, 0x33, 0x22, 0x11); // Light, GREEN, same as above auto ds18b2 = DS18B20(0x28, 0x02, 0x55, 0x44, 0x33, 0x22, 0x11); // Light, BLUE, same as above auto ds18b3 = DS18B20(0x28, 0x03, 0x55, 0x44, 0x33, 0x22, 0x11); // Light, CLEAR, same as above -auto ds18b4 = DS18B20(0x28, 0x04, 0x55, 0x44, 0x33, 0x22, 0x11); // Pressure, pascal - sealevel (101325), int16 from -2048 to +2047 -auto ds18b5 = DS18B20(0x28, 0x05, 0x55, 0x44, 0x33, 0x22, 0x11); // humidity, percent * 16, int16 from 0 to 1600 (translates to 0 to 100%) -auto ds18b6 = DS18B20(0x28, 0x06, 0x55, 0x44, 0x33, 0x22, 0x11); // temp, °C*16, int16 from -2048 to +2047 (translates to -128 to 128°C) +auto ds18b4 = DS18B20(0x28, 0x04, 0x55, 0x44, 0x33, 0x22, + 0x11); // Pressure, pascal - sealevel (101325), int16 from -2048 to +2047 +auto ds18b5 = + DS18B20(0x28, 0x05, 0x55, 0x44, 0x33, 0x22, + 0x11); // humidity, percent * 16, int16 from 0 to 1600 (translates to 0 to 100%) +auto ds18b6 = DS18B20(0x28, 0x06, 0x55, 0x44, 0x33, 0x22, + 0x11); // temp, °C*16, int16 from -2048 to +2047 (translates to -128 to 128°C) auto ds18b7 = DS18B20(0x28, 0x07, 0x55, 0x44, 0x33, 0x22, 0x11); // unused #include @@ -47,7 +52,7 @@ bool blinking(void); void setup() { wdt_reset(); - wdt_enable (WDTO_250MS); + wdt_enable(WDTO_250MS); if (enable_debug) { @@ -121,9 +126,9 @@ void updateSensorTCS(void) // 8560 559 Serial.println(""); } - for (uint8_t i=0; i<4; ++i) + for (uint8_t i = 0; i < 4; ++i) { - value_crgb[i] = value_crgb[i]>>2; + value_crgb[i] = value_crgb[i] >> 2; if (value_crgb[i] > 2047) value_crgb[i] = 2047; } @@ -190,21 +195,21 @@ void loop() if (process == 0) updateSensorTCS(); if (process == 1) updateSensorMPL(); if (process == 2) updateSensorSI7(); - if (++process>2) process = 0; + if (++process > 2) process = 0; } } bool blinking(void) { - constexpr uint32_t interval = 1000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + constexpr uint32_t interval = 1000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS18B20_thermometer/DS18B20_thermometer.ino b/examples/DS18B20_thermometer/DS18B20_thermometer.ino index 431307e..6758851 100644 --- a/examples/DS18B20_thermometer/DS18B20_thermometer.ino +++ b/examples/DS18B20_thermometer/DS18B20_thermometer.ino @@ -6,17 +6,20 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ +#include "DS18B20.h" // Digital Thermometer, 12bit #include "OneWireHub.h" -#include "DS18B20.h" // Digital Thermometer, 12bit -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); -auto ds18b20 = DS18B20(DS18B20::family_code, 0x00, 0x00, 0xB2, 0x18, 0xDA, 0x00); // DS18B20: 9-12bit, -55 - +85 degC -auto ds18s20 = DS18B20(0x10, 0x00, 0x00, 0xA2, 0x18, 0xDA, 0x00); // DS18S20: 9 bit, -55 - +85 degC -auto ds1822 = DS18B20(0x22, 0x00, 0x00, 0x22, 0x18, 0xDA, 0x00); // DS1822: 9-12bit, -55 - +125 degC +auto ds18b20 = DS18B20(DS18B20::family_code, 0x00, 0x00, 0xB2, 0x18, 0xDA, + 0x00); // DS18B20: 9-12bit, -55 - +85 degC +auto ds18s20 = + DS18B20(0x10, 0x00, 0x00, 0xA2, 0x18, 0xDA, 0x00); // DS18S20: 9 bit, -55 - +85 degC +auto ds1822 = + DS18B20(0x22, 0x00, 0x00, 0x22, 0x18, 0xDA, 0x00); // DS1822: 9-12bit, -55 - +125 degC bool blinking(void); @@ -43,7 +46,8 @@ void setup() ds18s20.setTemperature(int8_t(-55)); Serial.print(ds18b20.getTemperature()); Serial.print(", "); - Serial.println(ds18s20.getTemperature()); // ds18s20 is limited to signed 9bit, so it could behave different + Serial.println( + ds18s20.getTemperature()); // ds18s20 is limited to signed 9bit, so it could behave different Serial.print("Test - set Temperatures to 0 degC: "); ds18b20.setTemperature(int8_t(0)); @@ -99,15 +103,15 @@ void loop() bool blinking(void) { - constexpr uint32_t interval = 1000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + constexpr uint32_t interval = 1000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS2401_serial/DS2401_serial.ino b/examples/DS2401_serial/DS2401_serial.ino index f9860fc..4d3ccb7 100644 --- a/examples/DS2401_serial/DS2401_serial.ino +++ b/examples/DS2401_serial/DS2401_serial.ino @@ -6,17 +6,19 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ +#include "DS2401.h" // Serial Number #include "OneWireHub.h" -#include "DS2401.h" // Serial Number -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); -auto ds2401A = DS2401( DS2401::family_code, 0x00, 0xA0, 0x01, 0x24, 0xDA, 0x00 ); // Work - Serial Number -auto ds2401B = DS2401( DS2401::family_code, 0x00, 0xB0, 0x01, 0x24, 0xDA, 0x00 ); // Work - Serial Number -auto ds2401C = DS2401( DS2401::family_code, 0x00, 0xC0, 0x01, 0x24, 0xDA, 0x00 ); -auto ds1990A = DS2401( 0x81, 0x00, 0xA0, 0x90, 0x19, 0xDA, 0x00 ); +auto hub = OneWireHub(pin_onewire); +auto ds2401A = + DS2401(DS2401::family_code, 0x00, 0xA0, 0x01, 0x24, 0xDA, 0x00); // Work - Serial Number +auto ds2401B = + DS2401(DS2401::family_code, 0x00, 0xB0, 0x01, 0x24, 0xDA, 0x00); // Work - Serial Number +auto ds2401C = DS2401(DS2401::family_code, 0x00, 0xC0, 0x01, 0x24, 0xDA, 0x00); +auto ds1990A = DS2401(0x81, 0x00, 0xA0, 0x90, 0x19, 0xDA, 0x00); bool blinking(void); @@ -68,15 +70,15 @@ void loop() bool blinking(void) { - const uint32_t interval = 50000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 50000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS2405_switch/DS2405_switch.ino b/examples/DS2405_switch/DS2405_switch.ino index 6f220b9..24ff9ea 100644 --- a/examples/DS2405_switch/DS2405_switch.ino +++ b/examples/DS2405_switch/DS2405_switch.ino @@ -6,14 +6,15 @@ * - Note: feedback to master is unclear, ds9490 does not read after matchRom */ +#include "DS2405.h" // Dual channel addressable switch #include "OneWireHub.h" -#include "DS2405.h" // Dual channel addressable switch -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; auto hub = OneWireHub(pin_onewire); -auto ds2405 = DS2405( DS2405::family_code, 0x00, 0x00, 0x05, 0x24, 0xDA, 0x00 ); // Work - Dual channel addressable switch +auto ds2405 = DS2405(DS2405::family_code, 0x00, 0x00, 0x05, 0x24, 0xDA, + 0x00); // Work - Dual channel addressable switch void setup() { @@ -51,6 +52,4 @@ void loop() digitalWrite(pin_led, switch_state); } - - } diff --git a/examples/DS2408_switch/DS2408_switch.ino b/examples/DS2408_switch/DS2408_switch.ino index 36d0942..e75773f 100644 --- a/examples/DS2408_switch/DS2408_switch.ino +++ b/examples/DS2408_switch/DS2408_switch.ino @@ -14,14 +14,14 @@ * */ -#include "OneWireHub.h" #include "DS2408.h" +#include "OneWireHub.h" -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; auto hub = OneWireHub(pin_onewire); -auto ds2408 = DS2408( DS2408::family_code, 0x00, 0x00, 0x08, 0x24, 0xDA, 0x00 ); +auto ds2408 = DS2408(DS2408::family_code, 0x00, 0x00, 0x08, 0x24, 0xDA, 0x00); bool blinking(void); @@ -38,12 +38,12 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test - clear Activity-State of GPIO 3"); Serial.println(ds2408.getPinActivity(3)); - ds2408.setPinActivity(3,0); + ds2408.setPinActivity(3, 0); Serial.println(ds2408.getPinActivity(3)); Serial.println("Test - clear State of GPIO 3"); Serial.println(ds2408.getPinState(3)); - ds2408.setPinState(3,0); + ds2408.setPinState(3, 0); Serial.println(ds2408.getPinState(3)); Serial.println(ds2408.getPinActivity(3)); // is active again @@ -61,12 +61,12 @@ void loop() digitalWrite(10, ds2408.getPinState(0)); digitalWrite(11, ds2408.getPinState(1)); - digitalWrite(2, ds2408.getPinState(2)); - digitalWrite(3, ds2408.getPinState(3)); - digitalWrite(4, ds2408.getPinState(4)); - digitalWrite(5, ds2408.getPinState(5)); - digitalWrite(6, ds2408.getPinState(6)); - digitalWrite(7, ds2408.getPinState(7)); + digitalWrite(2, ds2408.getPinState(2)); + digitalWrite(3, ds2408.getPinState(3)); + digitalWrite(4, ds2408.getPinState(4)); + digitalWrite(5, ds2408.getPinState(5)); + digitalWrite(6, ds2408.getPinState(6)); + digitalWrite(7, ds2408.getPinState(7)); // Blink triggers the state-change if (blinking()) @@ -74,21 +74,21 @@ void loop() // this could be used to report up to eight states to 1wire master //ds2408.setPinState(0, digitalRead(10)); Serial.print("0x"); - Serial.println(ds2408.getPinState(),BIN); + Serial.println(ds2408.getPinState(), BIN); } } bool blinking(void) { - const uint32_t interval = 1000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 1000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS2413_switch/DS2413_switch.ino b/examples/DS2413_switch/DS2413_switch.ino index 2e152eb..8903523 100644 --- a/examples/DS2413_switch/DS2413_switch.ino +++ b/examples/DS2413_switch/DS2413_switch.ino @@ -5,14 +5,15 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ +#include "DS2413.h" // Dual channel addressable switch #include "OneWireHub.h" -#include "DS2413.h" // Dual channel addressable switch -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; auto hub = OneWireHub(pin_onewire); -auto ds2413 = DS2413( DS2413::family_code, 0x00, 0x00, 0x13, 0x24, 0xDA, 0x00 ); // Work - Dual channel addressable switch +auto ds2413 = DS2413(DS2413::family_code, 0x00, 0x00, 0x13, 0x24, 0xDA, + 0x00); // Work - Dual channel addressable switch bool blinking(void); @@ -29,26 +30,26 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test - set State of switch 0"); Serial.println(ds2413.getPinState(0)); - ds2413.setPinState(0,1); + ds2413.setPinState(0, 1); Serial.println(ds2413.getPinState(0)); Serial.println("Test - set State of switch 1"); - ds2413.setPinState(1,1); + ds2413.setPinState(1, 1); Serial.println(ds2413.getPinState(1)); Serial.println("Test - set Latch of switch 1"); Serial.println(ds2413.getPinLatch(1)); - ds2413.setPinLatch(1,1); + ds2413.setPinLatch(1, 1); Serial.println(ds2413.getPinLatch(1)); // latch is set Serial.println("Test - check State of switch 1"); Serial.println(ds2413.getPinState(1)); // will be zero because of latching - ds2413.setPinState(1,1); + ds2413.setPinState(1, 1); Serial.println(ds2413.getPinState(1)); // still zero Serial.println("Test - disable latch and set State of switch 1"); - ds2413.setPinLatch(1,0); - ds2413.setPinState(1,1); + ds2413.setPinLatch(1, 0); + ds2413.setPinState(1, 1); Serial.println(ds2413.getPinState(1)); // works again, no latching Serial.println("config done"); @@ -76,15 +77,15 @@ void loop() bool blinking(void) { - const uint32_t interval = 1000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 1000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS2423_RAM/DS2423_RAM.ino b/examples/DS2423_RAM/DS2423_RAM.ino index decd2a1..bfc5ce8 100644 --- a/examples/DS2423_RAM/DS2423_RAM.ino +++ b/examples/DS2423_RAM/DS2423_RAM.ino @@ -7,12 +7,12 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ -#include "OneWireHub.h" #include "DS2423.h" +#include "OneWireHub.h" -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); auto ds2423 = DS2423(DS2423::family_code, 0x00, 0x00, 0x23, 0x24, 0xDA, 0x00); void setup() @@ -26,25 +26,26 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test Write Text Data to page 0"); constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; - ds2423.writeMemory(reinterpret_cast(memory),sizeof(memory),0x00); + ds2423.writeMemory(reinterpret_cast(memory), sizeof(memory), 0x00); Serial.println("Test Write binary Data to page 1"); - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 1*32); + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 1 * 32); Serial.print("Test Read binary Data to page 1: 0x"); uint8_t mem_read[16]; ds2423.readMemory(mem_read, 16, 31); // begin one byte earlier than page 1 - Serial.println(mem_read[2],HEX); // should read 0x11 + Serial.println(mem_read[2], HEX); // should read 0x11 Serial.println("Test Write binary Data to page 12 and influence counter0"); Serial.println(ds2423.getCounter(0)); - ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 12*32+16); // second half of page 12 + ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 12 * 32 + 16); // second half of page 12 Serial.println(ds2423.getCounter(0)); Serial.println("Test Read and write Counter 1: "); Serial.println(ds2423.getCounter(1)); - ds2423.setCounter(1,2000); + ds2423.setCounter(1, 2000); Serial.println(ds2423.getCounter(1)); Serial.println("Test Inc and Decrement Counter 2: "); diff --git a/examples/DS2430_EEPROM/DS2430_EEPROM.ino b/examples/DS2430_EEPROM/DS2430_EEPROM.ino index 19f1364..bffb0af 100644 --- a/examples/DS2430_EEPROM/DS2430_EEPROM.ino +++ b/examples/DS2430_EEPROM/DS2430_EEPROM.ino @@ -5,12 +5,12 @@ * - DS9490R-Controller, atmega328@16MHz as device-emulator */ -#include "OneWireHub.h" #include "DS2430.h" +#include "OneWireHub.h" -constexpr uint8_t pin_onewire { 2 }; +constexpr uint8_t pin_onewire{2}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); auto ds2430 = DS2430(DS2430::family_code, 0x00, 0x00, 0x31, 0x24, 0xDA, 0x00); void setup() @@ -24,7 +24,7 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test Write Text Data to page 0"); constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; - ds2430.writeMemory(reinterpret_cast(memory),sizeof(memory),0x00); + ds2430.writeMemory(reinterpret_cast(memory), sizeof(memory), 0x00); ds2430.syncScratchpad(); Serial.println("config done"); diff --git a/examples/DS2431_EEPROM/DS2431_EEPROM.ino b/examples/DS2431_EEPROM/DS2431_EEPROM.ino index 58f82e0..aa05512 100644 --- a/examples/DS2431_EEPROM/DS2431_EEPROM.ino +++ b/examples/DS2431_EEPROM/DS2431_EEPROM.ino @@ -6,12 +6,12 @@ * - tested on buspirate and two different real 1-wire masters (DS9490 and a PIC18-Device) */ -#include "OneWireHub.h" #include "DS2431.h" +#include "OneWireHub.h" -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); auto ds2431 = DS2431(DS2431::family_code, 0x00, 0x00, 0x31, 0x24, 0xDA, 0x00); void setup() @@ -25,36 +25,37 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test Write Text Data to page 0"); constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; - ds2431.writeMemory(reinterpret_cast(memory),sizeof(memory),0x00); + ds2431.writeMemory(reinterpret_cast(memory), sizeof(memory), 0x00); Serial.println("Test Write binary Data to page 1"); - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - ds2431.writeMemory(mem_dummy, sizeof(mem_dummy), 1*32); + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + ds2431.writeMemory(mem_dummy, sizeof(mem_dummy), 1 * 32); Serial.print("Test Read binary Data to page 1: 0x"); uint8_t mem_read[16]; ds2431.readMemory(mem_read, 16, 31); // begin one byte earlier than page 1 - Serial.println(mem_read[2],HEX); // should read 0x11 + Serial.println(mem_read[2], HEX); // should read 0x11 Serial.println("Test Set Page Protection for p1"); - Serial.println(ds2431.getPageProtection(1*32)); // ZERO - ds2431.setPageProtection(1*32); - Serial.println(ds2431.getPageProtection(1*32 - 1)); // ZERO, out of bounds - Serial.println(ds2431.getPageProtection(1*32)); // ONE - Serial.println(ds2431.getPageProtection(1*32 + 8)); // ONE - Serial.println(ds2431.getPageProtection(1*32 +16)); // ONE - Serial.println(ds2431.getPageProtection(2*32)); // ZERO, out of bounds + Serial.println(ds2431.getPageProtection(1 * 32)); // ZERO + ds2431.setPageProtection(1 * 32); + Serial.println(ds2431.getPageProtection(1 * 32 - 1)); // ZERO, out of bounds + Serial.println(ds2431.getPageProtection(1 * 32)); // ONE + Serial.println(ds2431.getPageProtection(1 * 32 + 8)); // ONE + Serial.println(ds2431.getPageProtection(1 * 32 + 16)); // ONE + Serial.println(ds2431.getPageProtection(2 * 32)); // ZERO, out of bounds Serial.println("Test Set EPROM Mode for p2"); - constexpr uint8_t mem_FF[] = { 0xFF, 0xFF }; - ds2431.writeMemory(reinterpret_cast(mem_FF),sizeof(mem_FF),2*32); - Serial.println(ds2431.getPageEpromMode(2*32)); // ZERO - ds2431.setPageEpromMode(2*32); - Serial.println(ds2431.getPageEpromMode(2*32 - 1)); // ZERO, out of bounds - Serial.println(ds2431.getPageEpromMode(2*32)); // ONE - Serial.println(ds2431.getPageEpromMode(2*32 + 8)); // ONE - Serial.println(ds2431.getPageEpromMode(2*32 +16)); // ONE - Serial.println(ds2431.getPageEpromMode(3*32)); // ZERO, out of bounds + constexpr uint8_t mem_FF[] = {0xFF, 0xFF}; + ds2431.writeMemory(reinterpret_cast(mem_FF), sizeof(mem_FF), 2 * 32); + Serial.println(ds2431.getPageEpromMode(2 * 32)); // ZERO + ds2431.setPageEpromMode(2 * 32); + Serial.println(ds2431.getPageEpromMode(2 * 32 - 1)); // ZERO, out of bounds + Serial.println(ds2431.getPageEpromMode(2 * 32)); // ONE + Serial.println(ds2431.getPageEpromMode(2 * 32 + 8)); // ONE + Serial.println(ds2431.getPageEpromMode(2 * 32 + 16)); // ONE + Serial.println(ds2431.getPageEpromMode(3 * 32)); // ZERO, out of bounds // ds2431.clearMemory(); // begin fresh after doing some work diff --git a/examples/DS2433_EEPROM/DS2433_EEPROM.ino b/examples/DS2433_EEPROM/DS2433_EEPROM.ino index 5d3ac20..ee75bf3 100644 --- a/examples/DS2433_EEPROM/DS2433_EEPROM.ino +++ b/examples/DS2433_EEPROM/DS2433_EEPROM.ino @@ -5,12 +5,12 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ -#include "OneWireHub.h" #include "DS2433.h" +#include "OneWireHub.h" -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); auto ds2433 = DS2433(DS2433::family_code, 0x00, 0x00, 0x33, 0x24, 0xDA, 0x00); void setup() @@ -24,16 +24,17 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test Write Text Data to page 0"); constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; - ds2433.writeMemory(reinterpret_cast(memory),sizeof(memory),0x00); + ds2433.writeMemory(reinterpret_cast(memory), sizeof(memory), 0x00); Serial.println("Test Write binary Data to page 1"); - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - ds2433.writeMemory(mem_dummy, sizeof(mem_dummy), 1*32); + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + ds2433.writeMemory(mem_dummy, sizeof(mem_dummy), 1 * 32); Serial.print("Test Read binary Data to page 1: 0x"); uint8_t mem_read[16]; ds2433.readMemory(mem_read, 16, 31); // begin one byte earlier than page 1 - Serial.println(mem_read[2],HEX); // should read 0x11 + Serial.println(mem_read[2], HEX); // should read 0x11 // ds2433.clearMemory(); // begin fresh after doing some work diff --git a/examples/DS2434_IBM701c/DS2434_IBM701c.ino b/examples/DS2434_IBM701c/DS2434_IBM701c.ino index 6c272a2..6dff6ee 100644 --- a/examples/DS2434_IBM701c/DS2434_IBM701c.ino +++ b/examples/DS2434_IBM701c/DS2434_IBM701c.ino @@ -6,12 +6,12 @@ * - arduino uno target: 4318 byte PROG, 392 byte RAM */ -#include "OneWireHub.h" #include "DS2434.h" +#include "OneWireHub.h" -constexpr uint8_t pin_onewire { 2 }; +constexpr uint8_t pin_onewire{2}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); auto ds2434 = DS2434(0x1B, 0x01, 0x02, 0x12, 0x34, 0x56, 0x78); void setup() @@ -20,13 +20,14 @@ void setup() hub.attach(ds2434); // add default-data - constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c, - 0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0, - 0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial - ds2434.writeMemory(reinterpret_cast(mem1),sizeof(mem1),0x00); + constexpr uint8_t + mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c, 0xff, + 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0, 0x20, 0x20, + 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63}; // last 4 Byte seem to be Serial + ds2434.writeMemory(reinterpret_cast(mem1), sizeof(mem1), 0x00); - constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50 }; - ds2434.writeMemory(reinterpret_cast(mem2),sizeof(mem2),0x20); + constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50}; + ds2434.writeMemory(reinterpret_cast(mem2), sizeof(mem2), 0x20); ds2434.lockNV1(); ds2434.setID(0xCABDu); @@ -47,5 +48,4 @@ void loop() ds2434.setTemperature(temp++); if (temp > 25u) temp = 20u; } - } diff --git a/examples/DS2438_battMon/DS2438_battMon.ino b/examples/DS2438_battMon/DS2438_battMon.ino index c1c75ee..3cfbfc3 100644 --- a/examples/DS2438_battMon/DS2438_battMon.ino +++ b/examples/DS2438_battMon/DS2438_battMon.ino @@ -6,14 +6,15 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ +#include "DS2438.h" // Smart Battery Monitor #include "OneWireHub.h" -#include "DS2438.h" // Smart Battery Monitor -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; auto hub = OneWireHub(pin_onewire); -auto ds2438 = DS2438( DS2438::family_code, 0x00, 0x00, 0x38, 0x24, 0xDA, 0x00 ); // - Smart Battery Monitor +auto ds2438 = DS2438(DS2438::family_code, 0x00, 0x00, 0x38, 0x24, 0xDA, + 0x00); // - Smart Battery Monitor bool blinking(void); @@ -29,7 +30,7 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.print("Test: set Temperature in float 38 deg C: "); - ds2438.setTemperature(38.0f); // can vary from -55 to 125deg + ds2438.setTemperature(38.0f); // can vary from -55 to 125deg Serial.println(ds2438.getTemperature()); Serial.print("Test: set Voltage to 8.70 V: "); @@ -37,21 +38,22 @@ void setup() Serial.println(ds2438.getVoltage()); Serial.print("Test: set Current to 700 n: "); - ds2438.setCurrent(700); // hasn't any unit or scale + ds2438.setCurrent(700); // hasn't any unit or scale Serial.println(ds2438.getCurrent()); Serial.println("Test Write Text Data to page 3"); constexpr char memory[] = "abcASCII"; - ds2438.writeMemory(reinterpret_cast(memory),sizeof(memory),3*8); + ds2438.writeMemory(reinterpret_cast(memory), sizeof(memory), 3 * 8); Serial.println("Test Write binary Data to page 4&5"); - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - ds2438.writeMemory(mem_dummy, sizeof(mem_dummy), 4*8); + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + ds2438.writeMemory(mem_dummy, sizeof(mem_dummy), 4 * 8); Serial.print("Test Read binary Data to page 4: 0x"); uint8_t mem_read[16]; - ds2438.readMemory(mem_read, 16, 4*8-1); // begin one byte earlier than page begins - Serial.println(mem_read[2],HEX); // should read 0x11 + ds2438.readMemory(mem_read, 16, 4 * 8 - 1); // begin one byte earlier than page begins + Serial.println(mem_read[2], HEX); // should read 0x11 // values will be overwritten by the loop() @@ -71,8 +73,8 @@ void loop() static uint16_t current = 10; if ((temp += 0.05) > 30.0) temp = 10.0; - if ((volt_10mV++) > 200 ) volt_10mV = 10; - if ((current++) > 200 ) current = 10; + if ((volt_10mV++) > 200) volt_10mV = 10; + if ((current++) > 200) current = 10; ds2438.setTemperature(temp); ds2438.setVoltage(volt_10mV); @@ -84,15 +86,15 @@ void loop() bool blinking(void) { - const uint32_t interval = 2000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 2000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS2450_ADC/DS2450_ADC.ino b/examples/DS2450_ADC/DS2450_ADC.ino index 9fb688c..44e870c 100644 --- a/examples/DS2450_ADC/DS2450_ADC.ino +++ b/examples/DS2450_ADC/DS2450_ADC.ino @@ -5,14 +5,14 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ -#include "OneWireHub.h" #include "DS2450.h" +#include "OneWireHub.h" -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; auto hub = OneWireHub(pin_onewire); -auto ds2450 = DS2450( DS2450::family_code, 0x00, 0x00, 0x50, 0x24, 0xDA, 0x00 ); +auto ds2450 = DS2450(DS2450::family_code, 0x00, 0x00, 0x50, 0x24, 0xDA, 0x00); bool blinking(void); @@ -29,7 +29,7 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test - set all Potentiometers to 42"); Serial.println(ds2450.getPotentiometer(0)); - ds2450.setPotentiometer(42,42,42,42); // set all channels at once + ds2450.setPotentiometer(42, 42, 42, 42); // set all channels at once Serial.println(ds2450.getPotentiometer(0)); Serial.println(ds2450.getPotentiometer(1)); Serial.println(ds2450.getPotentiometer(2)); @@ -37,7 +37,7 @@ void setup() Serial.println("Test - set Potentiometer 1 to 55000"); Serial.println(ds2450.getPotentiometer(1)); - ds2450.setPotentiometer(1,55000); + ds2450.setPotentiometer(1, 55000); Serial.println(ds2450.getPotentiometer(1)); // ds2450.clearMemory(); // begin fresh after doing some work @@ -62,15 +62,15 @@ void loop() bool blinking(void) { - const uint32_t interval = 2000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 2000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino b/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino index 8cced05..c25f000 100644 --- a/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino +++ b/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino @@ -23,24 +23,26 @@ * !!! Note that some latest Dell models may ask for more information !!! */ -#include "OneWireHub.h" #include "DS2502.h" +#include "OneWireHub.h" // Using GPIO2 on an ESP01 module (Requires 10k pull-up to 3.3V) -constexpr uint8_t pin_onewire { 2 }; +constexpr uint8_t pin_onewire{2}; // EEPROM strings, the length is always 42 bytes, including 2 bytes of CRC16 checksum. -constexpr uint8_t chargerStrlen { 42 }; +constexpr uint8_t chargerStrlen{42}; // https://github.com/KivApple/dell-charger-emulator -constexpr const char* charger45W = "DELL00AC045195023CN0CDF577243865Q27F2A05\x3D\x94"; +constexpr const char *charger45W = "DELL00AC045195023CN0CDF577243865Q27F2A05\x3D\x94"; // https://nickschicht.wordpress.com/2009/07/15/dell-power-supply-fault/ -constexpr const char* charger65W = "DELL00AC065195033CN05U0927161552F31B8A03\xBC\x8F"; -constexpr const char* charger90W = "DELL00AC090195046CN0C80234866161R23H8A03\x4D\x7C"; +constexpr const char *charger65W = "DELL00AC065195033CN05U0927161552F31B8A03\xBC\x8F"; +constexpr const char *charger90W = "DELL00AC090195046CN0C80234866161R23H8A03\x4D\x7C"; // I made this up, works with Dell Inspiron 15R N5110 and Dell Inspiron 15R 5521 -constexpr const char* charger130W = "DELL00AC130195067CN0CDF577243865Q27F2233\x9D\x72"; +constexpr const char *charger130W = "DELL00AC130195067CN0CDF577243865Q27F2233\x9D\x72"; -auto hub = OneWireHub(pin_onewire); -auto dellCH = DS2502( 0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x0A); // address does not matter, laptop uses skipRom -> note that therefore only one slave device is allowed on the bus +auto hub = OneWireHub(pin_onewire); +auto dellCH = DS2502( + 0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, + 0x0A); // address does not matter, laptop uses skipRom -> note that therefore only one slave device is allowed on the bus void setup() { @@ -50,7 +52,7 @@ void setup() // Setup OneWire hub.attach(dellCH); // Populate the emulated EEPROM with the 42 byte ID string - dellCH.writeMemory((uint8_t*)charger130W, chargerStrlen); + dellCH.writeMemory((uint8_t *) charger130W, chargerStrlen); } void loop() diff --git a/examples/DS2502_EEPROM/DS2502_EEPROM.ino b/examples/DS2502_EEPROM/DS2502_EEPROM.ino index 602e369..bad7669 100644 --- a/examples/DS2502_EEPROM/DS2502_EEPROM.ino +++ b/examples/DS2502_EEPROM/DS2502_EEPROM.ino @@ -6,15 +6,15 @@ * - DS9490R-Master, atmega328@16MHz as Slave */ -#include "OneWireHub.h" #include "DS2502.h" +#include "OneWireHub.h" -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); -auto ds2502 = DS2502( DS2502::family_code, 0x00, 0xA0, 0x02, 0x25, 0xDA, 0x00 ); -auto ds2501a = DS2502( 0x91, 0x00, 0xA0, 0x01, 0x25, 0xDA, 0x00 ); -auto ds2501b = DS2502( 0x11, 0x00, 0xB0, 0x02, 0x25, 0xDA, 0x00 ); +auto hub = OneWireHub(pin_onewire); +auto ds2502 = DS2502(DS2502::family_code, 0x00, 0xA0, 0x02, 0x25, 0xDA, 0x00); +auto ds2501a = DS2502(0x91, 0x00, 0xA0, 0x01, 0x25, 0xDA, 0x00); +auto ds2501b = DS2502(0x11, 0x00, 0xB0, 0x02, 0x25, 0xDA, 0x00); void setup() { @@ -29,13 +29,14 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test Page Redirection p1 to p3"); Serial.println(ds2502.getPageRedirection(1)); - ds2502.setPageRedirection(1,3); + ds2502.setPageRedirection(1, 3); Serial.println(ds2502.getPageRedirection(1)); Serial.println("Test Write Data to page 3"); Serial.println(ds2502.getPageUsed(3)); - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - ds2502.writeMemory(mem_dummy, sizeof(mem_dummy), 3*32); + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + ds2502.writeMemory(mem_dummy, sizeof(mem_dummy), 3 * 32); Serial.println(ds2502.getPageUsed(3)); Serial.println("Test Write Data to protected page 0 -> is possible, only affects master"); @@ -48,8 +49,8 @@ void setup() Serial.print("Test Read binary Data to page 3: 0x"); uint8_t mem_read[16]; - ds2502.readMemory(mem_read, 16, 3*32 - 1); // begin one byte earlier than page 4 - Serial.println(mem_read[2],HEX); // should read 0x11 + ds2502.readMemory(mem_read, 16, 3 * 32 - 1); // begin one byte earlier than page 4 + Serial.println(mem_read[2], HEX); // should read 0x11 // ds2502.clearMemory(); // begin fresh after doing some work diff --git a/examples/DS2506_EEPROM/DS2506_EEPROM.ino b/examples/DS2506_EEPROM/DS2506_EEPROM.ino index 5dc9244..9093dc1 100644 --- a/examples/DS2506_EEPROM/DS2506_EEPROM.ino +++ b/examples/DS2506_EEPROM/DS2506_EEPROM.ino @@ -7,16 +7,16 @@ */ -#include "OneWireHub.h" #include "DS2506.h" +#include "OneWireHub.h" -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); -auto ds2503 = DS2506( 0x13, 0x00, 0x00, 0x03, 0x25, 0xDA, 0x00 ); -auto ds2505 = DS2506( 0x0B, 0x00, 0x00, 0x05, 0x25, 0xDA, 0x00 ); -auto ds2506 = DS2506( 0x0F, 0x00, 0x00, 0x06, 0x25, 0xDA, 0x00 ); +auto ds2503 = DS2506(0x13, 0x00, 0x00, 0x03, 0x25, 0xDA, 0x00); +auto ds2505 = DS2506(0x0B, 0x00, 0x00, 0x05, 0x25, 0xDA, 0x00); +auto ds2506 = DS2506(0x0F, 0x00, 0x00, 0x06, 0x25, 0xDA, 0x00); void setup() @@ -39,32 +39,33 @@ void setup() Serial.println("Test Page Redirection p3 to p4"); Serial.println(ds2506.getPageRedirection(3)); - ds2506.setPageRedirection(3,4); + ds2506.setPageRedirection(3, 4); Serial.println(ds2506.getPageRedirection(3)); Serial.println("Test Page Redirection p2 to p4 -> fails"); Serial.println(ds2506.getPageRedirection(2)); - ds2506.setPageRedirection(2,4); + ds2506.setPageRedirection(2, 4); Serial.println(ds2506.getPageRedirection(2)); // should show the same as before --> is protected Serial.println("Test Write Data to page 4"); Serial.println(ds2506.getPageUsed(4)); // unused - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 4*32); + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 4 * 32); Serial.println(ds2506.getPageUsed(4)); // is used now Serial.println("Test Write Data to protected page 0 -> is possible, only affects master"); - Serial.println(ds2506.getPageUsed(0)); // is unused - Serial.println(ds2506.getPageProtection(0)); // is unprotected - ds2506.setPageProtection(0); // protect it - Serial.println(ds2506.getPageProtection(0)); // is protected + Serial.println(ds2506.getPageUsed(0)); // is unused + Serial.println(ds2506.getPageProtection(0)); // is unprotected + ds2506.setPageProtection(0); // protect it + Serial.println(ds2506.getPageProtection(0)); // is protected ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 16); // write in second half of page - Serial.println(ds2506.getPageUsed(0)); // is used now + Serial.println(ds2506.getPageUsed(0)); // is used now Serial.print("Test Read binary Data to page 4: 0x"); uint8_t mem_read[16]; - ds2506.readMemory(mem_read, 16, 4*32 - 1); // begin one byte earlier than page 4 - Serial.println(mem_read[2],HEX); // should read 0x11 + ds2506.readMemory(mem_read, 16, 4 * 32 - 1); // begin one byte earlier than page 4 + Serial.println(mem_read[2], HEX); // should read 0x11 // ds2506.clearMemory(); // begin fresh after doing some work @@ -75,5 +76,4 @@ void loop() { // following function must be called periodically hub.poll(); - } diff --git a/examples/DS2890_poti/DS2890_poti.ino b/examples/DS2890_poti/DS2890_poti.ino index 020479f..dc860c0 100644 --- a/examples/DS2890_poti/DS2890_poti.ino +++ b/examples/DS2890_poti/DS2890_poti.ino @@ -5,14 +5,15 @@ * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave */ +#include "DS2890.h" // Single channel digital potentiometer #include "OneWireHub.h" -#include "DS2890.h" // Single channel digital potentiometer -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; auto hub = OneWireHub(pin_onewire); -auto ds2890 = DS2890( 0x2C, 0x00, 0x00, 0x90, 0x28, 0xDA, 0x00 ); // Work - Single channel digital potentiometer +auto ds2890 = DS2890(0x2C, 0x00, 0x00, 0x90, 0x28, 0xDA, + 0x00); // Work - Single channel digital potentiometer bool blinking(void); @@ -29,12 +30,12 @@ void setup() // Test-Cases: the following code is just to show basic functions, can be removed any time Serial.println("Test Potentiometer 0"); Serial.println(ds2890.getPotentiometer(0)); - ds2890.setPotentiometer(0,240); + ds2890.setPotentiometer(0, 240); Serial.println(ds2890.getPotentiometer(0)); Serial.println("Test Potentiometer 1"); Serial.println(ds2890.getPotentiometer(1)); - ds2890.setPotentiometer(1,255); + ds2890.setPotentiometer(1, 255); Serial.println(ds2890.getPotentiometer(1)); Serial.println("Test Read Control Register"); @@ -64,21 +65,20 @@ void loop() Serial.print(ds2890.getPotentiometer(3)); Serial.print(" of 255 with config: "); Serial.println(ds2890.getRegCtrl()); - } } bool blinking(void) { - const uint32_t interval = 500; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 500; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } diff --git a/examples/OneWireHubTest/OneWireHubTest.ino b/examples/OneWireHubTest/OneWireHubTest.ino index 66fbe54..120824c 100644 --- a/examples/OneWireHubTest/OneWireHubTest.ino +++ b/examples/OneWireHubTest/OneWireHubTest.ino @@ -29,37 +29,39 @@ #include "DS2502.h" // #include "DS2890.h" // Single channel digital potentiometer -constexpr uint8_t pin_led { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led{13}; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); -auto ds1822 = DS18B20(0x22, 0x0D, 0x01, 0x08, 0x02, 0x00, 0x00); -auto ds18B20 = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x00); // Work - Digital Thermometer -auto ds18S20 = DS18B20(0x10, 0x0D, 0x01, 0x08, 0x0F, 0x02, 0x00); -auto ds2401a = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A ); // Work - Serial Number -auto ds2401b = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B ); // Work - Serial Number -auto ds2405 = DS2405( 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - Single address switch +auto hub = OneWireHub(pin_onewire); +auto ds1822 = DS18B20(0x22, 0x0D, 0x01, 0x08, 0x02, 0x00, 0x00); +auto ds18B20 = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x00); // Work - Digital Thermometer +auto ds18S20 = DS18B20(0x10, 0x0D, 0x01, 0x08, 0x0F, 0x02, 0x00); +auto ds2401a = DS2401(0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A); // Work - Serial Number +auto ds2401b = DS2401(0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B); // Work - Serial Number +auto ds2405 = DS2405(0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // - Single address switch // auto ds2408 = DS2408( 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 8-Channel Addressable Switch -auto ds2413 = DS2413( 0x3A, 0x0D, 0x02, 0x04, 0x01, 0x03, 0x00 ); // Work - Dual channel addressable switch +auto ds2413 = + DS2413(0x3A, 0x0D, 0x02, 0x04, 0x01, 0x03, 0x00); // Work - Dual channel addressable switch // auto ds2423 = DS2423( 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4kb 1-Wire RAM with Counter // auto ds2433 = DS2433( 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4Kb 1-Wire EEPROM -auto ds2438 = DS2438( 0x26, 0x0D, 0x02, 0x04, 0x03, 0x08, 0x00 ); // - Smart Battery Monitor -auto ds2450 = DS2450( 0x20, 0x0D, 0x0A, 0x02, 0x04, 0x05, 0x00 ); // - 4 channel A/D -auto ds2890A = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0A ); // Work - Single channel digital potentiometer +auto ds2438 = DS2438(0x26, 0x0D, 0x02, 0x04, 0x03, 0x08, 0x00); // - Smart Battery Monitor +auto ds2450 = DS2450(0x20, 0x0D, 0x0A, 0x02, 0x04, 0x05, 0x00); // - 4 channel A/D +auto ds2890A = DS2890(0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, + 0x0A); // Work - Single channel digital potentiometer //auto ds2890B = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0B ); //auto ds2890C = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0C ); bool blinking() { - constexpr uint32_t interval = 500; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + constexpr uint32_t interval = 500; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(pin_led, ledState); return 1; } @@ -112,10 +114,10 @@ void loop() // DS2450 static uint16_t p1, p2, p3, p4; - p1 +=1; - p2 +=2; - p3 +=4; - p4 +=8; - ds2450.setPotentiometer(p1,p2,p3,p4); + p1 += 1; + p2 += 2; + p3 += 4; + p4 += 8; + ds2450.setPotentiometer(p1, p2, p3, p4); } } diff --git a/examples/debug/CRC-Comparison/CRC-Comparison.ino b/examples/debug/CRC-Comparison/CRC-Comparison.ino index 63a60d7..ae41369 100644 --- a/examples/debug/CRC-Comparison/CRC-Comparison.ino +++ b/examples/debug/CRC-Comparison/CRC-Comparison.ino @@ -29,11 +29,11 @@ void setup() Serial.begin(115200); Serial.println("Test-Code for faster CRC-Calculations"); - constexpr uint8_t li[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed " - "do eiusmod tempor incididunt ut labore et dolore magna " - "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " - "ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis " - "aute irure dolor"; + constexpr uint8_t li[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed " + "do eiusmod tempor incididunt ut labore et dolore magna " + "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " + "ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis " + "aute irure dolor"; constexpr uint8_t li_size = sizeof(li); Serial.print("CRC-ing "); @@ -47,8 +47,7 @@ void setup() v1A_crc16_reset(); time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - v1A_crc16_update(li[bytePos]); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) v1A_crc16_update(li[bytePos]); time_stop = micros(); Serial.print("Var 1A took "); @@ -59,10 +58,9 @@ void setup() /// Start Var 1B ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - v1B_crc16_update(li[bytePos], crc); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) v1B_crc16_update(li[bytePos], crc); time_stop = micros(); Serial.print("Var 1B took "); @@ -73,7 +71,7 @@ void setup() /// Start Var 1C ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) crc = v1C_crc16_update(li[bytePos], crc); @@ -87,10 +85,10 @@ void setup() /// Start Var 2A ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - crc = v2A_crc16(li, li_size); - time_stop = micros(); + crc = v2A_crc16(li, li_size); + time_stop = micros(); Serial.print("Var 2A took "); Serial.print(time_stop - time_start); @@ -100,10 +98,9 @@ void setup() /// Start Var 2B ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - crc = v2B_crc16(crc,li[bytePos], 1); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) crc = v2B_crc16(crc, li[bytePos], 1); time_stop = micros(); Serial.print("Var 2B took "); @@ -114,10 +111,9 @@ void setup() /// Start Var 2C ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - crc = v2C_crc16(crc, li[bytePos]); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) crc = v2C_crc16(crc, li[bytePos]); time_stop = micros(); Serial.print("Var 2C took "); @@ -128,10 +124,9 @@ void setup() /// Start Var 2D ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - v2D_crc16(crc, li[bytePos]); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) v2D_crc16(crc, li[bytePos]); time_stop = micros(); Serial.print("Var 2D took "); @@ -142,10 +137,9 @@ void setup() /// Start Var 2E ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - crc = v2E_crc16(crc, li[bytePos]); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) crc = v2E_crc16(crc, li[bytePos]); time_stop = micros(); Serial.print("Var 2E took "); @@ -157,10 +151,9 @@ void setup() /// Start Var 3A ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - crc = v3A_crc16(crc, li[bytePos]); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) crc = v3A_crc16(crc, li[bytePos]); time_stop = micros(); Serial.print("Var 3A took "); @@ -171,10 +164,9 @@ void setup() /// Start Var 3B ////////////////////////////////////////////////// - crc = 0; + crc = 0; time_start = micros(); - for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) - crc = _crc16_update(crc, li[bytePos]); + for (uint8_t bytePos = 0; bytePos < li_size; ++bytePos) crc = _crc16_update(crc, li[bytePos]); time_stop = micros(); Serial.print("Var 3B took "); @@ -182,23 +174,16 @@ void setup() Serial.print(" us, got "); Serial.println(crc, HEX); Serial.flush(); - } -void loop() -{ - -} +void loop() {} /// Variant 1A - old code static uint16_t crc16; -void v1A_crc16_reset(void) -{ - crc16 = 0; -} +void v1A_crc16_reset(void) { crc16 = 0; } void v1A_crc16_update(uint8_t b) { @@ -206,16 +191,12 @@ void v1A_crc16_update(uint8_t b) { const bool mix = (static_cast(crc16) ^ b) & static_cast(0x01); crc16 >>= 1; - if (mix) - crc16 ^= static_cast(0xA001); + if (mix) crc16 ^= static_cast(0xA001); b >>= 1; } } -uint16_t v1A_crc16_get(void) -{ - return crc16; -} +uint16_t v1A_crc16_get(void) { return crc16; } /// Variant 1B - break up the loop for parallel sending and try pass by reference @@ -229,7 +210,7 @@ bool v1B_crc16_update(uint8_t dataByte, uint16_t &crc16) uint8_t mix = ((uint8_t) crc16 ^ dataByte) & static_cast(0x01); crc16 >>= 1; - if (mix) crc16 ^= static_cast(0xA001); + if (mix) crc16 ^= static_cast(0xA001); dataByte >>= 1; //if (_error) return false; @@ -248,7 +229,7 @@ uint16_t v1C_crc16_update(uint8_t dataByte, uint16_t crc16) uint8_t mix = ((uint8_t) crc16 ^ dataByte) & static_cast(0x01); crc16 >>= 1; - if (mix) crc16 ^= static_cast(0xA001); + if (mix) crc16 ^= static_cast(0xA001); dataByte >>= 1; //if (_error) return false; @@ -260,8 +241,7 @@ uint16_t v1C_crc16_update(uint8_t dataByte, uint16_t crc16) uint16_t v2A_crc16(const uint8_t address[], const uint8_t len) { - static const uint8_t oddParity[16] = - {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; + static const uint8_t oddParity[16] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; uint16_t crc = 0; // init value @@ -270,11 +250,10 @@ uint16_t v2A_crc16(const uint8_t address[], const uint8_t len) // Even though we're just copying a byte from the input, // we'll be doing 16-bit computation with it. uint16_t cdata = address[i]; - cdata = (cdata ^ crc) & static_cast(0xff); + cdata = (cdata ^ crc) & static_cast(0xff); crc >>= 8; - if (oddParity[cdata & 0x0F] ^ oddParity[cdata >> 4]) - crc ^= 0xC001; + if (oddParity[cdata & 0x0F] ^ oddParity[cdata >> 4]) crc ^= 0xC001; cdata <<= 6; crc ^= cdata; @@ -290,19 +269,17 @@ uint16_t v2A_crc16(const uint8_t address[], const uint8_t len) uint16_t v2B_crc16(uint16_t crc, const uint8_t value, const uint8_t len) { - static const uint8_t oddParity[16] = - {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; + static const uint8_t oddParity[16] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; for (uint8_t i = 0; i < len; ++i) { // Even though we're just copying a byte from the input, // we'll be doing 16-bit computation with it. uint16_t cdata = value; - cdata = (cdata ^ crc) & static_cast(0xff); + cdata = (cdata ^ crc) & static_cast(0xff); crc >>= 8; - if (oddParity[cdata & 0x0F] ^ oddParity[cdata >> 4]) - crc ^= 0xC001; + if (oddParity[cdata & 0x0F] ^ oddParity[cdata >> 4]) crc ^= 0xC001; cdata <<= 6; crc ^= cdata; @@ -318,9 +295,9 @@ uint16_t v2B_crc16(uint16_t crc, const uint8_t value, const uint8_t len) uint16_t v2C_crc16(uint16_t crc, uint8_t value) { static const uint8_t oddParity[16] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; - value = (value ^ static_cast(crc)); + value = (value ^ static_cast(crc)); crc >>= 8; - if (oddParity[value & 0x0F] ^ oddParity[value >> 4]) crc ^= 0xC001; + if (oddParity[value & 0x0F] ^ oddParity[value >> 4]) crc ^= 0xC001; uint16_t cdata = (static_cast(value) << 6); crc ^= cdata; crc ^= (static_cast(cdata) << 1); @@ -332,9 +309,9 @@ uint16_t v2C_crc16(uint16_t crc, uint8_t value) void v2D_crc16(uint16_t &crc, uint8_t value) { static const uint8_t oddParity[16] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; - value = (value ^ static_cast(crc)); + value = (value ^ static_cast(crc)); crc >>= 8; - if (oddParity[value & 0x0F] ^ oddParity[value >> 4]) crc ^= 0xC001; + if (oddParity[value & 0x0F] ^ oddParity[value >> 4]) crc ^= 0xC001; uint16_t cdata = (static_cast(value) << 6); crc ^= cdata; crc ^= (static_cast(cdata) << 1); @@ -349,7 +326,7 @@ uint16_t v2E_crc16(uint16_t crc, uint8_t value) //value = (value ^ static_cast(crc)); value ^= static_cast(crc); crc >>= static_cast(8); - if (oddParity[value & 0x0F] ^ oddParity[value >> 4]) crc ^= 0xC001; + if (oddParity[value & 0x0F] ^ oddParity[value >> 4]) crc ^= 0xC001; //if (oddParity[static_cast(value & static_cast(0x0F))] ^ oddParity[value >> 4]) crc ^= 0xC001; // --> no difference //if (oddParity[value & 0x0F] ^ oddParity[static_cast(value >> static_cast(4))]) crc ^= 0xC001; // --> no difference //if (static_cast(oddParity[value & 0x0F] ^ oddParity[value >> 4])) crc ^= 0xC001; // --> no difference @@ -422,8 +399,8 @@ uint16_t v3A_crc16(uint16_t crc, uint8_t value) crc ^= value; for (uint8_t i = 0; i < 8; ++i) { - if (crc & 1) crc = (crc >> 1) ^ 0xA001; - else crc = (crc >> 1); + if (crc & 1) crc = (crc >> 1) ^ 0xA001; + else crc = (crc >> 1); } return crc; diff --git a/examples/debug/attiny85-4slaves/attiny85-4slaves.ino b/examples/debug/attiny85-4slaves/attiny85-4slaves.ino index 415b19e..8ced2d3 100644 --- a/examples/debug/attiny85-4slaves/attiny85-4slaves.ino +++ b/examples/debug/attiny85-4slaves/attiny85-4slaves.ino @@ -10,30 +10,30 @@ #include "OneWireHub.h" // include all libs to find errors -#include "DS2401.h" // Serial Number #include "DS18B20.h" // Digital Thermometer +#include "DS2401.h" // Serial Number -const uint8_t led_PIN = 1; // the number of the LED pin -const uint8_t OneWire_PIN = 2; +const uint8_t led_PIN = 1; // the number of the LED pin +const uint8_t OneWire_PIN = 2; -OneWireHub hub = OneWireHub(OneWire_PIN); -DS18B20 ds18B20a = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x0A); // Work - Digital Thermometer -DS18B20 ds18B20b = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x0B); -DS2401 ds2401a = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A ); // Work - Serial Number -DS2401 ds2401b = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B ); +OneWireHub hub = OneWireHub(OneWire_PIN); +DS18B20 ds18B20a = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x0A); // Work - Digital Thermometer +DS18B20 ds18B20b = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x0B); +DS2401 ds2401a = DS2401(0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A); // Work - Serial Number +DS2401 ds2401b = DS2401(0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B); bool blinking() { - const uint32_t interval = 5000; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 5000; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(led_PIN, ledState); return 1; } diff --git a/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino b/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino index 08f1689..6150356 100644 --- a/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino +++ b/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino @@ -15,15 +15,16 @@ * >>>> https://github.com/orgua/OneWireHub */ +#include "DS18B20.h" // Digital Thermometer, 12bit #include "OneWireHub.h" -#include "DS18B20.h" // Digital Thermometer, 12bit -constexpr uint8_t pin_led_dbg { 13 }; -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_led_dbg{13}; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); // do an bus-timing-calibration on first sensor-attachment +auto hub = OneWireHub(pin_onewire); // do an bus-timing-calibration on first sensor-attachment -auto ds18b20 = DS18B20(DS18B20::family_code, 0x00, 0x02, 0x0B, 0x08, 0x01, 0x0D); // Digital Thermometer +auto ds18b20 = + DS18B20(DS18B20::family_code, 0x00, 0x02, 0x0B, 0x08, 0x01, 0x0D); // Digital Thermometer ///////////////////////////////////////////////////////////////////////// /////// Main Code ////////////////////////////////////////// @@ -39,14 +40,14 @@ void setup() hub.attach(ds18b20); pinMode(pin_led_dbg, OUTPUT); - digitalWrite(pin_led_dbg,HIGH); + digitalWrite(pin_led_dbg, HIGH); } void loop() { - digitalWrite(pin_led_dbg,HIGH); + digitalWrite(pin_led_dbg, HIGH); const timeOW_t value_ipl = hub.waitLoopsCalibrate(); - digitalWrite(pin_led_dbg,LOW); + digitalWrite(pin_led_dbg, LOW); Serial.print(value_ipl); Serial.println("\t instructions per loop"); @@ -59,25 +60,28 @@ void loop() // advanced calibration loop --> try to track and measure it with a logic analyzer if (false) { - io_reg_t debug_bitMask = PIN_TO_BITMASK(pin_led_dbg); + io_reg_t debug_bitMask = PIN_TO_BITMASK(pin_led_dbg); volatile io_reg_t *debug_baseReg = PIN_TO_BASEREG(pin_led_dbg); pinMode(pin_led_dbg, OUTPUT); DIRECT_WRITE_LOW(debug_baseReg, debug_bitMask); - const timeOW_t loops_1ms = timeUsToLoops(uint16_t(VALUE1k)); - timeOW_t loops_left = 1; + const timeOW_t loops_1ms = timeUsToLoops(uint16_t(VALUE1k)); + timeOW_t loops_left = 1; while (loops_left) { DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); // Fast high low flank DIRECT_WRITE_LOW(debug_baseReg, debug_bitMask); - uint32_t retries = loops_1ms; // volatile needs ~2.5ms for the 1ms-loop .... but in a separate function it works as expected - while ((!DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)); // try to wait 1ms while LOW + uint32_t retries = + loops_1ms; // volatile needs ~2.5ms for the 1ms-loop .... but in a separate function it works as expected + while ((!DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)) + ; // try to wait 1ms while LOW DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); // switch to HIGH retries += loops_1ms; - while ((DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)); // try to wait 1ms while HIGH + while ((DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)) + ; // try to wait 1ms while HIGH loops_left = retries; DIRECT_WRITE_LOW(debug_baseReg, debug_bitMask); @@ -89,12 +93,14 @@ void loop() DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); // switch to HIGH uint32_t retries = loops_1ms; - while ((DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)); // try to wait 1ms while HIGH + while ((DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)) + ; // try to wait 1ms while HIGH DIRECT_WRITE_LOW(debug_baseReg, debug_bitMask); retries += loops_1ms; - while (!(DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)); // try to wait 1ms while LOW + while (!(DIRECT_READ(debug_baseReg, debug_bitMask)) && (--retries)) + ; // try to wait 1ms while LOW loops_left = retries; DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); // Fast high low flank diff --git a/examples/debug/irq-driven-playground/irq-driven-playground.ino b/examples/debug/irq-driven-playground/irq-driven-playground.ino index ed93f66..c060c3e 100644 --- a/examples/debug/irq-driven-playground/irq-driven-playground.ino +++ b/examples/debug/irq-driven-playground/irq-driven-playground.ino @@ -32,19 +32,19 @@ static jmp_buf break_here; */ -const uint8_t led_PIN = 13; +const uint8_t led_PIN = 13; bool blinking() { - const uint32_t interval = 500; // interval at which to blink (milliseconds) - static uint32_t nextMillis = millis(); // will store next time LED will updated + const uint32_t interval = 500; // interval at which to blink (milliseconds) + static uint32_t nextMillis = millis(); // will store next time LED will updated if (millis() > nextMillis) { - nextMillis += interval; // save the next time you blinked the LED - static uint8_t ledState = LOW; // ledState used to set the LED - if (ledState == LOW) ledState = HIGH; - else ledState = LOW; + nextMillis += interval; // save the next time you blinked the LED + static uint8_t ledState = LOW; // ledState used to set the LED + if (ledState == LOW) ledState = HIGH; + else ledState = LOW; digitalWrite(led_PIN, ledState); return 1; } @@ -61,13 +61,13 @@ void irq_mockup() if (has_to_resume) { has_to_resume = 0; - longjmp(break_here,1); + longjmp(break_here, 1); } //// put the state-machine here // waitReset // showPresence -/* + /* static bool flipFlop = true; if (flipFlop) @@ -89,7 +89,7 @@ void irq_mockup() bool send(const uint8_t dataByte) { Serial.print(" Sending 0x"); - Serial.print(dataByte,HEX); + Serial.print(dataByte, HEX); Serial.print(": "); for (uint8_t bitMask = 0x01; bitMask; bitMask <<= 1) @@ -103,17 +103,13 @@ bool send(const uint8_t dataByte) } - bool sendBit(const bool value) { Serial.print(value); Serial.print(" "); Serial.flush(); // wait for next Timeslot - if (setjmp(break_here)) - { - return true; - } + if (setjmp(break_here)) { return true; } else { has_to_resume = 1; diff --git a/examples/debug/optimize_pinAccess/optimize_pinAccess.ino b/examples/debug/optimize_pinAccess/optimize_pinAccess.ino index 579c53c..bf30f52 100644 --- a/examples/debug/optimize_pinAccess/optimize_pinAccess.ino +++ b/examples/debug/optimize_pinAccess/optimize_pinAccess.ino @@ -10,24 +10,25 @@ /////// From OnewireHub <0.9.7 ////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////// -uint8_t pin_bitMaskL; +uint8_t pin_bitMaskL; volatile uint8_t *baseRegL; void pinConfigLegacy(const uint8_t pin) { // setup direct pin-access pin_bitMaskL = digitalPinToBitMask(pin); - baseRegL = portInputRegister(digitalPinToPort(pin)); + baseRegL = portInputRegister(digitalPinToPort(pin)); } void pinTestLegacy(void) { - volatile uint8_t *reg asm("r30") = baseRegL; // note: asm only for AVR, really needed? investigate + volatile uint8_t *reg asm("r30") = + baseRegL; // note: asm only for AVR, really needed? investigate DIRECT_WRITE_LOW(reg, pin_bitMaskL); DIRECT_MODE_OUTPUT(reg, pin_bitMaskL); // set it low, so it always reads zero - while(1) + while (1) { DIRECT_WRITE_HIGH(reg, pin_bitMaskL); DIRECT_WRITE_LOW(reg, pin_bitMaskL); @@ -46,7 +47,7 @@ void pinTestLegacy(void) #define IO_REG_ASM asm("r30") */ -IO_REG_TYPE bitmask; +IO_REG_TYPE bitmask; volatile IO_REG_TYPE *baseReg; void pinConfigOneWireLib(const uint8_t pin) @@ -59,16 +60,16 @@ void pinConfigOneWireLib(const uint8_t pin) void pinTestOneWireLib(void) { - IO_REG_TYPE mask = bitmask; // note: why? it is already done, why not const + IO_REG_TYPE mask = bitmask; // note: why? it is already done, why not const volatile IO_REG_TYPE *reg IO_REG_ASM = baseReg; // TODO: really needed as a copy? why volatile // call noInterrupts(); // note: why needed? it does not need to be atomic, only with pin-changing interrupts DIRECT_WRITE_LOW(reg, mask); - DIRECT_MODE_OUTPUT(reg, mask); // drive output low + DIRECT_MODE_OUTPUT(reg, mask); // drive output low interrupts(); - while(1) + while (1) { DIRECT_WRITE_HIGH(reg, mask); DIRECT_WRITE_LOW(reg, mask); @@ -80,7 +81,8 @@ void pinTestOneWireLib(void) using io_reg_t = uint8_t; // define special datatype for register-access io_reg_t pin_bitMask; -volatile io_reg_t *pin_baseReg; // needs to be volatile, because its only written but never read, so it gets optimized out +volatile io_reg_t * + pin_baseReg; // needs to be volatile, because its only written but never read, so it gets optimized out void pinConfigClean(const uint8_t pin) { @@ -95,7 +97,7 @@ void pinTestClean(void) DIRECT_WRITE_LOW(pin_baseReg, pin_bitMask); DIRECT_MODE_OUTPUT(pin_baseReg, pin_bitMask); // put it low, so it always reads zero - while(1) + while (1) { DIRECT_WRITE_HIGH(pin_baseReg, pin_bitMask); DIRECT_WRITE_LOW(pin_baseReg, pin_bitMask); @@ -108,7 +110,7 @@ void setup() const uint8_t pin_test = 8; // measurement with oszi --> each of this work with an atmega328p, 16MHz Clock bring 571 kHz pinFreq for case 1-3, double for case 4 - switch(4) + switch (4) { case 0: case 1: @@ -134,7 +136,4 @@ void setup() } } -void loop() -{ - -} +void loop() {} diff --git a/examples/debug/programsize_documentation/programsize_documentation.ino b/examples/debug/programsize_documentation/programsize_documentation.ino index ac86053..4eff7b2 100644 --- a/examples/debug/programsize_documentation/programsize_documentation.ino +++ b/examples/debug/programsize_documentation/programsize_documentation.ino @@ -20,14 +20,15 @@ * 3440 // 128 bytes rework error-handling and send/recv-routines */ +#include "DS18B20.h" // Digital Thermometer, 12bit #include "OneWireHub.h" -#include "DS18B20.h" // Digital Thermometer, 12bit -constexpr uint8_t pin_onewire { 8 }; +constexpr uint8_t pin_onewire{8}; -auto hub = OneWireHub(pin_onewire); +auto hub = OneWireHub(pin_onewire); -auto ds18b20 = DS18B20(DS18B20::family_code, 0x00, 0x02, 0x0B, 0x08, 0x01, 0x0D); // Digital Thermometer +auto ds18b20 = + DS18B20(DS18B20::family_code, 0x00, 0x02, 0x0B, 0x08, 0x01, 0x0D); // Digital Thermometer void setup() diff --git a/library.json b/library.json index 48c41d2..e69c4e8 100644 --- a/library.json +++ b/library.json @@ -1,28 +1,27 @@ { -"name": "OneWireHub", -"frameworks": "Arduino", -"keywords": "onewire, 1-wire, bus, slave, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890", -"description": "OneWire slave device emulator with support for up to 32 simultaneous devices", -"authors": -[ - { - "name": "Ingmar Splitt", - "url": "https://github.com/orgua", - "maintainer": true + "name": "OneWireHub", + "frameworks": "Arduino", + "keywords": + "onewire, 1-wire, bus, slave, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890", + "description": "OneWire slave device emulator with support for up to 32 simultaneous devices", + "authors": [ + { + "name": "Ingmar Splitt", + "url": "https://github.com/orgua", + "maintainer": true + }, + { + "name": "MarkusLange" + }, + { + "name": "Shagrat2" + } + ], + "repository": { + "type": "git", + "url": "https://github.com/orgua/OneWireHub" }, - { - "name": "MarkusLange" - }, - { - "name": "Shagrat2" - } -], -"repository": -{ - "type": "git", - "url": "https://github.com/orgua/OneWireHub" -}, - "version": "2.2.4", + "version": "3.0.0", "examples": [ "examples/*/*.ino" ] diff --git a/library.properties b/library.properties index 982ecba..85cb09a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=OneWireHub -version=2.2.4 +version=3.0.0 author=Ingmar Splitt, orgua, MarkusLange, Shagrat2 maintainer=orgua sentence=OneWire slave device emulator with support for up to 32 simultaneous 1wire devices. diff --git a/main.cpp b/main.cpp index f66f139..7a646cc 100644 --- a/main.cpp +++ b/main.cpp @@ -1,14 +1,14 @@ // // // +#include #include #include -#include using namespace std; -#include "src/platform.h" #include "src/OneWireHub.h" +#include "src/platform.h" // include all libs to find errors #include "src/BAE910.h" @@ -27,33 +27,33 @@ using namespace std; #include "src/DS2506.h" // 64kb EEPROM #include "src/DS2890.h" // Single channel digital potentiometer -uint32_t millis(void) +uint32_t millis(void) { static uint32_t counter = 0; return counter++; } -constexpr uint8_t operator "" _u8(const unsigned long long int value) +constexpr uint8_t operator"" _u8(const unsigned long long int value) { return static_cast(value); } -constexpr uint32_t operator "" _u32(const unsigned long long int value) +constexpr uint32_t operator"" _u32(const unsigned long long int value) { return static_cast(value); } -constexpr int8_t operator "" _i8(const unsigned long long int value) +constexpr int8_t operator"" _i8(const unsigned long long int value) { return static_cast(value); } -constexpr int16_t operator "" _i16(const unsigned long long int value) +constexpr int16_t operator"" _i16(const unsigned long long int value) { return static_cast(value); } -constexpr int32_t operator "" _i32(const unsigned long long int value) +constexpr int32_t operator"" _i32(const unsigned long long int value) { return static_cast(value); } @@ -65,7 +65,8 @@ void test_eq(const T1 value_A, const T2 value_B, const string message) { if (value_A != value_B) { - cout << "- FAIL (" << to_string(value_A) << " != " << to_string(value_B) << ") " << message << endl; + cout << "- FAIL (" << to_string(value_A) << " != " << to_string(value_B) << ") " << message + << endl; tests_failed++; } tests_absolved++; @@ -74,8 +75,8 @@ void test_eq(const T1 value_A, const T2 value_B, const string message) template const vector initializeLinear(const T1 value_start, const T1 value_increment, const size_t size) { - vector data(size,value_start); - T1 value = value_start; + vector data(size, value_start); + T1 value = value_start; for (size_t index = 0; index < size; ++index) { data[index] = value; @@ -89,42 +90,48 @@ int main() { cout << "- initialize all devices" << endl; - constexpr uint8_t OneWire_PIN = 8; - - auto hubA = OneWireHub(OneWire_PIN); - auto hubB = OneWireHub(OneWire_PIN); - auto hubC = OneWireHub(OneWire_PIN); - auto hubD = OneWireHub(OneWire_PIN); - - auto ds1822 = DS18B20(0x22, 0x0D, 0x01, 0x08, 0x02, 0x00, 0x00); - auto ds18B20 = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x00); // Work - Digital Thermometer - auto ds18S20 = DS18B20(0x10, 0x0D, 0x01, 0x08, 0x0F, 0x02, 0x00); - auto ds2401a = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A ); // Work - Serial Number - auto ds2401b = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B ); // Work - Serial Number - auto ds2405 = DS2405( 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - Single address switch - auto ds2408 = DS2408( 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 8-Channel Addressable Switch - auto ds2413 = DS2413( 0x3A, 0x0D, 0x02, 0x04, 0x01, 0x03, 0x00 ); // Work - Dual channel addressable switch - - auto ds2401c = DS2401( 0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0C ); // additional device for testing - - auto ds2423 = DS2423( 0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4kb 1-Wire RAM with Counter - auto ds2431 = DS2431( 0x2D, 0xE8, 0x9F, 0x90, 0x0E, 0x00, 0x00 ); // Work - 1kb 1-Wire EEPROM - auto ds2433 = DS2433( 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ); // - 4Kb 1-Wire EEPROM - auto ds2438 = DS2438( 0x26, 0x0D, 0x02, 0x04, 0x03, 0x08, 0x00 ); // - Smart Battery Monitor - auto ds2450 = DS2450( DS2450::family_code, 0x00, 0x00, 0x50, 0x24, 0xDA, 0x00 ); // - 4 channel A/D - auto ds2502 = DS2502( DS2502::family_code, 0x00, 0xA0, 0x02, 0x25, 0xDA, 0x00 ); - auto ds2501a = DS2502( 0x91, 0x00, 0xA0, 0x01, 0x25, 0xDA, 0x00 ); - auto ds2501b = DS2502( 0x11, 0x00, 0xB0, 0x02, 0x25, 0xDA, 0x00 ); - - auto ds2503 = DS2506( 0x13, 0x00, 0x00, 0x03, 0x25, 0xDA, 0x00 ); - auto ds2505 = DS2506( 0x0B, 0x00, 0x00, 0x05, 0x25, 0xDA, 0x00 ); - auto ds2506 = DS2506( 0x0F, 0x00, 0x00, 0x06, 0x25, 0xDA, 0x00 ); - auto ds2890A = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0A ); // Work - Single channel digital potentiometer - auto ds2890B = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0B ); - auto ds2890C = DS2890( 0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0C ); - auto bae910 = BAE910(BAE910::family_code, 0x00, 0x00, 0x10, 0xE9, 0xBA, 0x00); - - auto ds2434 = DS2434(0x1B, 0x01, 0x02, 0x12, 0x34, 0x56, 0x78); + constexpr uint8_t OneWire_PIN = 8; + + auto hubA = OneWireHub(OneWire_PIN); + auto hubB = OneWireHub(OneWire_PIN); + auto hubC = OneWireHub(OneWire_PIN); + auto hubD = OneWireHub(OneWire_PIN); + + auto ds1822 = DS18B20(0x22, 0x0D, 0x01, 0x08, 0x02, 0x00, 0x00); + auto ds18B20 = DS18B20(0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, 0x00); // Work - Digital Thermometer + auto ds18S20 = DS18B20(0x10, 0x0D, 0x01, 0x08, 0x0F, 0x02, 0x00); + auto ds2401a = DS2401(0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0A); // Work - Serial Number + auto ds2401b = DS2401(0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0B); // Work - Serial Number + auto ds2405 = DS2405(0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // - Single address switch + auto ds2408 = + DS2408(0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // - 8-Channel Addressable Switch + auto ds2413 = DS2413(0x3A, 0x0D, 0x02, 0x04, 0x01, 0x03, + 0x00); // Work - Dual channel addressable switch + + auto ds2401c = + DS2401(0x01, 0x00, 0x0D, 0x24, 0x01, 0x00, 0x0C); // additional device for testing + + auto ds2423 = + DS2423(0x1D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // - 4kb 1-Wire RAM with Counter + auto ds2431 = DS2431(0x2D, 0xE8, 0x9F, 0x90, 0x0E, 0x00, 0x00); // Work - 1kb 1-Wire EEPROM + auto ds2433 = DS2433(0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // - 4Kb 1-Wire EEPROM + auto ds2438 = DS2438(0x26, 0x0D, 0x02, 0x04, 0x03, 0x08, 0x00); // - Smart Battery Monitor + auto ds2450 = + DS2450(DS2450::family_code, 0x00, 0x00, 0x50, 0x24, 0xDA, 0x00); // - 4 channel A/D + auto ds2502 = DS2502(DS2502::family_code, 0x00, 0xA0, 0x02, 0x25, 0xDA, 0x00); + auto ds2501a = DS2502(0x91, 0x00, 0xA0, 0x01, 0x25, 0xDA, 0x00); + auto ds2501b = DS2502(0x11, 0x00, 0xB0, 0x02, 0x25, 0xDA, 0x00); + + auto ds2503 = DS2506(0x13, 0x00, 0x00, 0x03, 0x25, 0xDA, 0x00); + auto ds2505 = DS2506(0x0B, 0x00, 0x00, 0x05, 0x25, 0xDA, 0x00); + auto ds2506 = DS2506(0x0F, 0x00, 0x00, 0x06, 0x25, 0xDA, 0x00); + auto ds2890A = DS2890(0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, + 0x0A); // Work - Single channel digital potentiometer + auto ds2890B = DS2890(0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0B); + auto ds2890C = DS2890(0x2C, 0x0D, 0x02, 0x08, 0x09, 0x00, 0x0C); + auto bae910 = BAE910(BAE910::family_code, 0x00, 0x00, 0x10, 0xE9, 0xBA, 0x00); + + auto ds2434 = DS2434(0x1B, 0x01, 0x02, 0x12, 0x34, 0x56, 0x78); cout << "- attach devices to hubs" << endl; @@ -162,21 +169,20 @@ int main() // TODO: maybe put the code in src_files to the depending device_unittest.h { - bae910.memory.field.SW_VER = 0x01; + bae910.memory.field.SW_VER = 0x01; bae910.memory.field.BOOTSTRAP_VER = 0x01; - bae910.memory.field.rtc = 1000; + bae910.memory.field.rtc = 1000; // there is nothing else to do here } - { /// DS18B20 - const auto temp_A = initializeLinear( -55.0f, 1.0f, 181); - const auto temp_B = initializeLinear( int8_t(-55), 1_i8, 181); + const auto temp_A = initializeLinear(-55.0f, 1.0f, 181); + const auto temp_B = initializeLinear(int8_t(-55), 1_i8, 181); // write and read back temperatures, float and int - for (const auto temp : temp_A) + for (const auto temp: temp_A) { ds1822.setTemperature(temp); test_eq(ds1822.getTemperature(), temp, "DS1822 float temp =" + to_string(temp)); @@ -188,13 +194,13 @@ int main() ds1822.setTemperature(126.0f); test_eq(ds1822.getTemperature(), 125.0f, "DS1822 float out of bounds POS"); - for (const auto temp : temp_B) + for (const auto temp: temp_B) { ds18B20.setTemperature(temp); test_eq(ds18B20.getTemperature(), temp, "DS18B22 int8 temp =" + to_string(temp)); } - for (const auto temp : temp_B) + for (const auto temp: temp_B) { ds18S20.setTemperature(temp); test_eq(ds18S20.getTemperature(), temp, "DS18S22 int8 temp =" + to_string(temp)); @@ -203,25 +209,31 @@ int main() { // DS18B20 & DS1822 Datasheet examples, both same - const std::array temp_degC { 125.0f, 85.0f, 25.0625f, 10.125f, 0.5f, 0.0f, -0.5f, -10.125f, -25.0625f, -55.0f }; - const std::array temp_raw { 0x07D0, 0x0550, 0x0191, 0x00A2, 0x0008, 0x0000, 0xFFF8_i16, 0xFF5E_i16, 0xFE6F_i16, 0xFC90_i16 }; + const std::array temp_degC{125.0f, 85.0f, 25.0625f, 10.125f, 0.5f, + 0.0f, -0.5f, -10.125f, -25.0625f, -55.0f}; + const std::array temp_raw{0x07D0, 0x0550, 0x0191, 0x00A2, + 0x0008, 0x0000, 0xFFF8_i16, 0xFF5E_i16, + 0xFE6F_i16, 0xFC90_i16}; - for (size_t index {0}; index < temp_degC.size(); ++index) + for (size_t index{0}; index < temp_degC.size(); ++index) { ds18B20.setTemperature(temp_degC[index]); - test_eq(ds18B20.getTemperatureRaw(), temp_raw[index], "DS18B22 datasheet test" + to_string(index)); + test_eq(ds18B20.getTemperatureRaw(), temp_raw[index], + "DS18B22 datasheet test" + to_string(index)); } } { // DS18S20 Datasheet examples - const std::array temp_degC { 85.0f, 25.0f, 0.5f, 0.0f, -0.5f, -25.0f, -55.0f }; - const std::array temp_raw { 0x00AA, 0x0032, 0x0001, 0x0000, 0xFFFF_i16, 0xFFCE_i16, 0xFF92_i16 }; + const std::array temp_degC{85.0f, 25.0f, 0.5f, 0.0f, -0.5f, -25.0f, -55.0f}; + const std::array temp_raw{0x00AA, 0x0032, 0x0001, 0x0000, + 0xFFFF_i16, 0xFFCE_i16, 0xFF92_i16}; - for (size_t index {0}; index < temp_degC.size(); ++index) + for (size_t index{0}; index < temp_degC.size(); ++index) { ds18S20.setTemperature(temp_degC[index]); - test_eq(ds18S20.getTemperatureRaw(), temp_raw[index], "DS18S22 datasheet test" + to_string(index)); + test_eq(ds18S20.getTemperatureRaw(), temp_raw[index], + "DS18S22 datasheet test" + to_string(index)); } } @@ -259,50 +271,61 @@ int main() /// DS2413 const auto values_pin = initializeLinear(0_u8, 1_u8, 2); - for (const auto value : values_pin) + for (const auto value: values_pin) { - ds2413.setPinState(value,false); + ds2413.setPinState(value, false); test_eq(ds2413.getPinState(value), false, "DS2413 state of pin " + to_string(value)); - ds2413.setPinState(value,true); + ds2413.setPinState(value, true); test_eq(ds2413.getPinState(value), true, "DS2413 state of pin " + to_string(value)); - ds2413.setPinLatch(value,false); + ds2413.setPinLatch(value, false); test_eq(ds2413.getPinLatch(value), false, "DS2413 latch of pin " + to_string(value)); - ds2413.setPinLatch(value,true); + ds2413.setPinLatch(value, true); test_eq(ds2413.getPinLatch(value), true, "DS2413 latch of pin " + to_string(value)); - test_eq(ds2413.getPinState(value), false, "DS2413 change in state of pin " + to_string(value) + " because of latch"); - ds2413.setPinState(value,true); - test_eq(ds2413.getPinState(value), false, "DS2413 re-enable state of pin " + to_string(value) + " fails because pin still latched"); + test_eq(ds2413.getPinState(value), false, + "DS2413 change in state of pin " + to_string(value) + " because of latch"); + ds2413.setPinState(value, true); + test_eq(ds2413.getPinState(value), false, + "DS2413 re-enable state of pin " + to_string(value) + + " fails because pin still latched"); - ds2413.setPinLatch(value,false); - test_eq(ds2413.getPinState(value), false, "DS2413 state of pin " + to_string(value) + " after disabling latch"); + ds2413.setPinLatch(value, false); + test_eq(ds2413.getPinState(value), false, + "DS2413 state of pin " + to_string(value) + " after disabling latch"); - ds2413.setPinState(value,true); - test_eq(ds2413.getPinState(value), true, "DS2413 re-enable state of pin " + to_string(value) + " after disabling latch works"); + ds2413.setPinState(value, true); + test_eq(ds2413.getPinState(value), true, + "DS2413 re-enable state of pin " + to_string(value) + + " after disabling latch works"); } } { // DS2423 - constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; ds2423.clearMemory(); // begin fresh after doing some work test_eq(ds2423.getCounter(0), 0_u32, "DS2423 write counter 0 - fresh state"); - ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 12*32+16); // second half of page 12 - test_eq(ds2423.getCounter(0), 1_u32, "DS2423 write counter 0 - increment by writing register"); + ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 12 * 32 + 16); // second half of page 12 + test_eq(ds2423.getCounter(0), 1_u32, + "DS2423 write counter 0 - increment by writing register"); test_eq(ds2423.getCounter(1), 0_u32, "DS2423 write counter 1 - fresh state"); - ds2423.setCounter(1,2000); + ds2423.setCounter(1, 2000); test_eq(ds2423.getCounter(1), 2000_u32, "DS2423 write counter 1 - set counter"); - ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 12*32+17); // second half of page 12 and 1 byte of page 13 - test_eq(ds2423.getCounter(0), 2_u32, "DS2423 write counter 0 - increment by writing register"); - test_eq(ds2423.getCounter(1), 2001_u32, "DS2423 write counter 1 - increment by writing register"); + ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), + 12 * 32 + 17); // second half of page 12 and 1 byte of page 13 + test_eq(ds2423.getCounter(0), 2_u32, + "DS2423 write counter 0 - increment by writing register"); + test_eq(ds2423.getCounter(1), 2001_u32, + "DS2423 write counter 1 - increment by writing register"); test_eq(ds2423.getCounter(2), 0_u32, "DS2423 write counter 2 - fresh state"); ds2423.incrementCounter(2); @@ -313,108 +336,116 @@ int main() test_eq(ds2423.getCounter(3), 0_u32, "DS2423 write counter 3 - fresh state"); // Test-Cases: the following code is just to show basic functions, can be removed any time - ds2423.writeMemory(reinterpret_cast(memory),sizeof(memory),0x00); - ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 1*32); + ds2423.writeMemory(reinterpret_cast(memory), sizeof(memory), 0x00); + ds2423.writeMemory(mem_dummy, sizeof(mem_dummy), 1 * 32); uint8_t mem_read[sizeof(memory)]; ds2423.readMemory(mem_read, sizeof(memory), 0x00); for (size_t index = 0; index < sizeof(memory); ++index) { - test_eq(mem_read[index], memory[index], "DS2423 mem re-read at position A " + to_string(index)); + test_eq(mem_read[index], memory[index], + "DS2423 mem re-read at position A " + to_string(index)); } ds2423.readMemory(mem_read, sizeof(mem_dummy), 31); // begin one byte earlier than page 1 for (size_t index = 1; index < sizeof(mem_dummy); ++index) { - test_eq(mem_read[index], mem_dummy[index-1], "DS2423 mem re-read at position B " + to_string(index)); + test_eq(mem_read[index], mem_dummy[index - 1], + "DS2423 mem re-read at position B " + to_string(index)); } } { // DS2431 - constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; ds2431.clearMemory(); // begin fresh after doing some work - ds2431.writeMemory(reinterpret_cast(memory),sizeof(memory),0x00); - ds2431.writeMemory(mem_dummy, sizeof(mem_dummy), 1*32); + ds2431.writeMemory(reinterpret_cast(memory), sizeof(memory), 0x00); + ds2431.writeMemory(mem_dummy, sizeof(mem_dummy), 1 * 32); uint8_t mem_read[sizeof(memory)]; ds2431.readMemory(mem_read, sizeof(memory), 0x00); for (size_t index = 0; index < sizeof(memory); ++index) { - test_eq(mem_read[index], memory[index], "DS2431 mem re-read at position A " + to_string(index)); + test_eq(mem_read[index], memory[index], + "DS2431 mem re-read at position A " + to_string(index)); } ds2431.readMemory(mem_read, sizeof(mem_dummy), 31); // begin one byte earlier than page 1 for (size_t index = 1; index < sizeof(mem_dummy); ++index) { - test_eq(mem_read[index], mem_dummy[index-1], "DS2431 mem re-read at position B " + to_string(index)); - } - - test_eq(ds2431.getPageProtection(1*32 - 1), false, "DS2431 test page protection before"); - test_eq(ds2431.getPageProtection(1*32 + 0), false, "DS2431 test page protection before"); - test_eq(ds2431.getPageProtection(2*32 + 0), false, "DS2431 test page protection before"); - ds2431.setPageProtection(1*32); - test_eq(ds2431.getPageProtection(1*32 - 1), false, "DS2431 test page protection after"); - test_eq(ds2431.getPageProtection(1*32 + 0), true, "DS2431 test page protection after"); - test_eq(ds2431.getPageProtection(1*32 + 8), true, "DS2431 test page protection after"); - test_eq(ds2431.getPageProtection(1*32 + 18), true, "DS2431 test page protection after"); - test_eq(ds2431.getPageProtection(2*32 - 1), true, "DS2431 test page protection after"); - test_eq(ds2431.getPageProtection(2*32 - 0), false, "DS2431 test page protection after"); - ds2431.setPageProtection(2*32); - test_eq(ds2431.getPageProtection(2*32 - 0), true, "DS2431 test page protection after"); - - - constexpr uint8_t mem_FF[] = { 0xFF, 0xFF }; - ds2431.writeMemory(reinterpret_cast(mem_FF),sizeof(mem_FF),2*32); - test_eq(ds2431.getPageEpromMode(2*32 - 1), false, "DS2431 test page eprom mode before"); - test_eq(ds2431.getPageEpromMode(2*32 - 0), false, "DS2431 test page eprom mode before"); - test_eq(ds2431.getPageEpromMode(2*32 + 1), false, "DS2431 test page eprom mode before"); - ds2431.setPageEpromMode(2*32); - test_eq(ds2431.getPageEpromMode(2*32 - 1), false, "DS2431 test page eprom mode after"); - test_eq(ds2431.getPageEpromMode(2*32 - 0), true, "DS2431 test page eprom mode after"); - test_eq(ds2431.getPageEpromMode(2*32 + 1), true, "DS2431 test page eprom mode after"); - test_eq(ds2431.getPageEpromMode(3*32 - 1), true, "DS2431 test page eprom mode after"); - test_eq(ds2431.getPageEpromMode(3*32 - 0), false, "DS2431 test page eprom mode after"); + test_eq(mem_read[index], mem_dummy[index - 1], + "DS2431 mem re-read at position B " + to_string(index)); + } + + test_eq(ds2431.getPageProtection(1 * 32 - 1), false, "DS2431 test page protection before"); + test_eq(ds2431.getPageProtection(1 * 32 + 0), false, "DS2431 test page protection before"); + test_eq(ds2431.getPageProtection(2 * 32 + 0), false, "DS2431 test page protection before"); + ds2431.setPageProtection(1 * 32); + test_eq(ds2431.getPageProtection(1 * 32 - 1), false, "DS2431 test page protection after"); + test_eq(ds2431.getPageProtection(1 * 32 + 0), true, "DS2431 test page protection after"); + test_eq(ds2431.getPageProtection(1 * 32 + 8), true, "DS2431 test page protection after"); + test_eq(ds2431.getPageProtection(1 * 32 + 18), true, "DS2431 test page protection after"); + test_eq(ds2431.getPageProtection(2 * 32 - 1), true, "DS2431 test page protection after"); + test_eq(ds2431.getPageProtection(2 * 32 - 0), false, "DS2431 test page protection after"); + ds2431.setPageProtection(2 * 32); + test_eq(ds2431.getPageProtection(2 * 32 - 0), true, "DS2431 test page protection after"); + + + constexpr uint8_t mem_FF[] = {0xFF, 0xFF}; + ds2431.writeMemory(reinterpret_cast(mem_FF), sizeof(mem_FF), 2 * 32); + test_eq(ds2431.getPageEpromMode(2 * 32 - 1), false, "DS2431 test page eprom mode before"); + test_eq(ds2431.getPageEpromMode(2 * 32 - 0), false, "DS2431 test page eprom mode before"); + test_eq(ds2431.getPageEpromMode(2 * 32 + 1), false, "DS2431 test page eprom mode before"); + ds2431.setPageEpromMode(2 * 32); + test_eq(ds2431.getPageEpromMode(2 * 32 - 1), false, "DS2431 test page eprom mode after"); + test_eq(ds2431.getPageEpromMode(2 * 32 - 0), true, "DS2431 test page eprom mode after"); + test_eq(ds2431.getPageEpromMode(2 * 32 + 1), true, "DS2431 test page eprom mode after"); + test_eq(ds2431.getPageEpromMode(3 * 32 - 1), true, "DS2431 test page eprom mode after"); + test_eq(ds2431.getPageEpromMode(3 * 32 - 0), false, "DS2431 test page eprom mode after"); // TODO: test real eprom } { // DS2433 - constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + constexpr char memory[] = "abcdefg-test-data full ASCII:-?+"; + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; ds2433.clearMemory(); // begin fresh after doing some work - ds2433.writeMemory(reinterpret_cast(memory),sizeof(memory),0x00); - ds2433.writeMemory(mem_dummy, sizeof(mem_dummy), 1*32); + ds2433.writeMemory(reinterpret_cast(memory), sizeof(memory), 0x00); + ds2433.writeMemory(mem_dummy, sizeof(mem_dummy), 1 * 32); uint8_t mem_read[sizeof(memory)]; ds2433.readMemory(mem_read, sizeof(memory), 0); // begin one byte earlier than page 1 for (size_t index = 0; index < sizeof(memory); ++index) { - test_eq(mem_read[index], memory[index], "DS2433 mem re-read at position A " + to_string(index)); + test_eq(mem_read[index], memory[index], + "DS2433 mem re-read at position A " + to_string(index)); } ds2433.readMemory(mem_read, sizeof(mem_dummy), 31); // begin one byte earlier than page 1 for (size_t index = 1; index < sizeof(mem_dummy); ++index) { - test_eq(mem_read[index], mem_dummy[index-1], "DS2433 mem re-read at position B " + to_string(index)); + test_eq(mem_read[index], mem_dummy[index - 1], + "DS2433 mem re-read at position B " + to_string(index)); } } { // DS2438 - const auto temp_A = initializeLinear( -55.0f, 1.0f, 181); - const auto temp_B = initializeLinear( int8_t(-55), 1_i8, 181); + const auto temp_A = initializeLinear(-55.0f, 1.0f, 181); + const auto temp_B = initializeLinear(int8_t(-55), 1_i8, 181); - for (const auto temp : temp_A) + for (const auto temp: temp_A) { ds2438.setTemperature(temp); test_eq(ds2438.getTemperature(), temp, "DS2438 float temp =" + to_string(temp)); @@ -426,7 +457,7 @@ int main() ds2438.setTemperature(126.0f); test_eq(ds2438.getTemperature(), 125.0f, "DS2438 float out of bounds POS"); - for (const auto temp : temp_B) + for (const auto temp: temp_B) { ds2438.setTemperature(temp); test_eq(ds2438.getTemperature(), temp, "DS2438 int8 temp =" + to_string(temp)); @@ -445,24 +476,28 @@ int main() } - constexpr char memory[] = "abcASCII"; - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + constexpr char memory[] = "abcASCII"; + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - ds2438.writeMemory(reinterpret_cast(memory),sizeof(memory),3*8); - ds2438.writeMemory(mem_dummy, sizeof(mem_dummy), 4*8); + ds2438.writeMemory(reinterpret_cast(memory), sizeof(memory), 3 * 8); + ds2438.writeMemory(mem_dummy, sizeof(mem_dummy), 4 * 8); uint8_t mem_read[sizeof(mem_dummy)]; - ds2438.readMemory(mem_read, sizeof(memory), 3*8); // begin one byte earlier than page 1 + ds2438.readMemory(mem_read, sizeof(memory), 3 * 8); // begin one byte earlier than page 1 for (size_t index = 0; index < sizeof(memory); ++index) { - test_eq(mem_read[index], memory[index], "DS2438 mem re-read at position A " + to_string(index)); + test_eq(mem_read[index], memory[index], + "DS2438 mem re-read at position A " + to_string(index)); } - ds2438.readMemory(mem_read, sizeof(mem_dummy), 4*8-1); // begin one byte earlier than page 1 + ds2438.readMemory(mem_read, sizeof(mem_dummy), + 4 * 8 - 1); // begin one byte earlier than page 1 for (size_t index = 1; index < sizeof(mem_dummy); ++index) { - test_eq(mem_read[index], mem_dummy[index-1], "DS2438 mem re-read at position B " + to_string(index)); + test_eq(mem_read[index], mem_dummy[index - 1], + "DS2438 mem re-read at position B " + to_string(index)); } } @@ -470,22 +505,25 @@ int main() // DS2450 ds2450.clearMemory(); // begin fresh after doing some work - constexpr uint16_t test_data[] = { 0, 1, 2, 10, 101, 511, 1111, 33333, 65535, 77}; + constexpr uint16_t test_data[] = {0, 1, 2, 10, 101, 511, 1111, 33333, 65535, 77}; - ds2450.setPotentiometer(77,77,77,77); // set all channels at once + ds2450.setPotentiometer(77, 77, 77, 77); // set all channels at once for (uint8_t poti_write = 0; poti_write < 4; ++poti_write) { - for (size_t index = 0; index < (sizeof(test_data)/2); ++index) + for (size_t index = 0; index < (sizeof(test_data) / 2); ++index) { - ds2450.setPotentiometer(poti_write,test_data[index]); + ds2450.setPotentiometer(poti_write, test_data[index]); // check also for cross-pollution for (uint8_t poti_read = 0; poti_read < 4; ++poti_read) { - const uint16_t result = (poti_read == poti_write) ? test_data[index] : uint16_t(77); - test_eq(ds2450.getPotentiometer(poti_read), result, "DS2450 test for poti " + to_string(poti_write) + " with poti " + to_string(poti_read)); + const uint16_t result = + (poti_read == poti_write) ? test_data[index] : uint16_t(77); + test_eq(ds2450.getPotentiometer(poti_read), result, + "DS2450 test for poti " + to_string(poti_write) + " with poti " + + to_string(poti_read)); } } } @@ -499,38 +537,44 @@ int main() for (uint8_t page = 0; page < 4; ++page) { - ds2502.readMemory(mem_read, sizeof(mem_read), page * 32_u8); // begin one byte earlier than page 1 + ds2502.readMemory(mem_read, sizeof(mem_read), + page * 32_u8); // begin one byte earlier than page 1 for (size_t index = 0; index < sizeof(mem_read); ++index) { test_eq(mem_read[index], 0xFF, "DS2502 mem re-read in a clean state"); } } - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; test_eq(ds2502.getPageUsed(3), 0, "DS2502 get page used counter"); - ds2502.writeMemory(mem_dummy, sizeof(mem_dummy), 3*32); + ds2502.writeMemory(mem_dummy, sizeof(mem_dummy), 3 * 32); test_eq(ds2502.getPageUsed(3), 1, "DS2502 get page used counter"); - ds2502.readMemory(mem_read, sizeof(mem_read), 1_u8 * 32_u8); // begin one byte earlier than page 1 + ds2502.readMemory(mem_read, sizeof(mem_read), + 1_u8 * 32_u8); // begin one byte earlier than page 1 for (size_t index = 0; index < sizeof(mem_read); ++index) { test_eq(mem_read[index], 0xFF, "DS2502 mem re-read page 1 - still clean state"); } - ds2502.readMemory(mem_read, sizeof(mem_read), 3_u8 * 32_u8); // begin one byte earlier than page 1 + ds2502.readMemory(mem_read, sizeof(mem_read), + 3_u8 * 32_u8); // begin one byte earlier than page 1 for (size_t index = 0; index < sizeof(mem_read); ++index) { test_eq(mem_read[index], mem_dummy[index], "DS2502 mem re-read page 3 - new data"); } test_eq(ds2502.getPageRedirection(1), 0, "DS2502 test for redirection "); - ds2502.setPageRedirection(1,3); + ds2502.setPageRedirection(1, 3); test_eq(ds2502.getPageRedirection(1), 3, "DS2502 test for redirection "); - ds2502.readMemory(mem_read, sizeof(mem_read), 1_u8 * 32_u8); // begin one byte earlier than page 1 + ds2502.readMemory(mem_read, sizeof(mem_read), + 1_u8 * 32_u8); // begin one byte earlier than page 1 for (size_t index = 0; index < sizeof(mem_read); ++index) { - test_eq(mem_read[index], 0xFF, "DS2502 mem re-read page 1 - still clean, only affects master"); + test_eq(mem_read[index], 0xFF, + "DS2502 mem re-read page 1 - still clean, only affects master"); } // Test Write Data to protected page 0 -> is possible, only affects master"); @@ -539,20 +583,24 @@ int main() ds2502.setPageProtection(0); test_eq(ds2502.getPageProtection(0), true, "DS2502 get page-protection after protecting"); ds2502.writeMemory(mem_dummy, sizeof(mem_dummy), 16); // write in second half of page - test_eq(ds2502.getPageUsed(0), 1, "DS2502 get use-counter after write to protected page (only affects master)"); + test_eq(ds2502.getPageUsed(0), 1, + "DS2502 get use-counter after write to protected page (only affects master)"); } { // DS2506 - constexpr uint8_t mem_dummy[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; - uint8_t mem_read[sizeof(mem_dummy)]; + constexpr uint8_t mem_dummy[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}; + uint8_t mem_read[sizeof(mem_dummy)]; ds2506.clearMemory(); // begin fresh after doing some work ds2506.clearStatus(); // begin fresh after doing some work for (uint8_t page = 0; page < 8; ++page) { - test_eq(ds2506.getRedirectionProtection(page), false, "DS2506 get protection for redirection (not modified yet) for page " + to_string(page)); + test_eq(ds2506.getRedirectionProtection(page), false, + "DS2506 get protection for redirection (not modified yet) for page " + + to_string(page)); } ds2506.setRedirectionProtection(2); @@ -560,48 +608,55 @@ int main() for (uint8_t page = 0; page < 8; ++page) { const bool result = (page == 2); - test_eq(ds2506.getRedirectionProtection(page), result, "DS2506 get protection for redirection (modified) for page " + to_string(page)); + test_eq(ds2506.getRedirectionProtection(page), result, + "DS2506 get protection for redirection (modified) for page " + to_string(page)); } for (uint8_t page = 0; page < 8; ++page) { - test_eq(ds2506.getPageRedirection(page), 0_u8, "DS2506 get page redirection (not modified yet) for page " + to_string(page)); + test_eq(ds2506.getPageRedirection(page), 0_u8, + "DS2506 get page redirection (not modified yet) for page " + to_string(page)); } - ds2506.setPageRedirection(2,4); // -> will fail - ds2506.setPageRedirection(3,4); // -> will work + ds2506.setPageRedirection(2, 4); // -> will fail + ds2506.setPageRedirection(3, 4); // -> will work for (uint8_t page = 0; page < 8; ++page) { const uint8_t result = (page == 3) ? 4_u8 : 0_u8; - test_eq(ds2506.getPageRedirection(page), result, "DS2506 get page redirection (modified) for page " + to_string(page)); + test_eq(ds2506.getPageRedirection(page), result, + "DS2506 get page redirection (modified) for page " + to_string(page)); } for (uint8_t page = 0; page < 8; ++page) { - test_eq(ds2506.getPageUsed(page), false, "DS2506 get page usage (not modified yet) for page " + to_string(page)); + test_eq(ds2506.getPageUsed(page), false, + "DS2506 get page usage (not modified yet) for page " + to_string(page)); } - ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 4*32); + ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 4 * 32); for (uint8_t page = 0; page < 8; ++page) { const bool result = (page == 4); - test_eq(ds2506.getPageUsed(page), result, "DS2506 get page usage (modified) for page " + to_string(page)); + test_eq(ds2506.getPageUsed(page), result, + "DS2506 get page usage (modified) for page " + to_string(page)); } ds2506.readMemory(mem_read, sizeof(mem_read), 4_u8 * 32_u8); for (size_t index = 0; index < sizeof(mem_read); ++index) { - test_eq(mem_read[index], mem_dummy[index], "DS2506 mem re-read page 4 - previously written"); + test_eq(mem_read[index], mem_dummy[index], + "DS2506 mem re-read page 4 - previously written"); } ds2506.readMemory(mem_read, sizeof(mem_read), 3_u8 * 32_u8); for (size_t index = 0; index < sizeof(mem_read); ++index) { - test_eq(mem_read[index], 0xFF, "DS2506 mem re-read page 3 - redirected, but only for master, so unchanged"); + test_eq(mem_read[index], 0xFF, + "DS2506 mem re-read page 3 - redirected, but only for master, so unchanged"); } // Test Write Data to protected page 0 -> is possible, only affects master"); @@ -611,18 +666,20 @@ int main() test_eq(ds2506.getPageProtection(0), true, "DS2506 get page-protection after protecting"); ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 16); // write in second half of page - test_eq(ds2506.getPageUsed(0), 1, "DS2506 get use-counter after write to protected page (only affects master)"); + test_eq(ds2506.getPageUsed(0), 1, + "DS2506 get use-counter after write to protected page (only affects master)"); ds2506.readMemory(mem_read, sizeof(mem_read), 16_u8); for (size_t index = 0; index < sizeof(mem_read); ++index) { - test_eq(mem_read[index], mem_dummy[index], "DS2506 mem re-read page 1 - previously written"); + test_eq(mem_read[index], mem_dummy[index], + "DS2506 mem re-read page 1 - previously written"); } } { // DS2890 - constexpr uint8_t test_data[] = { 0, 1, 2, 10, 101, 200, 254, 255, 77}; + constexpr uint8_t test_data[] = {0, 1, 2, 10, 101, 200, 254, 255, 77}; for (uint8_t poti_write = 0; poti_write < 4; ++poti_write) { @@ -633,13 +690,16 @@ int main() { for (size_t index = 0; index < sizeof(test_data); ++index) { - ds2890A.setPotentiometer(poti_write,test_data[index]); + ds2890A.setPotentiometer(poti_write, test_data[index]); // check also for cross-pollution for (uint8_t poti_read = 0; poti_read < 4; ++poti_read) { - const uint16_t result = (poti_read == poti_write) ? test_data[index] : uint16_t(77); - test_eq(ds2890A.getPotentiometer(poti_read), result, "DS2890 test for poti " + to_string(poti_write) + " with poti " + to_string(poti_read)); + const uint16_t result = + (poti_read == poti_write) ? test_data[index] : uint16_t(77); + test_eq(ds2890A.getPotentiometer(poti_read), result, + "DS2890 test for poti " + to_string(poti_write) + " with poti " + + to_string(poti_read)); } } } @@ -651,13 +711,14 @@ int main() { // DS2434 // add default-data - constexpr uint8_t mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c, - 0xff, 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0, - 0x20, 0x20, 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63 }; // last 4 Byte seem to be Serial - ds2434.writeMemory(reinterpret_cast(mem1),sizeof(mem1),0x00); + constexpr uint8_t + mem1[24] = {0x14, 0x10, 0x90, 0xd0, 0x03, 0x32, 0x4b, 0x3c, 0xff, + 0x04, 0x64, 0x04, 0x9e, 0x9a, 0x3a, 0xf0, 0x20, 0x20, + 0x04, 0xee, 0x63, 0xB8, 0x3E, 0x63}; // last 4 Byte seem to be Serial + ds2434.writeMemory(reinterpret_cast(mem1), sizeof(mem1), 0x00); - constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50 }; - ds2434.writeMemory(reinterpret_cast(mem2),sizeof(mem2),0x20); + constexpr uint8_t mem2[8] = {0x33, 0x2e, 0x33, 0x2e, 0x9e, 0x10, 0x3f, 0x50}; + ds2434.writeMemory(reinterpret_cast(mem2), sizeof(mem2), 0x20); ds2434.lockNV1(); ds2434.setID(0xCABDu); @@ -689,13 +750,14 @@ int main() { // test new algorithms without bit masks TODO: replace in crc and write/read const uint8_t data_test = 0b11001010; - bool write_bits_A[8], write_bits_B[8]; + bool write_bits_A[8], write_bits_B[8]; { uint8_t index = 0; for (uint8_t bitMask = 0x01; bitMask != 0; bitMask <<= 1) { - write_bits_A[index++] = ((bitMask & data_test) != 0); // TODO: shifting value could be faster + write_bits_A[index++] = + ((bitMask & data_test) != 0); // TODO: shifting value could be faster } } @@ -704,36 +766,35 @@ int main() uint8_t value = data_test; for (uint8_t bitMask = 0x01; bitMask != 0; bitMask <<= 1) { - write_bits_B[index++] = ((value & 0x01) != 0); // TODO: shifting value could be faster + write_bits_B[index++] = + ((value & 0x01) != 0); // TODO: shifting value could be faster value >>= 1; } } for (size_t index = 0; index < 8; ++index) { - test_eq(write_bits_B[index], write_bits_A[index], "algo without bitmask on position " + to_string(index)); + test_eq(write_bits_B[index], write_bits_A[index], + "algo without bitmask on position " + to_string(index)); } } { // test three possible implementations of the same algorithm for correctness TODO: replace in crc and write/read const uint8_t data_size = 8; - uint8_t data_array_A[data_size]; - uint8_t data_array_B[data_size]; - uint8_t data_array_C[data_size]; + uint8_t data_array_A[data_size]; + uint8_t data_array_B[data_size]; + uint8_t data_array_C[data_size]; { - uint8_t * data_array = data_array_A; - for (uint8_t index = 0; index < data_size; index++) - { - data_array[index] = index; - } + uint8_t *data_array = data_array_A; + for (uint8_t index = 0; index < data_size; index++) { data_array[index] = index; } } { - uint8_t * data_array = data_array_B; - uint8_t _size = data_size; - uint8_t _index = 0; + uint8_t *data_array = data_array_B; + uint8_t _size = data_size; + uint8_t _index = 0; while (_size-- > 0) { @@ -743,22 +804,20 @@ int main() } { - uint8_t * data_array = data_array_C; - uint8_t _size = data_size; - uint8_t _index = 0; + uint8_t *data_array = data_array_C; + uint8_t _size = data_size; + uint8_t _index = 0; - while (_size-- > 0) - { - *data_array++ = _index++; - } + while (_size-- > 0) { *data_array++ = _index++; } } for (size_t index = 0; index < data_size; ++index) { - test_eq(data_array_B[index], data_array_A[index], "algo without index B on position " + to_string(index)); - test_eq(data_array_C[index], data_array_A[index], "algo without index C on position " + to_string(index)); + test_eq(data_array_B[index], data_array_A[index], + "algo without index B on position " + to_string(index)); + test_eq(data_array_C[index], data_array_A[index], + "algo without index C on position " + to_string(index)); } - } Serial.print("use Serial at least once"); @@ -774,7 +833,8 @@ int main() if (hubB.hasError()) hubB.printError(); if (hubC.hasError()) hubC.printError(); - cout << "Program did run " << tests_absolved << " tests, " << tests_failed << " of them failed." << endl; + cout << "Program did run " << tests_absolved << " tests, " << tests_failed << " of them failed." + << endl; return static_cast(tests_failed); }; diff --git a/src/BAE910.cpp b/src/BAE910.cpp index d296195..2863a9a 100644 --- a/src/BAE910.cpp +++ b/src/BAE910.cpp @@ -1,52 +1,56 @@ #include "BAE910.h" -BAE910::BAE910(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) +BAE910::BAE910(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) { - static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); - static_assert(sizeof(sBAE910) <= BAE910_MEMORY_SIZE, "Memory-struct is larger than its memory"); // not needed anymore, but not hurting either + static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); + static_assert( + sizeof(sBAE910) <= BAE910_MEMORY_SIZE, + "Memory-struct is larger than its memory"); // not needed anymore, but not hurting either // clear memory memset(&memory.bytes[0], static_cast(0x00), BAE910_MEMORY_SIZE); // disable bus-features: // TODO: test, as datasheet does not clear this up -> this settings keeps the previous behavior - fast_read_rom = false; + fast_read_rom = false; fast_search_rom = false; } -void BAE910::duty(OneWireHub * const hub) +void BAE910::duty(OneWireHub *const hub) { uint8_t cmd, ta1, ta2, len, eCmd; // command, targetAddress, length and extended command - uint16_t crc { 0 }; + uint16_t crc{0}; - if (hub->recv(&cmd,1,crc)) return; + if (hub->recv(&cmd, 1, crc)) return; switch (cmd) { case 0x11: // READ VERSION - if (hub->send(&memory.field.SW_VER,1,crc)) return; - if (hub->send(&memory.field.BOOTSTRAP_VER,1,crc)) return; + if (hub->send(&memory.field.SW_VER, 1, crc)) return; + if (hub->send(&memory.field.BOOTSTRAP_VER, 1, crc)) return; crc = ~crc; - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; break; case 0x12: // READ TYPE - if (hub->send(&BAE910_DEVICE_TYPE,1,crc)) return; - if (hub->send(&BAE910_CHIP_TYPE,1,crc)) return; + if (hub->send(&BAE910_DEVICE_TYPE, 1, crc)) return; + if (hub->send(&BAE910_CHIP_TYPE, 1, crc)) return; crc = ~crc; - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; break; case 0x14: // READ MEMORY - if (hub->recv(&ta1,1,crc)) return; - if (hub->recv(&ta2,1,crc)) return; - if (hub->recv(&len,1,crc)) return; + if (hub->recv(&ta1, 1, crc)) return; + if (hub->recv(&ta2, 1, crc)) return; + if (hub->recv(&len, 1, crc)) return; if ((ta1 + len > 0x80) || (ta2 > 0)) { @@ -56,18 +60,18 @@ void BAE910::duty(OneWireHub * const hub) // reverse byte order for (uint8_t i = 0; i < len; ++i) { - if (hub->send(&memory.bytes[0x7F - ta1 - i],1,crc)) return; + if (hub->send(&memory.bytes[0x7F - ta1 - i], 1, crc)) return; } crc = ~crc; - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; break; case 0x15: // WRITE MEMORY - if (hub->recv(&ta1,1,crc)) return; - if (hub->recv(&ta2,1,crc)) return; - if (hub->recv(&len,1,crc)) return; + if (hub->recv(&ta1, 1, crc)) return; + if (hub->recv(&ta2, 1, crc)) return; + if (hub->recv(&len, 1, crc)) return; if ((len > BAE910_SCRATCHPAD_SIZE) || (ta1 + len > 0x80) || (ta2 > 0)) { @@ -75,12 +79,12 @@ void BAE910::duty(OneWireHub * const hub) return; } - if (hub->recv(scratchpad,len,crc)) return; + if (hub->recv(scratchpad, len, crc)) return; crc = ~crc; - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; // verify answer from master, then copy memory - if (hub->recv(&eCmd ,1)) return; + if (hub->recv(&eCmd, 1)) return; if (eCmd == 0xBC) { while (len-- > 0) // reverse byte order @@ -90,10 +94,8 @@ void BAE910::duty(OneWireHub * const hub) } break; -// case 0x13: // EXTENDED COMMAND -// case 0x16: // ERASE EEPROM PAGE (not needed/implemented yet) - default: - - hub->raiseSlaveError(cmd); + // case 0x13: // EXTENDED COMMAND + // case 0x16: // ERASE EEPROM PAGE (not needed/implemented yet) + default: hub->raiseSlaveError(cmd); } } diff --git a/src/BAE910.h b/src/BAE910.h index 5cb48ad..ce037d8 100644 --- a/src/BAE910.h +++ b/src/BAE910.h @@ -8,15 +8,17 @@ #include "OneWireItem.h" //// CONFIG ///////////////////////////////////////////// -static constexpr uint8_t BAE910_DEVICE_TYPE { 0x02 }; // Type 2 for BAE0910. Type 3 for BAE0911 (planned) -static constexpr uint8_t BAE910_CHIP_TYPE { 0x01 }; // Chip type= 0x01 for the MC9S08SH8, 8 pin package SO-IC 8 +static constexpr uint8_t BAE910_DEVICE_TYPE{ + 0x02}; // Type 2 for BAE0910. Type 3 for BAE0911 (planned) +static constexpr uint8_t BAE910_CHIP_TYPE{ + 0x01}; // Chip type= 0x01 for the MC9S08SH8, 8 pin package SO-IC 8 -static constexpr uint8_t BAE910_SCRATCHPAD_SIZE { 32 }; +static constexpr uint8_t BAE910_SCRATCHPAD_SIZE{32}; //// END OF CONFIG ////////////////////////////////////// typedef struct { -// --> reversed fields and write/read in reverse order to achieve swapped byte order + // --> reversed fields and write/read in reverse order to achieve swapped byte order uint32_t userp; uint32_t usero; uint32_t usern; @@ -84,9 +86,10 @@ typedef struct uint8_t BOOTSTRAP_VER; } sBAE910; -static constexpr uint8_t BAE910_MEMORY_SIZE { sizeof(sBAE910) }; +static constexpr uint8_t BAE910_MEMORY_SIZE{sizeof(sBAE910)}; -typedef union { +typedef union +{ uint8_t bytes[BAE910_MEMORY_SIZE]; sBAE910 field; } mBAE910; // overlay with memory_array @@ -94,20 +97,19 @@ typedef union { class BAE910 : public OneWireItem { protected: - uint8_t scratchpad[BAE910_SCRATCHPAD_SIZE]; public: - - static constexpr uint8_t family_code { 0xFC }; + static constexpr uint8_t family_code{0xFC}; mBAE910 memory; - static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); - BAE910(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + BAE910(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; // TODO: can be extended with clearMemory(), writeMemory(), readMemory() similar to ds2506 }; diff --git a/src/DS18B20.cpp b/src/DS18B20.cpp index 2ce15d9..00b2864 100644 --- a/src/DS18B20.cpp +++ b/src/DS18B20.cpp @@ -1,7 +1,9 @@ #include "DS18B20.h" -DS18B20::DS18B20(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) +DS18B20::DS18B20(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) { scratchpad[0] = 0xA0; // TLSB --> 10 degC as std scratchpad[1] = 0x00; // TMSB @@ -12,7 +14,7 @@ DS18B20::DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5 scratchpad[5] = 0xFF; // 0xFF scratchpad[6] = 0x00; // Reset scratchpad[7] = 0x10; // 0x10 - updateCRC(); // update scratchpad[8] + updateCRC(); // update scratchpad[8] ds18s20_mode = (ID1 == 0x10); // different tempRegister @@ -20,21 +22,19 @@ DS18B20::DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5 fast_search_rom = false; } -void DS18B20::updateCRC() -{ - scratchpad[8] = crc8(scratchpad, 8); -} +void DS18B20::updateCRC() { scratchpad[8] = crc8(scratchpad, 8); } -void DS18B20::duty(OneWireHub * const hub) +void DS18B20::duty(OneWireHub *const hub) { uint8_t cmd; - if (hub->recv(&cmd,1)) return; + if (hub->recv(&cmd, 1)) return; switch (cmd) { case 0x4E: // WRITE SCRATCHPAD // write 3 byte of data to scratchpad[2:4], ds18s20 only first 2 bytes (TH, TL) - hub->recv(&scratchpad[2], 3); // don't return here, so crc gets updated even if write not complete + hub->recv(&scratchpad[2], + 3); // don't return here, so crc gets updated even if write not complete updateCRC(); break; @@ -47,7 +47,7 @@ void DS18B20::duty(OneWireHub * const hub) break; // send1 if parasite power is used, is passive case 0xB8: // RECALL E2 (3 byte EEPROM to Scratchpad[2:4]) - break;// signal that OP is done, 1s is passive ... + break; // signal that OP is done, 1s is passive ... case 0xB4: // READ POWER SUPPLY //hub->sendBit(0); // 1: say i am external powered, 0: uses parasite power, 1 is passive, so omit it ... @@ -57,8 +57,7 @@ void DS18B20::duty(OneWireHub * const hub) // we have 94 ... 750ms time here (9-12bit conversion) break; // send 1s, is passive ... - default: - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } @@ -102,10 +101,7 @@ void DS18B20::setTemperatureRaw(const int16_t value_raw) { value &= 0x07FF; // upper 5 bits are signum } - else - { - value |= 0xF800; - } + else { value |= 0xF800; } } scratchpad[0] = reinterpret_cast(&value)[0]; @@ -116,18 +112,12 @@ void DS18B20::setTemperatureRaw(const int16_t value_raw) updateCRC(); } -int DS18B20::getTemperature(void) const +int DS18B20::getTemperature(void) const { int16_t value = getTemperatureRaw(); - if (ds18s20_mode) - { - value /= 2; - } - else - { - value /= 16; - } + if (ds18s20_mode) { value /= 2; } + else { value /= 16; } return value; } diff --git a/src/DS18B20.h b/src/DS18B20.h index a089d6f..9f9c715 100644 --- a/src/DS18B20.h +++ b/src/DS18B20.h @@ -13,7 +13,6 @@ class DS18B20 : public OneWireItem { private: - uint8_t scratchpad[9]; void updateCRC(void); @@ -21,12 +20,12 @@ class DS18B20 : public OneWireItem bool ds18s20_mode; public: + static constexpr uint8_t family_code{0x28}; // is compatible to ds1822 (0x22) and ds18S20 (0x10) - static constexpr uint8_t family_code { 0x28 }; // is compatible to ds1822 (0x22) and ds18S20 (0x10) - - DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS18B20(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; void setTemperature(float value_degC); // -55 to +125 degC void setTemperature(int8_t value_degC); // -55 to +125 degC @@ -34,7 +33,6 @@ class DS18B20 : public OneWireItem void setTemperatureRaw(int16_t value_raw); int16_t getTemperatureRaw() const; - }; #endif diff --git a/src/DS2401.cpp b/src/DS2401.cpp index 6820e04..4c788dd 100644 --- a/src/DS2401.cpp +++ b/src/DS2401.cpp @@ -1,22 +1,22 @@ #include "DS2401.h" -DS2401::DS2401(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) +DS2401::DS2401(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) { // disable bus-features: - fast_read_rom = false; + fast_read_rom = false; fast_search_rom = false; } -void DS2401::duty(OneWireHub * const hub) +void DS2401::duty(OneWireHub *const hub) { uint8_t cmd; - if (hub->recv(&cmd)) return; + if (hub->recv(&cmd)) return; switch (cmd) { - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } diff --git a/src/DS2401.h b/src/DS2401.h index aaac616..f0d2a23 100644 --- a/src/DS2401.h +++ b/src/DS2401.h @@ -10,13 +10,12 @@ class DS2401 : public OneWireItem { public: + static constexpr uint8_t family_code{0x01}; - static constexpr uint8_t family_code { 0x01 }; - - DS2401(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); - - void duty(OneWireHub * hub) final; + DS2401(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); + void duty(OneWireHub *hub) final; }; #endif diff --git a/src/DS2405.cpp b/src/DS2405.cpp index b39539e..c1610fc 100644 --- a/src/DS2405.cpp +++ b/src/DS2405.cpp @@ -1,16 +1,19 @@ #include "DS2405.h" -DS2405::DS2405(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) +DS2405::DS2405(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) { pin_state = false; } -void DS2405::duty(OneWireHub * const hub) +void DS2405::duty(OneWireHub *const hub) { // IC uses weird bus-features to operate., match-rom is enough pin_state = !pin_state; noInterrupts(); - while(!hub->sendBit(pin_state)); // if master issues read slots it gets the state... + while (!hub->sendBit(pin_state)) + ; // if master issues read slots it gets the state... interrupts(); // TODO: when alarm search is implemented (0xEC): diff --git a/src/DS2405.h b/src/DS2405.h index fd91015..a923a44 100644 --- a/src/DS2405.h +++ b/src/DS2405.h @@ -11,26 +11,19 @@ class DS2405 : public OneWireItem { private: - bool pin_state; public: + static constexpr uint8_t family_code{0x05}; - static constexpr uint8_t family_code { 0x05 }; - - DS2405(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2405(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void setPinState(const bool value) - { - pin_state = value; - } + void setPinState(const bool value) { pin_state = value; } - bool getPinState(void) const - { - return pin_state; - } + bool getPinState(void) const { return pin_state; } }; #endif diff --git a/src/DS2408.cpp b/src/DS2408.cpp index 454185d..f7c573c 100644 --- a/src/DS2408.cpp +++ b/src/DS2408.cpp @@ -1,135 +1,133 @@ #include "DS2408.h" -DS2408::DS2408(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) +DS2408::DS2408(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) { clearMemory(); } -void DS2408::duty(OneWireHub * const hub) +void DS2408::duty(OneWireHub *const hub) { - constexpr uint8_t DATA_xAA { 0xAA }; - uint8_t cmd, reg_TA, data; // command, targetAddress and databytes - uint16_t crc { 0 }; + constexpr uint8_t DATA_xAA{0xAA}; + uint8_t cmd, reg_TA, data; // command, targetAddress and databytes + uint16_t crc{0}; - if (hub->recv(&cmd,1,crc)) return; + if (hub->recv(&cmd, 1, crc)) return; switch (cmd) { - case 0xF0: // Read PIO Registers + case 0xF0: // Read PIO Registers - if (hub->recv(®_TA,1,crc)) return; - if((reg_TA < REG_OFFSET) || (reg_TA >= REG_OFFSET + MEM_SIZE)) return; - if (hub->recv(&data,1,crc)) return; // seconds part of reg_TA, should be zero + if (hub->recv(®_TA, 1, crc)) return; + if ((reg_TA < REG_OFFSET) || (reg_TA >= REG_OFFSET + MEM_SIZE)) return; + if (hub->recv(&data, 1, crc)) return; // seconds part of reg_TA, should be zero if (data != 0) return; { const uint8_t start = (reg_TA - REG_OFFSET); const uint8_t length = MEM_SIZE - start; - if (hub->send(&memory[start],length,crc)) return; + if (hub->send(&memory[start], length, crc)) return; } crc = ~crc; // most important step, easy to miss.... - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; break; // after memory readout this chip sends logic 1s, which is the same as staying passive - case 0x5A: // Channel-Access Write + case 0x5A: // Channel-Access Write - while(true) + while (true) { - if (hub->recv(&data,1)) return; - if (hub->recv(&cmd ,1)) return; // just because we have to receive something + if (hub->recv(&data, 1)) return; + if (hub->recv(&cmd, 1)) return; // just because we have to receive something //if (cmd != ~data) return false; //inverted data, not working properly memory[REG_PIO_ACTIVITY] |= data ^ memory[REG_PIO_LOGIC]; - memory[REG_PIO_OUTPUT] = data; - memory[REG_PIO_LOGIC] = data; + memory[REG_PIO_OUTPUT] = data; + memory[REG_PIO_LOGIC] = data; if (hub->send(&DATA_xAA)) return; - if (hub->send(memory,4)) return; // TODO: i think this is right, datasheet says: DS2408 samples the status of the PIO pins, as shown in Figure 9, and sends it to the master + if (hub->send(memory, 4)) + return; // TODO: i think this is right, datasheet says: DS2408 samples the status of the PIO pins, as shown in Figure 9, and sends it to the master } - case 0xF5: // Channel-Access Read + case 0xF5: // Channel-Access Read while (true) { static uint16_t crc2 = crc; - if (hub->send(memory,4,crc)) return; + if (hub->send(memory, 4, crc)) return; crc = ~crc; // most important step, easy to miss.... - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; crc = crc2; } - case 0xC3: // reset activity latches + case 0xC3: // reset activity latches memory[REG_PIO_ACTIVITY] = 0x00; - while(!hub->send(&DATA_xAA)); + while (!hub->send(&DATA_xAA)) + ; break; - case 0xCC: // write conditional search register + case 0xCC: // write conditional search register - if (hub->recv(®_TA,1)) return; - if(reg_TA < (REG_SEARCH_MASK + REG_OFFSET)) return; - if (hub->recv(&data,1)) return; // seconds part of reg_TA, should be zero - if (data != 0) return; + if (hub->recv(®_TA, 1)) return; + if (reg_TA < (REG_SEARCH_MASK + REG_OFFSET)) return; + if (hub->recv(&data, 1)) return; // seconds part of reg_TA, should be zero + if (data != 0) return; - while(reg_TA <= REG_CONTROL_STATUS + REG_OFFSET) + while (reg_TA <= REG_CONTROL_STATUS + REG_OFFSET) { - if (hub->recv(&memory[reg_TA - REG_OFFSET],1)) return; + if (hub->recv(&memory[reg_TA - REG_OFFSET], 1)) return; } // TODO: page 18 datasheet, no alarm search yet, control-register has influence break; - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } void DS2408::clearMemory(void) { - memory[REG_PIO_LOGIC] = 0xFF; - memory[REG_PIO_OUTPUT] = 0xFF; - memory[REG_PIO_ACTIVITY] = 0xFF; - memory[REG_SEARCH_MASK] = 0; - memory[REG_SEARCH_SELECT] = 0; - memory[REG_CONTROL_STATUS] = 0x88; - memory[REG_RD_ABOVE_ALWAYS_FF_8E] = 0xFF; - memory[REG_RD_ABOVE_ALWAYS_FF_8F] = 0xFF; + memory[REG_PIO_LOGIC] = 0xFF; + memory[REG_PIO_OUTPUT] = 0xFF; + memory[REG_PIO_ACTIVITY] = 0xFF; + memory[REG_SEARCH_MASK] = 0; + memory[REG_SEARCH_SELECT] = 0; + memory[REG_CONTROL_STATUS] = 0x88; + memory[REG_RD_ABOVE_ALWAYS_FF_8E] = 0xFF; + memory[REG_RD_ABOVE_ALWAYS_FF_8F] = 0xFF; } void DS2408::setPinState(const uint8_t pinNumber, const bool value) { uint8_t pio_state = memory[REG_PIO_LOGIC]; - if(value) pio_state |= 1 << pinNumber; - else pio_state &= ~(1 << pinNumber); + if (value) pio_state |= 1 << pinNumber; + else pio_state &= ~(1 << pinNumber); // look for changes in the activity latches - memory[REG_PIO_ACTIVITY] |= pio_state ^ memory[REG_PIO_LOGIC]; // TODO: just good guess here, has anyone the energy to figure out each register? - memory[REG_PIO_LOGIC] = pio_state; - memory[REG_PIO_OUTPUT] = pio_state; + memory[REG_PIO_ACTIVITY] |= + pio_state ^ + memory[REG_PIO_LOGIC]; // TODO: just good guess here, has anyone the energy to figure out each register? + memory[REG_PIO_LOGIC] = pio_state; + memory[REG_PIO_OUTPUT] = pio_state; } bool DS2408::getPinState(const uint8_t pinNumber) const { - return static_cast(memory[REG_PIO_LOGIC] & ( 1 << pinNumber )); + return static_cast(memory[REG_PIO_LOGIC] & (1 << pinNumber)); } -uint8_t DS2408::getPinState(void) const -{ - return memory[REG_PIO_LOGIC]; -} +uint8_t DS2408::getPinState(void) const { return memory[REG_PIO_LOGIC]; } void DS2408::setPinActivity(const uint8_t pinNumber, const bool value) { - if (value) memory[REG_PIO_ACTIVITY] |= (1<(memory[REG_PIO_ACTIVITY] & ( 1 << pinNumber )); + return static_cast(memory[REG_PIO_ACTIVITY] & (1 << pinNumber)); } -uint8_t DS2408::getPinActivity(void) const -{ - return memory[REG_PIO_ACTIVITY]; -} +uint8_t DS2408::getPinActivity(void) const { return memory[REG_PIO_ACTIVITY]; } diff --git a/src/DS2408.h b/src/DS2408.h index f727a7c..1aa8401 100644 --- a/src/DS2408.h +++ b/src/DS2408.h @@ -10,31 +10,32 @@ class DS2408 : public OneWireItem { private: - - static constexpr uint8_t MEM_SIZE { 8 }; + static constexpr uint8_t MEM_SIZE{8}; // Register Indexes - static constexpr uint8_t REG_OFFSET { 0x88 }; - static constexpr uint8_t REG_PIO_LOGIC { 0 }; // 0x88 - Current state - static constexpr uint8_t REG_PIO_OUTPUT { 1 }; // 0x89 - Last write, latch state register - static constexpr uint8_t REG_PIO_ACTIVITY { 2 }; // 0x8A - State Change Activity - static constexpr uint8_t REG_SEARCH_MASK { 3 }; // 0x8B - RW Conditional Search Channel Selection Mask - static constexpr uint8_t REG_SEARCH_SELECT { 4 }; // 0x8C - RW Conditional Search Channel Polarity Selection - static constexpr uint8_t REG_CONTROL_STATUS { 5 }; // 0x8D - RW Control Register - static constexpr uint8_t REG_RD_ABOVE_ALWAYS_FF_8E { 6 }; // 0x8E - these bytes give always 0xFF - static constexpr uint8_t REG_RD_ABOVE_ALWAYS_FF_8F { 7 }; // 0x8F - these bytes give always 0xFF + static constexpr uint8_t REG_OFFSET{0x88}; + static constexpr uint8_t REG_PIO_LOGIC{0}; // 0x88 - Current state + static constexpr uint8_t REG_PIO_OUTPUT{1}; // 0x89 - Last write, latch state register + static constexpr uint8_t REG_PIO_ACTIVITY{2}; // 0x8A - State Change Activity + static constexpr uint8_t REG_SEARCH_MASK{ + 3}; // 0x8B - RW Conditional Search Channel Selection Mask + static constexpr uint8_t REG_SEARCH_SELECT{ + 4}; // 0x8C - RW Conditional Search Channel Polarity Selection + static constexpr uint8_t REG_CONTROL_STATUS{5}; // 0x8D - RW Control Register + static constexpr uint8_t REG_RD_ABOVE_ALWAYS_FF_8E{6}; // 0x8E - these bytes give always 0xFF + static constexpr uint8_t REG_RD_ABOVE_ALWAYS_FF_8F{7}; // 0x8F - these bytes give always 0xFF uint8_t memory[MEM_SIZE]; public: + static constexpr uint8_t family_code{0x29}; - static constexpr uint8_t family_code { 0x29 }; - - DS2408(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2408(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); + void clearMemory(void); void setPinState(uint8_t pinNumber, bool value); bool getPinState(uint8_t pinNumber) const; @@ -45,7 +46,6 @@ class DS2408 : public OneWireItem uint8_t getPinActivity(void) const; // TODO: do we need FN to set the output register? - }; #endif diff --git a/src/DS2413.cpp b/src/DS2413.cpp index 9f47f1a..f966a80 100644 --- a/src/DS2413.cpp +++ b/src/DS2413.cpp @@ -1,6 +1,8 @@ #include "DS2413.h" -DS2413::DS2413(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) +DS2413::DS2413(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) { pin_state[0] = false; pin_latch[0] = false; @@ -8,7 +10,7 @@ DS2413::DS2413(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, pin_latch[1] = false; } -void DS2413::duty(OneWireHub * const hub) +void DS2413::duty(OneWireHub *const hub) { uint8_t cmd, data; @@ -16,30 +18,29 @@ void DS2413::duty(OneWireHub * const hub) switch (cmd) { - case 0x5A: // PIO ACCESS WRITE + case 0x5A: // PIO ACCESS WRITE if (hub->recv(&data)) return; - data = ~data; // Write inverse + data = ~data; // Write inverse if (hub->send(&data)) return; // send inverted form for safety - setPinLatch(0, (data & static_cast(0x01)) != 0);// A - setPinLatch(1, (data & static_cast(0x02)) != 0);// B + setPinLatch(0, (data & static_cast(0x01)) != 0); // A + setPinLatch(1, (data & static_cast(0x02)) != 0); // B break; - case 0xF5: // PIO ACCESS READ + case 0xF5: // PIO ACCESS READ data = 0; - if (pin_state[0]) data |= static_cast(0x01); + if (pin_state[0]) data |= static_cast(0x01); if (!pin_latch[0]) data |= static_cast(0x02); - if (pin_state[1]) data |= static_cast(0x04); + if (pin_state[1]) data |= static_cast(0x04); if (!pin_latch[1]) data |= static_cast(0x08); data = data | (~data << 4); if (hub->send(&data)) return; break; - default: - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } diff --git a/src/DS2413.h b/src/DS2413.h index 40bf269..19bdbfa 100644 --- a/src/DS2413.h +++ b/src/DS2413.h @@ -10,40 +10,34 @@ class DS2413 : public OneWireItem { private: - - bool pin_state[2]; // sensed input for A and B - bool pin_latch[2]; // PIO can be set to input (0) or output-to-zero (1) + bool pin_state[2]; // sensed input for A and B + bool pin_latch[2]; // PIO can be set to input (0) or output-to-zero (1) public: + static constexpr uint8_t family_code{0x3A}; - static constexpr uint8_t family_code { 0x3A }; - - DS2413(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2413(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - bool setPinState(const uint8_t a_or_b, const bool value) + bool setPinState(const uint8_t a_or_b, const bool value) { if (value && pin_latch[a_or_b & 1]) return false; // can't set 1 because pin is latched pin_state[a_or_b & 1] = value; return true; } - bool getPinState(const uint8_t a_or_b) const - { - return pin_state[a_or_b & 1]; - } + bool getPinState(const uint8_t a_or_b) const { return pin_state[a_or_b & 1]; } - void setPinLatch(const uint8_t a_or_b, const bool value) // latching a pin will pull it down (state=zero) + void setPinLatch(const uint8_t a_or_b, + const bool value) // latching a pin will pull it down (state=zero) { pin_latch[a_or_b & 1] = value; if (value) setPinState(a_or_b, false); } - bool getPinLatch(const uint8_t a_or_b) const - { - return pin_latch[a_or_b & 1]; - } + bool getPinLatch(const uint8_t a_or_b) const { return pin_latch[a_or_b & 1]; } }; #endif diff --git a/src/DS2423.cpp b/src/DS2423.cpp index bc5ec9f..6a0388b 100644 --- a/src/DS2423.cpp +++ b/src/DS2423.cpp @@ -1,179 +1,185 @@ #include "DS2423.h" -DS2423::DS2423(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) +DS2423::DS2423(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) { - static_assert(sizeof(memory) < 65535, "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) < 65535, "Implementation does not cover the whole address-space"); clearMemory(); clearScratchpad(); - for (uint8_t n = 0; n < COUNTER_COUNT; ++n) setCounter(n,0); + for (uint8_t n = 0; n < COUNTER_COUNT; ++n) setCounter(n, 0); } -void DS2423::duty(OneWireHub * const hub) +void DS2423::duty(OneWireHub *const hub) { - constexpr uint32_t DUMMY_32b_ZERO { 0x00000000 }; // should be std::numeric_limits::lowest() - constexpr uint32_t DUMMY_32b_ONES { 0xFFFFFFFF }; - constexpr uint8_t ALTERNATING_10 { 0xAA }; - static uint16_t reg_TA { 0 }; - static uint8_t reg_ES { 0 }; - uint16_t crc { 0 }; // target_address - uint8_t data; + constexpr uint32_t DUMMY_32b_ZERO{ + 0x00000000}; // should be std::numeric_limits::lowest() + constexpr uint32_t DUMMY_32b_ONES{0xFFFFFFFF}; + constexpr uint8_t ALTERNATING_10{0xAA}; + static uint16_t reg_TA{0}; + static uint8_t reg_ES{0}; + uint16_t crc{0}; // target_address + uint8_t data; uint8_t cmd; - if (hub->recv(&cmd,1,crc)) return; + if (hub->recv(&cmd, 1, crc)) return; switch (cmd) { - case 0x0F: // Write Scratchpad + case 0x0F: // Write Scratchpad - if (hub->recv(reinterpret_cast(®_TA),2,crc)) break; + if (hub->recv(reinterpret_cast(®_TA), 2, crc)) break; reg_TA &= REG_TA_MASK; // compiler makes this to a 8bit OP, nice reg_ES = uint8_t(reg_TA) & PAGE_MASK; - for (;reg_ES < PAGE_SIZE; ++reg_ES) + for (; reg_ES < PAGE_SIZE; ++reg_ES) { - if (hub->recv(&scratchpad[reg_ES],1,crc)) + if (hub->recv(&scratchpad[reg_ES], 1, crc)) { - if (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) reg_ES |= REG_ES_PF_MASK; + if (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) + reg_ES |= REG_ES_PF_MASK; break; } } reg_ES--; reg_ES &= PAGE_MASK; - if (hub->getError() == Error::NO_ERROR) // try to send crc if wanted + if (hub->getError() == Error::NO_ERROR) // try to send crc if wanted { crc = ~crc; // normally crc16 is sent ~inverted hub->send(reinterpret_cast(&crc), 2); } break; - case 0xAA: // read Scratchpad + case 0xAA: // read Scratchpad - if (hub->send(reinterpret_cast(®_TA),2)) break; - if (hub->send(®_ES,1)) break; + if (hub->send(reinterpret_cast(®_TA), 2)) break; + if (hub->send(®_ES, 1)) break; { - const uint8_t start = uint8_t(reg_TA) & PAGE_MASK; - const uint8_t length = PAGE_SIZE - start; - if (hub->send(&scratchpad[start],length)) return; + const uint8_t start = uint8_t(reg_TA) & PAGE_MASK; + const uint8_t length = PAGE_SIZE - start; + if (hub->send(&scratchpad[start], length)) return; } break; // send 1s, be passive ... - case 0x5A: // copy scratchpad + case 0x5A: // copy scratchpad - if (hub->recv(&data,1)) break; + if (hub->recv(&data, 1)) break; if (data != reinterpret_cast(®_TA)[0]) break; - if (hub->recv(&data,1)) break; + if (hub->recv(&data, 1)) break; if (data != reinterpret_cast(®_TA)[1]) break; - if (hub->recv(&data,1)) break; - if (data != reg_ES) break; + if (hub->recv(&data, 1)) break; + if (data != reg_ES) break; - if ((reg_ES & REG_ES_PF_MASK) != 0) break; // stop if error occurred earlier - reg_ES |= REG_ES_AA_MASK; // compare was successful + if ((reg_ES & REG_ES_PF_MASK) != 0) break; // stop if error occurred earlier + reg_ES |= REG_ES_AA_MASK; // compare was successful // we have ~30µs to write the date { - const uint8_t start = uint8_t(reg_TA) & PAGE_MASK; - const uint8_t length = (reg_ES & PAGE_MASK) + uint8_t(1) - start; + const uint8_t start = uint8_t(reg_TA) & PAGE_MASK; + const uint8_t length = (reg_ES & PAGE_MASK) + uint8_t(1) - start; writeMemory(&scratchpad[start], length, reg_TA); } - while (!hub->send(&ALTERNATING_10)); // send 1s when alternating 1 & 0 after copy is complete + while (!hub->send(&ALTERNATING_10)) + ; // send 1s when alternating 1 & 0 after copy is complete break; - case 0xF0: // READ MEMORY + case 0xF0: // READ MEMORY - if (hub->recv(reinterpret_cast(®_TA),2)) break; + if (hub->recv(reinterpret_cast(®_TA), 2)) break; reg_TA &= REG_TA_MASK; // compiler makes this to a 8bit OP, nice { uint8_t page = uint8_t(reg_TA >> 5); uint8_t start = uint8_t(reg_TA) & PAGE_MASK; - for (;page < PAGE_COUNT; ++page) + for (; page < PAGE_COUNT; ++page) { const uint8_t length = PAGE_SIZE - start; - if (hub->send(&memory[(page*PAGE_SIZE) + start],length)) return; + if (hub->send(&memory[(page * PAGE_SIZE) + start], length)) return; start = 0; } } break; // send 1s, be passive ... - case 0xA5: // Read Memory + Counter + case 0xA5: // Read Memory + Counter - if (hub->recv(reinterpret_cast(®_TA),2,crc)) return; + if (hub->recv(reinterpret_cast(®_TA), 2, crc)) return; reg_TA &= REG_TA_MASK; // compiler makes this to a 8bit OP, nice { uint8_t page = uint8_t(reg_TA >> 5); uint8_t start = uint8_t(reg_TA) & PAGE_MASK; - for (;page < PAGE_COUNT; ++page) + for (; page < PAGE_COUNT; ++page) { const uint8_t length = PAGE_SIZE - start; - if (hub->send(&memory[(page*PAGE_SIZE) + start],length,crc)) return; + if (hub->send(&memory[(page * PAGE_SIZE) + start], length, crc)) return; start = 0; if (page >= COUNTER_PAGE_START) { - if (hub->send(reinterpret_cast(&memcounter[page-COUNTER_PAGE_START]),4,crc)) return; + if (hub->send(reinterpret_cast( + &memcounter[page - COUNTER_PAGE_START]), + 4, crc)) + return; } else { - if (hub->send(reinterpret_cast(&DUMMY_32b_ONES),4,crc)) return; + if (hub->send(reinterpret_cast(&DUMMY_32b_ONES), 4, crc)) + return; } - if (hub->send(reinterpret_cast(&DUMMY_32b_ZERO),4,crc)) return; + if (hub->send(reinterpret_cast(&DUMMY_32b_ZERO), 4, crc)) + return; crc = ~crc; - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; crc = 0; } } break; - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } if (cmd == 0x5A) clearScratchpad(); } -void DS2423::clearMemory(void) -{ - memset(memory, static_cast(0x00), MEM_SIZE); -} +void DS2423::clearMemory(void) { memset(memory, static_cast(0x00), MEM_SIZE); } -void DS2423::clearScratchpad(void) -{ - memset(scratchpad, static_cast(0x00), PAGE_SIZE); -} +void DS2423::clearScratchpad(void) { memset(scratchpad, static_cast(0x00), PAGE_SIZE); } -bool DS2423::writeMemory(const uint8_t* const source, const uint16_t length, const uint16_t position) +bool DS2423::writeMemory(const uint8_t *const source, const uint16_t length, + const uint16_t position) { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(&memory[position],source,_length); + memcpy(&memory[position], source, _length); - const uint8_t page_start = uint8_t(position>>5); - const uint8_t page_end = uint8_t((position+length-1)>>5); + const uint8_t page_start = uint8_t(position >> 5); + const uint8_t page_end = uint8_t((position + length - 1) >> 5); - for (uint8_t page = page_start; page <= page_end; ++page)// page 12 & 13 have write-counters, page 14&15 have hw-counters + for (uint8_t page = page_start; page <= page_end; + ++page) // page 12 & 13 have write-counters, page 14&15 have hw-counters { - if ((page == COUNTER_PAGE_START) || (page == COUNTER_PAGE_START + 1)) memcounter[page-COUNTER_PAGE_START]++; + if ((page == COUNTER_PAGE_START) || (page == COUNTER_PAGE_START + 1)) + memcounter[page - COUNTER_PAGE_START]++; } return true; } -bool DS2423::readMemory(uint8_t* const destination, const uint16_t length, const uint16_t position) const +bool DS2423::readMemory(uint8_t *const destination, const uint16_t length, + const uint16_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } -void DS2423::setCounter(uint8_t counter, uint32_t value) +void DS2423::setCounter(uint8_t counter, uint32_t value) { if (counter > COUNTER_COUNT) return; memcounter[counter] = value; @@ -185,14 +191,14 @@ uint32_t DS2423::getCounter(uint8_t counter) return memcounter[counter]; } -void DS2423::incrementCounter(uint8_t counter) +void DS2423::incrementCounter(uint8_t counter) { if (counter > COUNTER_COUNT) return; if (memcounter[counter] == 0xFFFF) return; memcounter[counter]++; } -void DS2423::decrementCounter(uint8_t counter) +void DS2423::decrementCounter(uint8_t counter) { if (counter > COUNTER_COUNT) return; if (memcounter[counter] == 0x0000) return; diff --git a/src/DS2423.h b/src/DS2423.h index 5b7009f..4b7c89b 100644 --- a/src/DS2423.h +++ b/src/DS2423.h @@ -10,46 +10,47 @@ class DS2423 : public OneWireItem { private: + static constexpr uint16_t MEM_SIZE{512}; - static constexpr uint16_t MEM_SIZE { 512 }; + static constexpr uint8_t PAGE_SIZE{32}; + static constexpr uint16_t PAGE_COUNT{MEM_SIZE / PAGE_SIZE}; + static constexpr uint8_t PAGE_MASK{0b00011111}; - static constexpr uint8_t PAGE_SIZE { 32 }; - static constexpr uint16_t PAGE_COUNT { MEM_SIZE / PAGE_SIZE }; - static constexpr uint8_t PAGE_MASK { 0b00011111 }; + static constexpr uint8_t COUNTER_COUNT{4}; + static constexpr uint8_t COUNTER_PAGE_START{ + 12}; // page 12&13 have write-counters, page 14&15 transmit the hw-counters - static constexpr uint8_t COUNTER_COUNT { 4 }; - static constexpr uint8_t COUNTER_PAGE_START{ 12 }; // page 12&13 have write-counters, page 14&15 transmit the hw-counters + static constexpr uint8_t REG_ES_PF_MASK{0b00100000}; // partial byte flag + static constexpr uint8_t REG_ES_ZERO_MASK{0b01000000}; // reads always zero + static constexpr uint8_t REG_ES_AA_MASK{ + 0b10000000}; // authorization accepted (data copied to target memory) - static constexpr uint8_t REG_ES_PF_MASK { 0b00100000 }; // partial byte flag - static constexpr uint8_t REG_ES_ZERO_MASK { 0b01000000 }; // reads always zero - static constexpr uint8_t REG_ES_AA_MASK { 0b10000000 }; // authorization accepted (data copied to target memory) + static constexpr uint16_t REG_TA_MASK{ + 0x01FF}; // Addresses will be stripped of the highest 7 bytes - static constexpr uint16_t REG_TA_MASK { 0x01FF }; // Addresses will be stripped of the highest 7 bytes + uint8_t memory[MEM_SIZE]; // 4kbit max storage + uint8_t scratchpad[PAGE_SIZE]; + uint32_t memcounter[COUNTER_COUNT]; - uint8_t memory[MEM_SIZE]; // 4kbit max storage - uint8_t scratchpad[PAGE_SIZE]; - uint32_t memcounter[COUNTER_COUNT]; - - void clearScratchpad(void); + void clearScratchpad(void); public: + static constexpr uint8_t family_code{0x1D}; - static constexpr uint8_t family_code { 0x1D }; - - DS2423(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2423(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); + void clearMemory(void); - bool writeMemory(const uint8_t* source, uint16_t length, uint16_t position = 0); - bool readMemory(uint8_t* destination, uint16_t length, uint16_t position = 0) const; + bool writeMemory(const uint8_t *source, uint16_t length, uint16_t position = 0); + bool readMemory(uint8_t *destination, uint16_t length, uint16_t position = 0) const; void setCounter(uint8_t counter, uint32_t value); uint32_t getCounter(uint8_t counter); void incrementCounter(uint8_t counter); void decrementCounter(uint8_t counter); - }; #endif diff --git a/src/DS2430.cpp b/src/DS2430.cpp index 0274c8d..7864f36 100644 --- a/src/DS2430.cpp +++ b/src/DS2430.cpp @@ -1,25 +1,28 @@ #include "DS2430.h" -DS2430::DS2430(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) +DS2430::DS2430(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) { - static_assert(sizeof(scratchpad) < 256, "Implementation does not cover the whole address-space"); - static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); + static_assert(sizeof(scratchpad) < 256, + "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); clearMemory(); clearScratchpad(); status_register = 0xFFu; } -void DS2430::duty(OneWireHub * const hub) +void DS2430::duty(OneWireHub *const hub) { - static uint8_t reg_a { 0u }; + static uint8_t reg_a{0u}; - uint8_t cmd, data; - if (hub->recv(&cmd,1u)) return; + uint8_t cmd, data; + if (hub->recv(&cmd, 1u)) return; switch (cmd) { - case 0x0F: // WRITE SCRATCHPAD COMMAND - if (hub->recv(®_a,1u)) return; + case 0x0F: // WRITE SCRATCHPAD COMMAND + if (hub->recv(®_a, 1u)) return; reg_a &= SCRATCHPAD1_MASK; while (!hub->recv(&scratchpad[reg_a], 1u)) { @@ -28,8 +31,8 @@ void DS2430::duty(OneWireHub * const hub) } break; - case 0xAA: // READ SCRATCHPAD COMMAND - if (hub->recv(®_a,1u)) return; + case 0xAA: // READ SCRATCHPAD COMMAND + if (hub->recv(®_a, 1u)) return; reg_a &= SCRATCHPAD1_MASK; while (!hub->send(&scratchpad[reg_a], 1u)) { @@ -38,24 +41,24 @@ void DS2430::duty(OneWireHub * const hub) } break; - case 0x55: // COPY SCRATCHPAD COMMAND - if (hub->recv(&data)) return; - if (data != 0xA5u) break; // verification + case 0x55: // COPY SCRATCHPAD COMMAND + if (hub->recv(&data)) return; + if (data != 0xA5u) break; // verification writeMemory(scratchpad, SCRATCHPAD1_SIZE, 0u); break; - case 0xF0: // READ MEMORY COMMAND - if (hub->recv(®_a,1u)) return; + case 0xF0: // READ MEMORY COMMAND + if (hub->recv(®_a, 1u)) return; reg_a &= SCRATCHPAD1_MASK; - while (!hub->send(&memory[reg_a], 1u)) + while (!hub->send(&memory[reg_a], 1u)) { reg_a = (reg_a + 1u) & SCRATCHPAD1_MASK; // wrap around if at x1F (reads in loop until reset issued) } break; - case 0x99: // WRITE APPLICATION REGISTER - if (hub->recv(®_a,1u)) return; + case 0x99: // WRITE APPLICATION REGISTER + if (hub->recv(®_a, 1u)) return; reg_a = (reg_a & SCRATCHPAD2_MASK) + SCRATCHPAD2_ADDR; if (!(status_register & 0b11)) return; while (!hub->recv(&scratchpad[reg_a], 1u)) @@ -65,14 +68,14 @@ void DS2430::duty(OneWireHub * const hub) } break; - case 0x66: // READ STATUS REGISTER - if (hub->recv(®_a)) return; - if (data != 0x00u) break; // verification + case 0x66: // READ STATUS REGISTER + if (hub->recv(®_a)) return; + if (data != 0x00u) break; // verification hub->send(&status_register, 1u); break; - case 0xC3: // READ APPLICATION REGISTER COMMAND - if (hub->recv(®_a,1u)) return; + case 0xC3: // READ APPLICATION REGISTER COMMAND + if (hub->recv(®_a, 1u)) return; reg_a = (reg_a & SCRATCHPAD2_MASK) + SCRATCHPAD2_ADDR; // original IC distinguishes between MEM and scratchpad here, but content is the same while (!hub->send(&scratchpad[reg_a], 1u)) @@ -82,50 +85,47 @@ void DS2430::duty(OneWireHub * const hub) } break; - case 0x5A: // COPY & LOCK APPLICATION REGISTER - if (hub->recv(&data)) return; - if (data != 0xA5u) break; // verification + case 0x5A: // COPY & LOCK APPLICATION REGISTER + if (hub->recv(&data)) return; + if (data != 0xA5u) break; // verification if (!(status_register & 0b11)) return; writeMemory(&scratchpad[SCRATCHPAD2_ADDR], SCRATCHPAD2_SIZE, SCRATCHPAD2_ADDR); status_register &= ~0b11u; // lock the OTP break; - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } -void DS2430::clearMemory(void) -{ - memset(memory, static_cast(0x00), sizeof(memory)); -} +void DS2430::clearMemory(void) { memset(memory, static_cast(0x00), sizeof(memory)); } void DS2430::clearScratchpad(void) { memset(scratchpad, static_cast(0x00), SCRATCHPAD_SIZE); } -bool DS2430::writeMemory(const uint8_t* const source, const uint8_t length, const uint8_t position) +bool DS2430::writeMemory(const uint8_t *const source, const uint8_t length, const uint8_t position) { - for (uint8_t i = 0; i < length; ++i) { + for (uint8_t i = 0; i < length; ++i) + { if ((position + i) >= sizeof(memory)) break; memory[position + i] = source[position + i]; } return true; } -bool DS2430::readMemory(uint8_t* const destination, const uint16_t length, const uint16_t position) const +bool DS2430::readMemory(uint8_t *const destination, const uint16_t length, + const uint16_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } bool DS2430::syncScratchpad() { uint8_t length = (MEM_SIZE > SCRATCHPAD_SIZE) ? SCRATCHPAD_SIZE : MEM_SIZE; - memcpy(scratchpad,memory,length); + memcpy(scratchpad, memory, length); return true; } diff --git a/src/DS2430.h b/src/DS2430.h index 4317dbf..282c4ad 100644 --- a/src/DS2430.h +++ b/src/DS2430.h @@ -9,17 +9,16 @@ class DS2430 : public OneWireItem { private: + static constexpr uint8_t MEM_SIZE{32 + 8}; - static constexpr uint8_t MEM_SIZE { 32 + 8 }; + static constexpr uint8_t SCRATCHPAD_SIZE{32 + 8}; - static constexpr uint8_t SCRATCHPAD_SIZE { 32 + 8 }; + static constexpr uint8_t SCRATCHPAD1_MASK{0b00011111}; + static constexpr uint8_t SCRATCHPAD1_SIZE{32}; - static constexpr uint8_t SCRATCHPAD1_MASK { 0b00011111 }; - static constexpr uint8_t SCRATCHPAD1_SIZE { 32 }; - - static constexpr uint8_t SCRATCHPAD2_ADDR { 32 }; - static constexpr uint8_t SCRATCHPAD2_SIZE { 8 }; - static constexpr uint8_t SCRATCHPAD2_MASK { 0b00000111 }; + static constexpr uint8_t SCRATCHPAD2_ADDR{32}; + static constexpr uint8_t SCRATCHPAD2_SIZE{8}; + static constexpr uint8_t SCRATCHPAD2_MASK{0b00000111}; uint8_t memory[MEM_SIZE]; @@ -27,22 +26,22 @@ class DS2430 : public OneWireItem uint8_t status_register; - void clearScratchpad(void); + void clearScratchpad(void); public: + static constexpr uint8_t family_code{0x14}; - static constexpr uint8_t family_code { 0x14 }; - - DS2430(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2430(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); + void clearMemory(void); - bool writeMemory(const uint8_t* source, uint8_t length, uint8_t position = 0); - bool readMemory(uint8_t* destination, uint16_t length, uint16_t position = 0) const; + bool writeMemory(const uint8_t *source, uint8_t length, uint8_t position = 0); + bool readMemory(uint8_t *destination, uint16_t length, uint16_t position = 0) const; - bool syncScratchpad(void); + bool syncScratchpad(void); // this FN copies content of memory to scratchpad // needed because programming interface only allows access to memory }; diff --git a/src/DS2431.cpp b/src/DS2431.cpp index 053732e..c844eb8 100644 --- a/src/DS2431.cpp +++ b/src/DS2431.cpp @@ -1,9 +1,12 @@ #include "DS2431.h" -DS2431::DS2431(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) +DS2431::DS2431(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) { - static_assert(sizeof(scratchpad) < 256, "Implementation does not cover the whole address-space"); - static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); + static_assert(sizeof(scratchpad) < 256, + "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); clearMemory(); clearScratchpad(); @@ -14,23 +17,23 @@ DS2431::DS2431(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, updatePageStatus(); } -void DS2431::duty(OneWireHub * const hub) +void DS2431::duty(OneWireHub *const hub) { - constexpr uint8_t ALTERNATING_10 { 0xAA }; - static uint16_t reg_TA { 0 }; // contains TA1, TA2 - static uint8_t reg_ES { 0 }; // E/S register - uint16_t crc { 0 }; + constexpr uint8_t ALTERNATING_10{0xAA}; + static uint16_t reg_TA{0}; // contains TA1, TA2 + static uint8_t reg_ES{0}; // E/S register + uint16_t crc{0}; - uint8_t page_offset { 0 }; - uint8_t cmd, data; - if (hub->recv(&cmd,1,crc)) return; + uint8_t page_offset{0}; + uint8_t cmd, data; + if (hub->recv(&cmd, 1, crc)) return; switch (cmd) { - case 0x0F: // WRITE SCRATCHPAD COMMAND + case 0x0F: // WRITE SCRATCHPAD COMMAND - if (hub->recv(reinterpret_cast(®_TA),2,crc)) return; - reg_ES = uint8_t(reg_TA) & SCRATCHPAD_MASK; + if (hub->recv(reinterpret_cast(®_TA), 2, crc)) return; + reg_ES = uint8_t(reg_TA) & SCRATCHPAD_MASK; page_offset = reg_ES; // receive up to 8 bytes of data @@ -38,136 +41,140 @@ void DS2431::duty(OneWireHub * const hub) { if (hub->recv(&scratchpad[reg_ES], 1, crc)) { - if (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) reg_ES |= REG_ES_PF_MASK; + if (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) + reg_ES |= REG_ES_PF_MASK; break; } } reg_ES--; reg_ES &= SCRATCHPAD_MASK; - if (hub->getError() == Error::NO_ERROR) // try to send crc if wanted + if (hub->getError() == Error::NO_ERROR) // try to send crc if wanted { crc = ~crc; // normally crc16 is sent ~inverted hub->send(reinterpret_cast(&crc), 2); } - if (reg_TA < (4*PAGE_SIZE)) // check if page is protected or in eprom-mode + if (reg_TA < (4 * PAGE_SIZE)) // check if page is protected or in eprom-mode { const uint8_t position = uint8_t(reg_TA) & ~SCRATCHPAD_MASK; - if (getPageProtection(reinterpret_cast(®_TA)[0])) // protected: load memory-segment to scratchpad + if (getPageProtection(reinterpret_cast( + ®_TA)[0])) // protected: load memory-segment to scratchpad { - for (uint8_t i = 0; i < SCRATCHPAD_SIZE; ++i) scratchpad[i] = memory[position + i]; + for (uint8_t i = 0; i < SCRATCHPAD_SIZE; ++i) + scratchpad[i] = memory[position + i]; } - else if (getPageEpromMode(reinterpret_cast(®_TA)[0])) // eprom: logical AND of memory and data + else if (getPageEpromMode(reinterpret_cast( + ®_TA)[0])) // eprom: logical AND of memory and data { - for (uint8_t i = page_offset; i <= reg_ES; ++i) scratchpad[i] &= memory[position + i]; + for (uint8_t i = page_offset; i <= reg_ES; ++i) + scratchpad[i] &= memory[position + i]; } } break; - case 0xAA: // READ SCRATCHPAD COMMAND + case 0xAA: // READ SCRATCHPAD COMMAND - if (hub->send(reinterpret_cast(®_TA),2,crc)) return; - if (hub->send(®_ES,1,crc)) return; + if (hub->send(reinterpret_cast(®_TA), 2, crc)) return; + if (hub->send(®_ES, 1, crc)) return; - { // send Scratchpad content - const uint8_t start = uint8_t(reg_TA) & SCRATCHPAD_MASK; - const uint8_t length = (reg_ES & SCRATCHPAD_MASK)+ uint8_t(1) - start; // difference to ds2433 - if (hub->send(&scratchpad[start],length,crc)) return; + { // send Scratchpad content + const uint8_t start = uint8_t(reg_TA) & SCRATCHPAD_MASK; + const uint8_t length = + (reg_ES & SCRATCHPAD_MASK) + uint8_t(1) - start; // difference to ds2433 + if (hub->send(&scratchpad[start], length, crc)) return; } crc = ~crc; - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; break; // send 1s when read is complete, is passive, so do nothing - case 0x55: // COPY SCRATCHPAD COMMAND + case 0x55: // COPY SCRATCHPAD COMMAND - if (hub->recv(&data)) return; - if (data != reinterpret_cast(®_TA)[0]) break; - if (hub->recv(&data)) return; - if (data != reinterpret_cast(®_TA)[1]) break; - if (hub->recv(&data)) return; - if (data != reg_ES) return; // Auth code must match + if (hub->recv(&data)) return; + if (data != reinterpret_cast(®_TA)[0]) break; + if (hub->recv(&data)) return; + if (data != reinterpret_cast(®_TA)[1]) break; + if (hub->recv(&data)) return; + if (data != reg_ES) return; // Auth code must match - if (getPageProtection(uint8_t(reg_TA))) break; // stop if page is protected (WriteMemory also checks this) - if ((reg_ES & REG_ES_PF_MASK) != 0) break; // stop if error occurred earlier + if (getPageProtection(uint8_t(reg_TA))) + break; // stop if page is protected (WriteMemory also checks this) + if ((reg_ES & REG_ES_PF_MASK) != 0) break; // stop if error occurred earlier reg_ES |= REG_ES_AA_MASK; // compare was successful reg_TA &= ~uint16_t(SCRATCHPAD_MASK); // Write Scratchpad to memory, writing takes about 10ms - writeMemory(scratchpad, SCRATCHPAD_SIZE, reinterpret_cast(®_TA)[0]); // checks if copy protected + writeMemory(scratchpad, SCRATCHPAD_SIZE, + reinterpret_cast(®_TA)[0]); // checks if copy protected noInterrupts(); - do - { + do { hub->clearError(); hub->sendBit(true); // send passive 1s - } - while (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH); // wait for timeslots + while (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH); // wait for timeslots interrupts(); - while (!hub->send(&ALTERNATING_10)); // alternating 1 & 0 after copy is complete + while (!hub->send(&ALTERNATING_10)) + ; // alternating 1 & 0 after copy is complete break; - case 0xF0: // READ MEMORY COMMAND + case 0xF0: // READ MEMORY COMMAND - if (hub->recv(reinterpret_cast(®_TA),2)) return; + if (hub->recv(reinterpret_cast(®_TA), 2)) return; if (reg_TA >= MEM_SIZE) return; - if (hub->send(&memory[reg_TA],MEM_SIZE - uint8_t(reg_TA),crc)) return; + if (hub->send(&memory[reg_TA], MEM_SIZE - uint8_t(reg_TA), crc)) return; break; // send 1s when read is complete, is passive, so do nothing here - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } -void DS2431::clearMemory(void) -{ - memset(memory, static_cast(0x00), sizeof(memory)); -} +void DS2431::clearMemory(void) { memset(memory, static_cast(0x00), sizeof(memory)); } void DS2431::clearScratchpad(void) { memset(scratchpad, static_cast(0x00), SCRATCHPAD_SIZE); } -bool DS2431::writeMemory(const uint8_t* const source, const uint8_t length, const uint8_t position) +bool DS2431::writeMemory(const uint8_t *const source, const uint8_t length, const uint8_t position) { - for (uint8_t i = 0; i < length; ++i) { + for (uint8_t i = 0; i < length; ++i) + { if ((position + i) >= sizeof(memory)) break; if (getPageProtection(position + i)) continue; memory[position + i] = source[i]; } - if ((position+length) > 127) updatePageStatus(); + if ((position + length) > 127) updatePageStatus(); return true; } -bool DS2431::readMemory(uint8_t* const destination, const uint16_t length, const uint16_t position) const +bool DS2431::readMemory(uint8_t *const destination, const uint16_t length, + const uint16_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } void DS2431::setPageProtection(const uint8_t position) { - if (position < 1*PAGE_SIZE) memory[0x80] = WP_MODE; - else if (position < 2*PAGE_SIZE) memory[0x81] = WP_MODE; - else if (position < 3*PAGE_SIZE) memory[0x82] = WP_MODE; - else if (position < 4*PAGE_SIZE) memory[0x83] = WP_MODE; - else if (position < 0x85) memory[0x84] = WP_MODE; - else if (position == 0x85) memory[0x85] = WP_MODE; - else if (position < 0x88) memory[0x85] = EP_MODE; + if (position < 1 * PAGE_SIZE) memory[0x80] = WP_MODE; + else if (position < 2 * PAGE_SIZE) memory[0x81] = WP_MODE; + else if (position < 3 * PAGE_SIZE) memory[0x82] = WP_MODE; + else if (position < 4 * PAGE_SIZE) memory[0x83] = WP_MODE; + else if (position < 0x85) memory[0x84] = WP_MODE; + else if (position == 0x85) memory[0x85] = WP_MODE; + else if (position < 0x88) memory[0x85] = EP_MODE; updatePageStatus(); } @@ -175,19 +182,19 @@ void DS2431::setPageProtection(const uint8_t position) bool DS2431::getPageProtection(const uint8_t position) const { // should be an accurate model of the control bytes - if (position < 1*PAGE_SIZE) + if (position < 1 * PAGE_SIZE) { if ((page_protection & 1) != 0) return true; } - else if (position < 2*PAGE_SIZE) + else if (position < 2 * PAGE_SIZE) { if ((page_protection & 2) != 0) return true; } - else if (position < 3*PAGE_SIZE) + else if (position < 3 * PAGE_SIZE) { if ((page_protection & 4) != 0) return true; } - else if (position < 4*PAGE_SIZE) + else if (position < 4 * PAGE_SIZE) { if ((page_protection & 8) != 0) return true; } @@ -209,11 +216,11 @@ bool DS2431::getPageProtection(const uint8_t position) const } else if (position == 0x85) { - if ((page_protection & (32+16)) != 0) return true; + if ((page_protection & (32 + 16)) != 0) return true; } else if ((position == 0x86) || (position == 0x87)) { - if ((page_protection & (64+16)) != 0) return true; + if ((page_protection & (64 + 16)) != 0) return true; } else if (position > 127) // filter the rest { @@ -224,28 +231,28 @@ bool DS2431::getPageProtection(const uint8_t position) const void DS2431::setPageEpromMode(const uint8_t position) { - if (position < 1*PAGE_SIZE) memory[0x80] = EP_MODE; - else if (position < 2*PAGE_SIZE) memory[0x81] = EP_MODE; - else if (position < 3*PAGE_SIZE) memory[0x82] = EP_MODE; - else if (position < 4*PAGE_SIZE) memory[0x83] = EP_MODE; + if (position < 1 * PAGE_SIZE) memory[0x80] = EP_MODE; + else if (position < 2 * PAGE_SIZE) memory[0x81] = EP_MODE; + else if (position < 3 * PAGE_SIZE) memory[0x82] = EP_MODE; + else if (position < 4 * PAGE_SIZE) memory[0x83] = EP_MODE; updatePageStatus(); } bool DS2431::getPageEpromMode(const uint8_t position) const { - if (position < 1*PAGE_SIZE) + if (position < 1 * PAGE_SIZE) { if ((page_eprom_mode & 1) != 0) return true; } - else if (position < 2*PAGE_SIZE) + else if (position < 2 * PAGE_SIZE) { if ((page_eprom_mode & 2) != 0) return true; } - else if (position < 3*PAGE_SIZE) + else if (position < 3 * PAGE_SIZE) { if ((page_eprom_mode & 4) != 0) return true; } - else if (position < 4*PAGE_SIZE) + else if (position < 4 * PAGE_SIZE) { if ((page_eprom_mode & 8) != 0) return true; } @@ -266,8 +273,8 @@ bool DS2431::updatePageStatus(void) if (memory[0x84] == WP_MODE) page_protection |= 16; if (memory[0x84] == EP_MODE) page_protection |= 16; - if (memory[0x85] == WP_MODE) page_protection |= 32; // only byte x85 - if (memory[0x85] == EP_MODE) page_protection |= 64+32; // also byte x86 x87 + if (memory[0x85] == WP_MODE) page_protection |= 32; // only byte x85 + if (memory[0x85] == EP_MODE) page_protection |= 64 + 32; // also byte x86 x87 if (memory[0x80] == EP_MODE) page_eprom_mode |= 1; if (memory[0x81] == EP_MODE) page_eprom_mode |= 2; diff --git a/src/DS2431.h b/src/DS2431.h index 229d215..b4378af 100644 --- a/src/DS2431.h +++ b/src/DS2431.h @@ -11,22 +11,22 @@ class DS2431 : public OneWireItem { private: + static constexpr uint8_t MEM_SIZE{144}; - static constexpr uint8_t MEM_SIZE { 144 }; + static constexpr uint8_t PAGE_SIZE{32}; + static constexpr uint8_t PAGE_COUNT{MEM_SIZE / PAGE_SIZE}; + static constexpr uint8_t PAGE_MASK{0b00011111}; - static constexpr uint8_t PAGE_SIZE { 32 }; - static constexpr uint8_t PAGE_COUNT { MEM_SIZE / PAGE_SIZE }; - static constexpr uint8_t PAGE_MASK { 0b00011111 }; + static constexpr uint8_t SCRATCHPAD_SIZE{8}; + static constexpr uint8_t SCRATCHPAD_MASK{0b00000111}; - static constexpr uint8_t SCRATCHPAD_SIZE { 8 }; - static constexpr uint8_t SCRATCHPAD_MASK { 0b00000111 }; + static constexpr uint8_t REG_ES_PF_MASK{0b00100000}; // partial byte flag + static constexpr uint8_t REG_ES_ZERO_MASK{0b01011000}; // reads always zero + static constexpr uint8_t REG_ES_AA_MASK{ + 0b10000000}; // authorization accepted (data copied to target memory) - static constexpr uint8_t REG_ES_PF_MASK { 0b00100000 }; // partial byte flag - static constexpr uint8_t REG_ES_ZERO_MASK { 0b01011000 }; // reads always zero - static constexpr uint8_t REG_ES_AA_MASK { 0b10000000 }; // authorization accepted (data copied to target memory) - - static constexpr uint8_t WP_MODE { 0x55 }; // write protect mode - static constexpr uint8_t EP_MODE { 0xAA }; // eprom mode + static constexpr uint8_t WP_MODE{0x55}; // write protect mode + static constexpr uint8_t EP_MODE{0xAA}; // eprom mode uint8_t memory[MEM_SIZE]; @@ -34,27 +34,27 @@ class DS2431 : public OneWireItem uint8_t page_protection; uint8_t page_eprom_mode; - bool updatePageStatus(void); - void clearScratchpad(void); + bool updatePageStatus(void); + void clearScratchpad(void); public: + static constexpr uint8_t family_code{0x2D}; - static constexpr uint8_t family_code { 0x2D }; - - DS2431(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2431(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); + void clearMemory(void); - bool writeMemory(const uint8_t* source, uint8_t length, uint8_t position = 0); - bool readMemory(uint8_t* destination, uint16_t length, uint16_t position = 0) const; + bool writeMemory(const uint8_t *source, uint8_t length, uint8_t position = 0); + bool readMemory(uint8_t *destination, uint16_t length, uint16_t position = 0) const; - void setPageProtection(uint8_t position); - bool getPageProtection(uint8_t position) const; + void setPageProtection(uint8_t position); + bool getPageProtection(uint8_t position) const; - void setPageEpromMode(uint8_t position); - bool getPageEpromMode(uint8_t position) const; + void setPageEpromMode(uint8_t position); + bool getPageEpromMode(uint8_t position) const; }; #endif diff --git a/src/DS2433.cpp b/src/DS2433.cpp index 80fd58d..267e74e 100644 --- a/src/DS2433.cpp +++ b/src/DS2433.cpp @@ -1,30 +1,32 @@ #include "DS2433.h" -DS2433::DS2433(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) +DS2433::DS2433(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) { - static_assert(sizeof(memory) < 65535, "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) < 65535, "Implementation does not cover the whole address-space"); clearMemory(); clearScratchpad(); } -void DS2433::duty(OneWireHub * const hub) +void DS2433::duty(OneWireHub *const hub) { - constexpr uint8_t ALTERNATE_01 { 0b10101010 }; + constexpr uint8_t ALTERNATE_01{0b10101010}; - static uint16_t reg_TA { 0 }; // contains TA1, TA2 (Target Address) - static uint8_t reg_ES { 31 }; // E/S register + static uint16_t reg_TA{0}; // contains TA1, TA2 (Target Address) + static uint8_t reg_ES{31}; // E/S register uint8_t data, cmd; - uint16_t crc { 0 }; + uint16_t crc{0}; - if (hub->recv(&cmd,1,crc)) return; + if (hub->recv(&cmd, 1, crc)) return; switch (cmd) { - case 0x0F: // WRITE SCRATCHPAD COMMAND + case 0x0F: // WRITE SCRATCHPAD COMMAND - if (hub->recv(reinterpret_cast(®_TA),2,crc)) return; - reg_TA &= MEM_MASK; // make sure to stay in boundary + if (hub->recv(reinterpret_cast(®_TA), 2, crc)) return; + reg_TA &= MEM_MASK; // make sure to stay in boundary reg_ES = uint8_t(reg_TA) & PAGE_MASK; // register-offset // receive up to 8 bytes of data @@ -32,103 +34,99 @@ void DS2433::duty(OneWireHub * const hub) { if (hub->recv(&scratchpad[reg_ES], 1, crc)) { - if (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) reg_ES |= REG_ES_PF_MASK; + if (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) + reg_ES |= REG_ES_PF_MASK; break; } } reg_ES--; reg_ES &= PAGE_MASK; - if (hub->getError() == Error::NO_ERROR) // try to send crc if wanted + if (hub->getError() == Error::NO_ERROR) // try to send crc if wanted { crc = ~crc; // normally crc16 is sent ~inverted hub->send(reinterpret_cast(&crc), 2); } break; - case 0x55: // COPY SCRATCHPAD + case 0x55: // COPY SCRATCHPAD if (hub->recv(&data)) return; // TA1 if (data != reinterpret_cast(®_TA)[0]) return; - if (hub->recv(&data)) return; // TA2 + if (hub->recv(&data)) return; // TA2 if (data != reinterpret_cast(®_TA)[1]) return; - if (hub->recv(&data)) return; // ES + if (hub->recv(&data)) return; // ES if (data != reg_ES) return; - if ((reg_ES & REG_ES_PF_MASK) != 0) break; // stop if error occurred earlier + if ((reg_ES & REG_ES_PF_MASK) != 0) break; // stop if error occurred earlier reg_ES |= REG_ES_AA_MASK; // compare was successful - { // Write Scratchpad to memory, writing takes about 5ms + { // Write Scratchpad to memory, writing takes about 5ms const uint8_t start = uint8_t(reg_TA) & PAGE_MASK; - const uint8_t length = (reg_ES & PAGE_MASK)+ uint8_t(1) - start; + const uint8_t length = (reg_ES & PAGE_MASK) + uint8_t(1) - start; writeMemory(&scratchpad[start], length, reg_TA); } noInterrupts(); - do - { + do { hub->clearError(); hub->sendBit(true); // send passive 1s } - while (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH); // wait for timeslots + while (hub->getError() == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH); // wait for timeslots interrupts(); - while (!hub->send(&ALTERNATE_01)); // send alternating 1 & 0 after copy is complete + while (!hub->send(&ALTERNATE_01)) + ; // send alternating 1 & 0 after copy is complete break; - case 0xAA: // READ SCRATCHPAD COMMAND + case 0xAA: // READ SCRATCHPAD COMMAND - if (hub->send(reinterpret_cast(®_TA),2)) return; - if (hub->send(®_ES,1)) return; + if (hub->send(reinterpret_cast(®_TA), 2)) return; + if (hub->send(®_ES, 1)) return; - { // send Scratchpad content + { // send Scratchpad content const uint8_t start = uint8_t(reg_TA) & PAGE_MASK; const uint8_t length = PAGE_SIZE - start; - if (hub->send(&scratchpad[start],length)) return; + if (hub->send(&scratchpad[start], length)) return; } return; // datasheed says we should send all 1s, till reset (1s are passive... so nothing to do here) - case 0xF0: // READ MEMORY + case 0xF0: // READ MEMORY - if (hub->recv(reinterpret_cast(®_TA),2)) return; + if (hub->recv(reinterpret_cast(®_TA), 2)) return; - for (uint16_t i = reg_TA; i < MEM_SIZE; i+=PAGE_SIZE) // model of the 32byte scratchpad + for (uint16_t i = reg_TA; i < MEM_SIZE; + i += PAGE_SIZE) // model of the 32byte scratchpad { - if (hub->send(&memory[i],PAGE_SIZE)) return; + if (hub->send(&memory[i], PAGE_SIZE)) return; } return; // datasheed says we should send all 1s, till reset (1s are passive... so nothing to do here) - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } -void DS2433::clearMemory(void) -{ - memset(memory, static_cast(0x00), MEM_SIZE); -} +void DS2433::clearMemory(void) { memset(memory, static_cast(0x00), MEM_SIZE); } -void DS2433::clearScratchpad(void) -{ - memset(scratchpad, static_cast(0x00), PAGE_SIZE); -} +void DS2433::clearScratchpad(void) { memset(scratchpad, static_cast(0x00), PAGE_SIZE); } -bool DS2433::writeMemory(const uint8_t* const source, const uint16_t length, const uint16_t position) +bool DS2433::writeMemory(const uint8_t *const source, const uint16_t length, + const uint16_t position) { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(&memory[position],source,_length); + memcpy(&memory[position], source, _length); return true; } -bool DS2433::readMemory(uint8_t* const destination, const uint16_t length, const uint16_t position) const +bool DS2433::readMemory(uint8_t *const destination, const uint16_t length, + const uint16_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } diff --git a/src/DS2433.h b/src/DS2433.h index 204ef35..795d2e2 100644 --- a/src/DS2433.h +++ b/src/DS2433.h @@ -10,35 +10,35 @@ class DS2433 : public OneWireItem { private: + static constexpr uint16_t MEM_SIZE{512}; + static constexpr uint16_t MEM_MASK{0x01FF}; - static constexpr uint16_t MEM_SIZE { 512 }; - static constexpr uint16_t MEM_MASK { 0x01FF }; + static constexpr uint8_t PAGE_SIZE{32}; + static constexpr uint16_t PAGE_COUNT{MEM_SIZE / PAGE_SIZE}; + static constexpr uint8_t PAGE_MASK{0b00011111}; - static constexpr uint8_t PAGE_SIZE { 32 }; - static constexpr uint16_t PAGE_COUNT { MEM_SIZE / PAGE_SIZE }; - static constexpr uint8_t PAGE_MASK { 0b00011111 }; - - static constexpr uint8_t REG_ES_PF_MASK { 0b00100000 }; // partial byte flag - static constexpr uint8_t REG_ES_ZERO_MASK { 0b01000000 }; // reads always zero - static constexpr uint8_t REG_ES_AA_MASK { 0b10000000 }; // authorization accepted (data copied to target memory) + static constexpr uint8_t REG_ES_PF_MASK{0b00100000}; // partial byte flag + static constexpr uint8_t REG_ES_ZERO_MASK{0b01000000}; // reads always zero + static constexpr uint8_t REG_ES_AA_MASK{ + 0b10000000}; // authorization accepted (data copied to target memory) uint8_t memory[MEM_SIZE]; // 4kbit max storage uint8_t scratchpad[PAGE_SIZE]; - void clearScratchpad(void); + void clearScratchpad(void); public: + static constexpr uint8_t family_code{0x23}; - static constexpr uint8_t family_code { 0x23 }; - - DS2433(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2433(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); + void clearMemory(void); - bool writeMemory(const uint8_t* source, uint16_t length, uint16_t position = 0); - bool readMemory(uint8_t* destination, uint16_t length, uint16_t position = 0) const; + bool writeMemory(const uint8_t *source, uint16_t length, uint16_t position = 0); + bool readMemory(uint8_t *destination, uint16_t length, uint16_t position = 0) const; }; #endif diff --git a/src/DS2434.cpp b/src/DS2434.cpp index b654bce..72d6e7f 100644 --- a/src/DS2434.cpp +++ b/src/DS2434.cpp @@ -1,6 +1,8 @@ #include "DS2434.h" -DS2434::DS2434(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) +DS2434::DS2434(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) { // disable bus-features: // The DS2434 is NOT compatible with multidrop -> only one device on bus! @@ -11,155 +13,153 @@ DS2434::DS2434(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, } // As this device is not multidrop, it needs to handle ALL commands from the master -void DS2434::duty(OneWireHub * const hub) +void DS2434::duty(OneWireHub *const hub) { - uint8_t start_byte, cmd, data; + uint8_t start_byte, cmd, data; uint32_t time_now; - if (hub->recv(&cmd)) return; + if (hub->recv(&cmd)) return; switch (cmd) { - case 0x11: // Read Scratchpad - if (hub->recv(&start_byte)) return; - if (start_byte >= PAGE4_ADDR) return; - for (uint8_t nByte = start_byte; nByte < PAGE4_ADDR; ++nByte) - { - // read through scratchpad until comm-error is raised - if (hub->send(&scratchpad[nByte], 1)) return; - } - // TODO: is endless reading needed? probably not - break; - - case 0x17: // Write Scratchpad - if (hub->recv(&start_byte)) return; - if (start_byte >= PAGE4_ADDR) return; // when out of limits - for (uint8_t nByte = start_byte; nByte < PAGE4_ADDR; ++nByte) - { - if (hub->recv(&data, 1)) return; - scratchpad[nByte] = data; - } - break; - - case 0x22: // copy scratchpad SP1 to NV1 - if (memory[0x62] & 0b100u) return; // check LOCK-Status - writeMemory(&scratchpad[PAGE1_ADDR], PAGE_SIZE, PAGE1_ADDR); - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - - case 0x25: // copy scratchpad SP2 to NV2 - writeMemory(&scratchpad[PAGE2_ADDR], PAGE_SIZE, PAGE2_ADDR); - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - - case 0x28: // copy scratchpad SP3 to SRAM - writeMemory(&scratchpad[PAGE3_ADDR], PAGE_SIZE, PAGE3_ADDR); - break; - - case 0x71: // Recall Memory, NV1 to SP1 - readMemory(&scratchpad[PAGE1_ADDR], PAGE_SIZE, PAGE1_ADDR); - break; - - case 0x77: // Recall Memory, NV2 to SP2 - readMemory(&scratchpad[PAGE2_ADDR], PAGE_SIZE, PAGE2_ADDR); - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - - case 0x7A: // Recall Memory, SRAM to SP3 - readMemory(&scratchpad[PAGE3_ADDR], PAGE_SIZE, PAGE3_ADDR); - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - - case 0x43: // lock NV1 - lockNV1(); - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - case 0x44: // unlock NV1 - unlockNV1(); - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - - case 0xD2: // trigger temperature-reading - request_temp = true; - timer_temp = millis() + DURATION_TEMP_ms; - break; - - case 0xB2: // read Page 4 and 5 - if (hub->recv(&start_byte)) return; - if (start_byte < PAGE4_ADDR) return; // when out of limits - if (start_byte >= PAGE6_ADDR) return; - - // update status byte, TODO: done here because laptop waits -> check duration - time_now = millis(); - if (time_now >= timer_nvwr) memory[0x62] &= ~0b10u; // erase busy-flag - else memory[0x62] |= 0b10u; // set busy-flag - if (time_now >= timer_temp) memory[0x62] &= ~0b1u; // erase busy-flag - else memory[0x62] |= 0b1u; // set busy-flag - - for (uint8_t nByte = start_byte; nByte < PAGE6_ADDR; ++nByte) - { - if (hub->send(&memory[nByte], 1)) return; - } - break; - - case 0xB5: // increment Cycle - if (++memory[0x83] == 0u) - { - // after overflow of LSB - memory[0x82]++; - } - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - - case 0xB8: // reset Cycle - memory[0x82] = 0u; - memory[0x83] = 0u; - // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) - timer_nvwr = millis() + DURATION_NVWR_ms; - break; - - case 0x8E: // secret command just to avoid triggering an error - break; - case 0x84: // second secret command - if (hub->recv(&data)) return; - break; - - default: - hub->raiseSlaveError(cmd); + case 0x11: // Read Scratchpad + if (hub->recv(&start_byte)) return; + if (start_byte >= PAGE4_ADDR) return; + for (uint8_t nByte = start_byte; nByte < PAGE4_ADDR; ++nByte) + { + // read through scratchpad until comm-error is raised + if (hub->send(&scratchpad[nByte], 1)) return; + } + // TODO: is endless reading needed? probably not + break; + + case 0x17: // Write Scratchpad + if (hub->recv(&start_byte)) return; + if (start_byte >= PAGE4_ADDR) return; // when out of limits + for (uint8_t nByte = start_byte; nByte < PAGE4_ADDR; ++nByte) + { + if (hub->recv(&data, 1)) return; + scratchpad[nByte] = data; + } + break; + + case 0x22: // copy scratchpad SP1 to NV1 + if (memory[0x62] & 0b100u) return; // check LOCK-Status + writeMemory(&scratchpad[PAGE1_ADDR], PAGE_SIZE, PAGE1_ADDR); + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0x25: // copy scratchpad SP2 to NV2 + writeMemory(&scratchpad[PAGE2_ADDR], PAGE_SIZE, PAGE2_ADDR); + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0x28: // copy scratchpad SP3 to SRAM + writeMemory(&scratchpad[PAGE3_ADDR], PAGE_SIZE, PAGE3_ADDR); + break; + + case 0x71: // Recall Memory, NV1 to SP1 + readMemory(&scratchpad[PAGE1_ADDR], PAGE_SIZE, PAGE1_ADDR); + break; + + case 0x77: // Recall Memory, NV2 to SP2 + readMemory(&scratchpad[PAGE2_ADDR], PAGE_SIZE, PAGE2_ADDR); + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0x7A: // Recall Memory, SRAM to SP3 + readMemory(&scratchpad[PAGE3_ADDR], PAGE_SIZE, PAGE3_ADDR); + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0x43: // lock NV1 + lockNV1(); + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + case 0x44: // unlock NV1 + unlockNV1(); + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0xD2: // trigger temperature-reading + request_temp = true; + timer_temp = millis() + DURATION_TEMP_ms; + break; + + case 0xB2: // read Page 4 and 5 + if (hub->recv(&start_byte)) return; + if (start_byte < PAGE4_ADDR) return; // when out of limits + if (start_byte >= PAGE6_ADDR) return; + + // update status byte, TODO: done here because laptop waits -> check duration + time_now = millis(); + if (time_now >= timer_nvwr) memory[0x62] &= ~0b10u; // erase busy-flag + else memory[0x62] |= 0b10u; // set busy-flag + if (time_now >= timer_temp) memory[0x62] &= ~0b1u; // erase busy-flag + else memory[0x62] |= 0b1u; // set busy-flag + + for (uint8_t nByte = start_byte; nByte < PAGE6_ADDR; ++nByte) + { + if (hub->send(&memory[nByte], 1)) return; + } + break; + + case 0xB5: // increment Cycle + if (++memory[0x83] == 0u) + { + // after overflow of LSB + memory[0x82]++; + } + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0xB8: // reset Cycle + memory[0x82] = 0u; + memory[0x83] = 0u; + // NOTE: OP occupies real NV for ~ 10 ms (NVB-Bit) + timer_nvwr = millis() + DURATION_NVWR_ms; + break; + + case 0x8E: // secret command just to avoid triggering an error + break; + case 0x84: // second secret command + if (hub->recv(&data)) return; + break; + + default: hub->raiseSlaveError(cmd); } } -void DS2434::clearMemory(void) -{ - memset(memory, static_cast(0xFF), MEM_SIZE); -} +void DS2434::clearMemory(void) { memset(memory, static_cast(0xFF), MEM_SIZE); } void DS2434::clearScratchpad(void) { memset(scratchpad, static_cast(0xFF), SCRATCHPAD_SIZE); } -bool DS2434::writeMemory(const uint8_t* const source, const uint16_t length, const uint16_t position) +bool DS2434::writeMemory(const uint8_t *const source, const uint16_t length, + const uint16_t position) { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(&memory[position],source,_length); + memcpy(&memory[position], source, _length); return true; } -bool DS2434::readMemory(uint8_t* const destination, const uint16_t length, const uint16_t position) const +bool DS2434::readMemory(uint8_t *const destination, const uint16_t length, + const uint16_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } void DS2434::setTemperature(const int8_t temp_degC) @@ -179,27 +179,12 @@ void DS2434::setTemperature(const int8_t temp_degC) request_temp = false; } -bool DS2434::getTemperatureRequest() const -{ - return (request_temp); -} +bool DS2434::getTemperatureRequest() const { return (request_temp); } -void DS2434::lockNV1() -{ - memory[0x62] |= 0b100u; -} +void DS2434::lockNV1() { memory[0x62] |= 0b100u; } -void DS2434::unlockNV1() -{ - memory[0x62] &= ~0b100u; -} +void DS2434::unlockNV1() { memory[0x62] &= ~0b100u; } -void DS2434::setBatteryCounter(uint16_t value) -{ - *((uint16_t *) &memory[0x82]) = value; -} +void DS2434::setBatteryCounter(uint16_t value) { *((uint16_t *) &memory[0x82]) = value; } -void DS2434::setID(uint16_t value) -{ - *((uint16_t *) &memory[0x80]) = value; -} +void DS2434::setID(uint16_t value) { *((uint16_t *) &memory[0x80]) = value; } diff --git a/src/DS2434.h b/src/DS2434.h index 9ea1434..216e7ef 100644 --- a/src/DS2434.h +++ b/src/DS2434.h @@ -9,9 +9,9 @@ #include "OneWireItem.h" class DS2434 : public OneWireItem - { +{ private: -/* + /* PAGE 1 NV1: - lockable nonvolatile, 24 byte - user data: battery chemistry descriptors, manufacturing lot codes, gas gauge information .. @@ -32,58 +32,59 @@ class DS2434 : public OneWireItem - B0:1: ID, 16 bit ROM, 0x5344 - B2:3: cycle counter */ - static constexpr uint8_t PAGE1_SIZE { 24 }; // NV1, lockable nonvolatile - static constexpr uint8_t PAGE1_ADDR { 0x00 }; - static constexpr uint8_t PAGE2_SIZE { 8 }; // NV2, nonvolatile - static constexpr uint8_t PAGE2_ADDR { 0x20 }; - static constexpr uint8_t PAGE3_SIZE { 32 }; // SRAM, scratchpad - static constexpr uint8_t PAGE3_ADDR { 0x40 }; - static constexpr uint8_t PAGE4_SIZE { 4 }; // SRAM, Temp & Status - static constexpr uint8_t PAGE4_ADDR { 0x60 }; - static constexpr uint8_t PAGE5_SIZE { 4 }; // E2, Battery Cycle Counter & ID - static constexpr uint8_t PAGE5_ADDR { 0x80 }; - static constexpr uint8_t PAGE6_ADDR { 0xA0 }; // LIMIT + static constexpr uint8_t PAGE1_SIZE{24}; // NV1, lockable nonvolatile + static constexpr uint8_t PAGE1_ADDR{0x00}; + static constexpr uint8_t PAGE2_SIZE{8}; // NV2, nonvolatile + static constexpr uint8_t PAGE2_ADDR{0x20}; + static constexpr uint8_t PAGE3_SIZE{32}; // SRAM, scratchpad + static constexpr uint8_t PAGE3_ADDR{0x40}; + static constexpr uint8_t PAGE4_SIZE{4}; // SRAM, Temp & Status + static constexpr uint8_t PAGE4_ADDR{0x60}; + static constexpr uint8_t PAGE5_SIZE{4}; // E2, Battery Cycle Counter & ID + static constexpr uint8_t PAGE5_ADDR{0x80}; + static constexpr uint8_t PAGE6_ADDR{0xA0}; // LIMIT // pages simplified with 5x 32byte (there is enough RAM) - static constexpr uint8_t PAGE_SIZE { 32 }; - static constexpr uint8_t PAGE_COUNT { 5 }; + static constexpr uint8_t PAGE_SIZE{32}; + static constexpr uint8_t PAGE_COUNT{5}; - static constexpr uint8_t MEM_SIZE { 4 * PAGE_SIZE + 4 }; // Limit the memory size to the working space - static constexpr uint8_t SCRATCHPAD_SIZE { 3 * PAGE_SIZE }; // Scratchpad is used for first 3 pages + static constexpr uint8_t MEM_SIZE{4 * PAGE_SIZE + + 4}; // Limit the memory size to the working space + static constexpr uint8_t SCRATCHPAD_SIZE{3 * PAGE_SIZE}; // Scratchpad is used for first 3 pages - static constexpr uint32_t DURATION_TEMP_ms { 230 }; - static constexpr uint32_t DURATION_NVWR_ms { 10 }; - uint32_t timer_temp = 0u; - uint32_t timer_nvwr = 0u; - bool request_temp = false; + static constexpr uint32_t DURATION_TEMP_ms{230}; + static constexpr uint32_t DURATION_NVWR_ms{10}; + uint32_t timer_temp = 0u; + uint32_t timer_nvwr = 0u; + bool request_temp = false; - uint8_t memory[MEM_SIZE]; - uint8_t scratchpad[SCRATCHPAD_SIZE]; + uint8_t memory[MEM_SIZE]; + uint8_t scratchpad[SCRATCHPAD_SIZE]; - void clearScratchpad(void); + void clearScratchpad(void); public: + static constexpr uint8_t family_code{0x53}; // TODO: 1B seems to be right (for ds2436) - static constexpr uint8_t family_code { 0x53 }; // TODO: 1B seems to be right (for ds2436) + DS2434(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - DS2434(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + void duty(OneWireHub *hub) final; - void duty(OneWireHub * hub) final; + void clearMemory(void); - void clearMemory(void); + bool writeMemory(const uint8_t *source, uint16_t length, uint16_t position = 0); + bool readMemory(uint8_t *destination, uint16_t length, uint16_t position = 0) const; - bool writeMemory(const uint8_t* source, uint16_t length, uint16_t position = 0); - bool readMemory(uint8_t* destination, uint16_t length, uint16_t position = 0) const; + void setTemperature(int8_t temp_degC); // can vary from -40 to 127 degC + bool getTemperatureRequest(void) const; - void setTemperature(int8_t temp_degC); // can vary from -40 to 127 degC - bool getTemperatureRequest(void) const; + void lockNV1(); + void unlockNV1(); - void lockNV1(); - void unlockNV1(); + void setBatteryCounter(uint16_t value); - void setBatteryCounter(uint16_t value); - - void setID(uint16_t value); + void setID(uint16_t value); }; #endif //ONEWIREHUB_DS2434_H diff --git a/src/DS2438.cpp b/src/DS2438.cpp index ff842a4..4f98280 100644 --- a/src/DS2438.cpp +++ b/src/DS2438.cpp @@ -1,33 +1,35 @@ #include "DS2438.h" -DS2438::DS2438(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) +DS2438::DS2438(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) { - static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); clearMemory(); } -void DS2438::duty(OneWireHub * const hub) +void DS2438::duty(OneWireHub *const hub) { uint8_t page, cmd; - if (hub->recv(&cmd)) return; + if (hub->recv(&cmd)) return; switch (cmd) { // reordered for better timing - case 0xBE: // Read Scratchpad + case 0xBE: // Read Scratchpad - if (hub->recv(&page)) return; + if (hub->recv(&page)) return; if (page >= PAGE_COUNT) return; if (hub->send(&memory[page * 8], 8)) return; if (hub->send(crc[page])) return; break; - case 0x4E: // Write Scratchpad + case 0x4E: // Write Scratchpad - if (hub->recv(&page)) return; + if (hub->recv(&page)) return; if (page >= PAGE_COUNT) return; // when page out of limits - for (uint8_t nByte = page<<3; nByte < (page+1)<<3; ++nByte) + for (uint8_t nByte = page << 3; nByte < (page + 1) << 3; ++nByte) { uint8_t data; if (hub->recv(&data, 1)) break; @@ -37,26 +39,29 @@ void DS2438::duty(OneWireHub * const hub) calcCRC(page); break; - case 0x48: // copy scratchpad + case 0x48: // copy scratchpad // do nothing special, goto recall for now - case 0xB8: // Recall Memory + case 0xB8: // Recall Memory - if (hub->recv(&page)) return; + if (hub->recv(&page)) return; if (page >= PAGE_COUNT) page = PAGE_COUNT - 1; // when page out of limits break; - case 0x44: // Convert T + case 0x44: // Convert T break; //hub->sendBit(1); // 1 is passive, so omit it ... - case 0xB4: // Convert V + case 0xB4: // Convert V // Copy VDD or VAD into page zero based on REG0_MASK_AD - if (memory[0] & REG0_MASK_AD) { + if (memory[0] & REG0_MASK_AD) + { memory[3] = vddVoltage[0]; memory[4] = vddVoltage[1]; - } else { + } + else + { memory[3] = vadVoltage[0]; memory[4] = vadVoltage[1]; } @@ -64,20 +69,18 @@ void DS2438::duty(OneWireHub * const hub) break; //hub->sendBit(1); // 1 is passive, so omit it ... - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } void DS2438::calcCRC(const uint8_t page) { - if (page < PAGE_COUNT) crc[page] = crc8(&memory[page * 8], 8); + if (page < PAGE_COUNT) crc[page] = crc8(&memory[page * 8], 8); } void DS2438::clearMemory(void) { - memcpy(memory,MemDS2438,(PAGE_COUNT*PAGE_SIZE)); + memcpy(memory, MemDS2438, (PAGE_COUNT * PAGE_SIZE)); memory[0] |= REG0_MASK_IAD; // enable automatic current measurements memory[0] |= REG0_MASK_CA; // enable current accumulator (page7, byte 4-7) @@ -86,22 +89,20 @@ void DS2438::clearMemory(void) memory[0] &= ~REG0_MASK_NVB; // eeprom busy flag memory[0] &= ~REG0_MASK_ADB; // adc busy flag - for (uint8_t page = 0; page < PAGE_COUNT; ++page) - { - calcCRC(page); - } + for (uint8_t page = 0; page < PAGE_COUNT; ++page) { calcCRC(page); } } -bool DS2438::writeMemory(const uint8_t* const source, const uint8_t length, const uint8_t position) +bool DS2438::writeMemory(const uint8_t *const source, const uint8_t length, const uint8_t position) { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(&memory[position],source,_length); + memcpy(&memory[position], source, _length); - const uint8_t page_start = uint8_t(position>>3); - const uint8_t page_end = uint8_t((position+length)>>3); + const uint8_t page_start = uint8_t(position >> 3); + const uint8_t page_end = uint8_t((position + length) >> 3); - for (uint8_t page = page_start; page <= page_end; ++page)// page 12 & 13 have write-counters, page 14&15 have hw-counters + for (uint8_t page = page_start; page <= page_end; + ++page) // page 12 & 13 have write-counters, page 14&15 have hw-counters { calcCRC(page); } @@ -109,22 +110,23 @@ bool DS2438::writeMemory(const uint8_t* const source, const uint8_t length, cons return true; } -bool DS2438::readMemory(uint8_t* const destination, const uint8_t length, const uint8_t position) const +bool DS2438::readMemory(uint8_t *const destination, const uint8_t length, + const uint8_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } void DS2438::setTemperature(const float temp_degC) { int16_t value = static_cast(temp_degC * 256.0); - if (value > 125*256) value = 125*256; - if (value < -55*256) value = -55*256; + if (value > 125 * 256) value = 125 * 256; + if (value < -55 * 256) value = -55 * 256; - memory[1] = static_cast(value&0xF8); + memory[1] = static_cast(value & 0xF8); memory[2] = uint8_t(value >> 8); calcCRC(0); @@ -143,12 +145,9 @@ void DS2438::setTemperature(const int8_t temp_degC) // can vary from -55 to 125d calcCRC(0); } -int8_t DS2438::getTemperature() const -{ - return memory[2]; -} +int8_t DS2438::getTemperature() const { return memory[2]; } -void convertVoltage(uint8_t* const destination, const uint16_t voltage_10mV) // 10 bit +void convertVoltage(uint8_t *const destination, const uint16_t voltage_10mV) // 10 bit { destination[0] = uint8_t(voltage_10mV & 0xFF); destination[1] = uint8_t((voltage_10mV >> 8) & static_cast(0x03)); @@ -166,29 +165,18 @@ void DS2438::setVoltage(const uint16_t voltage_10mV) calcCRC(0); } -void DS2438::setVDDVoltage(uint16_t voltage_10mV) -{ - convertVoltage(vddVoltage, voltage_10mV); -} +void DS2438::setVDDVoltage(uint16_t voltage_10mV) { convertVoltage(vddVoltage, voltage_10mV); } -void DS2438::setVADVoltage(uint16_t voltage_10mV) { - convertVoltage(vadVoltage, voltage_10mV); -} +void DS2438::setVADVoltage(uint16_t voltage_10mV) { convertVoltage(vadVoltage, voltage_10mV); } -uint16_t DS2438::getVoltage(void) const -{ - return ((memory[4]<<8) | memory[3]); -} +uint16_t DS2438::getVoltage(void) const { return ((memory[4] << 8) | memory[3]); } void DS2438::setCurrent(const int16_t value) // signed 11 bit { memory[5] = uint8_t(value & 0xFF); memory[6] = uint8_t((value >> 8) & static_cast(0x03)); - if (value<0) memory[6] |= 0xFC; // all upper bits (7:2) are the signum + if (value < 0) memory[6] |= 0xFC; // all upper bits (7:2) are the signum calcCRC(0); } -int16_t DS2438::getCurrent(void) const -{ - return ((memory[6]<<8) | memory[5]); -} +int16_t DS2438::getCurrent(void) const { return ((memory[6] << 8) | memory[5]); } diff --git a/src/DS2438.h b/src/DS2438.h index 741471e..cbe3ba1 100644 --- a/src/DS2438.h +++ b/src/DS2438.h @@ -7,18 +7,13 @@ #include "OneWireItem.h" -constexpr uint8_t MemDS2438[64] = - { - // memory[0] = REG0_MASK_IAD | REG0_MASK_CA | REG0_MASK_EE | REG0_MASK_AD; - 0x09, 0x20, 0x14, 0xAC, 0x00, 0x40, 0x01, 0x00, - 0xEC, 0xAB, 0x23, 0x58, 0xFF, 0x08, 0x00, 0xFC, - 0x00, 0x00, 0x00, 0x00, 0x6D, 0x83, 0x03, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - }; +constexpr uint8_t MemDS2438[64] = { + // memory[0] = REG0_MASK_IAD | REG0_MASK_CA | REG0_MASK_EE | REG0_MASK_AD; + 0x09, 0x20, 0x14, 0xAC, 0x00, 0x40, 0x01, 0x00, 0xEC, 0xAB, 0x23, 0x58, 0xFF, + 0x08, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x6D, 0x83, 0x03, 0x02, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; // Memory-Fragments: // 0x00 1byte - Status / Config @@ -49,55 +44,58 @@ struct DS2438_page0 // overlay with memory if needed (like done in ds2408) class DS2438 : public OneWireItem { private: + static constexpr uint8_t PAGE_COUNT{ + 8}; // how much of the real 8 pages should be emulated, use at least 1, max 8 + static constexpr uint8_t PAGE_SIZE{8}; // - static constexpr uint8_t PAGE_COUNT { 8 }; // how much of the real 8 pages should be emulated, use at least 1, max 8 - static constexpr uint8_t PAGE_SIZE { 8 }; // - - static constexpr uint8_t MEM_SIZE { PAGE_COUNT * PAGE_SIZE }; + static constexpr uint8_t MEM_SIZE{PAGE_COUNT * PAGE_SIZE}; // Register Addresses - static constexpr uint8_t REG0_MASK_IAD { 0x01 }; // enable automatic current measurements - static constexpr uint8_t REG0_MASK_CA { 0x02 }; // enable current accumulator (page7, byte 4-7) - static constexpr uint8_t REG0_MASK_EE { 0x04 }; // shadow accu to eeprom - static constexpr uint8_t REG0_MASK_AD { 0x08 }; // 1: battery voltage, 0: ADC-GPIO - static constexpr uint8_t REG0_MASK_TB { 0x10 }; // temperature busy flag - static constexpr uint8_t REG0_MASK_NVB { 0x20 }; // eeprom busy flag - static constexpr uint8_t REG0_MASK_ADB { 0x40 }; // adc busy flag - - uint8_t memory[MEM_SIZE]; // this mem is the "scratchpad" in the datasheet., no EEPROM implemented - uint8_t crc[PAGE_COUNT+1]; // keep the matching crc for each memory-page, reading can be very time-sensitive + static constexpr uint8_t REG0_MASK_IAD{0x01}; // enable automatic current measurements + static constexpr uint8_t REG0_MASK_CA{0x02}; // enable current accumulator (page7, byte 4-7) + static constexpr uint8_t REG0_MASK_EE{0x04}; // shadow accu to eeprom + static constexpr uint8_t REG0_MASK_AD{0x08}; // 1: battery voltage, 0: ADC-GPIO + static constexpr uint8_t REG0_MASK_TB{0x10}; // temperature busy flag + static constexpr uint8_t REG0_MASK_NVB{0x20}; // eeprom busy flag + static constexpr uint8_t REG0_MASK_ADB{0x40}; // adc busy flag + + uint8_t memory + [MEM_SIZE]; // this mem is the "scratchpad" in the datasheet., no EEPROM implemented + uint8_t crc + [PAGE_COUNT + + 1]; // keep the matching crc for each memory-page, reading can be very time-sensitive // One of the following is placed in scratchpad depending on state of REG0_MASK_AD when voltage conversion is requested - uint8_t vadVoltage[2]; // unsigned 10 bit - uint8_t vddVoltage[2]; // unsigned 10 bit + uint8_t vadVoltage[2]; // unsigned 10 bit + uint8_t vddVoltage[2]; // unsigned 10 bit void calcCRC(uint8_t page); public: + static constexpr uint8_t family_code{0x26}; - static constexpr uint8_t family_code { 0x26 }; - - DS2438(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2438(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); + void clearMemory(void); - bool writeMemory(const uint8_t* source, uint8_t length, uint8_t position = 0); - bool readMemory(uint8_t* destination, uint8_t length, uint8_t position = 0) const; + bool writeMemory(const uint8_t *source, uint8_t length, uint8_t position = 0); + bool readMemory(uint8_t *destination, uint8_t length, uint8_t position = 0) const; - void setTemperature(float temp_degC); // can vary from -55 to 125deg - void setTemperature(int8_t temp_degC); - int8_t getTemperature(void) const; + void setTemperature(float temp_degC); // can vary from -55 to 125deg + void setTemperature(int8_t temp_degC); + int8_t getTemperature(void) const; // setVoltage should be considered deprecated in favor of setVDDVoltage (default) & setVADVoltage - void setVoltage(uint16_t voltage_10mV); // unsigned 10 bit - void setVDDVoltage(uint16_t voltage_10mV); // unsigned 10 bit - void setVADVoltage(uint16_t voltage_10mV); // unsigned 10 bit + void setVoltage(uint16_t voltage_10mV); // unsigned 10 bit + void setVDDVoltage(uint16_t voltage_10mV); // unsigned 10 bit + void setVADVoltage(uint16_t voltage_10mV); // unsigned 10 bit uint16_t getVoltage(void) const; - void setCurrent(int16_t value); // signed 11 bit - int16_t getCurrent(void) const; + void setCurrent(int16_t value); // signed 11 bit + int16_t getCurrent(void) const; }; #endif diff --git a/src/DS2450.cpp b/src/DS2450.cpp index 8e0ed05..5f32ad1 100644 --- a/src/DS2450.cpp +++ b/src/DS2450.cpp @@ -1,25 +1,26 @@ #include "DS2450.h" -DS2450::DS2450(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) +DS2450::DS2450(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) { - static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) < 256, "Implementation does not cover the whole address-space"); clearMemory(); } -void DS2450::duty(OneWireHub * const hub) +void DS2450::duty(OneWireHub *const hub) { uint16_t reg_TA, crc = 0; // target address uint8_t cmd; - if (hub->recv(&cmd,1,crc)) return; - if (hub->recv(reinterpret_cast(®_TA),2,crc)) return; + if (hub->recv(&cmd, 1, crc)) return; + if (hub->recv(reinterpret_cast(®_TA), 2, crc)) return; switch (cmd) { case 0xAA: // READ MEMORY - while(reg_TA < MEM_SIZE) + while (reg_TA < MEM_SIZE) { const uint8_t length = PAGE_SIZE - (uint8_t(reg_TA) & PAGE_MASK); if (hub->send(&memory[reg_TA], length, crc)) return; @@ -35,16 +36,16 @@ void DS2450::duty(OneWireHub * const hub) case 0x55: // write memory (only page 1&2 allowed) - while(reg_TA < MEM_SIZE) + while (reg_TA < MEM_SIZE) { uint8_t data; - if (hub->recv(&data, 1, crc)) break; + if (hub->recv(&data, 1, crc)) break; crc = ~crc; // normally crc16 is sent ~inverted if (hub->send(reinterpret_cast(&crc), 2)) break; - if (hub->send(&data, 1)) break; - if (reg_TA >= PAGE_SIZE) memory[reg_TA] = data; // write data, page 0 is off limits + if (hub->send(&data, 1)) break; + if (reg_TA >= PAGE_SIZE) memory[reg_TA] = data; // write data, page 0 is off limits crc = ++reg_TA; // prepare next address-readout: load new TA into crc } @@ -56,16 +57,14 @@ void DS2450::duty(OneWireHub * const hub) // received reg_TA contains: input select mask (not important) and read out control byte // in reality master can now set registers of potentiometers to 0x0000 or 0xFFFF to track changes crc = ~crc; // normally crc16 is sent ~inverted - if (hub->send(reinterpret_cast(&crc),2)) return; + if (hub->send(reinterpret_cast(&crc), 2)) return; // takes max 5.3 ms for 16 bit ( 4 CH * 16 bit * 80 us + 160 us per request = 5.3 ms ) noInterrupts(); hub->sendBit(false); // still converting.... interrupts(); break; // finished conversion: send 1, is passive ... - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } @@ -78,10 +77,10 @@ void DS2450::clearMemory(void) for (uint8_t adc = 0; adc < POTI_COUNT; ++adc) { // CONTROL/STATUS DATA - memory[(1*PAGE_SIZE) + (adc*2) + 0] = 0x00; // 16bit - memory[(1*PAGE_SIZE) + (adc*2) + 1] = 0x8C; // enable POR, Alarm enable high / low + memory[(1 * PAGE_SIZE) + (adc * 2) + 0] = 0x00; // 16bit + memory[(1 * PAGE_SIZE) + (adc * 2) + 1] = 0x8C; // enable POR, Alarm enable high / low // alarm settings - memory[(2*PAGE_SIZE) + (adc*2) + 1] = 0xFF; // high threshold max + memory[(2 * PAGE_SIZE) + (adc * 2) + 1] = 0xFF; // high threshold max } } @@ -92,19 +91,20 @@ void DS2450::correctMemory(void) //// control / status data /// byte 0,2,4,6 // bit 0:3 -> RC3 sets resolution of the ADCs. 1to15bits and 0 for 16 bits. MSB aligned - memory[(1*PAGE_SIZE) + (adc*2)] &= 0b11001111; // bit 4:5 must be always zero + memory[(1 * PAGE_SIZE) + (adc * 2)] &= 0b11001111; // bit 4:5 must be always zero // bit 6 -> output control: set 0 for enablesd transistors // bit 7 -> output enable: set 0 for ADC, /// byte 1,3,5,7 // bit 0 -> IR sets input voltage: 0 for 2.55 V, 1 for 5.1 V - memory[(1*PAGE_SIZE) + (adc*2) + 1] &= 0b10111101; // bit 1&6 -> always zero + memory[(1 * PAGE_SIZE) + (adc * 2) + 1] &= 0b10111101; // bit 1&6 -> always zero // bit 2:3 -> enable alarm search low, high // bit 4:5 -> alarm flag for low, high // bit 7 -> power on reset, must be written 0 by master } } -bool DS2450::setPotentiometer(const uint16_t p1, const uint16_t p2, const uint16_t p3, const uint16_t p4) +bool DS2450::setPotentiometer(const uint16_t p1, const uint16_t p2, const uint16_t p3, + const uint16_t p4) { setPotentiometer(0, p1); setPotentiometer(1, p2); @@ -116,10 +116,10 @@ bool DS2450::setPotentiometer(const uint16_t p1, const uint16_t p2, const uint16 bool DS2450::setPotentiometer(const uint8_t channel, const uint16_t value) { if (channel >= POTI_COUNT) return false; - uint8_t LByte = static_cast(value>>0) & static_cast(0xFF); - uint8_t HByte = static_cast(value>>8) & static_cast(0xFF); - memory[(2*channel) ] = LByte; - memory[(2*channel)+1] = HByte; + uint8_t LByte = static_cast(value >> 0) & static_cast(0xFF); + uint8_t HByte = static_cast(value >> 8) & static_cast(0xFF); + memory[(2 * channel)] = LByte; + memory[(2 * channel) + 1] = HByte; correctMemory(); return true; // TODO: check with alarm settings p2, and raise alarm, also check when data is written } @@ -128,7 +128,7 @@ uint16_t DS2450::getPotentiometer(const uint8_t channel) const { if (channel >= POTI_COUNT) return 0; uint16_t value; - value = memory[(2*channel)+1]<<8; - value |= memory[(2*channel) ]; + value = memory[(2 * channel) + 1] << 8; + value |= memory[(2 * channel)]; return value; } diff --git a/src/DS2450.h b/src/DS2450.h index fa039ed..a63b62e 100644 --- a/src/DS2450.h +++ b/src/DS2450.h @@ -10,13 +10,12 @@ class DS2450 : public OneWireItem { private: + static constexpr uint8_t POTI_COUNT{4}; + static constexpr uint8_t PAGE_COUNT{4}; + static constexpr uint8_t PAGE_SIZE{2 * POTI_COUNT}; + static constexpr uint8_t PAGE_MASK{0b00000111}; - static constexpr uint8_t POTI_COUNT { 4 }; - static constexpr uint8_t PAGE_COUNT { 4 }; - static constexpr uint8_t PAGE_SIZE { 2*POTI_COUNT }; - static constexpr uint8_t PAGE_MASK { 0b00000111 }; - - static constexpr uint8_t MEM_SIZE { PAGE_COUNT*PAGE_SIZE }; + static constexpr uint8_t MEM_SIZE{PAGE_COUNT * PAGE_SIZE}; uint8_t memory[MEM_SIZE]; // Page1 : conversion results: 16 bit for Channel A, B, C & D, power on default: 0x00 @@ -27,13 +26,14 @@ class DS2450 : public OneWireItem void correctMemory(void); public: - static constexpr uint8_t family_code { 0x20 }; + static constexpr uint8_t family_code{0x20}; - DS2450(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2450(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); + void clearMemory(void); bool setPotentiometer(uint16_t p1, uint16_t p2, uint16_t p3, uint16_t p4); bool setPotentiometer(uint8_t channel, uint16_t value); diff --git a/src/DS2502.cpp b/src/DS2502.cpp index 4690a8f..b16f0a1 100644 --- a/src/DS2502.cpp +++ b/src/DS2502.cpp @@ -1,6 +1,8 @@ #include "DS2502.h" -DS2502::DS2502(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) +DS2502::DS2502(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) { static_assert(MEM_SIZE < 256, "Implementation does not cover the whole address-space"); @@ -19,45 +21,45 @@ DS2502::DS2502(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, } else { - sizeof_memory = 128; // must be DS2502 then + sizeof_memory = 128; // must be DS2502 then } } -void DS2502::duty(OneWireHub * const hub) +void DS2502::duty(OneWireHub *const hub) { - uint8_t reg_TA[2], cmd, data, crc = 0; // Target address, redirected address, command, data, crc + uint8_t reg_TA[2], cmd, data, crc = 0; // Target address, redirected address, command, data, crc - if (hub->recv(&cmd)) return; - crc = crc8(&cmd,1,crc); + if (hub->recv(&cmd)) return; + crc = crc8(&cmd, 1, crc); - if (hub->recv(reg_TA,2)) return; - crc = crc8(reg_TA,2,crc); + if (hub->recv(reg_TA, 2)) return; + crc = crc8(reg_TA, 2, crc); if (reg_TA[1] != 0) return; // upper byte of target address should not contain any data switch (cmd) { - case 0xF0: // READ MEMORY + case 0xF0: // READ MEMORY - if (hub->send(&crc)) break; + if (hub->send(&crc)) break; crc = 0; // reInit CRC and send data for (uint8_t i = reg_TA[0]; i < sizeof_memory; ++i) { const uint8_t reg_RA = translateRedirection(i); if (hub->send(&memory[reg_RA])) return; - crc = crc8(&memory[reg_RA],1,crc); + crc = crc8(&memory[reg_RA], 1, crc); } hub->send(&crc); break; // datasheet says we should return all 1s, send(255), till reset, nothing to do here, 1s are passive - case 0xC3: // READ DATA (like 0xF0, but repeatedly till the end of page with following CRC) + case 0xC3: // READ DATA (like 0xF0, but repeatedly till the end of page with following CRC) if (hub->send(&crc)) break; while (reg_TA[0] < sizeof_memory) { - crc = 0; // reInit CRC and send data + crc = 0; // reInit CRC and send data const uint8_t reg_EA = (reg_TA[0] & ~PAGE_MASK) + PAGE_SIZE; // End Address for (uint8_t i = reg_TA[0]; i < reg_EA; ++i) { @@ -71,7 +73,7 @@ void DS2502::duty(OneWireHub * const hub) } break; // datasheet says we should return all 1s, send(255), till reset, nothing to do here, 1s are passive - case 0xAA: // READ STATUS // TODO: nearly same code as 0xF0, but with status[] instead of memory[] + case 0xAA: // READ STATUS // TODO: nearly same code as 0xF0, but with status[] instead of memory[] if (hub->send(&crc)) break; @@ -79,22 +81,22 @@ void DS2502::duty(OneWireHub * const hub) for (uint8_t i = reg_TA[0]; i < STATUS_SIZE; ++i) { if (hub->send(&status[i])) return; - crc = crc8(&status[i],1,crc); + crc = crc8(&status[i], 1, crc); } hub->send(&crc); break; // datasheet says we should return all 1s, send(255), till reset, nothing to do here, 1s are passive - case 0x0F: // WRITE MEMORY + case 0x0F: // WRITE MEMORY while (reg_TA[0] < sizeof_memory) { - if (hub->recv(&data)) break; - crc = crc8(&data,1,crc); + if (hub->recv(&data)) break; + crc = crc8(&data, 1, crc); - if (hub->send(&crc)) break; + if (hub->send(&crc)) break; const uint8_t reg_RA = translateRedirection(reg_TA[0]); - const uint8_t page = static_cast(reg_RA>>5); + const uint8_t page = static_cast(reg_RA >> 5); if (getPageProtection(page)) { const uint8_t mem_zero = 0x00; // send dummy data @@ -110,14 +112,14 @@ void DS2502::duty(OneWireHub * const hub) } break; - case 0x55: // WRITE STATUS + case 0x55: // WRITE STATUS while (reg_TA[0] < STATUS_SIZE) { - if (hub->recv(&data)) break; - crc = crc8(&data,1,crc); + if (hub->recv(&data)) break; + crc = crc8(&data, 1, crc); - if (hub->send(&crc)) break; + if (hub->send(&crc)) break; data = writeStatus(reg_TA[0], data); @@ -127,25 +129,20 @@ void DS2502::duty(OneWireHub * const hub) } break; - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } uint8_t DS2502::translateRedirection(const uint8_t source_address) const { - const uint8_t source_page = static_cast(source_address >> 5); - const uint8_t destin_page = getPageRedirection(source_page); - if (destin_page == 0x00) return source_address; - const uint8_t destin_address = (source_address & PAGE_MASK) | (destin_page << 5); + const uint8_t source_page = static_cast(source_address >> 5); + const uint8_t destin_page = getPageRedirection(source_page); + if (destin_page == 0x00) return source_address; + const uint8_t destin_address = (source_address & PAGE_MASK) | (destin_page << 5); return destin_address; } -void DS2502::clearMemory(void) -{ - memset(memory, static_cast(0xFF), MEM_SIZE); -} +void DS2502::clearMemory(void) { memset(memory, static_cast(0xFF), MEM_SIZE); } void DS2502::clearStatus(void) { @@ -153,75 +150,81 @@ void DS2502::clearStatus(void) status[STATUS_FACTORYP] = 0x00; // last byte should be always zero } -bool DS2502::writeMemory(const uint8_t* const source, const uint8_t length, const uint8_t position) +bool DS2502::writeMemory(const uint8_t *const source, const uint8_t length, const uint8_t position) { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(&memory[position],source,_length); + memcpy(&memory[position], source, _length); const uint8_t page_start = static_cast(position >> 5); const uint8_t page_stop = static_cast((position + _length) >> 5); for (uint8_t page = page_start; page <= page_stop; page++) setPageUsed(page); - return (_length==length); + return (_length == length); } -bool DS2502::readMemory(uint8_t* const destination, const uint8_t length, const uint8_t position) const +bool DS2502::readMemory(uint8_t *const destination, const uint8_t length, + const uint8_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } uint8_t DS2502::writeStatus(const uint8_t address, const uint8_t value) { - if (address < STATUS_UNDEF_B1) status[address] &= value; // writing is allowed only here + if (address < STATUS_UNDEF_B1) status[address] &= value; // writing is allowed only here return status[address]; } uint8_t DS2502::readStatus(const uint8_t address) const { - if (address >= STATUS_SIZE) return 0xFF; + if (address >= STATUS_SIZE) return 0xFF; return status[address]; } void DS2502::setPageProtection(const uint8_t page) { - if (page < PAGE_COUNT) status[STATUS_WP_PAGES] &= ~(uint8_t(1<= PAGE_COUNT) return true; - return ((status[STATUS_WP_PAGES] & uint8_t(1<= PAGE_COUNT) return true; - return ((status[STATUS_WP_PAGES] & uint8_t(1<<(page+4))) == 0); + return ((status[STATUS_WP_PAGES] & uint8_t(1 << (page + 4))) == 0); } bool DS2502::setPageRedirection(const uint8_t page_source, const uint8_t page_destin) { - if (page_source >= PAGE_COUNT) return false; // really available - if (page_destin >= PAGE_COUNT) return false; // virtual mem of the device + if (page_source >= PAGE_COUNT) return false; // really available + if (page_destin >= PAGE_COUNT) return false; // virtual mem of the device - status[page_source + STATUS_PG_REDIR] = (page_destin == page_source) ? uint8_t(0xFF) : ~page_destin; // datasheet dictates this, so no page can be redirected to page 0 + status[page_source + STATUS_PG_REDIR] = + (page_destin == page_source) + ? uint8_t(0xFF) + : ~page_destin; // datasheet dictates this, so no page can be redirected to page 0 return true; } uint8_t DS2502::getPageRedirection(const uint8_t page) const { if (page >= PAGE_COUNT) return 0x00; - return ~(status[page + STATUS_PG_REDIR]); // TODO: maybe invert this in ReadStatus and safe some Operations? Redirection is critical and often done + return ~( + status[page + + STATUS_PG_REDIR]); // TODO: maybe invert this in ReadStatus and safe some Operations? Redirection is critical and often done } diff --git a/src/DS2502.h b/src/DS2502.h index c1ce5bd..49fc1e7 100644 --- a/src/DS2502.h +++ b/src/DS2502.h @@ -10,49 +10,49 @@ class DS2502 : public OneWireItem { private: + static constexpr uint8_t PAGE_COUNT{4}; + static constexpr uint8_t PAGE_SIZE{32}; // bytes + static constexpr uint8_t PAGE_MASK{PAGE_SIZE - 1}; - static constexpr uint8_t PAGE_COUNT { 4 }; - static constexpr uint8_t PAGE_SIZE { 32 }; // bytes - static constexpr uint8_t PAGE_MASK { PAGE_SIZE - 1 }; + static constexpr uint8_t MEM_SIZE{PAGE_COUNT * PAGE_SIZE}; // bytes + static constexpr uint16_t MEM_MASK{MEM_SIZE - 1}; - static constexpr uint8_t MEM_SIZE { PAGE_COUNT * PAGE_SIZE }; // bytes - static constexpr uint16_t MEM_MASK { MEM_SIZE - 1 }; + static constexpr uint8_t STATUS_SIZE{8}; - static constexpr uint8_t STATUS_SIZE { 8 }; + static constexpr uint8_t STATUS_WP_PAGES{ + 0x00}; // 1 byte -> Page write protection and page used status + static constexpr uint8_t STATUS_PG_REDIR{0x01}; // 4 byte -> Page redirection + static constexpr uint8_t STATUS_UNDEF_B1{0x05}; // 2 byte -> reserved / undefined + static constexpr uint8_t STATUS_FACTORYP{0x07}; // 2 byte -> factoryprogrammed 0x00 - static constexpr uint8_t STATUS_WP_PAGES { 0x00 }; // 1 byte -> Page write protection and page used status - static constexpr uint8_t STATUS_PG_REDIR { 0x01 }; // 4 byte -> Page redirection - static constexpr uint8_t STATUS_UNDEF_B1 { 0x05 }; // 2 byte -> reserved / undefined - static constexpr uint8_t STATUS_FACTORYP { 0x07 }; // 2 byte -> factoryprogrammed 0x00 + uint8_t memory[MEM_SIZE]; // 4 pages of 32 bytes + uint8_t status[STATUS_SIZE]; // eprom status bytes: + uint8_t sizeof_memory; // device specific "real" size - uint8_t memory[MEM_SIZE]; // 4 pages of 32 bytes - uint8_t status[STATUS_SIZE]; // eprom status bytes: - uint8_t sizeof_memory; // device specific "real" size - - uint8_t translateRedirection(uint8_t source_address) const; + uint8_t translateRedirection(uint8_t source_address) const; public: - static constexpr uint8_t family_code = 0x09; // the ds2502 - DS2502(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2502(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); - void clearStatus(void); + void clearMemory(void); + void clearStatus(void); - bool writeMemory(const uint8_t* source, uint8_t length, uint8_t position = 0); - bool readMemory(uint8_t * destination, uint8_t length, uint8_t position = 0) const; + bool writeMemory(const uint8_t *source, uint8_t length, uint8_t position = 0); + bool readMemory(uint8_t *destination, uint8_t length, uint8_t position = 0) const; uint8_t writeStatus(uint8_t address, uint8_t value); uint8_t readStatus(uint8_t address) const; - void setPageProtection(uint8_t page); - bool getPageProtection(uint8_t page) const; + void setPageProtection(uint8_t page); + bool getPageProtection(uint8_t page) const; - void setPageUsed(uint8_t page); - bool getPageUsed(uint8_t page) const; + void setPageUsed(uint8_t page); + bool getPageUsed(uint8_t page) const; bool setPageRedirection(uint8_t page_source, uint8_t page_destin); uint8_t getPageRedirection(uint8_t page) const; diff --git a/src/DS2506.cpp b/src/DS2506.cpp index 8e73257..5e3d746 100644 --- a/src/DS2506.cpp +++ b/src/DS2506.cpp @@ -1,47 +1,49 @@ #include "DS2506.h" -DS2506::DS2506(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) +DS2506::DS2506(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) { - static_assert(sizeof(memory) <= 0xFFFF, "Implementation does not cover the whole address-space"); + static_assert(sizeof(memory) <= 0xFFFF, + "Implementation does not cover the whole address-space"); // set device specific "real" sizes switch (ID1) { - case 0x13: // DS2503 + case 0x13: // DS2503 sizeof_memory = 512; break; - case 0x0B: // DS2505 + case 0x0B: // DS2505 sizeof_memory = 2048; break; - case 0x0F: // DS2506 + case 0x0F: // DS2506 sizeof_memory = 8192; break; - default: - sizeof_memory = 256; + default: sizeof_memory = 256; } - page_count = sizeof_memory / PAGE_SIZE; // DS2506: 256 - status_segment = page_count / uint8_t(8); // DS2506: 32 + page_count = sizeof_memory / PAGE_SIZE; // DS2506: 256 + status_segment = page_count / uint8_t(8); // DS2506: 32 clearMemory(); clearStatus(); } -void DS2506::duty(OneWireHub * const hub) +void DS2506::duty(OneWireHub *const hub) { uint16_t reg_TA, reg_RA = 0, crc = 0; // Target address - uint8_t cmd, data; // redirected address, command, data, crc + uint8_t cmd, data; // redirected address, command, data, crc // always receives cmd and TA - if (hub->recv(&cmd,1,crc)) return; - if (hub->recv(reinterpret_cast(®_TA),2,crc)) return; + if (hub->recv(&cmd, 1, crc)) return; + if (hub->recv(reinterpret_cast(®_TA), 2, crc)) return; switch (cmd) { - case 0xF0: // READ MEMORY + case 0xF0: // READ MEMORY while (reg_TA <= sizeof_memory) { @@ -50,11 +52,11 @@ void DS2506::duty(OneWireHub * const hub) if (destin_TA < MEM_SIZE) { - if (hub->send(&memory[destin_TA],length,crc)) return; + if (hub->send(&memory[destin_TA], length, crc)) return; } else // fake data { - data = 0x00; + data = 0x00; uint8_t counter = length; while (counter-- > 0) { @@ -65,29 +67,31 @@ void DS2506::duty(OneWireHub * const hub) reg_TA += length; } crc = ~crc; // normally crc16 is sent ~inverted - hub->send(reinterpret_cast(&crc),2); + hub->send(reinterpret_cast(&crc), 2); break; // datasheet says we should return 1s, till reset, nothing to do here - case 0xA5: // EXTENDED READ MEMORY (with redirection-information) + case 0xA5: // EXTENDED READ MEMORY (with redirection-information) while (reg_TA <= sizeof_memory) { - const uint8_t source_page = static_cast(reg_TA>>5); - const uint8_t destin_page = getPageRedirection(source_page); - if (hub->send(&destin_page,1,crc)) return; + const uint8_t source_page = static_cast(reg_TA >> 5); + const uint8_t destin_page = getPageRedirection(source_page); + if (hub->send(&destin_page, 1, crc)) return; crc = ~crc; // normally crc16 is sent ~inverted - hub->send(reinterpret_cast(&crc),2); // send crc of (cmd,TA,destin_page) at first, then only crc of (destin_page) - crc=0; - const uint16_t destin_TA = translateRedirection(reg_TA); - const uint8_t length = PAGE_SIZE - uint8_t(reg_TA & PAGE_MASK); + hub->send( + reinterpret_cast(&crc), + 2); // send crc of (cmd,TA,destin_page) at first, then only crc of (destin_page) + crc = 0; + const uint16_t destin_TA = translateRedirection(reg_TA); + const uint8_t length = PAGE_SIZE - uint8_t(reg_TA & PAGE_MASK); if (destin_TA < MEM_SIZE) { - if (hub->send(&memory[destin_TA],length,crc)) return; + if (hub->send(&memory[destin_TA], length, crc)) return; } else // fake data { - data = 0x00; + data = 0x00; uint8_t counter = length; while (counter-- != 0) { @@ -96,17 +100,17 @@ void DS2506::duty(OneWireHub * const hub) } crc = ~crc; // normally crc16 is sent ~inverted - if (hub->send(reinterpret_cast(&crc),2)) break; + if (hub->send(reinterpret_cast(&crc), 2)) break; reg_TA += length; - crc=0; + crc = 0; } break; // datasheet says we should return 1s, till reset, nothing to do here - case 0xAA: // READ STATUS + case 0xAA: // READ STATUS while (reg_TA < STATUS_SIZE_DEV) // check for valid address { - reg_RA = reg_TA&uint8_t(7); + reg_RA = reg_TA & uint8_t(7); while (reg_RA < 8) { data = readStatus(reg_TA); // read byte by byte @@ -115,23 +119,23 @@ void DS2506::duty(OneWireHub * const hub) reg_TA++; } crc = ~crc; // normally crc16 is sent ~inverted - hub->send(reinterpret_cast(&crc),2); + hub->send(reinterpret_cast(&crc), 2); crc = 0; } break; - case 0x0F: // WRITE MEMORY + case 0x0F: // WRITE MEMORY while (reg_TA < sizeof_memory) // check for valid address { - if (hub->recv(&data,1,crc)) break; + if (hub->recv(&data, 1, crc)) break; crc = ~crc; // normally crc16 is sent ~inverted if (hub->send(reinterpret_cast(&crc), 2)) break; // master issues now a 480us 12V-Programming Pulse -> advantage for us, enough time to handle addressMapping - reg_RA = translateRedirection(reg_TA); - const uint8_t page = static_cast(reg_RA>>5); + reg_RA = translateRedirection(reg_TA); + const uint8_t page = static_cast(reg_RA >> 5); if (getPageProtection(page)) { const uint8_t mem_zero = 0x00; @@ -147,15 +151,15 @@ void DS2506::duty(OneWireHub * const hub) } break; - case 0xF3: // SPEED WRITE MEMORY, omit CRC + case 0xF3: // SPEED WRITE MEMORY, omit CRC while (reg_TA < sizeof_memory) // check for valid address { if (hub->recv(&data)) break; // master issues now a 480us 12V-Programming Pulse - reg_RA = translateRedirection(reg_TA); - const uint8_t page = static_cast(reg_RA>>5); + reg_RA = translateRedirection(reg_TA); + const uint8_t page = static_cast(reg_RA >> 5); if (getPageProtection(page)) { const uint8_t mem_zero = 0x00; @@ -171,11 +175,11 @@ void DS2506::duty(OneWireHub * const hub) } break; - case 0x55: // WRITE STATUS + case 0x55: // WRITE STATUS while (reg_TA < STATUS_SIZE_DEV) // check for valid address { - if (hub->recv(&data,1,crc)) break; + if (hub->recv(&data, 1, crc)) break; crc = ~crc; // normally crc16 is sent ~inverted if (hub->send(reinterpret_cast(&crc), 2)) break; @@ -187,11 +191,11 @@ void DS2506::duty(OneWireHub * const hub) } break; - case 0xF5: // SPEED WRITE STATUS, omit CRC + case 0xF5: // SPEED WRITE STATUS, omit CRC while (reg_TA < STATUS_SIZE_DEV) // check for valid address { - if (hub->recv(&data,1,crc)) break; + if (hub->recv(&data, 1, crc)) break; // master issues now a 480us 12V-Programming Pulse data = writeStatus(reg_TA, data); @@ -200,48 +204,43 @@ void DS2506::duty(OneWireHub * const hub) } break; - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } } -void DS2506::clearMemory(void) -{ - memset(memory, value_xFF, MEM_SIZE); -} +void DS2506::clearMemory(void) { memset(memory, value_xFF, MEM_SIZE); } -void DS2506::clearStatus(void) -{ - memset(status, value_xFF, STATUS_SIZE); -} +void DS2506::clearStatus(void) { memset(status, value_xFF, STATUS_SIZE); } -bool DS2506::writeMemory(const uint8_t* const source, const uint16_t length, const uint16_t position) +bool DS2506::writeMemory(const uint8_t *const source, const uint16_t length, + const uint16_t position) { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(&memory[position],source,_length); + memcpy(&memory[position], source, _length); const uint8_t page_start = static_cast(position >> 5); const uint8_t page_stop = static_cast((position + _length) >> 5); for (uint8_t page = page_start; page <= page_stop; page++) setPageUsed(page); - return (_length==length); + return (_length == length); } -bool DS2506::readMemory(uint8_t* const destination, const uint16_t length, const uint16_t position) const +bool DS2506::readMemory(uint8_t *const destination, const uint16_t length, + const uint16_t position) const { if (position >= MEM_SIZE) return false; const uint16_t _length = (position + length >= MEM_SIZE) ? (MEM_SIZE - position) : length; - memcpy(destination,&memory[position],_length); - return (_length==length); + memcpy(destination, &memory[position], _length); + return (_length == length); } -uint16_t DS2506::translateRedirection(const uint16_t source_address) const// TODO: extended read mem description implies that redirection is recursive +uint16_t DS2506::translateRedirection(const uint16_t source_address) + const // TODO: extended read mem description implies that redirection is recursive { - const uint8_t source_page = static_cast(source_address >> 5); - const uint8_t destin_page = getPageRedirection(source_page); - if (destin_page == 0x00) return source_address; + const uint8_t source_page = static_cast(source_address >> 5); + const uint8_t destin_page = getPageRedirection(source_page); + if (destin_page == 0x00) return source_address; const uint16_t destin_address = (source_address & PAGE_MASK) | (destin_page << 5); return destin_address; } @@ -250,33 +249,35 @@ uint16_t DS2506::translateRedirection(const uint16_t source_address) const// TOD uint8_t DS2506::readStatus(const uint16_t address) const { uint16_t SA = address; - uint8_t return_value { 0x00 }; + uint8_t return_value{0x00}; - if (address < STATUS_WP_REDIR_BEG) // is WP_PAGES + if (address < STATUS_WP_REDIR_BEG) // is WP_PAGES { - if (SA < STATUS_SEGMENT) return_value = status[SA+0*STATUS_SEGMENT]; // emulate protection + if (SA < STATUS_SEGMENT) + return_value = status[SA + 0 * STATUS_SEGMENT]; // emulate protection } - else if (address < STATUS_PG_WRITN_BEG) // is WP_REDIR + else if (address < STATUS_PG_WRITN_BEG) // is WP_REDIR { SA -= STATUS_WP_REDIR_BEG; - if (SA < STATUS_SEGMENT) return_value = status[SA+1*STATUS_SEGMENT]; // emulate protection + if (SA < STATUS_SEGMENT) + return_value = status[SA + 1 * STATUS_SEGMENT]; // emulate protection } - else if (address < STATUS_UNDEF_B1_BEG) // is PG_WRITTEN + else if (address < STATUS_UNDEF_B1_BEG) // is PG_WRITTEN { SA -= STATUS_PG_WRITN_BEG; - if (SA < STATUS_SEGMENT) return_value = status[SA+2*STATUS_SEGMENT]; // emulate written + if (SA < STATUS_SEGMENT) return_value = status[SA + 2 * STATUS_SEGMENT]; // emulate written } - else if (address < STATUS_PG_REDIR_BEG) // is undefined + else if (address < STATUS_PG_REDIR_BEG) // is undefined { - return_value = 0xFF; // emulate undefined read + return_value = 0xFF; // emulate undefined read } - else if (address < STATUS_UNDEF_B2_BEG) // is PG_REDIRECTION + else if (address < STATUS_UNDEF_B2_BEG) // is PG_REDIRECTION { SA -= STATUS_PG_REDIR_BEG; - if (SA < PAGE_COUNT) return_value = status[SA+3*STATUS_SEGMENT]; - else return_value = 0xFF; // emulate no redirection + if (SA < PAGE_COUNT) return_value = status[SA + 3 * STATUS_SEGMENT]; + else return_value = 0xFF; // emulate no redirection } - else return_value = 0xFF; // is undefined + else return_value = 0xFF; // is undefined return return_value; } @@ -285,34 +286,34 @@ uint8_t DS2506::writeStatus(const uint16_t address, const uint8_t value) { uint16_t SA = address; - if (address < STATUS_WP_REDIR_BEG) // is WP_PAGES + if (address < STATUS_WP_REDIR_BEG) // is WP_PAGES { - if (SA >= STATUS_SEGMENT) return 0x00; // emulate protection + if (SA >= STATUS_SEGMENT) return 0x00; // emulate protection } - else if (address < STATUS_PG_WRITN_BEG) // is WP_REDIR + else if (address < STATUS_PG_WRITN_BEG) // is WP_REDIR { SA -= STATUS_WP_REDIR_BEG; - if (SA >= STATUS_SEGMENT) return 0x00; // emulate protection + if (SA >= STATUS_SEGMENT) return 0x00; // emulate protection SA += STATUS_SEGMENT; } - else if (address < STATUS_UNDEF_B1_BEG) // is PG_WRITTEN + else if (address < STATUS_UNDEF_B1_BEG) // is PG_WRITTEN { SA -= STATUS_PG_WRITN_BEG; - if (SA >= STATUS_SEGMENT) return 0x00; // emulate written - SA += 2*STATUS_SEGMENT; + if (SA >= STATUS_SEGMENT) return 0x00; // emulate written + SA += 2 * STATUS_SEGMENT; } - else if (address < STATUS_PG_REDIR_BEG) // is undefined + else if (address < STATUS_PG_REDIR_BEG) // is undefined { - return 0xFF; // emulate undefined read + return 0xFF; // emulate undefined read } - else if (address < STATUS_UNDEF_B2_BEG) // is PG_REDIRECTION + else if (address < STATUS_UNDEF_B2_BEG) // is PG_REDIRECTION { SA -= STATUS_PG_REDIR_BEG; - if (SA >= PAGE_COUNT) return 0xFF; // emulate no redirection + if (SA >= PAGE_COUNT) return 0xFF; // emulate no redirection if (getRedirectionProtection(static_cast(SA))) return 0x00; - SA += 3*STATUS_SEGMENT; + SA += 3 * STATUS_SEGMENT; } - else return 0xFF; // is undefined + else return 0xFF; // is undefined status[SA] &= value; return status[SA]; @@ -320,64 +321,68 @@ uint8_t DS2506::writeStatus(const uint16_t address, const uint8_t value) void DS2506::setPageProtection(const uint8_t page) { - const uint8_t segment_pos = (page>>3); + const uint8_t segment_pos = (page >> 3); if (segment_pos >= STATUS_SEGMENT) return; - const uint8_t page_mask = ~(uint8_t(1)<<(page&7)); + const uint8_t page_mask = ~(uint8_t(1) << (page & 7)); status[segment_pos] &= page_mask; } bool DS2506::getPageProtection(const uint8_t page) const { - const uint8_t segment_pos = (page>>3); + const uint8_t segment_pos = (page >> 3); if (segment_pos >= STATUS_SEGMENT) return true; - const uint8_t page_mask = (uint8_t(1)<<(page&7)); + const uint8_t page_mask = (uint8_t(1) << (page & 7)); return ((status[segment_pos] & page_mask) == 0); } void DS2506::setRedirectionProtection(const uint8_t page) { - const uint8_t segment_pos = (page>>3); + const uint8_t segment_pos = (page >> 3); if (segment_pos >= STATUS_SEGMENT) return; - const uint8_t page_mask = ~(uint8_t(1)<<(page&7)); + const uint8_t page_mask = ~(uint8_t(1) << (page & 7)); status[STATUS_SEGMENT + segment_pos] &= page_mask; } bool DS2506::getRedirectionProtection(const uint8_t page) const { - const uint8_t segment_pos = (page>>3); + const uint8_t segment_pos = (page >> 3); if (segment_pos >= STATUS_SEGMENT) return true; - const uint8_t page_mask = (uint8_t(1)<<(page&7)); + const uint8_t page_mask = (uint8_t(1) << (page & 7)); return ((status[STATUS_SEGMENT + segment_pos] & page_mask) == 0); } void DS2506::setPageUsed(const uint8_t page) { - const uint8_t segment_pos = (page>>3); + const uint8_t segment_pos = (page >> 3); if (segment_pos >= STATUS_SEGMENT) return; - const uint8_t page_mask = ~(uint8_t(1)<<(page&7)); - status[2*STATUS_SEGMENT + segment_pos] &= page_mask; + const uint8_t page_mask = ~(uint8_t(1) << (page & 7)); + status[2 * STATUS_SEGMENT + segment_pos] &= page_mask; } bool DS2506::getPageUsed(const uint8_t page) const { - const uint8_t segment_pos = (page>>3); + const uint8_t segment_pos = (page >> 3); if (segment_pos >= STATUS_SEGMENT) return true; - const uint8_t page_mask = (uint8_t(1)<<(page&7)); - return ((status[2*STATUS_SEGMENT + segment_pos] & page_mask) == 0); + const uint8_t page_mask = (uint8_t(1) << (page & 7)); + return ((status[2 * STATUS_SEGMENT + segment_pos] & page_mask) == 0); } bool DS2506::setPageRedirection(const uint8_t page_source, const uint8_t page_destin) { - if (page_source >= PAGE_COUNT) return false; // really available - if (page_destin >= page_count) return false; // virtual mem of the device + if (page_source >= PAGE_COUNT) return false; // really available + if (page_destin >= page_count) return false; // virtual mem of the device if (getRedirectionProtection(page_source)) return false; - status[3*STATUS_SEGMENT + page_source] = (page_destin == page_source) ? uint8_t(0xFF) : ~page_destin; // datasheet dictates this, so no page can be redirected to page 0 + status[3 * STATUS_SEGMENT + page_source] = + (page_destin == page_source) + ? uint8_t(0xFF) + : ~page_destin; // datasheet dictates this, so no page can be redirected to page 0 return true; } uint8_t DS2506::getPageRedirection(const uint8_t page) const { if (page >= PAGE_COUNT) return 0x00; - return (~status[3*STATUS_SEGMENT + page]); // TODO: maybe invert this in ReadStatus and safe some Operations? Redirection is critical and often done + return (~status[3 * STATUS_SEGMENT + + page]); // TODO: maybe invert this in ReadStatus and safe some Operations? Redirection is critical and often done } diff --git a/src/DS2506.h b/src/DS2506.h index b0722b2..cdb1864 100644 --- a/src/DS2506.h +++ b/src/DS2506.h @@ -8,70 +8,74 @@ #include "OneWireItem.h" -constexpr uint8_t value_xFF { static_cast(0xFF) }; +constexpr uint8_t value_xFF{static_cast(0xFF)}; class DS2506 : public OneWireItem { private: - // Problem: atmega has 2kb RAM, this IC offers 8kb // Solution: out-of-bound-memory will be constant 0xFF, same for the depending status-registers - static constexpr uint16_t MEM_SIZE_PROPOSE { 256 }; // TUNE HERE! Give this device as much RAM as your CPU can spare + static constexpr uint16_t MEM_SIZE_PROPOSE{ + 256}; // TUNE HERE! Give this device as much RAM as your CPU can spare - static constexpr uint8_t PAGE_SIZE { 32 }; - static constexpr uint16_t PAGE_COUNT { MEM_SIZE_PROPOSE / PAGE_SIZE }; // ATM: 8 - static constexpr uint8_t PAGE_MASK { 0b00011111 }; + static constexpr uint8_t PAGE_SIZE{32}; + static constexpr uint16_t PAGE_COUNT{MEM_SIZE_PROPOSE / PAGE_SIZE}; // ATM: 8 + static constexpr uint8_t PAGE_MASK{0b00011111}; - static constexpr uint16_t MEM_SIZE { PAGE_COUNT * PAGE_SIZE }; - static constexpr uint16_t MEM_MASK { MEM_SIZE - 1 }; + static constexpr uint16_t MEM_SIZE{PAGE_COUNT * PAGE_SIZE}; + static constexpr uint16_t MEM_MASK{MEM_SIZE - 1}; - static constexpr uint8_t STATUS_SEGMENT { PAGE_COUNT / 8 }; // ATM: 1 - static constexpr uint16_t STATUS_SIZE { PAGE_COUNT + (3*STATUS_SEGMENT) }; - static constexpr uint16_t STATUS_SIZE_DEV { 0x200 }; // device specific "real" size + static constexpr uint8_t STATUS_SEGMENT{PAGE_COUNT / 8}; // ATM: 1 + static constexpr uint16_t STATUS_SIZE{PAGE_COUNT + (3 * STATUS_SEGMENT)}; + static constexpr uint16_t STATUS_SIZE_DEV{0x200}; // device specific "real" size - static constexpr uint8_t STATUS_WP_PAGES_BEG { 0x00 }; // 32 bytes -> Page write protection - static constexpr uint8_t STATUS_WP_REDIR_BEG { 0x20 }; // 32 bytes -> Redirection write protection - static constexpr uint8_t STATUS_PG_WRITN_BEG { 0x40 }; // 32 bytes -> Page used status (written ones) - static constexpr uint8_t STATUS_UNDEF_B1_BEG { 0x60 }; - static constexpr uint16_t STATUS_PG_REDIR_BEG { 0x100 }; // 256 bytes -> Redirection to page, 0xFF if valid, ones complement (xFD is page 2) - static constexpr uint16_t STATUS_UNDEF_B2_BEG { 0x200 }; + static constexpr uint8_t STATUS_WP_PAGES_BEG{0x00}; // 32 bytes -> Page write protection + static constexpr uint8_t STATUS_WP_REDIR_BEG{0x20}; // 32 bytes -> Redirection write protection + static constexpr uint8_t STATUS_PG_WRITN_BEG{ + 0x40}; // 32 bytes -> Page used status (written ones) + static constexpr uint8_t STATUS_UNDEF_B1_BEG{0x60}; + static constexpr uint16_t STATUS_PG_REDIR_BEG{ + 0x100}; // 256 bytes -> Redirection to page, 0xFF if valid, ones complement (xFD is page 2) + static constexpr uint16_t STATUS_UNDEF_B2_BEG{0x200}; - static_assert(MEM_SIZE > 255, "REAL MEM SIZE IS TOO SMALL"); - static_assert(STATUS_SEGMENT > 0, "REAL MEM SIZE IS TOO SMALL"); - static_assert(MEM_SIZE <= 8192, "REAL MEM SIZE IS TOO BIG, MAX IS 8291 bytes"); + static_assert(MEM_SIZE > 255, "REAL MEM SIZE IS TOO SMALL"); + static_assert(STATUS_SEGMENT > 0, "REAL MEM SIZE IS TOO SMALL"); + static_assert(MEM_SIZE <= 8192, "REAL MEM SIZE IS TOO BIG, MAX IS 8291 bytes"); - uint8_t memory[MEM_SIZE]; // at least 4 pages of 32 bytes - uint8_t status[STATUS_SIZE]; // eprom status bytes + uint8_t memory[MEM_SIZE]; // at least 4 pages of 32 bytes + uint8_t status[STATUS_SIZE]; // eprom status bytes - uint16_t sizeof_memory; // device specific "real" size - uint16_t page_count, status_segment; // device specific "real" size + uint16_t sizeof_memory; // device specific "real" size + uint16_t page_count, status_segment; // device specific "real" size - uint16_t translateRedirection(uint16_t source_address) const; // react to redirection in status and not available memory + uint16_t translateRedirection(uint16_t source_address) + const; // react to redirection in status and not available memory public: - static constexpr uint8_t family_code { 0x0F }; // the ds2506 + static constexpr uint8_t family_code{0x0F}; // the ds2506 - DS2506(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2506(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void clearMemory(void); - void clearStatus(void); + void clearMemory(void); + void clearStatus(void); - bool writeMemory(const uint8_t* source, uint16_t length, uint16_t position = 0); - bool readMemory(uint8_t* destination, uint16_t length, uint16_t position = 0) const; + bool writeMemory(const uint8_t *source, uint16_t length, uint16_t position = 0); + bool readMemory(uint8_t *destination, uint16_t length, uint16_t position = 0) const; uint8_t writeStatus(uint16_t address, uint8_t value); uint8_t readStatus(uint16_t address) const; - void setPageProtection(uint8_t page); - bool getPageProtection(uint8_t page) const; + void setPageProtection(uint8_t page); + bool getPageProtection(uint8_t page) const; - void setRedirectionProtection(uint8_t page); - bool getRedirectionProtection(uint8_t page) const; + void setRedirectionProtection(uint8_t page); + bool getRedirectionProtection(uint8_t page) const; - void setPageUsed(uint8_t page); - bool getPageUsed(uint8_t page) const; + void setPageUsed(uint8_t page); + bool getPageUsed(uint8_t page) const; bool setPageRedirection(uint8_t page_source, uint8_t page_destin); uint8_t getPageRedirection(uint8_t page) const; diff --git a/src/DS2890.cpp b/src/DS2890.cpp index 8fe876f..bbafd08 100644 --- a/src/DS2890.cpp +++ b/src/DS2890.cpp @@ -1,83 +1,87 @@ #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) +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) { - register_feat = REG_MASK_POTI_CHAR | REG_MASK_WIPER_SET | REG_MASK_POTI_NUMB | REG_MASK_WIPER_POS | REG_MASK_POTI_RESI; + register_feat = REG_MASK_POTI_CHAR | REG_MASK_WIPER_SET | REG_MASK_POTI_NUMB | + REG_MASK_WIPER_POS | REG_MASK_POTI_RESI; memset(register_poti, uint8_t(0), 4); - register_ctrl = 0b00001100; + register_ctrl = 0b00001100; } -void DS2890::duty(OneWireHub * const hub) +void DS2890::duty(OneWireHub *const hub) { - const uint8_t poti = register_ctrl&POTI_MASK; - uint8_t data, cmd; + const uint8_t poti = register_ctrl & POTI_MASK; + uint8_t data, cmd; - start_over: +start_over: - if (hub->recv(&cmd)) return; + if (hub->recv(&cmd)) return; switch (cmd) { - case 0x0F: // WRITE POSITION + case 0x0F: // WRITE POSITION - if (hub->recv(&data)) break; - if (hub->send(&data)) break; - if (hub->recv(&cmd)) break; + if (hub->recv(&data)) break; + if (hub->send(&data)) break; + if (hub->recv(&cmd)) break; if (cmd == RELEASE_CODE) register_poti[poti] = data; break; // respond with 1s ... passive - case 0x55: // WRITE CONTROL REGISTER + case 0x55: // WRITE CONTROL REGISTER - if (hub->recv(&data)) break; - if (hub->send(&data)) break; - if (hub->recv(&cmd)) break; + if (hub->recv(&data)) break; + if (hub->send(&data)) break; + if (hub->recv(&cmd)) break; if (cmd == RELEASE_CODE) { - if ((data&0x01) != 0) data &= ~0x04; - else data |= 0x04; - if ((data&0x02) != 0) data &= ~0x08; - else data |= 0x08; + if ((data & 0x01) != 0) data &= ~0x04; + else data |= 0x04; + if ((data & 0x02) != 0) data &= ~0x08; + else data |= 0x08; register_ctrl = data; } break; // respond with 1s ... passive - case 0xAA: // READ CONTROL REGISTER + case 0xAA: // READ CONTROL REGISTER - if (hub->send(®ister_feat)) break; - if (hub->send(®ister_ctrl)) break; + if (hub->send(®ister_feat)) break; + if (hub->send(®ister_ctrl)) break; noInterrupts(); - while (!hub->sendBit(false)); + while (!hub->sendBit(false)) + ; interrupts(); break; - case 0xF0: // READ POSITION + case 0xF0: // READ POSITION - if (hub->send(®ister_ctrl)) break; + if (hub->send(®ister_ctrl)) break; if (hub->send(®ister_poti[poti])) break; noInterrupts(); - while (!hub->sendBit(false)); + while (!hub->sendBit(false)) + ; interrupts(); break; - case 0xC3: // INCREMENT + case 0xC3: // INCREMENT if (register_poti[poti] < 0xFF) register_poti[poti]++; if (hub->send(®ister_poti[poti])) break; break; - case 0x99: // DECREMENT + case 0x99: // DECREMENT if (register_poti[poti] != 0) register_poti[poti]--; if (hub->send(®ister_poti[poti])) break; break; - default: - - hub->raiseSlaveError(cmd); + default: hub->raiseSlaveError(cmd); } - if ((cmd == 0xC3) || (cmd == 0x99)) goto start_over; // only for this device -> when INCREMENT or DECREMENT the master can issue another cmd right away + if ((cmd == 0xC3) || (cmd == 0x99)) + goto start_over; // only for this device -> when INCREMENT or DECREMENT the master can issue another cmd right away } diff --git a/src/DS2890.h b/src/DS2890.h index ace822c..aea01ad 100644 --- a/src/DS2890.h +++ b/src/DS2890.h @@ -10,49 +10,39 @@ class DS2890 : public OneWireItem { private: + static constexpr uint8_t POTI_SIZE{4}; // number of potis emulated + static constexpr uint8_t POTI_MASK{0b00000011}; - static constexpr uint8_t POTI_SIZE { 4 }; // number of potis emulated - static constexpr uint8_t POTI_MASK { 0b00000011 }; + static constexpr uint8_t REG_MASK_POTI_CHAR{0b00000001}; // 0: log, 1: linear + static constexpr uint8_t REG_MASK_WIPER_SET{0b00000010}; // 0: non, 1: volatile + static constexpr uint8_t REG_MASK_POTI_NUMB{0b00001100}; // 0..4 potis + static constexpr uint8_t REG_MASK_WIPER_POS{0b00110000}; // 32, 64, 128, 256 positions + static constexpr uint8_t REG_MASK_POTI_RESI{0b11000000}; // 5k, 10k, 50k, 100k Ohm Resistance - static constexpr uint8_t REG_MASK_POTI_CHAR { 0b00000001 }; // 0: log, 1: linear - static constexpr uint8_t REG_MASK_WIPER_SET { 0b00000010 }; // 0: non, 1: volatile - static constexpr uint8_t REG_MASK_POTI_NUMB { 0b00001100 }; // 0..4 potis - static constexpr uint8_t REG_MASK_WIPER_POS { 0b00110000 }; // 32, 64, 128, 256 positions - static constexpr uint8_t REG_MASK_POTI_RESI { 0b11000000 }; // 5k, 10k, 50k, 100k Ohm Resistance - - static constexpr uint8_t RELEASE_CODE { 0x96 }; + static constexpr uint8_t RELEASE_CODE{0x96}; uint8_t register_feat; uint8_t register_ctrl; uint8_t register_poti[POTI_SIZE]; public: + static constexpr uint8_t family_code{0x2C}; - static constexpr uint8_t family_code { 0x2C }; - - DS2890(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + DS2890(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); - void duty(OneWireHub * hub) final; + void duty(OneWireHub *hub) final; - void setPotentiometer(uint8_t channel, uint8_t value) + void setPotentiometer(uint8_t channel, uint8_t value) { - register_poti[channel&POTI_MASK] = value; + register_poti[channel & POTI_MASK] = value; } - uint8_t getPotentiometer(uint8_t channel) const - { - return register_poti[channel&POTI_MASK]; - } + uint8_t getPotentiometer(uint8_t channel) const { return register_poti[channel & POTI_MASK]; } - uint8_t getRegCtrl(void) const - { - return register_ctrl; - } + uint8_t getRegCtrl(void) const { return register_ctrl; } - uint8_t getRegFeat(void) const - { - return register_feat; - } + uint8_t getRegFeat(void) const { return register_feat; } }; #endif diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index e5c176e..82cd05b 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -7,22 +7,20 @@ OneWireHub::OneWireHub(const uint8_t pin) { _error = Error::NO_ERROR; - slave_count = 0; + slave_count = 0; slave_selected = nullptr; #if OVERDRIVE_ENABLE od_mode = false; #endif - for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) - { - slave_list[i] = nullptr; - } + for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) { slave_list[i] = nullptr; } // prepare pin pin_bitMask = PIN_TO_BITMASK(pin); pin_baseReg = PIN_TO_BASEREG(pin); - pinMode(pin, INPUT); // first port-access should by done by this FN, does more than DIRECT_MODE_.... + pinMode(pin, + INPUT); // first port-access should by done by this FN, does more than DIRECT_MODE_.... DIRECT_WRITE_LOW(pin_baseReg, pin_bitMask); // prepare debug: @@ -34,8 +32,12 @@ OneWireHub::OneWireHub(const uint8_t pin) DIRECT_WRITE_LOW(debug_baseReg, debug_bitMask); } - static_assert(VALUE_IPL, "Your architecture has not been calibrated yet, please run examples/debug/calibrate_by_bus_timing and report instructions per loop (IPL) to https://github.com/orgua/OneWireHub"); - static_assert(ONEWIRE_TIME_VALUE_MIN>2,"YOUR ARCHITECTURE IS TOO SLOW, THIS MAY RESULT IN TIMING-PROBLEMS"); // it could work though, never tested + static_assert(VALUE_IPL, "Your architecture has not been calibrated yet, please run " + "examples/debug/calibrate_by_bus_timing and report instructions per " + "loop (IPL) to https://github.com/orgua/OneWireHub"); + static_assert(ONEWIRE_TIME_VALUE_MIN > 2, + "YOUR ARCHITECTURE IS TOO SLOW, THIS MAY RESULT IN " + "TIMING-PROBLEMS"); // it could work though, never tested } @@ -61,19 +63,12 @@ uint8_t OneWireHub::attach(OneWireItem &sensor) for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) { // check for already attached sensors - if (slave_list[i] == &sensor) - { - return i; - } + if (slave_list[i] == &sensor) { return i; } // store position of first empty space - if ((position>ONEWIRESLAVE_LIMIT) && (slave_list[i] == nullptr)) - { - position = i; - } + if ((position > ONEWIRESLAVE_LIMIT) && (slave_list[i] == nullptr)) { position = i; } } - if (position == 255) - return 255; + if (position == 255) return 255; slave_list[position] = &sensor; slave_count++; @@ -81,7 +76,7 @@ uint8_t OneWireHub::attach(OneWireItem &sensor) return position; } -bool OneWireHub::detach(const OneWireItem &sensor) +bool OneWireHub::detach(const OneWireItem &sensor) { // find position of sensor uint8_t position = 255; @@ -94,16 +89,16 @@ bool OneWireHub::detach(const OneWireItem &sensor) } } - if (position != 255) return detach(position); + if (position != 255) return detach(position); return false; } -bool OneWireHub::detach(const uint8_t slave_number) +bool OneWireHub::detach(const uint8_t slave_number) { - if (slave_list[slave_number] == nullptr) return false; - if (slave_count == 0) return false; - if (slave_number >= ONEWIRESLAVE_LIMIT) return false; + if (slave_list[slave_number] == nullptr) return false; + if (slave_count == 0) return false; + if (slave_number >= ONEWIRESLAVE_LIMIT) return false; slave_list[slave_number] = nullptr; slave_count--; @@ -120,7 +115,7 @@ uint8_t OneWireHub::getNrOfFirstBitSet(const mask_t mask) const mask_t _mask = mask; for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) { - if ((_mask & 1) != 0) return i; + if ((_mask & 1) != 0) return i; _mask >>= 1; } return 0; @@ -131,7 +126,7 @@ uint8_t OneWireHub::getIndexOfNextSensorInList(const uint8_t index_start) const { for (uint8_t i = index_start; i < ONEWIRE_TREE_SIZE; ++i) { - if (slave_list[i] != nullptr) return i; + if (slave_list[i] != nullptr) return i; } return 0; } @@ -153,16 +148,13 @@ uint8_t OneWireHub::buildIDTree(void) mask_t bit_mask = 0x01; // build mask - for (uint8_t i = 0; i< ONEWIRESLAVE_LIMIT; ++i) + for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) { if (slave_list[i] != nullptr) mask_slaves |= bit_mask; bit_mask <<= 1; } - for (uint8_t i = 0; i< ONEWIRE_TREE_SIZE; ++i) - { - idTree[i].id_position = 255; - } + for (uint8_t i = 0; i < ONEWIRE_TREE_SIZE; ++i) { idTree[i].id_position = 255; } // begin with root-element buildIDTree(0, mask_slaves); // goto branch @@ -177,11 +169,11 @@ uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves while (position_IDBit < 64) { - mask_t mask_pos { 0 }; - mask_t mask_neg { 0 }; - const uint8_t pos_byte { static_cast(position_IDBit >> 3) }; - const uint8_t mask_bit { static_cast(1 << (position_IDBit & 7)) }; - mask_t mask_id { 1 }; + mask_t mask_pos{0}; + mask_t mask_neg{0}; + const uint8_t pos_byte{static_cast(position_IDBit >> 3)}; + const uint8_t mask_bit{static_cast(1 << (position_IDBit & 7))}; + mask_t mask_id{1}; // searchIDTree through all active slaves for (uint8_t id = 0; id < ONEWIRESLAVE_LIMIT; ++id) @@ -189,10 +181,8 @@ uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves if ((mask_slaves & mask_id) != 0) { // if slave is in mask differentiate the bitValue - if ((slave_list[id]->ID[pos_byte] & mask_bit) != 0) - mask_pos |= mask_id; - else - mask_neg |= mask_id; + if ((slave_list[id]->ID[pos_byte] & mask_bit) != 0) mask_pos |= mask_id; + else mask_neg |= mask_id; } mask_id <<= 1; } @@ -202,11 +192,11 @@ uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves // there was found a junction const uint8_t active_element = getNrOfFirstFreeIDTreeElement(); - idTree[active_element].id_position = position_IDBit; - idTree[active_element].slave_selected = getNrOfFirstBitSet(mask_slaves); + idTree[active_element].id_position = position_IDBit; + idTree[active_element].slave_selected = getNrOfFirstBitSet(mask_slaves); position_IDBit++; - idTree[active_element].got_one = buildIDTree(position_IDBit, mask_pos); - idTree[active_element].got_zero = buildIDTree(position_IDBit, mask_neg); + idTree[active_element].got_one = buildIDTree(position_IDBit, mask_pos); + idTree[active_element].got_zero = buildIDTree(position_IDBit, mask_neg); return active_element; } @@ -216,10 +206,10 @@ uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves // gone through the address, store this result uint8_t active_element = getNrOfFirstFreeIDTreeElement(); - idTree[active_element].id_position = 128; - idTree[active_element].slave_selected = getNrOfFirstBitSet(mask_slaves); - idTree[active_element].got_one = 255; - idTree[active_element].got_zero = 255; + idTree[active_element].id_position = 128; + idTree[active_element].slave_selected = getNrOfFirstBitSet(mask_slaves); + idTree[active_element].got_one = 255; + idTree[active_element].got_zero = 255; return active_element; } @@ -232,30 +222,38 @@ bool OneWireHub::poll(void) while (true) { // this additional check prevents an infinite loop when calling this FN without sensors attached - if (slave_count == 0) return true; + if (slave_count == 0) return true; // Once reset is done, go to next step - if (checkReset()) return false; + if (checkReset()) return false; // Reset is complete, tell the master we are present - if (showPresence()) return false; + if (showPresence()) return false; // Now that the master should know we are here, we will get a command from the master - if (recvAndProcessCmd()) return false; + if (recvAndProcessCmd()) return false; // on total success we want to start again, because the next reset could only be ~125 us away } } -bool OneWireHub::checkReset(void) // there is a specific high-time needed before a reset may occur --> >120us +bool OneWireHub::checkReset( + void) // there is a specific high-time needed before a reset may occur --> >120us { - static_assert(ONEWIRE_TIME_RESET_MIN[0] > (ONEWIRE_TIME_SLOT_MAX[0] + ONEWIRE_TIME_READ_MAX[0]), "Timings are wrong"); // last number should read: max(ONEWIRE_TIME_WRITE_ZERO,ONEWIRE_TIME_READ_MAX) - static_assert(ONEWIRE_TIME_READ_MAX[0] > ONEWIRE_TIME_WRITE_ZERO[0] , "switch ONEWIRE_TIME_WRITE_ZERO with ONEWIRE_TIME_READ_MAX in checkReset(), because it is bigger (worst case)"); + static_assert( + ONEWIRE_TIME_RESET_MIN[0] > (ONEWIRE_TIME_SLOT_MAX[0] + ONEWIRE_TIME_READ_MAX[0]), + "Timings are wrong"); // last number should read: max(ONEWIRE_TIME_WRITE_ZERO,ONEWIRE_TIME_READ_MAX) + static_assert(ONEWIRE_TIME_READ_MAX[0] > ONEWIRE_TIME_WRITE_ZERO[0], + "switch ONEWIRE_TIME_WRITE_ZERO with ONEWIRE_TIME_READ_MAX in checkReset(), " + "because it is bigger (worst case)"); static_assert(ONEWIRE_TIME_RESET_MAX[0] > ONEWIRE_TIME_RESET_MIN[0], "Timings are wrong"); #if OVERDRIVE_ENABLE - static_assert(ONEWIRE_TIME_RESET_MIN[1] > (ONEWIRE_TIME_SLOT_MAX[1] + ONEWIRE_TIME_READ_MAX[1]), "Timings are wrong"); - static_assert(ONEWIRE_TIME_READ_MAX[1] > ONEWIRE_TIME_WRITE_ZERO[1], "switch ONEWIRE_TIME_WRITE_ZERO with ONEWIRE_TIME_READ_MAX in checkReset(), because it is bigger (worst case)"); + static_assert(ONEWIRE_TIME_RESET_MIN[1] > (ONEWIRE_TIME_SLOT_MAX[1] + ONEWIRE_TIME_READ_MAX[1]), + "Timings are wrong"); + static_assert(ONEWIRE_TIME_READ_MAX[1] > ONEWIRE_TIME_WRITE_ZERO[1], + "switch ONEWIRE_TIME_WRITE_ZERO with ONEWIRE_TIME_READ_MAX in checkReset(), " + "because it is bigger (worst case)"); static_assert(ONEWIRE_TIME_RESET_MAX[0] > ONEWIRE_TIME_RESET_MIN[1], "Timings are wrong"); #endif @@ -265,22 +263,30 @@ bool OneWireHub::checkReset(void) // there is a specific high-time needed before if (_error == Error::RESET_IN_PROGRESS) { _error = Error::NO_ERROR; - if (waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MIN[od_mode] - ONEWIRE_TIME_SLOT_MAX[od_mode] - ONEWIRE_TIME_READ_MAX[od_mode], false) == 0) // last number should read: max(ONEWIRE_TIME_WRITE_ZERO,ONEWIRE_TIME_READ_MAX) + if (waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MIN[od_mode] - ONEWIRE_TIME_SLOT_MAX[od_mode] - + ONEWIRE_TIME_READ_MAX[od_mode], + false) == + 0) // last number should read: max(ONEWIRE_TIME_WRITE_ZERO,ONEWIRE_TIME_READ_MAX) { #if OVERDRIVE_ENABLE - const timeOW_t loops_remaining = waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MAX[0], false); // showPresence() wants to start at high, so wait for it - if (od_mode && ((ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[od_mode]) > loops_remaining)) + const timeOW_t loops_remaining = waitLoopsWhilePinIs( + ONEWIRE_TIME_RESET_MAX[0], + false); // showPresence() wants to start at high, so wait for it + if (od_mode && + ((ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[od_mode]) > loops_remaining)) { od_mode = false; // normal reset detected, so leave OD-Mode }; #else - waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MAX[0], false); // showPresence() wants to start at high, so wait for it + waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MAX[0], + false); // showPresence() wants to start at high, so wait for it #endif return false; } } - if (!DIRECT_READ(pin_baseReg, pin_bitMask)) return true; // just leave if pin is Low, don't bother to wait, TODO: really needed? + if (!DIRECT_READ(pin_baseReg, pin_bitMask)) + return true; // just leave if pin is Low, don't bother to wait, TODO: really needed? // wait for the bus to become low (master-controlled), since we are polling we don't know for how long it was zero if (waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_TIMEOUT, true) == 0) @@ -320,22 +326,26 @@ bool OneWireHub::showPresence(void) #endif // Master will delay it's "Presence" check (bus-read) after the reset - waitLoopsWhilePinIs(ONEWIRE_TIME_PRESENCE_TIMEOUT, true); // no pinCheck demanded, but this additional check can cut waitTime + waitLoopsWhilePinIs(ONEWIRE_TIME_PRESENCE_TIMEOUT, + true); // no pinCheck demanded, but this additional check can cut waitTime if (USE_GPIO_DEBUG) DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); // pull the bus low and hold it some time DIRECT_WRITE_LOW(pin_baseReg, pin_bitMask); - DIRECT_MODE_OUTPUT(pin_baseReg, pin_bitMask); // drive output low + DIRECT_MODE_OUTPUT(pin_baseReg, pin_bitMask); // drive output low - wait(ONEWIRE_TIME_PRESENCE_MIN[od_mode]); // stays till the end, because it drives the bus low itself + wait(ONEWIRE_TIME_PRESENCE_MIN + [od_mode]); // stays till the end, because it drives the bus low itself - DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); // allow it to float + DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); // allow it to float if (USE_GPIO_DEBUG) DIRECT_WRITE_LOW(debug_baseReg, debug_bitMask); // When the master or other slaves release the bus within a given time everything is fine - if (waitLoopsWhilePinIs((ONEWIRE_TIME_PRESENCE_MAX[od_mode] - ONEWIRE_TIME_PRESENCE_MIN[od_mode]), false) == 0) + if (waitLoopsWhilePinIs( + (ONEWIRE_TIME_PRESENCE_MAX[od_mode] - ONEWIRE_TIME_PRESENCE_MIN[od_mode]), false) == + 0) { _error = Error::PRESENCE_LOW_ON_LINE; return true; @@ -347,10 +357,10 @@ bool OneWireHub::showPresence(void) // note: this FN calls sendBit() & recvBit() but doesn't handle interrupts -> calling FN must do this void OneWireHub::searchIDTree(void) { - uint8_t position_IDBit = 0; - uint8_t trigger_pos = 0; - uint8_t active_slave = idTree[trigger_pos].slave_selected; - uint8_t trigger_bit = idTree[trigger_pos].id_position; + uint8_t position_IDBit = 0; + uint8_t trigger_pos = 0; + uint8_t active_slave = idTree[trigger_pos].slave_selected; + uint8_t trigger_bit = idTree[trigger_pos].id_position; while (position_IDBit < 64) { @@ -361,7 +371,7 @@ void OneWireHub::searchIDTree(void) if (sendBit(false)) return; const bool bit_recv = recvBit(); - if (_error != Error::NO_ERROR) return; + if (_error != Error::NO_ERROR) return; // switch to next junction trigger_pos = bit_recv ? idTree[trigger_pos].got_one : idTree[trigger_pos].got_zero; @@ -374,25 +384,25 @@ void OneWireHub::searchIDTree(void) { const uint8_t pos_byte = (position_IDBit >> 3); const uint8_t mask_bit = (static_cast(1) << (position_IDBit & (7))); - bool bit_send; + bool bit_send; if ((slave_list[active_slave]->ID[pos_byte] & mask_bit) != 0) { bit_send = true; - if (sendBit(true)) return; + if (sendBit(true)) return; if (sendBit(false)) return; } else { bit_send = false; if (sendBit(false)) return; - if (sendBit(true)) return; + if (sendBit(true)) return; } const bool bit_recv = recvBit(); - if (_error != Error::NO_ERROR) return; + if (_error != Error::NO_ERROR) return; - if (bit_send != bit_recv) return; + if (bit_send != bit_recv) return; } position_IDBit++; } @@ -404,7 +414,8 @@ bool OneWireHub::recvAndProcessCmd(void) { // If the only slave is not multidrop compatible, pass all data handling to the slave - if(slave_count == 1u){ + if (slave_count == 1u) + { slave_selected = slave_list[getIndexOfNextSensorInList()]; // TODO: this might be expensive for weak uC and OW in Overdrive and only one device emulated @@ -412,7 +423,8 @@ bool OneWireHub::recvAndProcessCmd(void) // - preselect when only one device present? // - move that at the end of switch in default (less impact for all other hosts) - if( slave_selected->skip_multidrop ){ + if (slave_selected->skip_multidrop) + { slave_selected->duty(this); return false; // TODO: Find the root-cause. This fixes the issue but may cause other problems. @@ -425,8 +437,9 @@ bool OneWireHub::recvAndProcessCmd(void) recv(&cmd); - if (_error == Error::RESET_IN_PROGRESS) return false; // stay in poll()-loop and trigger another datastream-detection - if (_error != Error::NO_ERROR) return true; + if (_error == Error::RESET_IN_PROGRESS) + return false; // stay in poll()-loop and trigger another datastream-detection + if (_error != Error::NO_ERROR) return true; switch (cmd) { @@ -438,7 +451,8 @@ bool OneWireHub::recvAndProcessCmd(void) interrupts(); // most ICs allow going for duty() right after search - if ((_error == Error::NO_ERROR) && (slave_selected != nullptr) && slave_selected->fast_search_rom) + if ((_error == Error::NO_ERROR) && (slave_selected != nullptr) && + slave_selected->fast_search_rom) { slave_selected->duty(this); } @@ -456,10 +470,7 @@ bool OneWireHub::recvAndProcessCmd(void) slave_selected = nullptr; - if (recv(address, 8)) - { - break; - } + if (recv(address, 8)) { break; } for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) { @@ -482,10 +493,7 @@ bool OneWireHub::recvAndProcessCmd(void) } } - if (!flag) - { - return true; - } + if (!flag) { return true; } if (slave_selected != nullptr) { @@ -554,7 +562,7 @@ bool OneWireHub::recvAndProcessCmd(void) default: // Unknown command - _error = Error::INCORRECT_ONEWIRE_CMD; + _error = Error::INCORRECT_ONEWIRE_CMD; _error_cmd = cmd; } @@ -572,7 +580,8 @@ bool OneWireHub::sendBit(const bool value) // Wait for bus to rise HIGH, signaling end of last timeslot timeOW_t retries = ONEWIRE_TIME_SLOT_MAX[od_mode]; - while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)); + while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) + ; if (retries == 0) { _error = Error::RESET_IN_PROGRESS; @@ -581,7 +590,8 @@ bool OneWireHub::sendBit(const bool value) // Wait for bus to fall LOW, start of new timeslot retries = ONEWIRE_TIME_MSG_HIGH_TIMEOUT; - while ((DIRECT_READ(pin_baseReg, pin_bitMask) != 0) && (--retries != 0)); + while ((DIRECT_READ(pin_baseReg, pin_bitMask) != 0) && (--retries != 0)) + ; if (retries == 0) { _error = Error::AWAIT_TIMESLOT_TIMEOUT_HIGH; @@ -594,12 +604,10 @@ bool OneWireHub::sendBit(const bool value) DIRECT_MODE_OUTPUT(pin_baseReg, pin_bitMask); retries = ONEWIRE_TIME_WRITE_ZERO[od_mode]; } - else - { - retries = ONEWIRE_TIME_READ_MAX[od_mode]; - } + else { retries = ONEWIRE_TIME_READ_MAX[od_mode]; } - while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)); // TODO: we should check for (!retries) because there could be a reset in progress... + while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) + ; // TODO: we should check for (!retries) because there could be a reset in progress... DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); return false; @@ -614,15 +622,16 @@ bool OneWireHub::send(const uint8_t address[], const uint8_t data_length) DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); uint8_t bytes_sent = 0; - for ( ; bytes_sent < data_length; ++bytes_sent) // loop for sending bytes + for (; bytes_sent < data_length; ++bytes_sent) // loop for sending bytes { const uint8_t dataByte = address[bytes_sent]; - for (uint8_t bitMask = 0x01; bitMask != 0; bitMask <<= 1) // loop for sending bits + for (uint8_t bitMask = 0x01; bitMask != 0; bitMask <<= 1) // loop for sending bits { if (sendBit(static_cast(bitMask & dataByte))) { - if ((bitMask == 0x01) && (_error == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; + if ((bitMask == 0x01) && (_error == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) + _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; interrupts(); return true; } @@ -644,22 +653,23 @@ bool OneWireHub::send(const uint8_t address[], const uint8_t data_length, uint16 DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); uint8_t bytes_sent = 0; - for ( ; bytes_sent < data_length; ++bytes_sent) // loop for sending bytes + for (; bytes_sent < data_length; ++bytes_sent) // loop for sending bytes { uint8_t dataByte = address[bytes_sent]; - for (uint8_t counter = 0; counter < 8; ++counter) // loop for sending bits + for (uint8_t counter = 0; counter < 8; ++counter) // loop for sending bits { if (sendBit(static_cast(0x01 & dataByte))) { - if ((counter == 0) && (_error ==Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; + if ((counter == 0) && (_error == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) + _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; interrupts(); return true; } const uint8_t mix = ((uint8_t) crc16 ^ dataByte) & static_cast(0x01); crc16 >>= 1; - if (mix != 0) crc16 ^= static_cast(0xA001); + if (mix != 0) crc16 ^= static_cast(0xA001); dataByte >>= 1; } if (USE_GPIO_DEBUG) @@ -672,17 +682,15 @@ bool OneWireHub::send(const uint8_t address[], const uint8_t data_length, uint16 return (bytes_sent != data_length); } -bool OneWireHub::send(const uint8_t dataByte) -{ - return send(&dataByte,1); -} +bool OneWireHub::send(const uint8_t dataByte) { return send(&dataByte, 1); } // NOTE: if called separately you need to handle interrupts, should be disabled during this FN bool OneWireHub::recvBit(void) { // Wait for bus to rise HIGH, signaling end of last timeslot timeOW_t retries = ONEWIRE_TIME_SLOT_MAX[od_mode]; - while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)); + while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) + ; if (retries == 0) { _error = Error::RESET_IN_PROGRESS; @@ -691,7 +699,8 @@ bool OneWireHub::recvBit(void) // Wait for bus to fall LOW, start of new timeslot retries = ONEWIRE_TIME_MSG_HIGH_TIMEOUT; - while ((DIRECT_READ(pin_baseReg, pin_bitMask) != 0) && (--retries != 0)); + while ((DIRECT_READ(pin_baseReg, pin_bitMask) != 0) && (--retries != 0)) + ; if (retries == 0) { _error = Error::AWAIT_TIMESLOT_TIMEOUT_HIGH; @@ -700,7 +709,8 @@ bool OneWireHub::recvBit(void) // wait a specific time to do a read (data is valid by then), // first difference to inner-loop of write() retries = ONEWIRE_TIME_READ_MIN[od_mode]; - while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)); + while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) + ; return (retries > 0); } @@ -713,16 +723,17 @@ bool OneWireHub::recv(uint8_t address[], const uint8_t data_length) DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); uint8_t bytes_received = 0; - for ( ; bytes_received < data_length; ++bytes_received) + for (; bytes_received < data_length; ++bytes_received) { uint8_t value = 0; for (uint8_t bitMask = 0x01; bitMask != 0; bitMask <<= 1) { - if (recvBit()) value |= bitMask; + if (recvBit()) value |= bitMask; if (_error != Error::NO_ERROR) { - if ((bitMask == 0x01) && (_error ==Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; + if ((bitMask == 0x01) && (_error == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) + _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; interrupts(); return true; } @@ -750,10 +761,10 @@ bool OneWireHub::recv(uint8_t address[], const uint8_t data_length, uint16_t &cr DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); uint8_t bytes_received = 0; - for ( ; bytes_received < data_length; ++bytes_received) + for (; bytes_received < data_length; ++bytes_received) { uint8_t value = 0; - uint8_t mix = 0; + uint8_t mix = 0; for (uint8_t bitMask = 0x01; bitMask != 0; bitMask <<= 1) { if (recvBit()) @@ -765,14 +776,15 @@ bool OneWireHub::recv(uint8_t address[], const uint8_t data_length, uint16_t &cr if (_error != Error::NO_ERROR) { - if ((bitMask == 0x01) && (_error ==Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; + if ((bitMask == 0x01) && (_error == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH)) + _error = Error::FIRST_BIT_OF_BYTE_TIMEOUT; interrupts(); return true; } mix ^= static_cast(crc16) & static_cast(0x01); crc16 >>= 1; - if (mix != 0) crc16 ^= static_cast(0xA001); + if (mix != 0) crc16 ^= static_cast(0xA001); } address[bytes_received] = value; @@ -791,10 +803,10 @@ bool OneWireHub::recv(uint8_t address[], const uint8_t data_length, uint16_t &cr void OneWireHub::wait(const uint16_t timeout_us) const { timeOW_t loops = timeUsToLoops(timeout_us); - bool state = false; + bool state = false; while (loops != 0) { - loops = waitLoopsWhilePinIs(loops,state); + loops = waitLoopsWhilePinIs(loops, state); state = !state; } } @@ -802,10 +814,10 @@ void OneWireHub::wait(const uint16_t timeout_us) const void OneWireHub::wait(const timeOW_t loops_wait) const { timeOW_t loops = loops_wait; - bool state = false; + bool state = false; while (loops != 0) { - loops = waitLoopsWhilePinIs(loops,state); + loops = waitLoopsWhilePinIs(loops, state); state = !state; } } @@ -815,7 +827,8 @@ void OneWireHub::wait(const timeOW_t loops_wait) const timeOW_t OneWireHub::waitLoopsWhilePinIs(volatile timeOW_t retries, const bool pin_value) const { if (retries == 0) return 0; - while ((DIRECT_READ(pin_baseReg, pin_bitMask) == pin_value) && (--retries != 0)); + while ((DIRECT_READ(pin_baseReg, pin_bitMask) == pin_value) && (--retries != 0)) + ; return retries; } @@ -823,8 +836,8 @@ void OneWireHub::waitLoops1ms(void) { if (USE_GPIO_DEBUG) { - constexpr timeOW_t loops_1ms = 1000_us; - timeOW_t loops_left = 1; + constexpr timeOW_t loops_1ms = 1000_us; + timeOW_t loops_left = 1; while (loops_left != 0) { waitLoopsWhilePinIs(loops_1ms, false); @@ -841,19 +854,22 @@ void OneWireHub::waitLoops1ms(void) // after that it measures with a waitLoops()-FN to determine the instructions-per-loop-value for the used architecture timeOW_t OneWireHub::waitLoopsCalibrate(void) { - const timeOW_t wait_loops{1000000 * microsecondsToClockCycles(1)}; // loops before canceling a pin-change-wait, 1s, TODO: change back to constexpr if possible (ardu due / zero are blocking) + const timeOW_t wait_loops{ + 1000000 * + microsecondsToClockCycles( + 1)}; // loops before canceling a pin-change-wait, 1s, TODO: change back to constexpr if possible (ardu due / zero are blocking) constexpr uint32_t TIME_RESET_MIN_US = 430; timeOW_t time_for_reset = 0; - timeOW_t repetitions = 10; + timeOW_t repetitions = 10; - DIRECT_MODE_INPUT(pin_baseReg,pin_bitMask); + DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); // repetitions the longest low-states on the bus with millis(), assume it is a OW-reset while (repetitions-- != 0) { #if defined(ARDUINO_ARCH_ESP8266) -ESP.wdtFeed(); + ESP.wdtFeed(); #endif uint32_t time_needed = 0; @@ -864,31 +880,31 @@ ESP.wdtFeed(); const uint32_t time_start = micros(); waitLoopsWhilePinIs(TIMEOW_MAX, false); const uint32_t time_stop = micros(); - time_needed = time_stop - time_start; + time_needed = time_stop - time_start; } if (time_needed > time_for_reset) time_for_reset = time_needed; } timeOW_t loops_for_reset = 0; - repetitions = 0; + repetitions = 0; noInterrupts(); while (repetitions++ < REPETITIONS) { #if defined(ARDUINO_ARCH_ESP8266) -ESP.wdtFeed(); + ESP.wdtFeed(); #endif if (waitLoopsWhilePinIs(wait_loops, true) == 0) continue; - const timeOW_t loops_left = waitLoopsWhilePinIs(TIMEOW_MAX, false); + const timeOW_t loops_left = waitLoopsWhilePinIs(TIMEOW_MAX, false); const timeOW_t loops_needed = TIMEOW_MAX - loops_left; - if (loops_needed>loops_for_reset) loops_for_reset = loops_needed; + if (loops_needed > loops_for_reset) loops_for_reset = loops_needed; } interrupts(); waitLoops1ms(); - const timeOW_t value_ipl = ( time_for_reset * microsecondsToClockCycles(1) ) / loops_for_reset; + const timeOW_t value_ipl = (time_for_reset * microsecondsToClockCycles(1)) / loops_for_reset; return value_ipl; } @@ -945,42 +961,38 @@ void OneWireHub::printError(void) const else if (_error == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) Serial.print("await timeout high"); else if (_error == Error::PRESENCE_HIGH_ON_LINE) Serial.print("presence high on line"); else if (_error == Error::INCORRECT_ONEWIRE_CMD) Serial.print("incorrect onewire command"); - else if (_error == Error::INCORRECT_SLAVE_USAGE) Serial.print("slave was used in incorrect way"); - else if (_error == Error::TRIED_INCORRECT_WRITE) Serial.print("tried to write in read-slot"); - else if (_error == Error::FIRST_TIMESLOT_TIMEOUT) Serial.print("found no timeslot after reset / presence (is OK)"); - else if (_error == Error::FIRST_BIT_OF_BYTE_TIMEOUT) Serial.print("first bit of byte timeout"); + else if (_error == Error::INCORRECT_SLAVE_USAGE) + Serial.print("slave was used in incorrect way"); + else if (_error == Error::TRIED_INCORRECT_WRITE) + Serial.print("tried to write in read-slot"); + else if (_error == Error::FIRST_TIMESLOT_TIMEOUT) + Serial.print("found no timeslot after reset / presence (is OK)"); + else if (_error == Error::FIRST_BIT_OF_BYTE_TIMEOUT) + Serial.print("first bit of byte timeout"); if ((_error == Error::INCORRECT_ONEWIRE_CMD) || (_error == Error::INCORRECT_SLAVE_USAGE)) { Serial.print(" [0x"); Serial.print(_error_cmd, HEX); Serial.println("]"); - } else - { - Serial.println(""); } + else { Serial.println(""); } } } -Error OneWireHub::getError(void) const -{ - return (_error); -} +Error OneWireHub::getError(void) const { return (_error); } -bool OneWireHub::hasError(void) const -{ - return (_error != Error::NO_ERROR); -} +bool OneWireHub::hasError(void) const { return (_error != Error::NO_ERROR); } void OneWireHub::raiseSlaveError(const uint8_t cmd) { - _error = Error::INCORRECT_SLAVE_USAGE; + _error = Error::INCORRECT_SLAVE_USAGE; _error_cmd = cmd; } Error OneWireHub::clearError(void) // and return it if needed { const Error _tmp = _error; - _error = Error::NO_ERROR; + _error = Error::NO_ERROR; return _tmp; } diff --git a/src/OneWireHub.h b/src/OneWireHub.h index c937a4b..50a81a8 100644 --- a/src/OneWireHub.h +++ b/src/OneWireHub.h @@ -3,12 +3,15 @@ #include "platform.h" // code for compatibility -using timeOW_t = uint32_t; -constexpr timeOW_t timeOW_max = 4294967295; // will arduino-gcc ever offer some stl? std::numeric_limits::max would be cleaner +using timeOW_t = uint32_t; +constexpr timeOW_t timeOW_max = + 4294967295; // will arduino-gcc ever offer some stl? std::numeric_limits::max would be cleaner -constexpr timeOW_t operator "" _us(const unsigned long long int time_us) // user defined literal used in config +constexpr timeOW_t +operator"" _us(const unsigned long long int time_us) // user defined literal used in config { - return timeOW_t(time_us * microsecondsToClockCycles(1) / VALUE_IPL); // note: microsecondsToClockCycles == speed in MHz.... + return timeOW_t(time_us * microsecondsToClockCycles(1) / + VALUE_IPL); // note: microsecondsToClockCycles == speed in MHz.... // TODO: overflow detection would be nice, but literals are allowed with return-only, not solvable ATM } @@ -16,15 +19,16 @@ constexpr timeOW_t operator "" _us(const unsigned long long int time_us) // user // same FN, but not as literal constexpr timeOW_t timeUsToLoops(const uint16_t time_us) { - return (time_us * microsecondsToClockCycles(1) / VALUE_IPL); // note: microsecondsToClockCycles == speed in MHz.... + return (time_us * microsecondsToClockCycles(1) / + VALUE_IPL); // note: microsecondsToClockCycles == speed in MHz.... } #include "OneWireHub_config.h" // outsource configfile #ifndef HUB_SLAVE_LIMIT -#error "Slavelimit not defined (why?)" + #error "Slavelimit not defined (why?)" #elif (HUB_SLAVE_LIMIT > 32) -#error "Slavelimit is set too high (32)" + #error "Slavelimit is set too high (32)" #elif (HUB_SLAVE_LIMIT > 16) using mask_t = uint32_t; #elif (HUB_SLAVE_LIMIT > 8) @@ -32,29 +36,30 @@ using mask_t = uint16_t; #elif (HUB_SLAVE_LIMIT > 0) using mask_t = uint8_t; #else -#error "Slavelimit is set to zero (why?)" + #error "Slavelimit is set to zero (why?)" #endif -constexpr timeOW_t VALUE1k { 1000 }; // commonly used constant -constexpr timeOW_t TIMEOW_MAX { 4294967295 }; // arduino does not support std-lib... - -enum class Error : uint8_t { - NO_ERROR = 0, - READ_TIMESLOT_TIMEOUT = 1, - WRITE_TIMESLOT_TIMEOUT = 2, - WAIT_RESET_TIMEOUT = 3, - VERY_LONG_RESET = 4, - VERY_SHORT_RESET = 5, - PRESENCE_LOW_ON_LINE = 6, - READ_TIMESLOT_TIMEOUT_LOW = 7, +constexpr timeOW_t VALUE1k{1000}; // commonly used constant +constexpr timeOW_t TIMEOW_MAX{4294967295}; // arduino does not support std-lib... + +enum class Error : uint8_t +{ + NO_ERROR = 0, + READ_TIMESLOT_TIMEOUT = 1, + WRITE_TIMESLOT_TIMEOUT = 2, + WAIT_RESET_TIMEOUT = 3, + VERY_LONG_RESET = 4, + VERY_SHORT_RESET = 5, + PRESENCE_LOW_ON_LINE = 6, + READ_TIMESLOT_TIMEOUT_LOW = 7, AWAIT_TIMESLOT_TIMEOUT_HIGH = 8, - PRESENCE_HIGH_ON_LINE = 9, - INCORRECT_ONEWIRE_CMD = 10, - INCORRECT_SLAVE_USAGE = 11, - TRIED_INCORRECT_WRITE = 12, - FIRST_TIMESLOT_TIMEOUT = 13, - FIRST_BIT_OF_BYTE_TIMEOUT = 14, - RESET_IN_PROGRESS = 15 + PRESENCE_HIGH_ON_LINE = 9, + INCORRECT_ONEWIRE_CMD = 10, + INCORRECT_SLAVE_USAGE = 11, + TRIED_INCORRECT_WRITE = 12, + FIRST_TIMESLOT_TIMEOUT = 13, + FIRST_BIT_OF_BYTE_TIMEOUT = 14, + RESET_IN_PROGRESS = 15 }; @@ -63,36 +68,36 @@ class OneWireItem; class OneWireHub { private: - - static constexpr uint8_t ONEWIRESLAVE_LIMIT { HUB_SLAVE_LIMIT }; - static constexpr uint8_t ONEWIRE_TREE_SIZE { ( 2 * ONEWIRESLAVE_LIMIT ) - 1 }; + static constexpr uint8_t ONEWIRESLAVE_LIMIT{HUB_SLAVE_LIMIT}; + static constexpr uint8_t ONEWIRE_TREE_SIZE{(2 * ONEWIRESLAVE_LIMIT) - 1}; #if OVERDRIVE_ENABLE bool od_mode; #else - static constexpr bool od_mode { false }; + static constexpr bool od_mode{false}; #endif Error _error; uint8_t _error_cmd; - io_reg_t pin_bitMask; + io_reg_t pin_bitMask; volatile io_reg_t *pin_baseReg; #if true //USE_GPIO_DEBUG - io_reg_t debug_bitMask; + io_reg_t debug_bitMask; volatile io_reg_t *debug_baseReg; #endif uint8_t slave_count; - OneWireItem *slave_list[ONEWIRESLAVE_LIMIT]; // private slave-list (use attach/detach) + OneWireItem *slave_list[ONEWIRESLAVE_LIMIT]; // private slave-list (use attach/detach) OneWireItem *slave_selected; - struct IDTree { + struct IDTree + { uint8_t slave_selected; // for which slave is this jump-command relevant uint8_t id_position; // where does the algorithm has to look for a junction - uint8_t got_zero; // if 0 switch to which tree branch - uint8_t got_one; // if 1 switch to which tree branch + uint8_t got_zero; // if 0 switch to which tree branch + uint8_t got_one; // if 1 switch to which tree branch } idTree[ONEWIRE_TREE_SIZE]; uint8_t buildIDTree(void); @@ -102,27 +107,26 @@ class OneWireHub uint8_t getNrOfFirstBitSet(mask_t mask) const; uint8_t getNrOfFirstFreeIDTreeElement(void) const; - bool checkReset(void); // returns true if error occurred - bool showPresence(void); // returns true if error occurred - bool recvAndProcessCmd(); // returns true if error occurred + bool checkReset(void); // returns true if error occurred + bool showPresence(void); // returns true if error occurred + bool recvAndProcessCmd(); // returns true if error occurred void wait(timeOW_t loops_wait) const; void wait(uint16_t timeout_us) const; - inline __attribute__((always_inline)) - timeOW_t waitLoopsWhilePinIs(volatile timeOW_t retries, bool pin_value = false) const; + inline __attribute__((always_inline)) timeOW_t + waitLoopsWhilePinIs(volatile timeOW_t retries, bool pin_value = false) const; public: - explicit OneWireHub(uint8_t pin); ~OneWireHub() = default; // nothing special to do here - OneWireHub(const OneWireHub& hub) = delete; // disallow copy constructor - OneWireHub(OneWireHub&& hub) = default; // default move constructor - OneWireHub& operator=(OneWireHub& hub) = delete; // disallow copy assignment - OneWireHub& operator=(const OneWireHub& hub) = delete; // disallow copy assignment - OneWireHub& operator=(OneWireHub&& hub) = delete; // disallow move assignment + OneWireHub(const OneWireHub &hub) = delete; // disallow copy constructor + OneWireHub(OneWireHub &&hub) = default; // default move constructor + OneWireHub &operator=(OneWireHub &hub) = delete; // disallow copy assignment + OneWireHub &operator=(const OneWireHub &hub) = delete; // disallow copy assignment + OneWireHub &operator=(OneWireHub &&hub) = delete; // disallow move assignment uint8_t attach(OneWireItem &sensor); bool detach(const OneWireItem &sensor); @@ -132,16 +136,18 @@ class OneWireHub bool poll(void); - bool sendBit(bool value); // returns 1 if error occurred - bool send(uint8_t dataByte); // returns 1 if error occurred - bool send(const uint8_t address[], uint8_t data_length = 1); // returns 1 if error occurred - bool send(const uint8_t address[], uint8_t data_length, uint16_t &crc16); // returns 1 if error occurred + bool sendBit(bool value); // returns 1 if error occurred + bool send(uint8_t dataByte); // returns 1 if error occurred + bool send(const uint8_t address[], uint8_t data_length = 1); // returns 1 if error occurred + bool send(const uint8_t address[], uint8_t data_length, + uint16_t &crc16); // returns 1 if error occurred // CRC takes ~7.4µs/byte (Atmega328P@16MHz) but is distributing the load between each bit-send to 0.9 µs/bit (see debug-crc-comparison.ino) // important: the final crc is expected to be inverted (crc=~crc) !!! - bool recvBit(void); - bool recv(uint8_t address[], uint8_t data_length = 1); // returns 1 if error occurred - bool recv(uint8_t address[], uint8_t data_length, uint16_t &crc16); // returns 1 if error occurred + bool recvBit(void); + bool recv(uint8_t address[], uint8_t data_length = 1); // returns 1 if error occurred + bool recv(uint8_t address[], uint8_t data_length, + uint16_t &crc16); // returns 1 if error occurred timeOW_t waitLoopsCalibrate(void); // returns Instructions per loop void waitLoops1ms(void); @@ -153,7 +159,6 @@ class OneWireHub bool hasError(void) const; // returns true if Error occurred void raiseSlaveError(uint8_t cmd = 0); Error clearError(void); - }; #endif diff --git a/src/OneWireHub_config.h b/src/OneWireHub_config.h index 5ea395c..aadf144 100644 --- a/src/OneWireHub_config.h +++ b/src/OneWireHub_config.h @@ -7,16 +7,22 @@ ///////////////////////////////////////////////////// // INFO: had to go with a define because some compilers use constexpr as simple const --> massive problems -#define HUB_SLAVE_LIMIT 8 // set the limit of the hub HERE, max is 32 devices -#define OVERDRIVE_ENABLE 0 // support overdrive for the slaves +#define HUB_SLAVE_LIMIT 8 // set the limit of the hub HERE, max is 32 devices +#define OVERDRIVE_ENABLE 0 // support overdrive for the slaves -constexpr bool USE_SERIAL_DEBUG { false }; // give debug messages when printError() is called (be aware! it may produce heisenbugs, timing is critical) SHOULD NOT be enabled with < 20 MHz uC -constexpr bool USE_GPIO_DEBUG { false }; // is a better alternative to serial debug (see readme.md for info) SHOULD NOT be enabled with < 20 MHz uC and Overdrive enabled -constexpr uint8_t GPIO_DEBUG_PIN { 7 }; // digital pin -constexpr uint32_t REPETITIONS { 5000 }; // for measuring the loop-delay --> 10000L takes ~110ms on atmega328p@16Mhz +constexpr bool USE_SERIAL_DEBUG{ + false}; // give debug messages when printError() is called (be aware! it may produce heisenbugs, timing is critical) SHOULD NOT be enabled with < 20 MHz uC +constexpr bool USE_GPIO_DEBUG{ + false}; // is a better alternative to serial debug (see readme.md for info) SHOULD NOT be enabled with < 20 MHz uC and Overdrive enabled +constexpr uint8_t GPIO_DEBUG_PIN{7}; // digital pin +constexpr uint32_t REPETITIONS{ + 5000}; // for measuring the loop-delay --> 10000L takes ~110ms on atmega328p@16Mhz -static_assert(!(USE_SERIAL_DEBUG && (microsecondsToClockCycles(1) < 20)), "Serial debug is enabled in OW-Config. SHOULD NOT be enabled with < 20 MHz uC"); -static_assert(!(USE_GPIO_DEBUG && (microsecondsToClockCycles(1) < 20) && (OVERDRIVE_ENABLE != 0)), "Gpio debug is enabled in OW-Config. SHOULD NOT be enabled with < 20 MHz uC and Overdrive enabled"); +static_assert(!(USE_SERIAL_DEBUG && (microsecondsToClockCycles(1) < 20)), + "Serial debug is enabled in OW-Config. SHOULD NOT be enabled with < 20 MHz uC"); +static_assert(!(USE_GPIO_DEBUG && (microsecondsToClockCycles(1) < 20) && (OVERDRIVE_ENABLE != 0)), + "Gpio debug is enabled in OW-Config. SHOULD NOT be enabled with < 20 MHz uC and " + "Overdrive enabled"); /// the following TIME-values are in microseconds and are taken mostly from the ds2408 datasheet // arrays contain the normal timing value and the overdrive-value, the literal "_us" converts the value right away to a usable unit @@ -24,27 +30,33 @@ static_assert(!(USE_GPIO_DEBUG && (microsecondsToClockCycles(1) < 20) && (OVERDR // was --> shagrat-legacy // Reset: every low-state of the master between MIN & MAX microseconds will be recognized as a Reset -constexpr timeOW_t ONEWIRE_TIME_RESET_TIMEOUT = { 5000_us }; // for not hanging to long in reset-detection, lower value is better for more responsive applications, but can miss resets -constexpr timeOW_t ONEWIRE_TIME_RESET_MIN[2] = { 430_us, 48_us }; // should be 480 -constexpr timeOW_t ONEWIRE_TIME_RESET_MAX[2] = { 960_us, 80_us }; // from ds2413 +constexpr timeOW_t ONEWIRE_TIME_RESET_TIMEOUT = { + 5000_us}; // for not hanging to long in reset-detection, lower value is better for more responsive applications, but can miss resets +constexpr timeOW_t ONEWIRE_TIME_RESET_MIN[2] = {430_us, 48_us}; // should be 480 +constexpr timeOW_t ONEWIRE_TIME_RESET_MAX[2] = {960_us, 80_us}; // from ds2413 // Presence: slave waits TIMEOUT and emits a low state after the reset with ~MIN length, if the bus stays low after that and exceeds MAX the hub will issue an error -constexpr timeOW_t ONEWIRE_TIME_PRESENCE_TIMEOUT = { 20_us }; // probe measures 25us, duration of high state between reset and presence -constexpr timeOW_t ONEWIRE_TIME_PRESENCE_MIN[2] = { 160_us, 8_us }; // was 125 -constexpr timeOW_t ONEWIRE_TIME_PRESENCE_MAX[2] = { 480_us, 32_us }; // should be 280, was 480 +constexpr timeOW_t ONEWIRE_TIME_PRESENCE_TIMEOUT = { + 20_us}; // probe measures 25us, duration of high state between reset and presence +constexpr timeOW_t ONEWIRE_TIME_PRESENCE_MIN[2] = {160_us, 8_us}; // was 125 +constexpr timeOW_t ONEWIRE_TIME_PRESENCE_MAX[2] = {480_us, 32_us}; // should be 280, was 480 -constexpr timeOW_t ONEWIRE_TIME_MSG_HIGH_TIMEOUT = { 15000_us }; // there can be these inactive / high timeperiods after reset / presence, this value defines the timeout for these -constexpr timeOW_t ONEWIRE_TIME_SLOT_MAX[2] = { 135_us, 30_us }; // should be 120, measured from falling edge to next falling edge +constexpr timeOW_t ONEWIRE_TIME_MSG_HIGH_TIMEOUT = { + 15000_us}; // there can be these inactive / high timeperiods after reset / presence, this value defines the timeout for these +constexpr timeOW_t ONEWIRE_TIME_SLOT_MAX[2] = { + 135_us, 30_us}; // should be 120, measured from falling edge to next falling edge // read and write from the viewpoint of the slave!!!! -constexpr timeOW_t ONEWIRE_TIME_READ_MIN[2] = { 20_us, 4_us }; // should be 15, was 30, says when it is safe to read a valid bit -constexpr timeOW_t ONEWIRE_TIME_READ_MAX[2] = { 60_us, 10_us }; // low states (zeros) of a master should not exceed this time in a slot -constexpr timeOW_t ONEWIRE_TIME_WRITE_ZERO[2] = { 30_us, 8_us }; // the hub holds a zero for this long +constexpr timeOW_t ONEWIRE_TIME_READ_MIN[2] = { + 20_us, 4_us}; // should be 15, was 30, says when it is safe to read a valid bit +constexpr timeOW_t ONEWIRE_TIME_READ_MAX[2] = { + 60_us, 10_us}; // low states (zeros) of a master should not exceed this time in a slot +constexpr timeOW_t ONEWIRE_TIME_WRITE_ZERO[2] = {30_us, 8_us}; // the hub holds a zero for this long // VALUES FOR STATIC ASSERTS -constexpr timeOW_t ONEWIRE_TIME_VALUE_MAX = { ONEWIRE_TIME_MSG_HIGH_TIMEOUT }; -constexpr timeOW_t ONEWIRE_TIME_VALUE_MIN = { ONEWIRE_TIME_READ_MIN[OVERDRIVE_ENABLE] }; +constexpr timeOW_t ONEWIRE_TIME_VALUE_MAX = {ONEWIRE_TIME_MSG_HIGH_TIMEOUT}; +constexpr timeOW_t ONEWIRE_TIME_VALUE_MIN = {ONEWIRE_TIME_READ_MIN[OVERDRIVE_ENABLE]}; // TODO: several compilers have problems with constexpress-FN in unified initializers of constexpr, will be removed for now -> test with arduino due, esp32, ... diff --git a/src/OneWireItem.cpp b/src/OneWireItem.cpp index addb340..0b2227e 100644 --- a/src/OneWireItem.cpp +++ b/src/OneWireItem.cpp @@ -1,6 +1,7 @@ #include "OneWireItem.h" -OneWireItem::OneWireItem(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7) +OneWireItem::OneWireItem(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, + uint8_t ID6, uint8_t ID7) { ID[0] = ID1; ID[1] = ID2; @@ -12,9 +13,7 @@ OneWireItem::OneWireItem(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uin ID[7] = crc8(ID, 7); } -void OneWireItem::sendID(OneWireHub * const hub) const { - hub->send(ID, 8); -} +void OneWireItem::sendID(OneWireHub *const hub) const { hub->send(ID, 8); } //The CRC code was excerpted and inspired by the Dallas Semiconductor //sample code bearing this copyright. @@ -81,13 +80,9 @@ uint16_t OneWireItem::crc16(const uint8_t address[], const uint8_t length, const uint16_t crc = init; // init value #if defined(__AVR__) - for (uint8_t i = 0; i < length; ++i) - { - crc = _crc16_update(crc, address[i]); - } + for (uint8_t i = 0; i < length; ++i) { crc = _crc16_update(crc, address[i]); } #else - static const uint8_t oddParity[16] = - {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; + static const uint8_t oddParity[16] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; for (uint8_t i = 0; i < length; ++i) { @@ -97,8 +92,7 @@ uint16_t OneWireItem::crc16(const uint8_t address[], const uint8_t length, const cdata = (cdata ^ crc) & static_cast(0xff); crc >>= 8; - if ((oddParity[cdata & 0x0F] ^ oddParity[cdata >> 4]) != 0) - crc ^= 0xC001; + if ((oddParity[cdata & 0x0F] ^ oddParity[cdata >> 4]) != 0) crc ^= 0xC001; cdata <<= 6; crc ^= cdata; @@ -117,7 +111,7 @@ uint16_t OneWireItem::crc16(uint8_t value, uint16_t crc) static const uint8_t oddParity[16] = {0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0}; value = (value ^ static_cast(crc)); crc >>= 8; - if ((oddParity[value & 0x0F] ^ oddParity[value >> 4]) != 0) crc ^= 0xC001; + if ((oddParity[value & 0x0F] ^ oddParity[value >> 4]) != 0) crc ^= 0xC001; uint16_t cdata = (static_cast(value) << 6); crc ^= cdata; crc ^= (static_cast(cdata) << 1); diff --git a/src/OneWireItem.h b/src/OneWireItem.h index d1550d1..c736ee7 100644 --- a/src/OneWireItem.h +++ b/src/OneWireItem.h @@ -4,7 +4,7 @@ #include "OneWireHub.h" #if defined(__AVR__) -#include + #include #endif // Feature to get first byte (family code) constant for every sensor --> var4 is implemented @@ -16,32 +16,32 @@ class OneWireItem { public: - - OneWireItem(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, uint8_t ID7); + OneWireItem(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, uint8_t ID6, + uint8_t ID7); ~OneWireItem() = default; // TODO: detach if deleted before hub - OneWireItem(const OneWireItem& owItem) = delete; // disallow copy constructor - OneWireItem(OneWireItem&& owItem) = default; // default move constructor - OneWireItem& operator=(OneWireItem& owItem) = delete; // disallow copy assignment - OneWireItem& operator=(const OneWireItem& owItem) = delete; // disallow copy assignment - OneWireItem& operator=(OneWireItem&& owItem) = delete; // disallow move assignment + OneWireItem(const OneWireItem &owItem) = delete; // disallow copy constructor + OneWireItem(OneWireItem &&owItem) = default; // default move constructor + OneWireItem &operator=(OneWireItem &owItem) = delete; // disallow copy assignment + OneWireItem &operator=(const OneWireItem &owItem) = delete; // disallow copy assignment + OneWireItem &operator=(OneWireItem &&owItem) = delete; // disallow move assignment // DEFAULT BUS-FEATURES: // Specify if the device can be used on a bus with other 1-wire devices // If FALSE all commands will be passed through directly to the duty() call of the device // NOTE: there can be only one device on the bus (beside the controller) - bool skip_multidrop { false }; + bool skip_multidrop{false}; // skip reboot after a search-rom command -> feature normal, except ds2401 & ds18b20 - bool fast_search_rom { true }; + bool fast_search_rom{true}; // skip reboot after a read-rom command -> feature normal, except ds2401 - bool fast_read_rom { true }; + bool fast_read_rom{true}; uint8_t ID[8]; - void sendID(OneWireHub * hub) const; + void sendID(OneWireHub *hub) const; - virtual void duty(OneWireHub * hub) = 0; + virtual void duty(OneWireHub *hub) = 0; static uint8_t crc8(const uint8_t data[], uint8_t data_size, uint8_t crc_init = 0); @@ -53,7 +53,6 @@ class OneWireItem // takes ~6µs/byte (Atmega328P@16MHz) (see debug-crc-comparison.ino) // important: the final crc is expected to be inverted (crc=~crc) !!! static uint16_t crc16(uint8_t value, uint16_t crc); - }; diff --git a/src/platform.cpp b/src/platform.cpp index 7653874..f29de2f 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -4,11 +4,11 @@ uint32_t micros() { return 0; }; // original arduino-fn takes about 3 µs to process @ 16 MHz -void cli() { }; -void sei() { }; +void cli(){}; +void sei(){}; -void noInterrupts() { }; +void noInterrupts(){}; -void interrupts() { }; +void interrupts(){}; #endif // ONEWIREHUB_FALLBACK_BASIC_FNs diff --git a/src/platform.h b/src/platform.h index 4ad8db7..371dbea 100644 --- a/src/platform.h +++ b/src/platform.h @@ -4,322 +4,352 @@ #ifndef ONEWIREHUB_PLATFORM_H #define ONEWIREHUB_PLATFORM_H -#if defined(ARDUINO) && (ARDUINO>=100) -#include +#if defined(ARDUINO) && (ARDUINO >= 100) + #include #endif // determine gcc version, will produce number like 40803 for gcc 4.8.3 #if defined(__GNUC__) -#define ONEWIRE_GCC_VERSION ( (__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) + #define ONEWIRE_GCC_VERSION ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) #else -#define ONEWIRE_GCC_VERSION 0 + #define ONEWIRE_GCC_VERSION 0 #endif #if defined(__AVR__) /* arduino (all with atmega, atiny) */ -#define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) -#define DIRECT_MODE_INPUT(base, mask) ((*((base)+1)) &= ~(mask)) -#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+1)) |= (mask)) -#define DIRECT_WRITE_LOW(base, mask) ((*((base)+2)) &= ~(mask)) -#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+2)) |= (mask)) + #define PIN_TO_BASEREG(pin) (portInputRegister(digitalPinToPort(pin))) + #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) + #define DIRECT_READ(base, mask) (((*(base)) & (mask)) ? 1 : 0) + #define DIRECT_MODE_INPUT(base, mask) ((*((base) + 1)) &= ~(mask)) + #define DIRECT_MODE_OUTPUT(base, mask) ((*((base) + 1)) |= (mask)) + #define DIRECT_WRITE_LOW(base, mask) ((*((base) + 2)) &= ~(mask)) + #define DIRECT_WRITE_HIGH(base, mask) ((*((base) + 2)) |= (mask)) using io_reg_t = uint8_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL {13}; // instructions per loop, compare 0 takes 11, compare 1 takes 13 cycles - -#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || defined(__MK64FX512__) /* teensy 3.2 to 3.6 */ -#define PIN_TO_BASEREG(pin) (portOutputRegister(pin)) -#define PIN_TO_BITMASK(pin) (1) -#define DIRECT_READ(base, mask) (*((base)+512)) -#define DIRECT_MODE_INPUT(base, mask) (*((base)+640) = 0) -#define DIRECT_MODE_OUTPUT(base, mask) (*((base)+640) = 1) -#define DIRECT_WRITE_LOW(base, mask) (*((base)+256) = 1) -#define DIRECT_WRITE_HIGH(base, mask) (*((base)+128) = 1) -using io_reg_t = uint8_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL {8}; // instructions per loop +constexpr uint8_t VALUE_IPL{ + 13}; // instructions per loop, compare 0 takes 11, compare 1 takes 13 cycles + +#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || \ + defined(__MK64FX512__) /* teensy 3.2 to 3.6 */ + #define PIN_TO_BASEREG(pin) (portOutputRegister(pin)) + #define PIN_TO_BITMASK(pin) (1) + #define DIRECT_READ(base, mask) (*((base) + 512)) + #define DIRECT_MODE_INPUT(base, mask) (*((base) + 640) = 0) + #define DIRECT_MODE_OUTPUT(base, mask) (*((base) + 640) = 1) + #define DIRECT_WRITE_LOW(base, mask) (*((base) + 256) = 1) + #define DIRECT_WRITE_HIGH(base, mask) (*((base) + 128) = 1) +using io_reg_t = uint8_t; // define special datatype for register-access +constexpr uint8_t VALUE_IPL{8}; // instructions per loop #elif defined(__MKL26Z64__) /* teensy LC */ -#define PIN_TO_BASEREG(pin) (portOutputRegister(pin)) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define DIRECT_READ(base, mask) ((*((base)+16) & (mask)) ? 1 : 0) -#define DIRECT_MODE_INPUT(base, mask) (*((base)+20) &= ~(mask)) -#define DIRECT_MODE_OUTPUT(base, mask) (*((base)+20) |= (mask)) -#define DIRECT_WRITE_LOW(base, mask) (*((base)+8) = (mask)) -#define DIRECT_WRITE_HIGH(base, mask) (*((base)+4) = (mask)) + #define PIN_TO_BASEREG(pin) (portOutputRegister(pin)) + #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) + #define DIRECT_READ(base, mask) ((*((base) + 16) & (mask)) ? 1 : 0) + #define DIRECT_MODE_INPUT(base, mask) (*((base) + 20) &= ~(mask)) + #define DIRECT_MODE_OUTPUT(base, mask) (*((base) + 20) |= (mask)) + #define DIRECT_WRITE_LOW(base, mask) (*((base) + 8) = (mask)) + #define DIRECT_WRITE_HIGH(base, mask) (*((base) + 4) = (mask)) using io_reg_t = uint8_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL {0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) /* arduino due */ -#define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define DIRECT_READ(base, mask) (((*((base)+15)) & (mask)) ? 1 : 0) -#define DIRECT_MODE_INPUT(base, mask) ((*((base)+5)) = (mask)) -#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+4)) = (mask)) -#define DIRECT_WRITE_LOW(base, mask) ((*((base)+13)) = (mask)) -#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+12)) = (mask)) -#ifndef PROGMEM -#define PROGMEM -#endif -#ifndef pgm_read_byte -#define pgm_read_byte(address) (*(const uint8_t *)(address)) -#endif + #define PIN_TO_BASEREG(pin) (&(digitalPinToPort(pin)->PIO_PER)) + #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) + #define DIRECT_READ(base, mask) (((*((base) + 15)) & (mask)) ? 1 : 0) + #define DIRECT_MODE_INPUT(base, mask) ((*((base) + 5)) = (mask)) + #define DIRECT_MODE_OUTPUT(base, mask) ((*((base) + 4)) = (mask)) + #define DIRECT_WRITE_LOW(base, mask) ((*((base) + 13)) = (mask)) + #define DIRECT_WRITE_HIGH(base, mask) ((*((base) + 12)) = (mask)) + #ifndef PROGMEM + #define PROGMEM + #endif + #ifndef pgm_read_byte + #define pgm_read_byte(address) (*(const uint8_t *) (address)) + #endif using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL { 22 }; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 22}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__PIC32MX__) -#define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define DIRECT_READ(base, mask) (((*(base+4)) & (mask)) ? 1 : 0) //PORTX + 0x10 -#define DIRECT_MODE_INPUT(base, mask) ((*(base+2)) = (mask)) //TRISXSET + 0x08 -#define DIRECT_MODE_OUTPUT(base, mask) ((*(base+1)) = (mask)) //TRISXCLR + 0x04 -#define DIRECT_WRITE_LOW(base, mask) ((*(base+8+1)) = (mask)) //LATXCLR + 0x24 -#define DIRECT_WRITE_HIGH(base, mask) ((*(base+8+2)) = (mask)) //LATXSET + 0x28 + #define PIN_TO_BASEREG(pin) (portModeRegister(digitalPinToPort(pin))) + #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) + #define DIRECT_READ(base, mask) (((*(base + 4)) & (mask)) ? 1 : 0) //PORTX + 0x10 + #define DIRECT_MODE_INPUT(base, mask) ((*(base + 2)) = (mask)) //TRISXSET + 0x08 + #define DIRECT_MODE_OUTPUT(base, mask) ((*(base + 1)) = (mask)) //TRISXCLR + 0x04 + #define DIRECT_WRITE_LOW(base, mask) ((*(base + 8 + 1)) = (mask)) //LATXCLR + 0x24 + #define DIRECT_WRITE_HIGH(base, mask) ((*(base + 8 + 2)) = (mask)) //LATXSET + 0x28 using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL { 0 }; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(ARDUINO_ARCH_ESP8266) /* nodeMCU, ESPduino, ... */ -#define PIN_TO_BASEREG(pin) ((volatile uint32_t*) GPO) -#define PIN_TO_BITMASK(pin) (1 << pin) -#define DIRECT_READ(base, mask) ((GPI & (mask)) ? 1 : 0) //GPIO_IN_ADDRESS -#define DIRECT_MODE_INPUT(base, mask) (GPE &= ~(mask)) //GPIO_ENABLE_W1TC_ADDRESS -#define DIRECT_MODE_OUTPUT(base, mask) (GPE |= (mask)) //GPIO_ENABLE_W1TS_ADDRESS -#define DIRECT_WRITE_LOW(base, mask) (GPOC = (mask)) //GPIO_OUT_W1TC_ADDRESS -#define DIRECT_WRITE_HIGH(base, mask) (GPOS = (mask)) //GPIO_OUT_W1TS_ADDRESS + #define PIN_TO_BASEREG(pin) ((volatile uint32_t *) GPO) + #define PIN_TO_BITMASK(pin) (1 << pin) + #define DIRECT_READ(base, mask) ((GPI & (mask)) ? 1 : 0) //GPIO_IN_ADDRESS + #define DIRECT_MODE_INPUT(base, mask) (GPE &= ~(mask)) //GPIO_ENABLE_W1TC_ADDRESS + #define DIRECT_MODE_OUTPUT(base, mask) (GPE |= (mask)) //GPIO_ENABLE_W1TS_ADDRESS + #define DIRECT_WRITE_LOW(base, mask) (GPOC = (mask)) //GPIO_OUT_W1TC_ADDRESS + #define DIRECT_WRITE_HIGH(base, mask) (GPOS = (mask)) //GPIO_OUT_W1TS_ADDRESS using io_reg_t = uint32_t; // define special datatype for register-access // The ESP8266 has two possible CPU frequencies: 160 MHz (26 IPL) and 80 MHz (22 IPL) -> something influences the IPL-Value -constexpr uint8_t VALUE_IPL { (microsecondsToClockCycles(1) > 120) ? 26 : 22 }; // instructions per loop +constexpr uint8_t VALUE_IPL{(microsecondsToClockCycles(1) > 120) ? 26 + : 22}; // instructions per loop #elif defined(ARDUINO_ARCH_ESP32) || defined(ESP32) /* ESP32 Family */ -#define PIN_TO_BASEREG(pin) (0) -#define PIN_TO_BITMASK(pin) (pin) -#define DIRECT_READ(base, pin) digitalRead(pin) -#define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) -#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) -#define DIRECT_MODE_INPUT(base, pin) pinMode(pin, INPUT) -#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT) -#define DELAY_MICROSECONDS(us) delayMicroseconds(us) + #define PIN_TO_BASEREG(pin) (0) + #define PIN_TO_BITMASK(pin) (pin) + #define DIRECT_READ(base, pin) digitalRead(pin) + #define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) + #define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) + #define DIRECT_MODE_INPUT(base, pin) pinMode(pin, INPUT) + #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) + #define DELAY_MICROSECONDS(us) delayMicroseconds(us) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL { 39 }; // instructions per loop, for 40 and 80 MHz (see esp8266 difference) +constexpr uint8_t VALUE_IPL{ + 39}; // instructions per loop, for 40 and 80 MHz (see esp8266 difference) #elif defined(ARDUINO_ARCH_SAMD) /* arduino family samd */ -// arduino-zero is defined(__SAMD21G18A__) - -// TODO: hack needed until alternative to IPL-approach is implemented -#define TMP_HACK -#ifdef TMP_HACK -#undef clockCyclesPerMicrosecond -#undef clockCyclesToMicroseconds -#undef microsecondsToClockCycles -// assuming SystemCoreClock is 48 MHz -#define MY_SYSCLK (48000000L) -//#define MY_SYSCLK (F_CPU) -#define clockCyclesPerMicrosecond() ( MY_SYSCLK / 1000000L ) -#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (MY_SYSCLK / 1000L) ) -#define microsecondsToClockCycles(a) ( (a) * (MY_SYSCLK / 1000000L) ) -#endif - -#define PIN_TO_BASEREG(pin) portModeRegister(digitalPinToPort(pin)) -#define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) -#define DIRECT_READ(base, mask) (((*((base)+8)) & (mask)) ? 1 : 0) -#define DIRECT_MODE_INPUT(base, mask) ((*((base)+1)) = (mask)) -#define DIRECT_MODE_OUTPUT(base, mask) ((*((base)+2)) = (mask)) -#define DIRECT_WRITE_LOW(base, mask) ((*((base)+5)) = (mask)) -#define DIRECT_WRITE_HIGH(base, mask) ((*((base)+6)) = (mask)) -using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL { 18 }; // instructions per loop + // arduino-zero is defined(__SAMD21G18A__) + + // TODO: hack needed until alternative to IPL-approach is implemented + #define TMP_HACK + #ifdef TMP_HACK + #undef clockCyclesPerMicrosecond + #undef clockCyclesToMicroseconds + #undef microsecondsToClockCycles + // assuming SystemCoreClock is 48 MHz + #define MY_SYSCLK (48000000L) + //#define MY_SYSCLK (F_CPU) + #define clockCyclesPerMicrosecond() (MY_SYSCLK / 1000000L) + #define clockCyclesToMicroseconds(a) (((a) *1000L) / (MY_SYSCLK / 1000L)) + #define microsecondsToClockCycles(a) ((a) * (MY_SYSCLK / 1000000L)) + #endif + + #define PIN_TO_BASEREG(pin) portModeRegister(digitalPinToPort(pin)) + #define PIN_TO_BITMASK(pin) (digitalPinToBitMask(pin)) + #define DIRECT_READ(base, mask) (((*((base) + 8)) & (mask)) ? 1 : 0) + #define DIRECT_MODE_INPUT(base, mask) ((*((base) + 1)) = (mask)) + #define DIRECT_MODE_OUTPUT(base, mask) ((*((base) + 2)) = (mask)) + #define DIRECT_WRITE_LOW(base, mask) ((*((base) + 5)) = (mask)) + #define DIRECT_WRITE_HIGH(base, mask) ((*((base) + 6)) = (mask)) +using io_reg_t = uint32_t; // define special datatype for register-access +constexpr uint8_t VALUE_IPL{18}; // instructions per loop #elif defined(NRF52) /* arduino primo */ -#define PIN_TO_BASEREG(pin) (0) -#define PIN_TO_BITMASK(pin) (pin) -#define DIRECT_READ(base, pin) nrf_gpio_pin_read(pin) -#define DIRECT_WRITE_LOW(base, pin) nrf_gpio_pin_clear(pin) -#define DIRECT_WRITE_HIGH(base, pin) nrf_gpio_pin_set(pin) -#define DIRECT_MODE_INPUT(base, pin) nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL) -#define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) + #define PIN_TO_BASEREG(pin) (0) + #define PIN_TO_BITMASK(pin) (pin) + #define DIRECT_READ(base, pin) nrf_gpio_pin_read(pin) + #define DIRECT_WRITE_LOW(base, pin) nrf_gpio_pin_clear(pin) + #define DIRECT_WRITE_HIGH(base, pin) nrf_gpio_pin_set(pin) + #define DIRECT_MODE_INPUT(base, pin) nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL) + #define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL {0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(NRF51) /* red bear blend, should be good for all nrf51x chips */ -#if defined(TARGET_NRF51822) -#include -#endif - -#define PIN_TO_BASEREG(pin) (0) -#define PIN_TO_BITMASK(pin) (pin) -#define DIRECT_READ(base, pin) nrf_gpio_pin_read(pin) -#define DIRECT_WRITE_LOW(base, pin) nrf_gpio_pin_clear(pin) -#define DIRECT_WRITE_HIGH(base, pin) nrf_gpio_pin_set(pin) -#define DIRECT_MODE_INPUT(base, pin) nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL) -#define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) + #if defined(TARGET_NRF51822) + #include + #endif + + #define PIN_TO_BASEREG(pin) (0) + #define PIN_TO_BITMASK(pin) (pin) + #define DIRECT_READ(base, pin) nrf_gpio_pin_read(pin) + #define DIRECT_WRITE_LOW(base, pin) nrf_gpio_pin_clear(pin) + #define DIRECT_WRITE_HIGH(base, pin) nrf_gpio_pin_set(pin) + #define DIRECT_MODE_INPUT(base, pin) nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL) + #define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL {0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__RFduino__) /* rf51 chip with special implementation */ -#define PIN_TO_BASEREG(pin) (0) -#define PIN_TO_BITMASK(pin) (pin) -#define DIRECT_READ(base, pin) digitalRead(pin) -#define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) -#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) -#define DIRECT_MODE_INPUT(base, pin) pinMode(pin, INPUT) -#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT) + #define PIN_TO_BASEREG(pin) (0) + #define PIN_TO_BITMASK(pin) (pin) + #define DIRECT_READ(base, pin) digitalRead(pin) + #define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) + #define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) + #define DIRECT_MODE_INPUT(base, pin) pinMode(pin, INPUT) + #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL {0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__arc__) /* Arduino101/Genuino101 specifics */ -#include "scss_registers.h" -#include "portable.h" -#include "avr/pgmspace.h" - -#define GPIO_ID(pin) (g_APinDescription[pin].ulGPIOId) -#define GPIO_TYPE(pin) (g_APinDescription[pin].ulGPIOType) -#define GPIO_BASE(pin) (g_APinDescription[pin].ulGPIOBase) -#define DIR_OFFSET_SS 0x01 -#define DIR_OFFSET_SOC 0x04 -#define EXT_PORT_OFFSET_SS 0x0A -#define EXT_PORT_OFFSET_SOC 0x50 - -/* GPIO registers base address */ -#define PIN_TO_BASEREG(pin) ((volatile uint32_t *)g_APinDescription[pin].ulGPIOBase) -#define PIN_TO_BITMASK(pin) pin + #include "avr/pgmspace.h" + #include "portable.h" + #include "scss_registers.h" + + #define GPIO_ID(pin) (g_APinDescription[pin].ulGPIOId) + #define GPIO_TYPE(pin) (g_APinDescription[pin].ulGPIOType) + #define GPIO_BASE(pin) (g_APinDescription[pin].ulGPIOBase) + #define DIR_OFFSET_SS 0x01 + #define DIR_OFFSET_SOC 0x04 + #define EXT_PORT_OFFSET_SS 0x0A + #define EXT_PORT_OFFSET_SOC 0x50 + + /* GPIO registers base address */ + #define PIN_TO_BASEREG(pin) ((volatile uint32_t *) g_APinDescription[pin].ulGPIOBase) + #define PIN_TO_BITMASK(pin) pin using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL {0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation -static inline __attribute__((always_inline)) -io_reg_t directRead(volatile io_reg_t *base, io_reg_t pin) +static inline __attribute__((always_inline)) io_reg_t directRead(volatile io_reg_t *base, + io_reg_t pin) { io_reg_t ret; - if (SS_GPIO == GPIO_TYPE(pin)) { - ret = READ_ARC_REG(((io_reg_t)base + EXT_PORT_OFFSET_SS)); - } else { - ret = MMIO_REG_VAL_FROM_BASE((io_reg_t)base, EXT_PORT_OFFSET_SOC); - } + if (SS_GPIO == GPIO_TYPE(pin)) { ret = READ_ARC_REG(((io_reg_t) base + EXT_PORT_OFFSET_SS)); } + else { ret = MMIO_REG_VAL_FROM_BASE((io_reg_t) base, EXT_PORT_OFFSET_SOC); } return ((ret >> GPIO_ID(pin)) & 0x01); } -static inline __attribute__((always_inline)) -void directModeInput(volatile io_reg_t *base, io_reg_t pin) +static inline __attribute__((always_inline)) void directModeInput(volatile io_reg_t *base, + io_reg_t pin) { - if (SS_GPIO == GPIO_TYPE(pin)) { - WRITE_ARC_REG(READ_ARC_REG((((io_reg_t)base) + DIR_OFFSET_SS)) & ~(0x01 << GPIO_ID(pin)), - ((io_reg_t)(base) + DIR_OFFSET_SS)); - } else { - MMIO_REG_VAL_FROM_BASE((io_reg_t)base, DIR_OFFSET_SOC) &= ~(0x01 << GPIO_ID(pin)); + if (SS_GPIO == GPIO_TYPE(pin)) + { + WRITE_ARC_REG(READ_ARC_REG((((io_reg_t) base) + DIR_OFFSET_SS)) & ~(0x01 << GPIO_ID(pin)), + ((io_reg_t) (base) + DIR_OFFSET_SS)); } + else { MMIO_REG_VAL_FROM_BASE((io_reg_t) base, DIR_OFFSET_SOC) &= ~(0x01 << GPIO_ID(pin)); } } -static inline __attribute__((always_inline)) -void directModeOutput(volatile io_reg_t *base, io_reg_t pin) +static inline __attribute__((always_inline)) void directModeOutput(volatile io_reg_t *base, + io_reg_t pin) { - if (SS_GPIO == GPIO_TYPE(pin)) { - WRITE_ARC_REG(READ_ARC_REG(((io_reg_t)(base) + DIR_OFFSET_SS)) | (0x01 << GPIO_ID(pin)), - ((io_reg_t)(base) + DIR_OFFSET_SS)); - } else { - MMIO_REG_VAL_FROM_BASE((io_reg_t)base, DIR_OFFSET_SOC) |= (0x01 << GPIO_ID(pin)); + if (SS_GPIO == GPIO_TYPE(pin)) + { + WRITE_ARC_REG(READ_ARC_REG(((io_reg_t) (base) + DIR_OFFSET_SS)) | (0x01 << GPIO_ID(pin)), + ((io_reg_t) (base) + DIR_OFFSET_SS)); } + else { MMIO_REG_VAL_FROM_BASE((io_reg_t) base, DIR_OFFSET_SOC) |= (0x01 << GPIO_ID(pin)); } } -static inline __attribute__((always_inline)) -void directWriteLow(volatile io_reg_t *base, io_reg_t pin) +static inline __attribute__((always_inline)) void directWriteLow(volatile io_reg_t *base, + io_reg_t pin) { - if (SS_GPIO == GPIO_TYPE(pin)) { + if (SS_GPIO == GPIO_TYPE(pin)) + { WRITE_ARC_REG(READ_ARC_REG(base) & ~(0x01 << GPIO_ID(pin)), base); - } else { - MMIO_REG_VAL(base) &= ~(0x01 << GPIO_ID(pin)); } + else { MMIO_REG_VAL(base) &= ~(0x01 << GPIO_ID(pin)); } } -static inline __attribute__((always_inline)) -void directWriteHigh(volatile io_reg_t *base, io_reg_t pin) +static inline __attribute__((always_inline)) void directWriteHigh(volatile io_reg_t *base, + io_reg_t pin) { - if (SS_GPIO == GPIO_TYPE(pin)) { + if (SS_GPIO == GPIO_TYPE(pin)) + { WRITE_ARC_REG(READ_ARC_REG(base) | (0x01 << GPIO_ID(pin)), base); - } else { - MMIO_REG_VAL(base) |= (0x01 << GPIO_ID(pin)); } + else { MMIO_REG_VAL(base) |= (0x01 << GPIO_ID(pin)); } } -#define DIRECT_READ(base, pin) directRead(base, pin) -#define DIRECT_MODE_INPUT(base, pin) directModeInput(base, pin) -#define DIRECT_MODE_OUTPUT(base, pin) directModeOutput(base, pin) -#define DIRECT_WRITE_LOW(base, pin) directWriteLow(base, pin) -#define DIRECT_WRITE_HIGH(base, pin) directWriteHigh(base, pin) + #define DIRECT_READ(base, pin) directRead(base, pin) + #define DIRECT_MODE_INPUT(base, pin) directModeInput(base, pin) + #define DIRECT_MODE_OUTPUT(base, pin) directModeOutput(base, pin) + #define DIRECT_WRITE_LOW(base, pin) directWriteLow(base, pin) + #define DIRECT_WRITE_HIGH(base, pin) directWriteHigh(base, pin) #else // any unknown architecture, including PC -#include + #include -#define PIN_TO_BASEREG(pin) (0) -#define PIN_TO_BITMASK(pin) (pin) -#define DIRECT_READ(base, pin) digitalRead(pin) -#define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) -#define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) -#define DIRECT_MODE_INPUT(base, pin) pinMode(pin,INPUT) -#define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin,OUTPUT) + #define PIN_TO_BASEREG(pin) (0) + #define PIN_TO_BITMASK(pin) (pin) + #define DIRECT_READ(base, pin) digitalRead(pin) + #define DIRECT_WRITE_LOW(base, pin) digitalWrite(pin, LOW) + #define DIRECT_WRITE_HIGH(base, pin) digitalWrite(pin, HIGH) + #define DIRECT_MODE_INPUT(base, pin) pinMode(pin, INPUT) + #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL {10}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{ + 10}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation -#warning "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture." + #warning \ + "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture." #endif - /////////////////////////////////////////// EXTRA PART ///////////////////////////////////////// // this part is loaded if no proper arduino-environment is found (good for external testing) // these used functions are mockups //////////////////////////////////////////////////////////////////////////////////////////////// #ifndef ARDUINO -#define ONEWIREHUB_FALLBACK_BASIC_FNs -#define ONEWIREHUB_FALLBACK_ADDITIONAL_FNs // to load up Serial below + #define ONEWIREHUB_FALLBACK_BASIC_FNs + #define ONEWIREHUB_FALLBACK_ADDITIONAL_FNs // to load up Serial below #endif #ifdef ARDUINO_attiny -#define ONEWIREHUB_FALLBACK_ADDITIONAL_FNs // to load up Serial below + #define ONEWIREHUB_FALLBACK_ADDITIONAL_FNs // to load up Serial below #endif #ifdef ONEWIREHUB_FALLBACK_BASIC_FNs -#define INPUT 1 -#define INPUT_PULLUP 1 -#define OUTPUT 0 -#define HIGH 1 -#define LOW 0 + #define INPUT 1 + #define INPUT_PULLUP 1 + #define OUTPUT 0 + #define HIGH 1 + #define LOW 0 static bool mockup_pin_value[256]; template -bool digitalRead(const T1 pin) { return (mockup_pin_value[pin & 0xFF] != 0); }; // mock up outputs +bool digitalRead(const T1 pin) +{ + return (mockup_pin_value[pin & 0xFF] != 0); +}; // mock up outputs template -void digitalWrite(const T1 pin, const T2 value) { mockup_pin_value[pin & 0xFF] = value; }; +void digitalWrite(const T1 pin, const T2 value) +{ + mockup_pin_value[pin & 0xFF] = value; +}; template -void pinMode(const T1 pin, const T2 value) { mockup_pin_value[pin & 0xFF] = value; }; +void pinMode(const T1 pin, const T2 value) +{ + mockup_pin_value[pin & 0xFF] = value; +}; template -T1 digitalPinToPort(const T1 pin) { return pin; }; +T1 digitalPinToPort(const T1 pin) +{ + return pin; +}; template -T1 * portInputRegister(const T1 port) { return port; }; +T1 *portInputRegister(const T1 port) +{ + return port; +}; template -T1 digitalPinToBitMask(const T1 pin) { return pin; }; +T1 digitalPinToBitMask(const T1 pin) +{ + return pin; +}; -constexpr uint32_t microsecondsToClockCycles(const uint32_t micros) { return (100*micros); }; // mockup, emulate 100 MHz CPU +constexpr uint32_t microsecondsToClockCycles(const uint32_t micros) +{ + return (100 * micros); +}; // mockup, emulate 100 MHz CPU template -void delayMicroseconds(const T1 micros) { }; +void delayMicroseconds(const T1 micros){}; /// the following fn are no templates and need to be defined in platform.cpp @@ -333,7 +363,7 @@ void noInterrupts(); void interrupts(); template -T1 pgm_read_byte(const T1* address) +T1 pgm_read_byte(const T1 *address) { return *address; } @@ -342,47 +372,42 @@ T1 pgm_read_byte(const T1* address) #ifdef ONEWIREHUB_FALLBACK_ADDITIONAL_FNs // Test to make it work on aTtiny85, 8MHz -/// README: use pin2 or pin3 for Attiny, source: https://github.com/gioblu/PJON/wiki/ATtiny-interfacing + /// README: use pin2 or pin3 for Attiny, source: https://github.com/gioblu/PJON/wiki/ATtiny-interfacing -#ifndef BIN -#define BIN 1 -#endif + #ifndef BIN + #define BIN 1 + #endif -#ifndef HEX -#define HEX 2 -#endif + #ifndef HEX + #define HEX 2 + #endif static class serial { private: - uint32_t speed; public: + void print(...){}; - void print(...) { }; - - void println(...) { }; + void println(...){}; - void flush() { }; + void flush(){}; void begin(const uint32_t speed_baud) { speed = speed_baud; }; } Serial; template -void memset(T1 * const address, const T1 initValue, const T2 bytes) +void memset(T1 *const address, const T1 initValue, const T2 bytes) { const T2 iterations = bytes / sizeof(T1); - for (T2 counter = 0; counter < iterations; ++counter) - { - address[counter] = (initValue); - } + for (T2 counter = 0; counter < iterations; ++counter) { address[counter] = (initValue); } } template -void memcpy(T1 * const destination, const T1* const source, const T2 bytes) +void memcpy(T1 *const destination, const T1 *const source, const T2 bytes) { const T2 iterations = bytes / sizeof(T1); for (T2 counter = 0; counter < iterations; ++counter) @@ -393,7 +418,8 @@ void memcpy(T1 * const destination, const T1* const source, const T2 bytes) template -bool memcmp(const T1* const source_A, const T1* const source_B, const T2 bytes) // return true if string is different +bool memcmp(const T1 *const source_A, const T1 *const source_B, + const T2 bytes) // return true if string is different { const T2 iterations = bytes / sizeof(T1); for (T2 counter = 0; counter < iterations; ++counter) @@ -403,15 +429,15 @@ bool memcmp(const T1* const source_A, const T1* const source_B, const T2 bytes) return false; } -void delay(uint32_t time_millis); -uint32_t millis(void); +void delay(uint32_t time_millis); +uint32_t millis(void); -void wdt_reset(void); -void wdt_enable(...); +void wdt_reset(void); +void wdt_enable(...); -#ifndef PROGMEM -#define PROGMEM -#endif // PROGMEM + #ifndef PROGMEM + #define PROGMEM + #endif // PROGMEM #endif // ONEWIREHUB_FALLBACK_ADDITIONAL_FNs From ba904452f693d3cf5ee3bc149e9c477cd7b3b3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 12:44:51 +0200 Subject: [PATCH 15/29] add documentation skeleton --- .github/workflows/sphinx_to_pages.yml | 35 +++++++++++++++++++++++ README.md | 3 +- docs/Makefile | 20 +++++++++++++ docs/README.md | 15 ++++++++++ docs/make.bat | 35 +++++++++++++++++++++++ docs/source/conf.py | 41 +++++++++++++++++++++++++++ docs/source/index.rst | 19 +++++++++++++ docs/source/robots.txt | 3 ++ 8 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/sphinx_to_pages.yml create mode 100644 docs/Makefile create mode 100644 docs/README.md create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 docs/source/robots.txt diff --git a/.github/workflows/sphinx_to_pages.yml b/.github/workflows/sphinx_to_pages.yml new file mode 100644 index 0000000..770c9c0 --- /dev/null +++ b/.github/workflows/sphinx_to_pages.yml @@ -0,0 +1,35 @@ +name: Generate Docs +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - name: Set up Python 🐍 + uses: actions/setup-python@v4 + - name: Checkout 🛎️ + uses: actions/checkout@v3 + with: + fetch-depth: 0 # otherwise, you will fail to push refs to dest repo + +# - name: Run Pre-Commit Tests 🧪 +# uses: pre-commit/action@v3.0.0 + + - name: Install dependencies 🔧 + run: pipenv shell + + - name: Build Documentation 🧱 + uses: sphinx-notes/pages@v2 + - name: Push changes 📌 + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: pages + force: true diff --git a/README.md b/README.md index 4a946c3..de8ac2a 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ OneWireHub ========== -The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Slaves with support for various devices. The motivation is to offer a shared code base for all OneWire-Slaves. With a small overhead one µC can emulate up to 32 ICs simultaneously. +The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Periphery with support for various devices & sensors. The motivation is to offer a shared code base for all OneWire-Slaves. With a small overhead one µC can emulate up to 32 ICs simultaneously. The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iLib) or SPI interface) and transfer their measurements into one or more emulated ds2438 which have 4x16bit registers for values. This feature removes the limitations of modern house-automation-systems. Add humidity, light and other sensors easy to your home automation environment. [![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) +[![Documentation](https://github.com/orgua/OneWireHub/actions/workflows/sphinx_to_pages.yml/badge.svg)](https://orgua.github.io/OneWireHub/) ### Implemented Slaves diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..0dc5d26 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,15 @@ +# Generate documentations manually + +Install pre-reqs via + +```Shell +pip3 install sphinx sphinxawesome-theme sphinx-sitemap myst-parser +# or use the provided dev-environment +pipenv shell +``` + +Generate docs via + +```Shell +make html +``` diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..dc1312a --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +if "%1" == "" goto help + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..aed6c2d --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,41 @@ +# -- Project information ----------------------------------------------------- + +project = 'OneWireHub' +project_full = "The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Periphery with support for various devices & sensors" +copyright = '2023, Ingmar Splitt' +author = 'Ingmar Splitt' +release = '3.0.0' +builder = "html" + +# -- General configuration --------------------------------------------------- + +extensions = [ + "sphinxawesome_theme", + "sphinx_sitemap", + "myst_parser", +] + +templates_path = ['_templates'] +exclude_patterns = ["build", "Thumbs.db", ".DS_Store"] + +# -- Options for HTML output ------------------------------------------------- + +html_title = project +html_collapsible_definitions = True +html_copy_source = False + +html_permalinks_icon = "#" +html_theme = "sphinxawesome_theme" +html_theme_options = { + "show_scrolltop": True, + "show_prev_next": True, + "extra_header_links": { + "Source": "https://github.com/orgua/OneWireHub", + }, +} +# TODO: https://sphinxawesome.xyz/how-to/options/ +html_baseurl = "https://orgua.github.io/OneWireHub/" +html_extra_path = ["robots.txt"] +html_static_path = ["_static"] + +sitemap_url_scheme = "{link}" diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..93409fd --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,19 @@ +.. OnewireHub documentation main file + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to OnewireHub's documentation! +====================================== + +.. toctree:: + :maxdepth: 2 + :caption: Contents: + + + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` diff --git a/docs/source/robots.txt b/docs/source/robots.txt new file mode 100644 index 0000000..8ecf90c --- /dev/null +++ b/docs/source/robots.txt @@ -0,0 +1,3 @@ +User-agent: * + +Sitemap: https://orgua.github.io/OneWireHub/sitemap.xml From 8fa3b1938da6d1dae5c521137ff6788f7420a0a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 12:45:04 +0200 Subject: [PATCH 16/29] add dev-env --- Pipfile | 16 ++ Pipfile.lock | 498 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 514 insertions(+) create mode 100644 Pipfile create mode 100644 Pipfile.lock diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..37bfdaf --- /dev/null +++ b/Pipfile @@ -0,0 +1,16 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pre-commit = "*" +sphinx = "*" +sphinxawesome-theme = "*" +sphinx-sitemap = "*" +myst-parser = "*" + +[dev-packages] + +[requires] +python_version = "3.11" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..40f9d1b --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,498 @@ +{ + "_meta": { + "hash": { + "sha256": "6110fac66c942db3f9eb60d07efbee27f5c22a1e0f87a79a464388c6cd68aa59" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.11" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "alabaster": { + "hashes": [ + "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3", + "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2" + ], + "markers": "python_version >= '3.6'", + "version": "==0.7.13" + }, + "babel": { + "hashes": [ + "sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610", + "sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455" + ], + "markers": "python_version >= '3.7'", + "version": "==2.12.1" + }, + "beautifulsoup4": { + "hashes": [ + "sha256:492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da", + "sha256:bd2520ca0d9d7d12694a53d44ac482d181b4ec1888909b035a3dbf40d0f57d4a" + ], + "markers": "python_full_version >= '3.6.0'", + "version": "==4.12.2" + }, + "certifi": { + "hashes": [ + "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7", + "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716" + ], + "markers": "python_version >= '3.6'", + "version": "==2023.5.7" + }, + "cfgv": { + "hashes": [ + "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426", + "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==3.3.1" + }, + "charset-normalizer": { + "hashes": [ + "sha256:04e57ab9fbf9607b77f7d057974694b4f6b142da9ed4a199859d9d4d5c63fe96", + "sha256:09393e1b2a9461950b1c9a45d5fd251dc7c6f228acab64da1c9c0165d9c7765c", + "sha256:0b87549028f680ca955556e3bd57013ab47474c3124dc069faa0b6545b6c9710", + "sha256:1000fba1057b92a65daec275aec30586c3de2401ccdcd41f8a5c1e2c87078706", + "sha256:1249cbbf3d3b04902ff081ffbb33ce3377fa6e4c7356f759f3cd076cc138d020", + "sha256:1920d4ff15ce893210c1f0c0e9d19bfbecb7983c76b33f046c13a8ffbd570252", + "sha256:193cbc708ea3aca45e7221ae58f0fd63f933753a9bfb498a3b474878f12caaad", + "sha256:1a100c6d595a7f316f1b6f01d20815d916e75ff98c27a01ae817439ea7726329", + "sha256:1f30b48dd7fa1474554b0b0f3fdfdd4c13b5c737a3c6284d3cdc424ec0ffff3a", + "sha256:203f0c8871d5a7987be20c72442488a0b8cfd0f43b7973771640fc593f56321f", + "sha256:246de67b99b6851627d945db38147d1b209a899311b1305dd84916f2b88526c6", + "sha256:2dee8e57f052ef5353cf608e0b4c871aee320dd1b87d351c28764fc0ca55f9f4", + "sha256:2efb1bd13885392adfda4614c33d3b68dee4921fd0ac1d3988f8cbb7d589e72a", + "sha256:2f4ac36d8e2b4cc1aa71df3dd84ff8efbe3bfb97ac41242fbcfc053c67434f46", + "sha256:3170c9399da12c9dc66366e9d14da8bf7147e1e9d9ea566067bbce7bb74bd9c2", + "sha256:3b1613dd5aee995ec6d4c69f00378bbd07614702a315a2cf6c1d21461fe17c23", + "sha256:3bb3d25a8e6c0aedd251753a79ae98a093c7e7b471faa3aa9a93a81431987ace", + "sha256:3bb7fda7260735efe66d5107fb7e6af6a7c04c7fce9b2514e04b7a74b06bf5dd", + "sha256:41b25eaa7d15909cf3ac4c96088c1f266a9a93ec44f87f1d13d4a0e86c81b982", + "sha256:45de3f87179c1823e6d9e32156fb14c1927fcc9aba21433f088fdfb555b77c10", + "sha256:46fb8c61d794b78ec7134a715a3e564aafc8f6b5e338417cb19fe9f57a5a9bf2", + "sha256:48021783bdf96e3d6de03a6e39a1171ed5bd7e8bb93fc84cc649d11490f87cea", + "sha256:4957669ef390f0e6719db3613ab3a7631e68424604a7b448f079bee145da6e09", + "sha256:5e86d77b090dbddbe78867a0275cb4df08ea195e660f1f7f13435a4649e954e5", + "sha256:6339d047dab2780cc6220f46306628e04d9750f02f983ddb37439ca47ced7149", + "sha256:681eb3d7e02e3c3655d1b16059fbfb605ac464c834a0c629048a30fad2b27489", + "sha256:6c409c0deba34f147f77efaa67b8e4bb83d2f11c8806405f76397ae5b8c0d1c9", + "sha256:7095f6fbfaa55defb6b733cfeb14efaae7a29f0b59d8cf213be4e7ca0b857b80", + "sha256:70c610f6cbe4b9fce272c407dd9d07e33e6bf7b4aa1b7ffb6f6ded8e634e3592", + "sha256:72814c01533f51d68702802d74f77ea026b5ec52793c791e2da806a3844a46c3", + "sha256:7a4826ad2bd6b07ca615c74ab91f32f6c96d08f6fcc3902ceeedaec8cdc3bcd6", + "sha256:7c70087bfee18a42b4040bb9ec1ca15a08242cf5867c58726530bdf3945672ed", + "sha256:855eafa5d5a2034b4621c74925d89c5efef61418570e5ef9b37717d9c796419c", + "sha256:8700f06d0ce6f128de3ccdbc1acaea1ee264d2caa9ca05daaf492fde7c2a7200", + "sha256:89f1b185a01fe560bc8ae5f619e924407efca2191b56ce749ec84982fc59a32a", + "sha256:8b2c760cfc7042b27ebdb4a43a4453bd829a5742503599144d54a032c5dc7e9e", + "sha256:8c2f5e83493748286002f9369f3e6607c565a6a90425a3a1fef5ae32a36d749d", + "sha256:8e098148dd37b4ce3baca71fb394c81dc5d9c7728c95df695d2dca218edf40e6", + "sha256:94aea8eff76ee6d1cdacb07dd2123a68283cb5569e0250feab1240058f53b623", + "sha256:95eb302ff792e12aba9a8b8f8474ab229a83c103d74a750ec0bd1c1eea32e669", + "sha256:9bd9b3b31adcb054116447ea22caa61a285d92e94d710aa5ec97992ff5eb7cf3", + "sha256:9e608aafdb55eb9f255034709e20d5a83b6d60c054df0802fa9c9883d0a937aa", + "sha256:a103b3a7069b62f5d4890ae1b8f0597618f628b286b03d4bc9195230b154bfa9", + "sha256:a386ebe437176aab38c041de1260cd3ea459c6ce5263594399880bbc398225b2", + "sha256:a38856a971c602f98472050165cea2cdc97709240373041b69030be15047691f", + "sha256:a401b4598e5d3f4a9a811f3daf42ee2291790c7f9d74b18d75d6e21dda98a1a1", + "sha256:a7647ebdfb9682b7bb97e2a5e7cb6ae735b1c25008a70b906aecca294ee96cf4", + "sha256:aaf63899c94de41fe3cf934601b0f7ccb6b428c6e4eeb80da72c58eab077b19a", + "sha256:b0dac0ff919ba34d4df1b6131f59ce95b08b9065233446be7e459f95554c0dc8", + "sha256:baacc6aee0b2ef6f3d308e197b5d7a81c0e70b06beae1f1fcacffdbd124fe0e3", + "sha256:bf420121d4c8dce6b889f0e8e4ec0ca34b7f40186203f06a946fa0276ba54029", + "sha256:c04a46716adde8d927adb9457bbe39cf473e1e2c2f5d0a16ceb837e5d841ad4f", + "sha256:c0b21078a4b56965e2b12f247467b234734491897e99c1d51cee628da9786959", + "sha256:c1c76a1743432b4b60ab3358c937a3fe1341c828ae6194108a94c69028247f22", + "sha256:c4983bf937209c57240cff65906b18bb35e64ae872da6a0db937d7b4af845dd7", + "sha256:c4fb39a81950ec280984b3a44f5bd12819953dc5fa3a7e6fa7a80db5ee853952", + "sha256:c57921cda3a80d0f2b8aec7e25c8aa14479ea92b5b51b6876d975d925a2ea346", + "sha256:c8063cf17b19661471ecbdb3df1c84f24ad2e389e326ccaf89e3fb2484d8dd7e", + "sha256:ccd16eb18a849fd8dcb23e23380e2f0a354e8daa0c984b8a732d9cfaba3a776d", + "sha256:cd6dbe0238f7743d0efe563ab46294f54f9bc8f4b9bcf57c3c666cc5bc9d1299", + "sha256:d62e51710986674142526ab9f78663ca2b0726066ae26b78b22e0f5e571238dd", + "sha256:db901e2ac34c931d73054d9797383d0f8009991e723dab15109740a63e7f902a", + "sha256:e03b8895a6990c9ab2cdcd0f2fe44088ca1c65ae592b8f795c3294af00a461c3", + "sha256:e1c8a2f4c69e08e89632defbfabec2feb8a8d99edc9f89ce33c4b9e36ab63037", + "sha256:e4b749b9cc6ee664a3300bb3a273c1ca8068c46be705b6c31cf5d276f8628a94", + "sha256:e6a5bf2cba5ae1bb80b154ed68a3cfa2fa00fde979a7f50d6598d3e17d9ac20c", + "sha256:e857a2232ba53ae940d3456f7533ce6ca98b81917d47adc3c7fd55dad8fab858", + "sha256:ee4006268ed33370957f55bf2e6f4d263eaf4dc3cfc473d1d90baff6ed36ce4a", + "sha256:eef9df1eefada2c09a5e7a40991b9fc6ac6ef20b1372abd48d2794a316dc0449", + "sha256:f058f6963fd82eb143c692cecdc89e075fa0828db2e5b291070485390b2f1c9c", + "sha256:f25c229a6ba38a35ae6e25ca1264621cc25d4d38dca2942a7fce0b67a4efe918", + "sha256:f2a1d0fd4242bd8643ce6f98927cf9c04540af6efa92323e9d3124f57727bfc1", + "sha256:f7560358a6811e52e9c4d142d497f1a6e10103d3a6881f18d04dbce3729c0e2c", + "sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac", + "sha256:f87f746ee241d30d6ed93969de31e5ffd09a2961a051e60ae6bddde9ec3583aa" + ], + "markers": "python_full_version >= '3.7.0'", + "version": "==3.2.0" + }, + "distlib": { + "hashes": [ + "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46", + "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e" + ], + "version": "==0.3.6" + }, + "docutils": { + "hashes": [ + "sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6", + "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b" + ], + "markers": "python_version >= '3.7'", + "version": "==0.20.1" + }, + "filelock": { + "hashes": [ + "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81", + "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec" + ], + "markers": "python_version >= '3.7'", + "version": "==3.12.2" + }, + "identify": { + "hashes": [ + "sha256:0aac67d5b4812498056d28a9a512a483f5085cc28640b02b258a59dac34301d4", + "sha256:986dbfb38b1140e763e413e6feb44cd731faf72d1909543178aa79b0e258265d" + ], + "markers": "python_version >= '3.7'", + "version": "==2.5.24" + }, + "idna": { + "hashes": [ + "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", + "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" + ], + "markers": "python_version >= '3.5'", + "version": "==3.4" + }, + "imagesize": { + "hashes": [ + "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b", + "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.4.1" + }, + "jinja2": { + "hashes": [ + "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852", + "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61" + ], + "markers": "python_version >= '3.7'", + "version": "==3.1.2" + }, + "markdown-it-py": { + "hashes": [ + "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", + "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb" + ], + "markers": "python_version >= '3.8'", + "version": "==3.0.0" + }, + "markupsafe": { + "hashes": [ + "sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e", + "sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e", + "sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431", + "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686", + "sha256:1577735524cdad32f9f694208aa75e422adba74f1baee7551620e43a3141f559", + "sha256:1b40069d487e7edb2676d3fbdb2b0829ffa2cd63a2ec26c4938b2d34391b4ecc", + "sha256:282c2cb35b5b673bbcadb33a585408104df04f14b2d9b01d4c345a3b92861c2c", + "sha256:2c1b19b3aaacc6e57b7e25710ff571c24d6c3613a45e905b1fde04d691b98ee0", + "sha256:2ef12179d3a291be237280175b542c07a36e7f60718296278d8593d21ca937d4", + "sha256:338ae27d6b8745585f87218a3f23f1512dbf52c26c28e322dbe54bcede54ccb9", + "sha256:3c0fae6c3be832a0a0473ac912810b2877c8cb9d76ca48de1ed31e1c68386575", + "sha256:3fd4abcb888d15a94f32b75d8fd18ee162ca0c064f35b11134be77050296d6ba", + "sha256:42de32b22b6b804f42c5d98be4f7e5e977ecdd9ee9b660fda1a3edf03b11792d", + "sha256:504b320cd4b7eff6f968eddf81127112db685e81f7e36e75f9f84f0df46041c3", + "sha256:525808b8019e36eb524b8c68acdd63a37e75714eac50e988180b169d64480a00", + "sha256:56d9f2ecac662ca1611d183feb03a3fa4406469dafe241673d521dd5ae92a155", + "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac", + "sha256:65c1a9bcdadc6c28eecee2c119465aebff8f7a584dd719facdd9e825ec61ab52", + "sha256:68e78619a61ecf91e76aa3e6e8e33fc4894a2bebe93410754bd28fce0a8a4f9f", + "sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8", + "sha256:6b2b56950d93e41f33b4223ead100ea0fe11f8e6ee5f641eb753ce4b77a7042b", + "sha256:787003c0ddb00500e49a10f2844fac87aa6ce977b90b0feaaf9de23c22508b24", + "sha256:7ef3cb2ebbf91e330e3bb937efada0edd9003683db6b57bb108c4001f37a02ea", + "sha256:8023faf4e01efadfa183e863fefde0046de576c6f14659e8782065bcece22198", + "sha256:8758846a7e80910096950b67071243da3e5a20ed2546e6392603c096778d48e0", + "sha256:8afafd99945ead6e075b973fefa56379c5b5c53fd8937dad92c662da5d8fd5ee", + "sha256:8c41976a29d078bb235fea9b2ecd3da465df42a562910f9022f1a03107bd02be", + "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2", + "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707", + "sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6", + "sha256:9dcdfd0eaf283af041973bff14a2e143b8bd64e069f4c383416ecd79a81aab58", + "sha256:aa7bd130efab1c280bed0f45501b7c8795f9fdbeb02e965371bbef3523627779", + "sha256:ab4a0df41e7c16a1392727727e7998a467472d0ad65f3ad5e6e765015df08636", + "sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c", + "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad", + "sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee", + "sha256:b7ff0f54cb4ff66dd38bebd335a38e2c22c41a8ee45aa608efc890ac3e3931bc", + "sha256:bfce63a9e7834b12b87c64d6b155fdd9b3b96191b6bd334bf37db7ff1fe457f2", + "sha256:c011a4149cfbcf9f03994ec2edffcb8b1dc2d2aede7ca243746df97a5d41ce48", + "sha256:c9c804664ebe8f83a211cace637506669e7890fec1b4195b505c214e50dd4eb7", + "sha256:ca379055a47383d02a5400cb0d110cef0a776fc644cda797db0c5696cfd7e18e", + "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b", + "sha256:cd0f502fe016460680cd20aaa5a76d241d6f35a1c3350c474bac1273803893fa", + "sha256:ceb01949af7121f9fc39f7d27f91be8546f3fb112c608bc4029aef0bab86a2a5", + "sha256:d080e0a5eb2529460b30190fcfcc4199bd7f827663f858a226a81bc27beaa97e", + "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb", + "sha256:df0be2b576a7abbf737b1575f048c23fb1d769f267ec4358296f31c2479db8f9", + "sha256:e09031c87a1e51556fdcb46e5bd4f59dfb743061cf93c4d6831bf894f125eb57", + "sha256:e4dd52d80b8c83fdce44e12478ad2e85c64ea965e75d66dbeafb0a3e77308fcc", + "sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2" + ], + "markers": "python_version >= '3.7'", + "version": "==2.1.3" + }, + "mdit-py-plugins": { + "hashes": [ + "sha256:b51b3bb70691f57f974e257e367107857a93b36f322a9e6d44ca5bf28ec2def9", + "sha256:d8ab27e9aed6c38aa716819fedfde15ca275715955f8a185a8e1cf90fb1d2c1b" + ], + "markers": "python_version >= '3.8'", + "version": "==0.4.0" + }, + "mdurl": { + "hashes": [ + "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", + "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" + ], + "markers": "python_version >= '3.7'", + "version": "==0.1.2" + }, + "myst-parser": { + "hashes": [ + "sha256:7c36344ae39c8e740dad7fdabf5aa6fc4897a813083c6cc9990044eb93656b14", + "sha256:ea929a67a6a0b1683cdbe19b8d2e724cd7643f8aa3e7bb18dd65beac3483bead" + ], + "index": "pypi", + "version": "==2.0.0" + }, + "nodeenv": { + "hashes": [ + "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2", + "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'", + "version": "==1.8.0" + }, + "packaging": { + "hashes": [ + "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61", + "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f" + ], + "markers": "python_version >= '3.7'", + "version": "==23.1" + }, + "platformdirs": { + "hashes": [ + "sha256:cec7b889196b9144d088e4c57d9ceef7374f6c39694ad1577a0aab50d27ea28c", + "sha256:f87ca4fcff7d2b0f81c6a748a77973d7af0f4d526f98f308477c3c436c74d528" + ], + "markers": "python_version >= '3.7'", + "version": "==3.8.1" + }, + "pre-commit": { + "hashes": [ + "sha256:10badb65d6a38caff29703362271d7dca483d01da88f9d7e05d0b97171c136cb", + "sha256:a2256f489cd913d575c145132ae196fe335da32d91a8294b7afe6622335dd023" + ], + "index": "pypi", + "version": "==3.3.3" + }, + "pygments": { + "hashes": [ + "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c", + "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1" + ], + "markers": "python_version >= '3.7'", + "version": "==2.15.1" + }, + "python-dotenv": { + "hashes": [ + "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba", + "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a" + ], + "markers": "python_version >= '3.8'", + "version": "==1.0.0" + }, + "pyyaml": { + "hashes": [ + "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf", + "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", + "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b", + "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57", + "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b", + "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4", + "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07", + "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba", + "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9", + "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287", + "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513", + "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0", + "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782", + "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0", + "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92", + "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f", + "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2", + "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc", + "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1", + "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c", + "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86", + "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4", + "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c", + "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34", + "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b", + "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d", + "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c", + "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb", + "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7", + "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737", + "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3", + "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d", + "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358", + "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53", + "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78", + "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803", + "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a", + "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f", + "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", + "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" + ], + "markers": "python_version >= '3.6'", + "version": "==6.0" + }, + "requests": { + "hashes": [ + "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", + "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" + ], + "markers": "python_version >= '3.7'", + "version": "==2.31.0" + }, + "setuptools": { + "hashes": [ + "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f", + "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235" + ], + "markers": "python_version >= '3.7'", + "version": "==68.0.0" + }, + "snowballstemmer": { + "hashes": [ + "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1", + "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a" + ], + "version": "==2.2.0" + }, + "soupsieve": { + "hashes": [ + "sha256:1c1bfee6819544a3447586c889157365a27e10d88cde3ad3da0cf0ddf646feb8", + "sha256:89d12b2d5dfcd2c9e8c22326da9d9aa9cb3dfab0a83a024f05704076ee8d35ea" + ], + "markers": "python_version >= '3.7'", + "version": "==2.4.1" + }, + "sphinx": { + "hashes": [ + "sha256:60c5e04756c1709a98845ed27a2eed7a556af3993afb66e77fec48189f742616", + "sha256:61e025f788c5977d9412587e733733a289e2b9fdc2fef8868ddfbfc4ccfe881d" + ], + "index": "pypi", + "version": "==7.0.1" + }, + "sphinx-sitemap": { + "hashes": [ + "sha256:95101f622d0d594161720cbe92a39d353efae9382f7f3563f06d150b1146fef6", + "sha256:98a7e3bb25acb467037b56f3585fc38d53d5a274542b1497393a66f71b79b125" + ], + "index": "pypi", + "version": "==2.5.0" + }, + "sphinxawesome-theme": { + "hashes": [ + "sha256:827b810ce314adb3146ccbce4787d6a6fa94de6dea7c61ef081a239ba70a1d25", + "sha256:fb6b4ba63583199d6c1d837ffc0fea8d63e4bc3537be9b27c563d82dcf3b25c2" + ], + "index": "pypi", + "version": "==4.1.0" + }, + "sphinxcontrib-applehelp": { + "hashes": [ + "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228", + "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e" + ], + "markers": "python_version >= '3.8'", + "version": "==1.0.4" + }, + "sphinxcontrib-devhelp": { + "hashes": [ + "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e", + "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.2" + }, + "sphinxcontrib-htmlhelp": { + "hashes": [ + "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff", + "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903" + ], + "markers": "python_version >= '3.8'", + "version": "==2.0.1" + }, + "sphinxcontrib-jsmath": { + "hashes": [ + "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", + "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.1" + }, + "sphinxcontrib-qthelp": { + "hashes": [ + "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72", + "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.3" + }, + "sphinxcontrib-serializinghtml": { + "hashes": [ + "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd", + "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952" + ], + "markers": "python_version >= '3.5'", + "version": "==1.1.5" + }, + "urllib3": { + "hashes": [ + "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1", + "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825" + ], + "markers": "python_version >= '3.7'", + "version": "==2.0.3" + }, + "virtualenv": { + "hashes": [ + "sha256:34da10f14fea9be20e0fd7f04aba9732f84e593dac291b757ce42e3368a39419", + "sha256:8ff19a38c1021c742148edc4f81cb43d7f8c6816d2ede2ab72af5b84c749ade1" + ], + "markers": "python_version >= '3.7'", + "version": "==20.23.1" + } + }, + "develop": {} +} From 7a43aa2ca0ef748c48acad64279808b9fa74fac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 13:33:15 +0200 Subject: [PATCH 17/29] replace discriminatory language --- .codespellrc | 2 +- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 98 ++ Pipfile.lock | 979 +++++++++--------- README.md | 74 +- examples/BAE910_device/BAE910_device.ino | 2 +- .../DS18B20_asInterface.ino | 2 +- .../DS18B20_thermometer.ino | 4 +- examples/DS2401_serial/DS2401_serial.ino | 4 +- examples/DS2405_switch/DS2405_switch.ino | 4 +- examples/DS2408_switch/DS2408_switch.ino | 8 +- examples/DS2413_switch/DS2413_switch.ino | 2 +- examples/DS2423_RAM/DS2423_RAM.ino | 2 +- examples/DS2431_EEPROM/DS2431_EEPROM.ino | 4 +- examples/DS2433_EEPROM/DS2433_EEPROM.ino | 2 +- examples/DS2438_battMon/DS2438_battMon.ino | 2 +- examples/DS2450_ADC/DS2450_ADC.ino | 2 +- examples/DS2502_DELLCHG/DS2502_DELLCHG.ino | 12 +- examples/DS2502_EEPROM/DS2502_EEPROM.ino | 4 +- examples/DS2506_EEPROM/DS2506_EEPROM.ino | 2 +- examples/DS2890_poti/DS2890_poti.ino | 2 +- examples/OneWireHubTest/OneWireHubTest.ino | 2 +- .../attiny85-4devices.ino} | 2 +- .../calibrate_by_bus_timing.ino | 2 +- .../optimize_pinAccess/optimize_pinAccess.ino | 2 +- keywords.txt | 2 +- library.json | 5 +- library.properties | 2 +- main.cpp | 13 +- src/BAE910.cpp | 8 +- src/BAE910.h | 2 +- src/DS18B20.cpp | 2 +- src/DS2401.cpp | 2 +- src/DS2405.cpp | 2 +- src/DS2408.cpp | 4 +- src/DS2413.cpp | 2 +- src/DS2413.h | 2 +- src/DS2423.cpp | 2 +- src/DS2430.cpp | 2 +- src/DS2431.cpp | 2 +- src/DS2433.cpp | 2 +- src/DS2434.cpp | 4 +- src/DS2438.cpp | 4 +- src/DS2450.cpp | 6 +- src/DS2502.cpp | 2 +- src/DS2506.cpp | 10 +- src/DS2890.cpp | 4 +- src/OneWireHub.cpp | 180 ++-- src/OneWireHub.h | 42 +- src/OneWireHub_config.h | 19 +- 50 files changed, 823 insertions(+), 723 deletions(-) create mode 100644 CONTRIBUTING.md rename examples/debug/{attiny85-4slaves/attiny85-4slaves.ino => attiny85-4devices/attiny85-4devices.ino} (96%) diff --git a/.codespellrc b/.codespellrc index be8dd00..493f928 100644 --- a/.codespellrc +++ b/.codespellrc @@ -3,7 +3,7 @@ builtin = clear,rare,informal,usage,code,en-GB_to_en-US -ignore-words-list = od,usera,thre,usere +ignore-words-list = od,usera,thre,usere,master # note: use lower-case! # options without argument diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 7738134..d29437c 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -137,5 +137,5 @@ https://www.contributor-covenant.org/translations. ## Example Onewire - naming scheme to use (WIP) - primary: controller, host -- secondary: hub-device, periphery +- secondary: hub-device, periphery, peripheral device - microcontroller running the hub: device-emulator diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..6bbb3c2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,98 @@ +# Welcome to OnewireHubs contributing guide + +Thank you for investing your time in contributing to our project! + +Read our [Code of Conduct](./CODE_OF_CONDUCT.md) to keep our community approachable and respectable. + +In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR. + + +## New contributor guide + +To get an overview of the project, read the [README](README.md). Here are some resources to help you get started with open source contributions: + +- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github) +- [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git) +- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow) +- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests) + + +## Getting started + +To navigate our codebase with confidence, see [the introduction to working in the docs repository](/contributing/working-in-docs-repository.md) :confetti_ball:. For more information on how we write our markdown files, see [the GitHub Markdown reference](contributing/content-markup-reference.md). + +Check to see what [types of contributions](/contributing/types-of-contributions.md) we accept before making changes. Some of them don't even require writing a single line of code :sparkles:. + +### Issues + +#### Create a new issue + +If you spot a problem with the docs, [search if an issue already exists](https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments). If a related issue doesn't exist, you can open a new issue using a relevant [issue form](https://github.com/github/docs/issues/new/choose). + +#### Solve an issue + +Scan through our [existing issues](https://github.com/github/docs/issues) to find one that interests you. You can narrow down the search using `labels` as filters. See [Labels](/contributing/how-to-use-labels.md) for more information. As a general rule, we don’t assign issues to anyone. If you find an issue to work on, you are welcome to open a PR with a fix. + +### Make Changes + +#### Make changes in the UI + +Click **Make a contribution** at the bottom of any docs page to make small changes such as a typo, sentence fix, or a broken link. This takes you to the `.md` file where you can make your changes and [create a pull request](#pull-request) for a review. + + + +#### Make changes in a codespace + +For more information about using a codespace for working on GitHub documentation, see "[Working in a codespace](https://github.com/github/docs/blob/main/contributing/codespace.md)." + +#### Make changes locally + +1. [Install Git LFS](https://docs.github.com/en/github/managing-large-files/versioning-large-files/installing-git-large-file-storage). + +2. Fork the repository. +- Using GitHub Desktop: + - [Getting started with GitHub Desktop](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/getting-started-with-github-desktop) will guide you through setting up Desktop. + - Once Desktop is set up, you can use it to [fork the repo](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/cloning-and-forking-repositories-from-github-desktop)! + +- Using the command line: + - [Fork the repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) so that you can make your changes without affecting the original project until you're ready to merge them. + +3. Install or update to **Node.js v16**. For more information, see [the development guide](contributing/development.md). + +4. Create a working branch and start with your changes! + +### Commit your update + +Commit the changes once you are happy with them. See [Atom's contributing guide](https://github.com/atom/atom/blob/master/CONTRIBUTING.md#git-commit-messages) to know how to use emoji for commit messages. + +Once your changes are ready, don't forget to [self-review](/contributing/self-review.md) to speed up the review process:zap:. + +### Pull Request + +When you're finished with the changes, create a pull request, also known as a PR. +- Fill the "Ready for review" template so that we can review your PR. This template helps reviewers understand your changes as well as the purpose of your pull request. +- Don't forget to [link PR to issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) if you are solving one. +- Enable the checkbox to [allow maintainer edits](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) so the branch can be updated for a merge. + Once you submit your PR, a Docs team member will review your proposal. We may ask questions or request for additional information. +- We may ask for changes to be made before a PR can be merged, either using [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) or pull request comments. You can apply suggested changes directly through the UI. You can make any other changes in your fork, then commit them to your branch. +- As you update your PR and apply changes, mark each conversation as [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations). +- If you run into any merge issues, checkout this [git tutorial](https://github.com/skills/resolve-merge-conflicts) to help you resolve merge conflicts and other issues. + +### Your PR is merged! + +Congratulations :tada::tada: The GitHub team thanks you :sparkles:. + +Once your PR is merged, your contributions will be publicly visible on the [GitHub docs](https://docs.github.com/en). + +Now that you are part of the GitHub docs community, see how else you can [contribute to the docs](/contributing/types-of-contributions.md). + +## Windows + +This site can be developed on Windows, however a few potential gotchas need to be kept in mind: + +1. Regular Expressions: Windows uses `\r\n` for line endings, while Unix based systems use `\n`. Therefore when working on Regular Expressions, use `\r?\n` instead of `\n` in order to support both environments. The Node.js [`os.EOL`](https://nodejs.org/api/os.html#os_os_eol) property can be used to get an OS-specific end-of-line marker. +2. Paths: Windows systems use `\` for the path separator, which would be returned by `path.join` and others. You could use `path.posix`, `path.posix.join` etc and the [slash](https://ghub.io/slash) module, if you need forward slashes - like for constructing URLs - or ensure your code works with either. +3. Bash: Not every Windows developer has a terminal that fully supports Bash, so it's generally preferred to write [scripts](/script) in JavaScript instead of Bash. +4. Filename too long error: There is a 260 character limit for a filename when Git is compiled with `msys`. While the suggestions below are not guaranteed to work and could possibly cause other issues, a few workarounds include: + - Update Git configuration: `git config --system core.longpaths true` + - Consider using a different Git client on Windows diff --git a/Pipfile.lock b/Pipfile.lock index 40f9d1b..2a4e774 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,498 +1,491 @@ { - "_meta": { - "hash": { - "sha256": "6110fac66c942db3f9eb60d07efbee27f5c22a1e0f87a79a464388c6cd68aa59" - }, + "_meta" : { + "hash": {"sha256": "6110fac66c942db3f9eb60d07efbee27f5c22a1e0f87a79a464388c6cd68aa59"}, "pipfile-spec": 6, - "requires": { - "python_version": "3.11" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] + "requires": {"python_version": "3.11"}, + "sources": [{"name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true}] }, - "default": { - "alabaster": { - "hashes": [ - "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3", - "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2" - ], - "markers": "python_version >= '3.6'", - "version": "==0.7.13" - }, - "babel": { - "hashes": [ - "sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610", - "sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455" - ], - "markers": "python_version >= '3.7'", - "version": "==2.12.1" - }, - "beautifulsoup4": { - "hashes": [ - "sha256:492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da", - "sha256:bd2520ca0d9d7d12694a53d44ac482d181b4ec1888909b035a3dbf40d0f57d4a" - ], - "markers": "python_full_version >= '3.6.0'", - "version": "==4.12.2" - }, - "certifi": { - "hashes": [ - "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7", - "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716" - ], - "markers": "python_version >= '3.6'", - "version": "==2023.5.7" - }, - "cfgv": { - "hashes": [ - "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426", - "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736" - ], - "markers": "python_full_version >= '3.6.1'", - "version": "==3.3.1" - }, - "charset-normalizer": { - "hashes": [ - "sha256:04e57ab9fbf9607b77f7d057974694b4f6b142da9ed4a199859d9d4d5c63fe96", - "sha256:09393e1b2a9461950b1c9a45d5fd251dc7c6f228acab64da1c9c0165d9c7765c", - "sha256:0b87549028f680ca955556e3bd57013ab47474c3124dc069faa0b6545b6c9710", - "sha256:1000fba1057b92a65daec275aec30586c3de2401ccdcd41f8a5c1e2c87078706", - "sha256:1249cbbf3d3b04902ff081ffbb33ce3377fa6e4c7356f759f3cd076cc138d020", - "sha256:1920d4ff15ce893210c1f0c0e9d19bfbecb7983c76b33f046c13a8ffbd570252", - "sha256:193cbc708ea3aca45e7221ae58f0fd63f933753a9bfb498a3b474878f12caaad", - "sha256:1a100c6d595a7f316f1b6f01d20815d916e75ff98c27a01ae817439ea7726329", - "sha256:1f30b48dd7fa1474554b0b0f3fdfdd4c13b5c737a3c6284d3cdc424ec0ffff3a", - "sha256:203f0c8871d5a7987be20c72442488a0b8cfd0f43b7973771640fc593f56321f", - "sha256:246de67b99b6851627d945db38147d1b209a899311b1305dd84916f2b88526c6", - "sha256:2dee8e57f052ef5353cf608e0b4c871aee320dd1b87d351c28764fc0ca55f9f4", - "sha256:2efb1bd13885392adfda4614c33d3b68dee4921fd0ac1d3988f8cbb7d589e72a", - "sha256:2f4ac36d8e2b4cc1aa71df3dd84ff8efbe3bfb97ac41242fbcfc053c67434f46", - "sha256:3170c9399da12c9dc66366e9d14da8bf7147e1e9d9ea566067bbce7bb74bd9c2", - "sha256:3b1613dd5aee995ec6d4c69f00378bbd07614702a315a2cf6c1d21461fe17c23", - "sha256:3bb3d25a8e6c0aedd251753a79ae98a093c7e7b471faa3aa9a93a81431987ace", - "sha256:3bb7fda7260735efe66d5107fb7e6af6a7c04c7fce9b2514e04b7a74b06bf5dd", - "sha256:41b25eaa7d15909cf3ac4c96088c1f266a9a93ec44f87f1d13d4a0e86c81b982", - "sha256:45de3f87179c1823e6d9e32156fb14c1927fcc9aba21433f088fdfb555b77c10", - "sha256:46fb8c61d794b78ec7134a715a3e564aafc8f6b5e338417cb19fe9f57a5a9bf2", - "sha256:48021783bdf96e3d6de03a6e39a1171ed5bd7e8bb93fc84cc649d11490f87cea", - "sha256:4957669ef390f0e6719db3613ab3a7631e68424604a7b448f079bee145da6e09", - "sha256:5e86d77b090dbddbe78867a0275cb4df08ea195e660f1f7f13435a4649e954e5", - "sha256:6339d047dab2780cc6220f46306628e04d9750f02f983ddb37439ca47ced7149", - "sha256:681eb3d7e02e3c3655d1b16059fbfb605ac464c834a0c629048a30fad2b27489", - "sha256:6c409c0deba34f147f77efaa67b8e4bb83d2f11c8806405f76397ae5b8c0d1c9", - "sha256:7095f6fbfaa55defb6b733cfeb14efaae7a29f0b59d8cf213be4e7ca0b857b80", - "sha256:70c610f6cbe4b9fce272c407dd9d07e33e6bf7b4aa1b7ffb6f6ded8e634e3592", - "sha256:72814c01533f51d68702802d74f77ea026b5ec52793c791e2da806a3844a46c3", - "sha256:7a4826ad2bd6b07ca615c74ab91f32f6c96d08f6fcc3902ceeedaec8cdc3bcd6", - "sha256:7c70087bfee18a42b4040bb9ec1ca15a08242cf5867c58726530bdf3945672ed", - "sha256:855eafa5d5a2034b4621c74925d89c5efef61418570e5ef9b37717d9c796419c", - "sha256:8700f06d0ce6f128de3ccdbc1acaea1ee264d2caa9ca05daaf492fde7c2a7200", - "sha256:89f1b185a01fe560bc8ae5f619e924407efca2191b56ce749ec84982fc59a32a", - "sha256:8b2c760cfc7042b27ebdb4a43a4453bd829a5742503599144d54a032c5dc7e9e", - "sha256:8c2f5e83493748286002f9369f3e6607c565a6a90425a3a1fef5ae32a36d749d", - "sha256:8e098148dd37b4ce3baca71fb394c81dc5d9c7728c95df695d2dca218edf40e6", - "sha256:94aea8eff76ee6d1cdacb07dd2123a68283cb5569e0250feab1240058f53b623", - "sha256:95eb302ff792e12aba9a8b8f8474ab229a83c103d74a750ec0bd1c1eea32e669", - "sha256:9bd9b3b31adcb054116447ea22caa61a285d92e94d710aa5ec97992ff5eb7cf3", - "sha256:9e608aafdb55eb9f255034709e20d5a83b6d60c054df0802fa9c9883d0a937aa", - "sha256:a103b3a7069b62f5d4890ae1b8f0597618f628b286b03d4bc9195230b154bfa9", - "sha256:a386ebe437176aab38c041de1260cd3ea459c6ce5263594399880bbc398225b2", - "sha256:a38856a971c602f98472050165cea2cdc97709240373041b69030be15047691f", - "sha256:a401b4598e5d3f4a9a811f3daf42ee2291790c7f9d74b18d75d6e21dda98a1a1", - "sha256:a7647ebdfb9682b7bb97e2a5e7cb6ae735b1c25008a70b906aecca294ee96cf4", - "sha256:aaf63899c94de41fe3cf934601b0f7ccb6b428c6e4eeb80da72c58eab077b19a", - "sha256:b0dac0ff919ba34d4df1b6131f59ce95b08b9065233446be7e459f95554c0dc8", - "sha256:baacc6aee0b2ef6f3d308e197b5d7a81c0e70b06beae1f1fcacffdbd124fe0e3", - "sha256:bf420121d4c8dce6b889f0e8e4ec0ca34b7f40186203f06a946fa0276ba54029", - "sha256:c04a46716adde8d927adb9457bbe39cf473e1e2c2f5d0a16ceb837e5d841ad4f", - "sha256:c0b21078a4b56965e2b12f247467b234734491897e99c1d51cee628da9786959", - "sha256:c1c76a1743432b4b60ab3358c937a3fe1341c828ae6194108a94c69028247f22", - "sha256:c4983bf937209c57240cff65906b18bb35e64ae872da6a0db937d7b4af845dd7", - "sha256:c4fb39a81950ec280984b3a44f5bd12819953dc5fa3a7e6fa7a80db5ee853952", - "sha256:c57921cda3a80d0f2b8aec7e25c8aa14479ea92b5b51b6876d975d925a2ea346", - "sha256:c8063cf17b19661471ecbdb3df1c84f24ad2e389e326ccaf89e3fb2484d8dd7e", - "sha256:ccd16eb18a849fd8dcb23e23380e2f0a354e8daa0c984b8a732d9cfaba3a776d", - "sha256:cd6dbe0238f7743d0efe563ab46294f54f9bc8f4b9bcf57c3c666cc5bc9d1299", - "sha256:d62e51710986674142526ab9f78663ca2b0726066ae26b78b22e0f5e571238dd", - "sha256:db901e2ac34c931d73054d9797383d0f8009991e723dab15109740a63e7f902a", - "sha256:e03b8895a6990c9ab2cdcd0f2fe44088ca1c65ae592b8f795c3294af00a461c3", - "sha256:e1c8a2f4c69e08e89632defbfabec2feb8a8d99edc9f89ce33c4b9e36ab63037", - "sha256:e4b749b9cc6ee664a3300bb3a273c1ca8068c46be705b6c31cf5d276f8628a94", - "sha256:e6a5bf2cba5ae1bb80b154ed68a3cfa2fa00fde979a7f50d6598d3e17d9ac20c", - "sha256:e857a2232ba53ae940d3456f7533ce6ca98b81917d47adc3c7fd55dad8fab858", - "sha256:ee4006268ed33370957f55bf2e6f4d263eaf4dc3cfc473d1d90baff6ed36ce4a", - "sha256:eef9df1eefada2c09a5e7a40991b9fc6ac6ef20b1372abd48d2794a316dc0449", - "sha256:f058f6963fd82eb143c692cecdc89e075fa0828db2e5b291070485390b2f1c9c", - "sha256:f25c229a6ba38a35ae6e25ca1264621cc25d4d38dca2942a7fce0b67a4efe918", - "sha256:f2a1d0fd4242bd8643ce6f98927cf9c04540af6efa92323e9d3124f57727bfc1", - "sha256:f7560358a6811e52e9c4d142d497f1a6e10103d3a6881f18d04dbce3729c0e2c", - "sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac", - "sha256:f87f746ee241d30d6ed93969de31e5ffd09a2961a051e60ae6bddde9ec3583aa" - ], - "markers": "python_full_version >= '3.7.0'", - "version": "==3.2.0" - }, - "distlib": { - "hashes": [ - "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46", - "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e" - ], - "version": "==0.3.6" - }, - "docutils": { - "hashes": [ - "sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6", - "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b" - ], - "markers": "python_version >= '3.7'", - "version": "==0.20.1" - }, - "filelock": { - "hashes": [ - "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81", - "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec" - ], - "markers": "python_version >= '3.7'", - "version": "==3.12.2" - }, - "identify": { - "hashes": [ - "sha256:0aac67d5b4812498056d28a9a512a483f5085cc28640b02b258a59dac34301d4", - "sha256:986dbfb38b1140e763e413e6feb44cd731faf72d1909543178aa79b0e258265d" - ], - "markers": "python_version >= '3.7'", - "version": "==2.5.24" - }, - "idna": { - "hashes": [ - "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", - "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" - ], - "markers": "python_version >= '3.5'", - "version": "==3.4" - }, - "imagesize": { - "hashes": [ - "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b", - "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.4.1" - }, - "jinja2": { - "hashes": [ - "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852", - "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61" - ], - "markers": "python_version >= '3.7'", - "version": "==3.1.2" - }, - "markdown-it-py": { - "hashes": [ - "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", - "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb" - ], - "markers": "python_version >= '3.8'", - "version": "==3.0.0" - }, - "markupsafe": { - "hashes": [ - "sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e", - "sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e", - "sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431", - "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686", - "sha256:1577735524cdad32f9f694208aa75e422adba74f1baee7551620e43a3141f559", - "sha256:1b40069d487e7edb2676d3fbdb2b0829ffa2cd63a2ec26c4938b2d34391b4ecc", - "sha256:282c2cb35b5b673bbcadb33a585408104df04f14b2d9b01d4c345a3b92861c2c", - "sha256:2c1b19b3aaacc6e57b7e25710ff571c24d6c3613a45e905b1fde04d691b98ee0", - "sha256:2ef12179d3a291be237280175b542c07a36e7f60718296278d8593d21ca937d4", - "sha256:338ae27d6b8745585f87218a3f23f1512dbf52c26c28e322dbe54bcede54ccb9", - "sha256:3c0fae6c3be832a0a0473ac912810b2877c8cb9d76ca48de1ed31e1c68386575", - "sha256:3fd4abcb888d15a94f32b75d8fd18ee162ca0c064f35b11134be77050296d6ba", - "sha256:42de32b22b6b804f42c5d98be4f7e5e977ecdd9ee9b660fda1a3edf03b11792d", - "sha256:504b320cd4b7eff6f968eddf81127112db685e81f7e36e75f9f84f0df46041c3", - "sha256:525808b8019e36eb524b8c68acdd63a37e75714eac50e988180b169d64480a00", - "sha256:56d9f2ecac662ca1611d183feb03a3fa4406469dafe241673d521dd5ae92a155", - "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac", - "sha256:65c1a9bcdadc6c28eecee2c119465aebff8f7a584dd719facdd9e825ec61ab52", - "sha256:68e78619a61ecf91e76aa3e6e8e33fc4894a2bebe93410754bd28fce0a8a4f9f", - "sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8", - "sha256:6b2b56950d93e41f33b4223ead100ea0fe11f8e6ee5f641eb753ce4b77a7042b", - "sha256:787003c0ddb00500e49a10f2844fac87aa6ce977b90b0feaaf9de23c22508b24", - "sha256:7ef3cb2ebbf91e330e3bb937efada0edd9003683db6b57bb108c4001f37a02ea", - "sha256:8023faf4e01efadfa183e863fefde0046de576c6f14659e8782065bcece22198", - "sha256:8758846a7e80910096950b67071243da3e5a20ed2546e6392603c096778d48e0", - "sha256:8afafd99945ead6e075b973fefa56379c5b5c53fd8937dad92c662da5d8fd5ee", - "sha256:8c41976a29d078bb235fea9b2ecd3da465df42a562910f9022f1a03107bd02be", - "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2", - "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707", - "sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6", - "sha256:9dcdfd0eaf283af041973bff14a2e143b8bd64e069f4c383416ecd79a81aab58", - "sha256:aa7bd130efab1c280bed0f45501b7c8795f9fdbeb02e965371bbef3523627779", - "sha256:ab4a0df41e7c16a1392727727e7998a467472d0ad65f3ad5e6e765015df08636", - "sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c", - "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad", - "sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee", - "sha256:b7ff0f54cb4ff66dd38bebd335a38e2c22c41a8ee45aa608efc890ac3e3931bc", - "sha256:bfce63a9e7834b12b87c64d6b155fdd9b3b96191b6bd334bf37db7ff1fe457f2", - "sha256:c011a4149cfbcf9f03994ec2edffcb8b1dc2d2aede7ca243746df97a5d41ce48", - "sha256:c9c804664ebe8f83a211cace637506669e7890fec1b4195b505c214e50dd4eb7", - "sha256:ca379055a47383d02a5400cb0d110cef0a776fc644cda797db0c5696cfd7e18e", - "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b", - "sha256:cd0f502fe016460680cd20aaa5a76d241d6f35a1c3350c474bac1273803893fa", - "sha256:ceb01949af7121f9fc39f7d27f91be8546f3fb112c608bc4029aef0bab86a2a5", - "sha256:d080e0a5eb2529460b30190fcfcc4199bd7f827663f858a226a81bc27beaa97e", - "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb", - "sha256:df0be2b576a7abbf737b1575f048c23fb1d769f267ec4358296f31c2479db8f9", - "sha256:e09031c87a1e51556fdcb46e5bd4f59dfb743061cf93c4d6831bf894f125eb57", - "sha256:e4dd52d80b8c83fdce44e12478ad2e85c64ea965e75d66dbeafb0a3e77308fcc", - "sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2" - ], - "markers": "python_version >= '3.7'", - "version": "==2.1.3" - }, - "mdit-py-plugins": { - "hashes": [ - "sha256:b51b3bb70691f57f974e257e367107857a93b36f322a9e6d44ca5bf28ec2def9", - "sha256:d8ab27e9aed6c38aa716819fedfde15ca275715955f8a185a8e1cf90fb1d2c1b" - ], - "markers": "python_version >= '3.8'", - "version": "==0.4.0" - }, - "mdurl": { - "hashes": [ - "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", - "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" - ], - "markers": "python_version >= '3.7'", - "version": "==0.1.2" - }, - "myst-parser": { - "hashes": [ - "sha256:7c36344ae39c8e740dad7fdabf5aa6fc4897a813083c6cc9990044eb93656b14", - "sha256:ea929a67a6a0b1683cdbe19b8d2e724cd7643f8aa3e7bb18dd65beac3483bead" - ], - "index": "pypi", - "version": "==2.0.0" - }, - "nodeenv": { - "hashes": [ - "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2", - "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6'", - "version": "==1.8.0" - }, - "packaging": { - "hashes": [ - "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61", - "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f" - ], - "markers": "python_version >= '3.7'", - "version": "==23.1" - }, - "platformdirs": { - "hashes": [ - "sha256:cec7b889196b9144d088e4c57d9ceef7374f6c39694ad1577a0aab50d27ea28c", - "sha256:f87ca4fcff7d2b0f81c6a748a77973d7af0f4d526f98f308477c3c436c74d528" - ], - "markers": "python_version >= '3.7'", - "version": "==3.8.1" - }, - "pre-commit": { - "hashes": [ - "sha256:10badb65d6a38caff29703362271d7dca483d01da88f9d7e05d0b97171c136cb", - "sha256:a2256f489cd913d575c145132ae196fe335da32d91a8294b7afe6622335dd023" - ], - "index": "pypi", - "version": "==3.3.3" - }, - "pygments": { - "hashes": [ - "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c", - "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1" - ], - "markers": "python_version >= '3.7'", - "version": "==2.15.1" - }, - "python-dotenv": { - "hashes": [ - "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba", - "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a" - ], - "markers": "python_version >= '3.8'", - "version": "==1.0.0" - }, - "pyyaml": { - "hashes": [ - "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf", - "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", - "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b", - "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57", - "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b", - "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4", - "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07", - "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba", - "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9", - "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287", - "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513", - "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0", - "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782", - "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0", - "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92", - "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f", - "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2", - "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc", - "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1", - "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c", - "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86", - "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4", - "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c", - "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34", - "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b", - "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d", - "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c", - "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb", - "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7", - "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737", - "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3", - "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d", - "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358", - "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53", - "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78", - "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803", - "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a", - "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f", - "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", - "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" - ], - "markers": "python_version >= '3.6'", - "version": "==6.0" - }, - "requests": { - "hashes": [ - "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", - "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" - ], - "markers": "python_version >= '3.7'", - "version": "==2.31.0" - }, - "setuptools": { - "hashes": [ - "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f", - "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235" - ], - "markers": "python_version >= '3.7'", - "version": "==68.0.0" - }, - "snowballstemmer": { - "hashes": [ - "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1", - "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a" - ], - "version": "==2.2.0" - }, - "soupsieve": { - "hashes": [ - "sha256:1c1bfee6819544a3447586c889157365a27e10d88cde3ad3da0cf0ddf646feb8", - "sha256:89d12b2d5dfcd2c9e8c22326da9d9aa9cb3dfab0a83a024f05704076ee8d35ea" - ], - "markers": "python_version >= '3.7'", - "version": "==2.4.1" - }, - "sphinx": { - "hashes": [ - "sha256:60c5e04756c1709a98845ed27a2eed7a556af3993afb66e77fec48189f742616", - "sha256:61e025f788c5977d9412587e733733a289e2b9fdc2fef8868ddfbfc4ccfe881d" - ], - "index": "pypi", - "version": "==7.0.1" - }, - "sphinx-sitemap": { - "hashes": [ - "sha256:95101f622d0d594161720cbe92a39d353efae9382f7f3563f06d150b1146fef6", - "sha256:98a7e3bb25acb467037b56f3585fc38d53d5a274542b1497393a66f71b79b125" - ], - "index": "pypi", - "version": "==2.5.0" - }, - "sphinxawesome-theme": { - "hashes": [ - "sha256:827b810ce314adb3146ccbce4787d6a6fa94de6dea7c61ef081a239ba70a1d25", - "sha256:fb6b4ba63583199d6c1d837ffc0fea8d63e4bc3537be9b27c563d82dcf3b25c2" - ], - "index": "pypi", - "version": "==4.1.0" - }, - "sphinxcontrib-applehelp": { - "hashes": [ - "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228", - "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e" - ], - "markers": "python_version >= '3.8'", - "version": "==1.0.4" - }, - "sphinxcontrib-devhelp": { - "hashes": [ - "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e", - "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4" - ], - "markers": "python_version >= '3.5'", - "version": "==1.0.2" - }, - "sphinxcontrib-htmlhelp": { - "hashes": [ - "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff", - "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903" - ], - "markers": "python_version >= '3.8'", - "version": "==2.0.1" - }, - "sphinxcontrib-jsmath": { - "hashes": [ - "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", - "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" - ], - "markers": "python_version >= '3.5'", - "version": "==1.0.1" - }, - "sphinxcontrib-qthelp": { - "hashes": [ - "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72", - "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6" - ], - "markers": "python_version >= '3.5'", - "version": "==1.0.3" - }, - "sphinxcontrib-serializinghtml": { - "hashes": [ - "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd", - "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952" - ], - "markers": "python_version >= '3.5'", - "version": "==1.1.5" - }, - "urllib3": { - "hashes": [ - "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1", - "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825" - ], - "markers": "python_version >= '3.7'", - "version": "==2.0.3" + "default" + : { + "alabaster": { + "hashes": [ + "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3", + "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2" + ], + "markers": "python_version >= '3.6'", + "version": "==0.7.13" + }, + "babel": { + "hashes": [ + "sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610", + "sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455" + ], + "markers": "python_version >= '3.7'", + "version": "==2.12.1" + }, + "beautifulsoup4": { + "hashes": [ + "sha256:492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da", + "sha256:bd2520ca0d9d7d12694a53d44ac482d181b4ec1888909b035a3dbf40d0f57d4a" + ], + "markers": "python_full_version >= '3.6.0'", + "version": "==4.12.2" + }, + "certifi": { + "hashes": [ + "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7", + "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716" + ], + "markers": "python_version >= '3.6'", + "version": "==2023.5.7" + }, + "cfgv": { + "hashes": [ + "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426", + "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==3.3.1" + }, + "charset-normalizer": { + "hashes": [ + "sha256:04e57ab9fbf9607b77f7d057974694b4f6b142da9ed4a199859d9d4d5c63fe96", + "sha256:09393e1b2a9461950b1c9a45d5fd251dc7c6f228acab64da1c9c0165d9c7765c", + "sha256:0b87549028f680ca955556e3bd57013ab47474c3124dc069faa0b6545b6c9710", + "sha256:1000fba1057b92a65daec275aec30586c3de2401ccdcd41f8a5c1e2c87078706", + "sha256:1249cbbf3d3b04902ff081ffbb33ce3377fa6e4c7356f759f3cd076cc138d020", + "sha256:1920d4ff15ce893210c1f0c0e9d19bfbecb7983c76b33f046c13a8ffbd570252", + "sha256:193cbc708ea3aca45e7221ae58f0fd63f933753a9bfb498a3b474878f12caaad", + "sha256:1a100c6d595a7f316f1b6f01d20815d916e75ff98c27a01ae817439ea7726329", + "sha256:1f30b48dd7fa1474554b0b0f3fdfdd4c13b5c737a3c6284d3cdc424ec0ffff3a", + "sha256:203f0c8871d5a7987be20c72442488a0b8cfd0f43b7973771640fc593f56321f", + "sha256:246de67b99b6851627d945db38147d1b209a899311b1305dd84916f2b88526c6", + "sha256:2dee8e57f052ef5353cf608e0b4c871aee320dd1b87d351c28764fc0ca55f9f4", + "sha256:2efb1bd13885392adfda4614c33d3b68dee4921fd0ac1d3988f8cbb7d589e72a", + "sha256:2f4ac36d8e2b4cc1aa71df3dd84ff8efbe3bfb97ac41242fbcfc053c67434f46", + "sha256:3170c9399da12c9dc66366e9d14da8bf7147e1e9d9ea566067bbce7bb74bd9c2", + "sha256:3b1613dd5aee995ec6d4c69f00378bbd07614702a315a2cf6c1d21461fe17c23", + "sha256:3bb3d25a8e6c0aedd251753a79ae98a093c7e7b471faa3aa9a93a81431987ace", + "sha256:3bb7fda7260735efe66d5107fb7e6af6a7c04c7fce9b2514e04b7a74b06bf5dd", + "sha256:41b25eaa7d15909cf3ac4c96088c1f266a9a93ec44f87f1d13d4a0e86c81b982", + "sha256:45de3f87179c1823e6d9e32156fb14c1927fcc9aba21433f088fdfb555b77c10", + "sha256:46fb8c61d794b78ec7134a715a3e564aafc8f6b5e338417cb19fe9f57a5a9bf2", + "sha256:48021783bdf96e3d6de03a6e39a1171ed5bd7e8bb93fc84cc649d11490f87cea", + "sha256:4957669ef390f0e6719db3613ab3a7631e68424604a7b448f079bee145da6e09", + "sha256:5e86d77b090dbddbe78867a0275cb4df08ea195e660f1f7f13435a4649e954e5", + "sha256:6339d047dab2780cc6220f46306628e04d9750f02f983ddb37439ca47ced7149", + "sha256:681eb3d7e02e3c3655d1b16059fbfb605ac464c834a0c629048a30fad2b27489", + "sha256:6c409c0deba34f147f77efaa67b8e4bb83d2f11c8806405f76397ae5b8c0d1c9", + "sha256:7095f6fbfaa55defb6b733cfeb14efaae7a29f0b59d8cf213be4e7ca0b857b80", + "sha256:70c610f6cbe4b9fce272c407dd9d07e33e6bf7b4aa1b7ffb6f6ded8e634e3592", + "sha256:72814c01533f51d68702802d74f77ea026b5ec52793c791e2da806a3844a46c3", + "sha256:7a4826ad2bd6b07ca615c74ab91f32f6c96d08f6fcc3902ceeedaec8cdc3bcd6", + "sha256:7c70087bfee18a42b4040bb9ec1ca15a08242cf5867c58726530bdf3945672ed", + "sha256:855eafa5d5a2034b4621c74925d89c5efef61418570e5ef9b37717d9c796419c", + "sha256:8700f06d0ce6f128de3ccdbc1acaea1ee264d2caa9ca05daaf492fde7c2a7200", + "sha256:89f1b185a01fe560bc8ae5f619e924407efca2191b56ce749ec84982fc59a32a", + "sha256:8b2c760cfc7042b27ebdb4a43a4453bd829a5742503599144d54a032c5dc7e9e", + "sha256:8c2f5e83493748286002f9369f3e6607c565a6a90425a3a1fef5ae32a36d749d", + "sha256:8e098148dd37b4ce3baca71fb394c81dc5d9c7728c95df695d2dca218edf40e6", + "sha256:94aea8eff76ee6d1cdacb07dd2123a68283cb5569e0250feab1240058f53b623", + "sha256:95eb302ff792e12aba9a8b8f8474ab229a83c103d74a750ec0bd1c1eea32e669", + "sha256:9bd9b3b31adcb054116447ea22caa61a285d92e94d710aa5ec97992ff5eb7cf3", + "sha256:9e608aafdb55eb9f255034709e20d5a83b6d60c054df0802fa9c9883d0a937aa", + "sha256:a103b3a7069b62f5d4890ae1b8f0597618f628b286b03d4bc9195230b154bfa9", + "sha256:a386ebe437176aab38c041de1260cd3ea459c6ce5263594399880bbc398225b2", + "sha256:a38856a971c602f98472050165cea2cdc97709240373041b69030be15047691f", + "sha256:a401b4598e5d3f4a9a811f3daf42ee2291790c7f9d74b18d75d6e21dda98a1a1", + "sha256:a7647ebdfb9682b7bb97e2a5e7cb6ae735b1c25008a70b906aecca294ee96cf4", + "sha256:aaf63899c94de41fe3cf934601b0f7ccb6b428c6e4eeb80da72c58eab077b19a", + "sha256:b0dac0ff919ba34d4df1b6131f59ce95b08b9065233446be7e459f95554c0dc8", + "sha256:baacc6aee0b2ef6f3d308e197b5d7a81c0e70b06beae1f1fcacffdbd124fe0e3", + "sha256:bf420121d4c8dce6b889f0e8e4ec0ca34b7f40186203f06a946fa0276ba54029", + "sha256:c04a46716adde8d927adb9457bbe39cf473e1e2c2f5d0a16ceb837e5d841ad4f", + "sha256:c0b21078a4b56965e2b12f247467b234734491897e99c1d51cee628da9786959", + "sha256:c1c76a1743432b4b60ab3358c937a3fe1341c828ae6194108a94c69028247f22", + "sha256:c4983bf937209c57240cff65906b18bb35e64ae872da6a0db937d7b4af845dd7", + "sha256:c4fb39a81950ec280984b3a44f5bd12819953dc5fa3a7e6fa7a80db5ee853952", + "sha256:c57921cda3a80d0f2b8aec7e25c8aa14479ea92b5b51b6876d975d925a2ea346", + "sha256:c8063cf17b19661471ecbdb3df1c84f24ad2e389e326ccaf89e3fb2484d8dd7e", + "sha256:ccd16eb18a849fd8dcb23e23380e2f0a354e8daa0c984b8a732d9cfaba3a776d", + "sha256:cd6dbe0238f7743d0efe563ab46294f54f9bc8f4b9bcf57c3c666cc5bc9d1299", + "sha256:d62e51710986674142526ab9f78663ca2b0726066ae26b78b22e0f5e571238dd", + "sha256:db901e2ac34c931d73054d9797383d0f8009991e723dab15109740a63e7f902a", + "sha256:e03b8895a6990c9ab2cdcd0f2fe44088ca1c65ae592b8f795c3294af00a461c3", + "sha256:e1c8a2f4c69e08e89632defbfabec2feb8a8d99edc9f89ce33c4b9e36ab63037", + "sha256:e4b749b9cc6ee664a3300bb3a273c1ca8068c46be705b6c31cf5d276f8628a94", + "sha256:e6a5bf2cba5ae1bb80b154ed68a3cfa2fa00fde979a7f50d6598d3e17d9ac20c", + "sha256:e857a2232ba53ae940d3456f7533ce6ca98b81917d47adc3c7fd55dad8fab858", + "sha256:ee4006268ed33370957f55bf2e6f4d263eaf4dc3cfc473d1d90baff6ed36ce4a", + "sha256:eef9df1eefada2c09a5e7a40991b9fc6ac6ef20b1372abd48d2794a316dc0449", + "sha256:f058f6963fd82eb143c692cecdc89e075fa0828db2e5b291070485390b2f1c9c", + "sha256:f25c229a6ba38a35ae6e25ca1264621cc25d4d38dca2942a7fce0b67a4efe918", + "sha256:f2a1d0fd4242bd8643ce6f98927cf9c04540af6efa92323e9d3124f57727bfc1", + "sha256:f7560358a6811e52e9c4d142d497f1a6e10103d3a6881f18d04dbce3729c0e2c", + "sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac", + "sha256:f87f746ee241d30d6ed93969de31e5ffd09a2961a051e60ae6bddde9ec3583aa" + ], + "markers": "python_full_version >= '3.7.0'", + "version": "==3.2.0" + }, + "distlib": { + "hashes": [ + "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46", + "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e" + ], + "version": "==0.3.6" + }, + "docutils": { + "hashes": [ + "sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6", + "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b" + ], + "markers": "python_version >= '3.7'", + "version": "==0.20.1" + }, + "filelock": { + "hashes": [ + "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81", + "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec" + ], + "markers": "python_version >= '3.7'", + "version": "==3.12.2" + }, + "identify": { + "hashes": [ + "sha256:0aac67d5b4812498056d28a9a512a483f5085cc28640b02b258a59dac34301d4", + "sha256:986dbfb38b1140e763e413e6feb44cd731faf72d1909543178aa79b0e258265d" + ], + "markers": "python_version >= '3.7'", + "version": "==2.5.24" + }, + "idna": { + "hashes": [ + "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", + "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" + ], + "markers": "python_version >= '3.5'", + "version": "==3.4" + }, + "imagesize": { + "hashes": [ + "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b", + "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.4.1" + }, + "jinja2": { + "hashes": [ + "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852", + "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61" + ], + "markers": "python_version >= '3.7'", + "version": "==3.1.2" + }, + "markdown-it-py": { + "hashes": [ + "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", + "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb" + ], + "markers": "python_version >= '3.8'", + "version": "==3.0.0" + }, + "markupsafe": { + "hashes": [ + "sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e", + "sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e", + "sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431", + "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686", + "sha256:1577735524cdad32f9f694208aa75e422adba74f1baee7551620e43a3141f559", + "sha256:1b40069d487e7edb2676d3fbdb2b0829ffa2cd63a2ec26c4938b2d34391b4ecc", + "sha256:282c2cb35b5b673bbcadb33a585408104df04f14b2d9b01d4c345a3b92861c2c", + "sha256:2c1b19b3aaacc6e57b7e25710ff571c24d6c3613a45e905b1fde04d691b98ee0", + "sha256:2ef12179d3a291be237280175b542c07a36e7f60718296278d8593d21ca937d4", + "sha256:338ae27d6b8745585f87218a3f23f1512dbf52c26c28e322dbe54bcede54ccb9", + "sha256:3c0fae6c3be832a0a0473ac912810b2877c8cb9d76ca48de1ed31e1c68386575", + "sha256:3fd4abcb888d15a94f32b75d8fd18ee162ca0c064f35b11134be77050296d6ba", + "sha256:42de32b22b6b804f42c5d98be4f7e5e977ecdd9ee9b660fda1a3edf03b11792d", + "sha256:504b320cd4b7eff6f968eddf81127112db685e81f7e36e75f9f84f0df46041c3", + "sha256:525808b8019e36eb524b8c68acdd63a37e75714eac50e988180b169d64480a00", + "sha256:56d9f2ecac662ca1611d183feb03a3fa4406469dafe241673d521dd5ae92a155", + "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac", + "sha256:65c1a9bcdadc6c28eecee2c119465aebff8f7a584dd719facdd9e825ec61ab52", + "sha256:68e78619a61ecf91e76aa3e6e8e33fc4894a2bebe93410754bd28fce0a8a4f9f", + "sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8", + "sha256:6b2b56950d93e41f33b4223ead100ea0fe11f8e6ee5f641eb753ce4b77a7042b", + "sha256:787003c0ddb00500e49a10f2844fac87aa6ce977b90b0feaaf9de23c22508b24", + "sha256:7ef3cb2ebbf91e330e3bb937efada0edd9003683db6b57bb108c4001f37a02ea", + "sha256:8023faf4e01efadfa183e863fefde0046de576c6f14659e8782065bcece22198", + "sha256:8758846a7e80910096950b67071243da3e5a20ed2546e6392603c096778d48e0", + "sha256:8afafd99945ead6e075b973fefa56379c5b5c53fd8937dad92c662da5d8fd5ee", + "sha256:8c41976a29d078bb235fea9b2ecd3da465df42a562910f9022f1a03107bd02be", + "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2", + "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707", + "sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6", + "sha256:9dcdfd0eaf283af041973bff14a2e143b8bd64e069f4c383416ecd79a81aab58", + "sha256:aa7bd130efab1c280bed0f45501b7c8795f9fdbeb02e965371bbef3523627779", + "sha256:ab4a0df41e7c16a1392727727e7998a467472d0ad65f3ad5e6e765015df08636", + "sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c", + "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad", + "sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee", + "sha256:b7ff0f54cb4ff66dd38bebd335a38e2c22c41a8ee45aa608efc890ac3e3931bc", + "sha256:bfce63a9e7834b12b87c64d6b155fdd9b3b96191b6bd334bf37db7ff1fe457f2", + "sha256:c011a4149cfbcf9f03994ec2edffcb8b1dc2d2aede7ca243746df97a5d41ce48", + "sha256:c9c804664ebe8f83a211cace637506669e7890fec1b4195b505c214e50dd4eb7", + "sha256:ca379055a47383d02a5400cb0d110cef0a776fc644cda797db0c5696cfd7e18e", + "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b", + "sha256:cd0f502fe016460680cd20aaa5a76d241d6f35a1c3350c474bac1273803893fa", + "sha256:ceb01949af7121f9fc39f7d27f91be8546f3fb112c608bc4029aef0bab86a2a5", + "sha256:d080e0a5eb2529460b30190fcfcc4199bd7f827663f858a226a81bc27beaa97e", + "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb", + "sha256:df0be2b576a7abbf737b1575f048c23fb1d769f267ec4358296f31c2479db8f9", + "sha256:e09031c87a1e51556fdcb46e5bd4f59dfb743061cf93c4d6831bf894f125eb57", + "sha256:e4dd52d80b8c83fdce44e12478ad2e85c64ea965e75d66dbeafb0a3e77308fcc", + "sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2" + ], + "markers": "python_version >= '3.7'", + "version": "==2.1.3" + }, + "mdit-py-plugins": { + "hashes": [ + "sha256:b51b3bb70691f57f974e257e367107857a93b36f322a9e6d44ca5bf28ec2def9", + "sha256:d8ab27e9aed6c38aa716819fedfde15ca275715955f8a185a8e1cf90fb1d2c1b" + ], + "markers": "python_version >= '3.8'", + "version": "==0.4.0" + }, + "mdurl": { + "hashes": [ + "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", + "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" + ], + "markers": "python_version >= '3.7'", + "version": "==0.1.2" + }, + "myst-parser": { + "hashes": [ + "sha256:7c36344ae39c8e740dad7fdabf5aa6fc4897a813083c6cc9990044eb93656b14", + "sha256:ea929a67a6a0b1683cdbe19b8d2e724cd7643f8aa3e7bb18dd65beac3483bead" + ], + "index": "pypi", + "version": "==2.0.0" + }, + "nodeenv": { + "hashes": [ + "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2", + "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, " + "3.4, 3.5, 3.6'", + "version": "==1.8.0" + }, + "packaging": { + "hashes": [ + "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61", + "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f" + ], + "markers": "python_version >= '3.7'", + "version": "==23.1" + }, + "platformdirs": { + "hashes": [ + "sha256:cec7b889196b9144d088e4c57d9ceef7374f6c39694ad1577a0aab50d27ea28c", + "sha256:f87ca4fcff7d2b0f81c6a748a77973d7af0f4d526f98f308477c3c436c74d528" + ], + "markers": "python_version >= '3.7'", + "version": "==3.8.1" + }, + "pre-commit": { + "hashes": [ + "sha256:10badb65d6a38caff29703362271d7dca483d01da88f9d7e05d0b97171c136cb", + "sha256:a2256f489cd913d575c145132ae196fe335da32d91a8294b7afe6622335dd023" + ], + "index": "pypi", + "version": "==3.3.3" + }, + "pygments": { + "hashes": [ + "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c", + "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1" + ], + "markers": "python_version >= '3.7'", + "version": "==2.15.1" + }, + "python-dotenv": { + "hashes": [ + "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba", + "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a" + ], + "markers": "python_version >= '3.8'", + "version": "==1.0.0" + }, + "pyyaml": { + "hashes": [ + "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf", + "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", + "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b", + "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57", + "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b", + "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4", + "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07", + "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba", + "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9", + "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287", + "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513", + "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0", + "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782", + "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0", + "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92", + "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f", + "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2", + "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc", + "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1", + "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c", + "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86", + "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4", + "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c", + "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34", + "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b", + "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d", + "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c", + "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb", + "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7", + "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737", + "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3", + "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d", + "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358", + "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53", + "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78", + "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803", + "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a", + "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f", + "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", + "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" + ], + "markers": "python_version >= '3.6'", + "version": "==6.0" + }, + "requests": { + "hashes": [ + "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", + "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" + ], + "markers": "python_version >= '3.7'", + "version": "==2.31.0" + }, + "setuptools": { + "hashes": [ + "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f", + "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235" + ], + "markers": "python_version >= '3.7'", + "version": "==68.0.0" + }, + "snowballstemmer": { + "hashes": [ + "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1", + "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a" + ], + "version": "==2.2.0" + }, + "soupsieve": { + "hashes": [ + "sha256:1c1bfee6819544a3447586c889157365a27e10d88cde3ad3da0cf0ddf646feb8", + "sha256:89d12b2d5dfcd2c9e8c22326da9d9aa9cb3dfab0a83a024f05704076ee8d35ea" + ], + "markers": "python_version >= '3.7'", + "version": "==2.4.1" + }, + "sphinx": { + "hashes": [ + "sha256:60c5e04756c1709a98845ed27a2eed7a556af3993afb66e77fec48189f742616", + "sha256:61e025f788c5977d9412587e733733a289e2b9fdc2fef8868ddfbfc4ccfe881d" + ], + "index": "pypi", + "version": "==7.0.1" + }, + "sphinx-sitemap": { + "hashes": [ + "sha256:95101f622d0d594161720cbe92a39d353efae9382f7f3563f06d150b1146fef6", + "sha256:98a7e3bb25acb467037b56f3585fc38d53d5a274542b1497393a66f71b79b125" + ], + "index": "pypi", + "version": "==2.5.0" + }, + "sphinxawesome-theme": { + "hashes": [ + "sha256:827b810ce314adb3146ccbce4787d6a6fa94de6dea7c61ef081a239ba70a1d25", + "sha256:fb6b4ba63583199d6c1d837ffc0fea8d63e4bc3537be9b27c563d82dcf3b25c2" + ], + "index": "pypi", + "version": "==4.1.0" + }, + "sphinxcontrib-applehelp": { + "hashes": [ + "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228", + "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e" + ], + "markers": "python_version >= '3.8'", + "version": "==1.0.4" + }, + "sphinxcontrib-devhelp": { + "hashes": [ + "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e", + "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.2" + }, + "sphinxcontrib-htmlhelp": { + "hashes": [ + "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff", + "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903" + ], + "markers": "python_version >= '3.8'", + "version": "==2.0.1" + }, + "sphinxcontrib-jsmath": { + "hashes": [ + "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", + "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.1" + }, + "sphinxcontrib-qthelp": { + "hashes": [ + "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72", + "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.3" + }, + "sphinxcontrib-serializinghtml": { + "hashes": [ + "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd", + "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952" + ], + "markers": "python_version >= '3.5'", + "version": "==1.1.5" + }, + "urllib3": { + "hashes": [ + "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1", + "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825" + ], + "markers": "python_version >= '3.7'", + "version": "==2.0.3" + }, + "virtualenv": { + "hashes": [ + "sha256:34da10f14fea9be20e0fd7f04aba9732f84e593dac291b757ce42e3368a39419", + "sha256:8ff19a38c1021c742148edc4f81cb43d7f8c6816d2ede2ab72af5b84c749ade1" + ], + "markers": "python_version >= '3.7'", + "version": "==20.23.1" + } }, - "virtualenv": { - "hashes": [ - "sha256:34da10f14fea9be20e0fd7f04aba9732f84e593dac291b757ce42e3368a39419", - "sha256:8ff19a38c1021c742148edc4f81cb43d7f8c6816d2ede2ab72af5b84c749ade1" - ], - "markers": "python_version >= '3.7'", - "version": "==20.23.1" - } - }, - "develop": {} + "develop": + {} } diff --git a/README.md b/README.md index de8ac2a..626da95 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,19 @@ OneWireHub ========== -The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Periphery with support for various devices & sensors. The motivation is to offer a shared code base for all OneWire-Slaves. With a small overhead one µC can emulate up to 32 ICs simultaneously. +The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Periphery with support for various devices & sensors. The motivation is to offer a shared code base for all OneWire-Periphery-Devices. With a small overhead one µC can emulate up to 32 ICs simultaneously. The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iLib) or SPI interface) and transfer their measurements into one or more emulated ds2438 which have 4x16bit registers for values. This feature removes the limitations of modern house-automation-systems. Add humidity, light and other sensors easy to your home automation environment. [![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) [![Documentation](https://github.com/orgua/OneWireHub/actions/workflows/sphinx_to_pages.yml/badge.svg)](https://orgua.github.io/OneWireHub/) -### Implemented Slaves +**Links** + +- [Main-Repository](https://github.com/orgua/OneWireHub) +- [Documentation](https://orgua.github.io/OneWireHub/) + + +### Implemented peripheral Devices - **BAE0910 (0xFC) multi purpose device (ADC, Clock, GPIO, PWM, EEPROM)** - **DS1822 (0x22) Digital Thermometer, 12bit** -> use DS18B20 with different family code @@ -40,34 +46,34 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### Features -- supports up to 32 slaves simultaneously (8 is standard setting), adjust HUB_SLAVE_LIMIT in src/OneWireHub_config.h to safe RAM & program space +- supports up to 32 peripheral devices simultaneously (8 is standard setting), adjust `ONEWIREHUB_DEVICE_LIMIT` in `src/OneWireHub_config.h` to safe RAM & program space - implementation-overhead for the hub is minimal and even saves resources for >1 emulated device -- hot-plug: add and remove slaves as needed during operation -- support for most onewire-features: MATCH ROM (0x55), SKIP ROM (0xCC), READ ROM (0x0F,0x33), RESUME COMMAND (0xA5) - - **OVERDRIVE-Mode**: Master can issue OD SKIP ROM (0x13) or OD MATCH ROM (0x69) and slave stays in this mode till it sees a long reset -> OD-feature must be activated in config - - ALARM SEARCH (0xEC) is NOT implemented yet! +- hot-plug: add and remove devices as needed during operation +- support for most onewire-features: `MATCH ROM` (0x55), `SKIP ROM` (0xCC), `READ ROM` (0x0F,0x33), `RESUME COMMAND` (0xA5) + - **OVERDRIVE-Mode**: OneWire-Host can issue `OD SKIP ROM` (0x13) or `OD MATCH ROM` (0x69) and peripheral device stays in this mode till it sees a long reset -> OD-feature must be activated in config + - `ALARM SEARCH` (0xEC) is NOT implemented yet! - cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=2.0.0 recommended)** - use of constexpr instead of #define for better compiler-messages and cleaner code - use static-assertions for compile-time plausibility checks - user defined literals convert constants into needed format / unit -- hardware-dependencies are combined in "platform.h", synced with [Onewire-Lib](https://github.com/PaulStoffregen/OneWire) +- hardware-dependencies are combined in `platform.h`, synced with [Onewire-Lib](https://github.com/PaulStoffregen/OneWire) - supported: arduino zero, teensy, pic32, [ATtiny](https://github.com/damellis/attiny), esp8266, esp32, raspberry (...) - tested architectures: atmega328 @ 16 MHz / arduino Uno, teensy3.2 - for portability and tests the hub can be compiled on a PC with the supplied mock-up functions in platform.h - at the moment the lib relies sole on loop-counting for timing, no direct access to interrupt or timers, **NOTE:** if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation -- hub and slaves are unit tested and run for each supported architecture through travis CI +- hub and emulated devices are unit tested and run for each supported architecture through travis CI - Serial-Debug output can be enabled in src/OneWireHub_config.h: set USE_SERIAL_DEBUG to 1 (be aware! it may produce heisenbugs, timing is critical) - GPIO-Debug output - shows status by issuing high-states (activate in src/OneWireHub_config.h, is a better alternative to serial debug) - during presence detection (after reset), - - after receiving / sending a whole byte (not during SEARCH ROM) - - when duty()-subroutines of an attached slave get called + - after receiving / sending a whole byte (not during `SEARCH ROM`) + - when duty()-subroutines of an attached device get called - during hub-startup it issues a 1ms long high-state (you can check the instruction-per-loop-value for your architecture with this) - provide documentation, numerous examples, easy interface for hub and sensors ### Supported and tested Hardware - embedded real life test - - setup: run test-example, use ds9490-master, arduino 1.8.3, Windows 10 and the board-library named in the brackets + - setup: run test-example, use ds9490-OneWire-Host, arduino 1.8.3, Windows 10 and the board-library named in the brackets - Arduino Uno ([Arduino AVR Boards](https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr)) - Teensy 3.2 ([teensyduino](https://github.com/PaulStoffregen/cores)) - Wemos D1 Mini ESP32S ([esp32](https://github.com/espressif/arduino-esp32)) @@ -100,17 +106,17 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - Low Level - hardware access - macros like DIRECT_READ() and DIRECT_WRITE() handle bus-access (platform.h) - checkReset() and showPresence() are used to react to a beginning OW-Message - - sendBit(), recvBit() manage the information inside each timeslot issued by the master + - sendBit(), recvBit() manage the information inside each timeslot issued by the OneWire-Host - Mid Level - onewire protocol logic - - send() and recv() can process data between device and master on byte-level (and do a CRC if needed) - - recvAndProcessCmd() handles basic commands of the master like: search-rom, match-rom, skip-rom, read-rom + - send() and recv() can process data between device and OneWire-Host on byte-level (and do a CRC if needed) + - recvAndProcessCmd() handles basic commands of the OneWire-Host like: search-rom, match-rom, skip-rom, read-rom - High Level - user interaction - - attach() adds an instance of a ow-device to the hub so the master can find it on the bus. there is a lot to do here. the device ID must be integrated into the tree-structure so that the hub knows how to react during a search-rom-command + - attach() adds an instance of a ow-device to the hub so the OneWire-Host can find it on the bus. there is a lot to do here. the device ID must be integrated into the tree-structure so that the hub knows how to react during a search-rom-command - detach() takes the selected emulated device offline and restructures the search-tree - poll() lets the hub listen to the bus. If there is a reset within a given time-frame it will continue to handle the message (show presence and receive commands), otherwise it will exit and you can do other stuff. the user should call this function as often as possible to intercept every message and therefore stay visible on the bus -- Slave Level: - - slave.duty() gets automatically called when the master sends special commands (for example match-rom). now it is possible to handle device specific commands like "read memory" or "do temperature measurement". These commands deviate for each device. - - slave.setTemperature() and slave.writeMemory() for example are individual functions that handle core-functionality of the device and can be called by the user +- Device Level: + - device.duty() gets automatically called when the OneWire-Host sends special commands (for example match-rom). now it is possible to handle device specific commands like "read memory" or "do temperature measurement". These commands deviate for each device. + - device.setTemperature() and device.writeMemory() for example are individual functions that handle core-functionality of the device and can be called by the user - for further details try reading the header-files or check the examples ### HELP - What to do if things don't work as expected? @@ -119,29 +125,29 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - update this lib to the latest release (v3.0.0) - if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation - check if clock-speed of the µC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical -- begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the master won't switch to higher data rates -- check if your setup is right: you need at least external power for your µC and a data line with ground line to your onewire-master (see section below) -- is there more than one master on the bus? It won't work! -- has any other sensor (real or emulated) ever worked with this master? -> the simplest device would be a ds2401 +- begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the OneWire-Host won't switch to higher data rates +- check if your setup is right: you need at least external power for your µC and a data line with ground line to your OneWire-Host (see section below) +- is there more than one OneWire-Host on the bus? It won't work! +- has any other sensor (real or emulated) ever worked with this OneWire-Host? -> the simplest device would be a ds2401 - if communication works, but is unstable please check with logic analyzer - - maybe your master is slow and just needs a higher ONEWIRE_TIME_MSG_HIGH_TIMEOUT-value (see OneWireHub_config.h line 37) + - maybe your OneWire-Host is slow and just needs a higher ONEWIRE_TIME_MSG_HIGH_TIMEOUT-value (see OneWireHub_config.h line 37) - make sure that serial- and gpio-debugging is disabled (see src/OneWireHub_config.h), especially when using overdrive (be aware! it may produce heisenbugs, timing is critical) - on a slow arduino it can be helpful to disable the serial port completely to get reliable results -> at least comment out serial.begin() - if you can provide a recording via logic-analyzer (logic 8 or similar) there should be chance we can help you - additional gpio-debug output can be enabled in src/OneWireHub_config.h: set USE_GPIO_DEBUG to 1 (it helps tracking state changes of the hub) - if you checked all these points feel free to open an issue at [Github](https://github.com/orgua/OneWireHub) and describe your troubleshooting process - - please provide the following basic info: which µC and master do you use, software versions, what device do you try to emulate, what works, what doesn't + - please provide the following basic info: which µC and OneWire-Host do you use, software versions, what device do you try to emulate, what works, what doesn't ### Recent development (latest at the top) - travis CI and unittests - more explicit coding, a lot of bugfixes with the help of unit tests (mainly esp8266, bea910, ds18b20) -- interface of hub and slave-devices has changed, check header-file or examples for more info +- interface of hub and devices has changed, check header-file or examples for more info - rework / clean handling of timing-constants with user defined literals. -- extend const-correctness to all onewire-slaves and unify naming of functions across similar devices +- extend const-correctness to all onewire-devices and unify naming of functions across similar devices - include tests into each device-example and add a lot of get()/set() for internal device-states - full support for ds2423, ds2450 and ds2503/5/6 -- fix and enhance ds2431, ds2433, ds2502, ds2890, probably every slave got a rework / optimization +- fix and enhance ds2431, ds2433, ds2502, ds2890, probably every device got a rework / optimization - overdrive-support! must be enabled in config file - works with atmega328@16MHz - rework send() and recv(), much more efficient -> less time without interrupts (no missing time with millis())! AND code is more compact (ds2433.cpp shrinks from 176 to 90 LOC) - rework Error-Handling-System (reduced a lot of overhead) @@ -156,22 +162,22 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - added or extended the ds2431, ds2431, ds2501, ds2502 (also tested) - added ds2431 (thanks to j-langlois) and BAE910 (thanks to Giermann), Dell Power Supply (thanks to Kondi) - prepare new timing-method which will replace the old one in the next couple of weeks (a 6µs millis() call at 8MHz is not suitable for OW) -- support for skipROM-cmd if only one slave is present (thanks to Giermann) +- support for skipROM-cmd if only one device is present (thanks to Giermann) - speed up atmel-crc-functions -- rework of error system, switch to enum, slaves can raise errors now & and Serial interferes less with OW-timings -- raise the maximal slave limit from 8 to 32, code adapts via variable dataTypes +- rework of error system, switch to enum, peripheral devices can raise errors now & and Serial interferes less with OW-timings +- raise the maximal peripheral device limit from 8 to 32, code adapts via variable dataTypes - per-bit-CRC16 with sendAndCRC16() and sendAndCRC16() for load-balancing, 900ns/bit instead of 7µs/byte on Atmega328@16MHz - faster CRC16 (ds2450 and ds2408 and ds2423), takes 5-7µs/byte instead of 10µs -- replace searchIDTree() algorithm, safes a lot of ram (debug-codeSize-4slaves.ino needs 3986 & 155 byte instead of 3928 & 891 byte) and allows >4 devices +- replace searchIDTree() algorithm, safes a lot of ram (debug-codeSize-4devices.ino needs 3986 & 155 byte instead of 3928 & 891 byte) and allows >4 devices ### Plans for the future - alarm / conditional search - switch to delay() for fast enough controllers (instead of tick-counting) -- debug tool to determine timings of exotic masters +- debug tool to determine timings of exotic OneWire-Hosts - better interrupt-handling (save the state before disabling) - irq-handled hub on supported ports, split lib into onewire() and onewireIRQ() -- test each example with real onewire-masters, for now it's tested with the onewire-lib and a loxone-system (ds18b20 passed) +- test each example with real OneWire-Hosts, for now it's tested with the onewire-lib and a loxone-system (ds18b20 passed) - [List of all Family-Codes](http://owfs.sourceforge.net/family.html) - [List of Maxim Sensors](https://www.maximintegrated.com/en/app-notes/index.mvp/id/3989) (at the bottom) diff --git a/examples/BAE910_device/BAE910_device.ino b/examples/BAE910_device/BAE910_device.ino index c432ccc..8ac785d 100644 --- a/examples/BAE910_device/BAE910_device.ino +++ b/examples/BAE910_device/BAE910_device.ino @@ -5,7 +5,7 @@ * Tested with: */ -#include "BAE910.h" // 3rd party OneWire slave device, family code 0xFC +#include "BAE910.h" // 3rd party OneWire peripheral device, family code 0xFC #include "OneWireHub.h" constexpr uint8_t pin_led{13}; diff --git a/examples/DS18B20_asInterface/DS18B20_asInterface.ino b/examples/DS18B20_asInterface/DS18B20_asInterface.ino index 50a8ce3..35c549e 100644 --- a/examples/DS18B20_asInterface/DS18B20_asInterface.ino +++ b/examples/DS18B20_asInterface/DS18B20_asInterface.ino @@ -6,7 +6,7 @@ * - temperature in degC * * Tested with: - * - DS9490R-Master, atmega328@16MHz as Slave + * - DS9490R-OneWire-Host, atmega328@16MHz as peripheral device */ constexpr bool enable_debug = 0; diff --git a/examples/DS18B20_thermometer/DS18B20_thermometer.ino b/examples/DS18B20_thermometer/DS18B20_thermometer.ino index 6758851..7bdc45d 100644 --- a/examples/DS18B20_thermometer/DS18B20_thermometer.ino +++ b/examples/DS18B20_thermometer/DS18B20_thermometer.ino @@ -2,8 +2,8 @@ * Example-Code that emulates a DS18B20 * * Tested with: - * - https://github.com/PaulStoffregen/OneWire --> DS18x20-Example, atmega328@16MHz as Slave - * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave + * - https://github.com/PaulStoffregen/OneWire --> DS18x20-Example, atmega328@16MHz as peripheral device + * - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS18B20.h" // Digital Thermometer, 12bit diff --git a/examples/DS2401_serial/DS2401_serial.ino b/examples/DS2401_serial/DS2401_serial.ino index 4d3ccb7..2ed5959 100644 --- a/examples/DS2401_serial/DS2401_serial.ino +++ b/examples/DS2401_serial/DS2401_serial.ino @@ -2,8 +2,8 @@ * Example-Code that emulates a DS2401 used as a binary button (like reed-contact - power on, power off) * * Tested with - * - https://github.com/PaulStoffregen/OneWire on the other side as Master, atmega328@16MHz as Slave - * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave + * - https://github.com/PaulStoffregen/OneWire on the other side as OneWire-Host, atmega328@16MHz as peripheral device + * - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS2401.h" // Serial Number diff --git a/examples/DS2405_switch/DS2405_switch.ino b/examples/DS2405_switch/DS2405_switch.ino index 24ff9ea..e545b8f 100644 --- a/examples/DS2405_switch/DS2405_switch.ino +++ b/examples/DS2405_switch/DS2405_switch.ino @@ -2,8 +2,8 @@ * Example-Code that emulates a DS2405 - One Channel addressable switch * * Tested with - * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave - * - Note: feedback to master is unclear, ds9490 does not read after matchRom + * - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device + * - Note: feedback to OneWire-Host is unclear, ds9490 does not read after matchRom */ #include "DS2405.h" // Dual channel addressable switch diff --git a/examples/DS2408_switch/DS2408_switch.ino b/examples/DS2408_switch/DS2408_switch.ino index e75773f..a85193c 100644 --- a/examples/DS2408_switch/DS2408_switch.ino +++ b/examples/DS2408_switch/DS2408_switch.ino @@ -2,9 +2,9 @@ * Example-Code that emulates a DS2408 - an 8CH GPIO Port Extender * * Tested with: - * - https://github.com/PaulStoffregen/OneWire on the other side as Master - * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave - * - BeagleBoneBlack running Linux 4.4.19. 1wire slave was accessed via original drivers: + * - https://github.com/PaulStoffregen/OneWire on the other side as OneWire-Host + * - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device + * - BeagleBoneBlack running Linux 4.4.19. 1wire device was accessed via original drivers: * * #set all pins to 1 (xFF) * echo -e '\xFF' |dd of=/sys/bus/w1/devices/29-010000000000/output bs=1 count=1 @@ -71,7 +71,7 @@ void loop() // Blink triggers the state-change if (blinking()) { - // this could be used to report up to eight states to 1wire master + // this could be used to report up to eight states to 1wire-host //ds2408.setPinState(0, digitalRead(10)); Serial.print("0x"); Serial.println(ds2408.getPinState(), BIN); diff --git a/examples/DS2413_switch/DS2413_switch.ino b/examples/DS2413_switch/DS2413_switch.ino index 8903523..228122d 100644 --- a/examples/DS2413_switch/DS2413_switch.ino +++ b/examples/DS2413_switch/DS2413_switch.ino @@ -2,7 +2,7 @@ * Example-Code that emulates a DS2413 Dual channel addressable switch * * Tested with - * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave + * - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS2413.h" // Dual channel addressable switch diff --git a/examples/DS2423_RAM/DS2423_RAM.ino b/examples/DS2423_RAM/DS2423_RAM.ino index bfc5ce8..7b9bea1 100644 --- a/examples/DS2423_RAM/DS2423_RAM.ino +++ b/examples/DS2423_RAM/DS2423_RAM.ino @@ -4,7 +4,7 @@ * THIS DEVICE IS ONLY A MOCKUP FOR NOW - NO REAL FUNCTION * * Tested with -* - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave +* - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS2423.h" diff --git a/examples/DS2431_EEPROM/DS2431_EEPROM.ino b/examples/DS2431_EEPROM/DS2431_EEPROM.ino index aa05512..72509a4 100644 --- a/examples/DS2431_EEPROM/DS2431_EEPROM.ino +++ b/examples/DS2431_EEPROM/DS2431_EEPROM.ino @@ -2,8 +2,8 @@ * Example-Code that emulates a DS2431 1024 bits EEPROM * * Tested with -* - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave -* - tested on buspirate and two different real 1-wire masters (DS9490 and a PIC18-Device) +* - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device +* - tested on buspirate and two different real 1-wire hosts (DS9490 and a PIC18-Device) */ #include "DS2431.h" diff --git a/examples/DS2433_EEPROM/DS2433_EEPROM.ino b/examples/DS2433_EEPROM/DS2433_EEPROM.ino index ee75bf3..f270112 100644 --- a/examples/DS2433_EEPROM/DS2433_EEPROM.ino +++ b/examples/DS2433_EEPROM/DS2433_EEPROM.ino @@ -2,7 +2,7 @@ * Example-Code that emulates a DS2433 4096 bits EEPROM * * Tested with -* - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave +* - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS2433.h" diff --git a/examples/DS2438_battMon/DS2438_battMon.ino b/examples/DS2438_battMon/DS2438_battMon.ino index 3cfbfc3..80e5dd2 100644 --- a/examples/DS2438_battMon/DS2438_battMon.ino +++ b/examples/DS2438_battMon/DS2438_battMon.ino @@ -3,7 +3,7 @@ * * Tested with: * - https://github.com/PaulStoffregen/OneWire - * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave + * - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS2438.h" // Smart Battery Monitor diff --git a/examples/DS2450_ADC/DS2450_ADC.ino b/examples/DS2450_ADC/DS2450_ADC.ino index 44e870c..ee87845 100644 --- a/examples/DS2450_ADC/DS2450_ADC.ino +++ b/examples/DS2450_ADC/DS2450_ADC.ino @@ -2,7 +2,7 @@ * Example-Code that emulates a DS2450 4 channel A/D * * Tested with -* - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave +* - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS2450.h" diff --git a/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino b/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino index c25f000..95b80ba 100644 --- a/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino +++ b/examples/DS2502_DELLCHG/DS2502_DELLCHG.ino @@ -3,7 +3,7 @@ * * Tested with * - dell notebook https://forum.pjrc.com/threads/33640-Teensy-2-OneWire-Slave - * - DS9490R-Master, atmega328@16MHz as Slave + * - DS9490R-OneWire-Host, atmega328@16MHz as peripheral device * - Arduino ProMini clone * - esp8266 (ESP-01 module, using GPIO2 with a 10k pull-up resistor) * - Dell Inspiron 15R N5110 and Dell Inspiron 15R 5521 @130W @@ -16,10 +16,10 @@ * * thanks to Nik / ploys for supplying traces of real data-traffic to figure out communication: * - reset and presence detection normal - * - cmd from master: 0xCC -> skip rom, so there is only ONE device allowed on the bus - * - cmd from master: 0xF0 -> read memory - * - address request from master: 0x0008 - * - master listens for data, gets CRC of seconds cmd and address first, then listens for 3 bytes, does not listen any further + * - cmd from host: 0xCC -> skip rom, so there is only ONE device allowed on the bus + * - cmd from host: 0xF0 -> read memory + * - address request from host: 0x0008 + * - OneWire-Host listens for data, gets CRC of seconds cmd and address first, then listens for 3 bytes, does not listen any further * !!! Note that some latest Dell models may ask for more information !!! */ @@ -42,7 +42,7 @@ constexpr const char *charger130W = "DELL00AC130195067CN0CDF577243865Q27F2233\x9 auto hub = OneWireHub(pin_onewire); auto dellCH = DS2502( 0x28, 0x0D, 0x01, 0x08, 0x0B, 0x02, - 0x0A); // address does not matter, laptop uses skipRom -> note that therefore only one slave device is allowed on the bus + 0x0A); // address does not matter, laptop uses skipRom -> note that therefore only one peripheral device is allowed on the bus void setup() { diff --git a/examples/DS2502_EEPROM/DS2502_EEPROM.ino b/examples/DS2502_EEPROM/DS2502_EEPROM.ino index bad7669..0bf1a26 100644 --- a/examples/DS2502_EEPROM/DS2502_EEPROM.ino +++ b/examples/DS2502_EEPROM/DS2502_EEPROM.ino @@ -3,7 +3,7 @@ * * Tested with * - dell notebook https://forum.pjrc.com/threads/33640-Teensy-2-OneWire-Slave - * - DS9490R-Master, atmega328@16MHz as Slave + * - DS9490R-OneWire-Host, atmega328@16MHz as peripheral device */ #include "DS2502.h" @@ -39,7 +39,7 @@ void setup() ds2502.writeMemory(mem_dummy, sizeof(mem_dummy), 3 * 32); Serial.println(ds2502.getPageUsed(3)); - Serial.println("Test Write Data to protected page 0 -> is possible, only affects master"); + Serial.println("Test Write Data to protected page 0 -> is possible, only affects OneWire-Host"); Serial.println(ds2502.getPageUsed(0)); Serial.println(ds2502.getPageProtection(0)); ds2502.setPageProtection(0); diff --git a/examples/DS2506_EEPROM/DS2506_EEPROM.ino b/examples/DS2506_EEPROM/DS2506_EEPROM.ino index 9093dc1..91c7d89 100644 --- a/examples/DS2506_EEPROM/DS2506_EEPROM.ino +++ b/examples/DS2506_EEPROM/DS2506_EEPROM.ino @@ -54,7 +54,7 @@ void setup() ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 4 * 32); Serial.println(ds2506.getPageUsed(4)); // is used now - Serial.println("Test Write Data to protected page 0 -> is possible, only affects master"); + Serial.println("Test Write Data to protected page 0 -> is possible, only affects OneWire-Host"); Serial.println(ds2506.getPageUsed(0)); // is unused Serial.println(ds2506.getPageProtection(0)); // is unprotected ds2506.setPageProtection(0); // protect it diff --git a/examples/DS2890_poti/DS2890_poti.ino b/examples/DS2890_poti/DS2890_poti.ino index dc860c0..053c082 100644 --- a/examples/DS2890_poti/DS2890_poti.ino +++ b/examples/DS2890_poti/DS2890_poti.ino @@ -2,7 +2,7 @@ * Example-Code that emulates a DS2890 Single channel digital potentiometer (datasheet has it covered for up to 4 CH) * * Tested with - * - DS9490R-Master, atmega328@16MHz and teensy3.2@96MHz as Slave + * - DS9490R-OneWire-Host, atmega328@16MHz and teensy3.2@96MHz as peripheral device */ #include "DS2890.h" // Single channel digital potentiometer diff --git a/examples/OneWireHubTest/OneWireHubTest.ino b/examples/OneWireHubTest/OneWireHubTest.ino index 120824c..06b3dcb 100644 --- a/examples/OneWireHubTest/OneWireHubTest.ino +++ b/examples/OneWireHubTest/OneWireHubTest.ino @@ -3,7 +3,7 @@ * --> attach sensors as needed * * Tested with: - * - https://github.com/PaulStoffregen/OneWire on the other side as Master + * - https://github.com/PaulStoffregen/OneWire on the other side as OneWire-Host * * Compile size (program / ram) * 9232 & 706 byte with arduino 1.6.10 and onewirehub 2.0.1 for UNO diff --git a/examples/debug/attiny85-4slaves/attiny85-4slaves.ino b/examples/debug/attiny85-4devices/attiny85-4devices.ino similarity index 96% rename from examples/debug/attiny85-4slaves/attiny85-4slaves.ino rename to examples/debug/attiny85-4devices/attiny85-4devices.ino index 8ced2d3..c03437d 100644 --- a/examples/debug/attiny85-4slaves/attiny85-4slaves.ino +++ b/examples/debug/attiny85-4devices/attiny85-4devices.ino @@ -4,7 +4,7 @@ * * Tested with: * - Attiny85-Board http://www.ebay.de/itm/221702922456 - * - DS9490R-Master, atmega328@16MHz as Slave + * - DS9490R-OneWire-Host, atmega328@16MHz as peripheral device */ #include "OneWireHub.h" diff --git a/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino b/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino index 6150356..03f6749 100644 --- a/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino +++ b/examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino @@ -1,7 +1,7 @@ /* * Test-Code for calibration - this sketch determines the value for "instructions per loop" for your µC/CPU-architecture * - * setup: upload sketch to controller and hook it up to a OW-master, it will calibrate itself to the "seen" reset-pulses + * setup: upload sketch to controller and hook it up to a OneWire-Host, it will calibrate itself to the "seen" reset-pulses * NOTE: you will need a serial-port to make this work * * --> read value per serial-com and write it to /src/platform.h to YOUR specific architecture diff --git a/examples/debug/optimize_pinAccess/optimize_pinAccess.ino b/examples/debug/optimize_pinAccess/optimize_pinAccess.ino index bf30f52..499d81f 100644 --- a/examples/debug/optimize_pinAccess/optimize_pinAccess.ino +++ b/examples/debug/optimize_pinAccess/optimize_pinAccess.ino @@ -86,7 +86,7 @@ volatile io_reg_t * void pinConfigClean(const uint8_t pin) { - pinMode(pin, INPUT); // as a OW-slave we should mostly listen + pinMode(pin, INPUT); // as a OW-peripheral-device we should mostly listen // setup direct pin-access pin_bitMask = PIN_TO_BITMASK(pin); pin_baseReg = PIN_TO_BASEREG(pin); diff --git a/keywords.txt b/keywords.txt index aaaf7f2..c90d657 100644 --- a/keywords.txt +++ b/keywords.txt @@ -50,7 +50,7 @@ waitLoops1ms KEYWORD2 waitLoopsDebug KEYWORD2 printError KEYWORD2 getError KEYWORD2 -raiseSlaveError KEYWORD2 +raiseDeviceError KEYWORD2 clearError KEYWORD2 ## OneWireItem diff --git a/library.json b/library.json index e69c4e8..d05f072 100644 --- a/library.json +++ b/library.json @@ -2,8 +2,9 @@ "name": "OneWireHub", "frameworks": "Arduino", "keywords": - "onewire, 1-wire, bus, slave, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890", - "description": "OneWire slave device emulator with support for up to 32 simultaneous devices", + "onewire, 1-wire, bus, periphery, device, sensor, temperature, voltage, current, memory, BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890", + "description": + "OneWire peripheral device emulator with support for up to 32 simultaneous devices", "authors": [ { "name": "Ingmar Splitt", diff --git a/library.properties b/library.properties index 85cb09a..219508c 100644 --- a/library.properties +++ b/library.properties @@ -2,7 +2,7 @@ name=OneWireHub version=3.0.0 author=Ingmar Splitt, orgua, MarkusLange, Shagrat2 maintainer=orgua -sentence=OneWire slave device emulator with support for up to 32 simultaneous 1wire devices. +sentence=OneWire peripheral device emulator with support for up to 32 simultaneous 1wire devices. paragraph=supported sensors: BAE910, DS1822, DS18B20, DS18S20, DS1990, DS2401, DS2405, DS2408, DS2411, DS2413, DS2423, DS2430, DS2431, DS2432, DS2433, DS2434, DS2438, DS2450, DS2501, DS2502, DS2503, DS2505, DS2506, DS2890 category=Sensors url=https://github.com/orgua/OneWireHub diff --git a/main.cpp b/main.cpp index 7a646cc..74f434c 100644 --- a/main.cpp +++ b/main.cpp @@ -574,17 +574,17 @@ int main() for (size_t index = 0; index < sizeof(mem_read); ++index) { test_eq(mem_read[index], 0xFF, - "DS2502 mem re-read page 1 - still clean, only affects master"); + "DS2502 mem re-read page 1 - still clean, only affects OneWire-Host"); } - // Test Write Data to protected page 0 -> is possible, only affects master"); + // Test Write Data to protected page 0 -> is possible, only affects OneWire-Host"); test_eq(ds2502.getPageUsed(0), 0, "DS2502 get use-counter before accessing it"); test_eq(ds2502.getPageProtection(0), false, "DS2502 get page-protection before protecting"); ds2502.setPageProtection(0); test_eq(ds2502.getPageProtection(0), true, "DS2502 get page-protection after protecting"); ds2502.writeMemory(mem_dummy, sizeof(mem_dummy), 16); // write in second half of page test_eq(ds2502.getPageUsed(0), 1, - "DS2502 get use-counter after write to protected page (only affects master)"); + "DS2502 get use-counter after write to protected page (only affects OneWire-Host)"); } { @@ -656,10 +656,11 @@ int main() for (size_t index = 0; index < sizeof(mem_read); ++index) { test_eq(mem_read[index], 0xFF, - "DS2506 mem re-read page 3 - redirected, but only for master, so unchanged"); + "DS2506 mem re-read page 3 - redirected, but only for OneWire-Host, so " + "unchanged"); } - // Test Write Data to protected page 0 -> is possible, only affects master"); + // Test Write Data to protected page 0 -> is possible, only affects OneWire-Host"); test_eq(ds2506.getPageUsed(0), 0, "DS2506 get use-counter before accessing it"); test_eq(ds2506.getPageProtection(0), false, "DS2506 get page-protection before protecting"); ds2506.setPageProtection(0); @@ -667,7 +668,7 @@ int main() ds2506.writeMemory(mem_dummy, sizeof(mem_dummy), 16); // write in second half of page test_eq(ds2506.getPageUsed(0), 1, - "DS2506 get use-counter after write to protected page (only affects master)"); + "DS2506 get use-counter after write to protected page (only affects OneWire-Host)"); ds2506.readMemory(mem_read, sizeof(mem_read), 16_u8); for (size_t index = 0; index < sizeof(mem_read); ++index) diff --git a/src/BAE910.cpp b/src/BAE910.cpp index 2863a9a..8a49ac7 100644 --- a/src/BAE910.cpp +++ b/src/BAE910.cpp @@ -54,7 +54,7 @@ void BAE910::duty(OneWireHub *const hub) if ((ta1 + len > 0x80) || (ta2 > 0)) { - hub->raiseSlaveError(cmd); + hub->raiseDeviceError(cmd); return; } // reverse byte order @@ -75,7 +75,7 @@ void BAE910::duty(OneWireHub *const hub) if ((len > BAE910_SCRATCHPAD_SIZE) || (ta1 + len > 0x80) || (ta2 > 0)) { - hub->raiseSlaveError(cmd); + hub->raiseDeviceError(cmd); return; } @@ -83,7 +83,7 @@ void BAE910::duty(OneWireHub *const hub) crc = ~crc; if (hub->send(reinterpret_cast(&crc), 2)) return; - // verify answer from master, then copy memory + // verify answer from OneWire-Host, then copy memory if (hub->recv(&eCmd, 1)) return; if (eCmd == 0xBC) { @@ -96,6 +96,6 @@ void BAE910::duty(OneWireHub *const hub) // case 0x13: // EXTENDED COMMAND // case 0x16: // ERASE EEPROM PAGE (not needed/implemented yet) - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/BAE910.h b/src/BAE910.h index ce037d8..77e9d81 100644 --- a/src/BAE910.h +++ b/src/BAE910.h @@ -1,4 +1,4 @@ -// Multifunction 1-wire slave device @@@ +// Multifunction 1-wire peripheral device @@@ // works, basic functionality // native bus-features: unknown diff --git a/src/DS18B20.cpp b/src/DS18B20.cpp index 00b2864..2d7bf23 100644 --- a/src/DS18B20.cpp +++ b/src/DS18B20.cpp @@ -57,7 +57,7 @@ void DS18B20::duty(OneWireHub *const hub) // we have 94 ... 750ms time here (9-12bit conversion) break; // send 1s, is passive ... - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2401.cpp b/src/DS2401.cpp index 4c788dd..9c4926e 100644 --- a/src/DS2401.cpp +++ b/src/DS2401.cpp @@ -17,6 +17,6 @@ void DS2401::duty(OneWireHub *const hub) switch (cmd) { - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2405.cpp b/src/DS2405.cpp index c1610fc..bbfdf4e 100644 --- a/src/DS2405.cpp +++ b/src/DS2405.cpp @@ -13,7 +13,7 @@ void DS2405::duty(OneWireHub *const hub) pin_state = !pin_state; noInterrupts(); while (!hub->sendBit(pin_state)) - ; // if master issues read slots it gets the state... + ; // if OneWire-Host issues read slots it gets the state... interrupts(); // TODO: when alarm search is implemented (0xEC): diff --git a/src/DS2408.cpp b/src/DS2408.cpp index f7c573c..642b407 100644 --- a/src/DS2408.cpp +++ b/src/DS2408.cpp @@ -47,7 +47,7 @@ void DS2408::duty(OneWireHub *const hub) memory[REG_PIO_LOGIC] = data; if (hub->send(&DATA_xAA)) return; if (hub->send(memory, 4)) - return; // TODO: i think this is right, datasheet says: DS2408 samples the status of the PIO pins, as shown in Figure 9, and sends it to the master + return; // TODO: i think this is right, datasheet says: DS2408 samples the status of the PIO pins, as shown in Figure 9, and sends it to the OneWire-Host } case 0xF5: // Channel-Access Read @@ -82,7 +82,7 @@ void DS2408::duty(OneWireHub *const hub) // TODO: page 18 datasheet, no alarm search yet, control-register has influence break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2413.cpp b/src/DS2413.cpp index f966a80..ba7f199 100644 --- a/src/DS2413.cpp +++ b/src/DS2413.cpp @@ -41,6 +41,6 @@ void DS2413::duty(OneWireHub *const hub) if (hub->send(&data)) return; break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2413.h b/src/DS2413.h index 19bdbfa..e5360b3 100644 --- a/src/DS2413.h +++ b/src/DS2413.h @@ -1,5 +1,5 @@ // Dual channel addressable switch -// Works, master can latch the pin and pull it thereby down +// Works, OneWire-Host can latch the pin and pull it thereby down // native bus-features: Overdrive capable #ifndef ONEWIRE_DS2413_H diff --git a/src/DS2423.cpp b/src/DS2423.cpp index 6a0388b..1537a6e 100644 --- a/src/DS2423.cpp +++ b/src/DS2423.cpp @@ -139,7 +139,7 @@ void DS2423::duty(OneWireHub *const hub) } break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } if (cmd == 0x5A) clearScratchpad(); diff --git a/src/DS2430.cpp b/src/DS2430.cpp index 7864f36..f274e62 100644 --- a/src/DS2430.cpp +++ b/src/DS2430.cpp @@ -93,7 +93,7 @@ void DS2430::duty(OneWireHub *const hub) status_register &= ~0b11u; // lock the OTP break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2431.cpp b/src/DS2431.cpp index c844eb8..bf7a7b8 100644 --- a/src/DS2431.cpp +++ b/src/DS2431.cpp @@ -132,7 +132,7 @@ void DS2431::duty(OneWireHub *const hub) if (hub->send(&memory[reg_TA], MEM_SIZE - uint8_t(reg_TA), crc)) return; break; // send 1s when read is complete, is passive, so do nothing here - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2433.cpp b/src/DS2433.cpp index 267e74e..21dae9c 100644 --- a/src/DS2433.cpp +++ b/src/DS2433.cpp @@ -105,7 +105,7 @@ void DS2433::duty(OneWireHub *const hub) } return; // datasheed says we should send all 1s, till reset (1s are passive... so nothing to do here) - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2434.cpp b/src/DS2434.cpp index 72d6e7f..ae9731e 100644 --- a/src/DS2434.cpp +++ b/src/DS2434.cpp @@ -12,7 +12,7 @@ DS2434::DS2434(uint8_t ID1, uint8_t ID2, uint8_t ID3, uint8_t ID4, uint8_t ID5, clearScratchpad(); } -// As this device is not multidrop, it needs to handle ALL commands from the master +// As this device is not multidrop, it needs to handle ALL commands from the OneWire-Host void DS2434::duty(OneWireHub *const hub) { uint8_t start_byte, cmd, data; @@ -133,7 +133,7 @@ void DS2434::duty(OneWireHub *const hub) if (hub->recv(&data)) return; break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2438.cpp b/src/DS2438.cpp index 4f98280..053c08c 100644 --- a/src/DS2438.cpp +++ b/src/DS2438.cpp @@ -69,7 +69,7 @@ void DS2438::duty(OneWireHub *const hub) break; //hub->sendBit(1); // 1 is passive, so omit it ... - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } @@ -155,7 +155,7 @@ void convertVoltage(uint8_t *const destination, const uint16_t voltage_10mV) // // Deprecated method for backward compatibility - put voltage in scratchpad but also store in default (VDD). // This will be overwritten as a result of convert command (0xB4) with either VDD (stored here) or VAD. -// If a system is designed such that the master knows to call 0xB4 it likely knows about REG0_MASK_AD too +// If a system is designed such that the OneWire-Host knows to call 0xB4 it likely knows about REG0_MASK_AD too // so SetVDDVoltage SetVADVoltage should be used. void DS2438::setVoltage(const uint16_t voltage_10mV) { diff --git a/src/DS2450.cpp b/src/DS2450.cpp index 5f32ad1..be7ff9e 100644 --- a/src/DS2450.cpp +++ b/src/DS2450.cpp @@ -55,7 +55,7 @@ void DS2450::duty(OneWireHub *const hub) case 0x3C: // convert, starts adc // received reg_TA contains: input select mask (not important) and read out control byte - // in reality master can now set registers of potentiometers to 0x0000 or 0xFFFF to track changes + // in reality OneWire-Host can now set registers of potentiometers to 0x0000 or 0xFFFF to track changes crc = ~crc; // normally crc16 is sent ~inverted if (hub->send(reinterpret_cast(&crc), 2)) return; // takes max 5.3 ms for 16 bit ( 4 CH * 16 bit * 80 us + 160 us per request = 5.3 ms ) @@ -64,7 +64,7 @@ void DS2450::duty(OneWireHub *const hub) interrupts(); break; // finished conversion: send 1, is passive ... - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } @@ -99,7 +99,7 @@ void DS2450::correctMemory(void) memory[(1 * PAGE_SIZE) + (adc * 2) + 1] &= 0b10111101; // bit 1&6 -> always zero // bit 2:3 -> enable alarm search low, high // bit 4:5 -> alarm flag for low, high - // bit 7 -> power on reset, must be written 0 by master + // bit 7 -> power on reset, must be written 0 by OneWire-Host } } diff --git a/src/DS2502.cpp b/src/DS2502.cpp index b16f0a1..d19b3c8 100644 --- a/src/DS2502.cpp +++ b/src/DS2502.cpp @@ -129,7 +129,7 @@ void DS2502::duty(OneWireHub *const hub) } break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2506.cpp b/src/DS2506.cpp index 5e3d746..4e25e17 100644 --- a/src/DS2506.cpp +++ b/src/DS2506.cpp @@ -132,7 +132,7 @@ void DS2506::duty(OneWireHub *const hub) crc = ~crc; // normally crc16 is sent ~inverted if (hub->send(reinterpret_cast(&crc), 2)) break; - // master issues now a 480us 12V-Programming Pulse -> advantage for us, enough time to handle addressMapping + // OneWire-Host issues now a 480us 12V-Programming Pulse -> advantage for us, enough time to handle addressMapping reg_RA = translateRedirection(reg_TA); const uint8_t page = static_cast(reg_RA >> 5); @@ -156,7 +156,7 @@ void DS2506::duty(OneWireHub *const hub) while (reg_TA < sizeof_memory) // check for valid address { if (hub->recv(&data)) break; - // master issues now a 480us 12V-Programming Pulse + // OneWire-Host issues now a 480us 12V-Programming Pulse reg_RA = translateRedirection(reg_TA); const uint8_t page = static_cast(reg_RA >> 5); @@ -183,7 +183,7 @@ void DS2506::duty(OneWireHub *const hub) crc = ~crc; // normally crc16 is sent ~inverted if (hub->send(reinterpret_cast(&crc), 2)) break; - // master issues now a 480us 12V-Programming Pulse + // OneWire-Host issues now a 480us 12V-Programming Pulse data = writeStatus(reg_TA, data); if (hub->send(&data)) break; @@ -196,7 +196,7 @@ void DS2506::duty(OneWireHub *const hub) while (reg_TA < STATUS_SIZE_DEV) // check for valid address { if (hub->recv(&data, 1, crc)) break; - // master issues now a 480us 12V-Programming Pulse + // OneWire-Host issues now a 480us 12V-Programming Pulse data = writeStatus(reg_TA, data); if (hub->send(&data)) break; @@ -204,7 +204,7 @@ void DS2506::duty(OneWireHub *const hub) } break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } } diff --git a/src/DS2890.cpp b/src/DS2890.cpp index bbafd08..ddc7ee2 100644 --- a/src/DS2890.cpp +++ b/src/DS2890.cpp @@ -79,9 +79,9 @@ void DS2890::duty(OneWireHub *const hub) if (hub->send(®ister_poti[poti])) break; break; - default: hub->raiseSlaveError(cmd); + default: hub->raiseDeviceError(cmd); } if ((cmd == 0xC3) || (cmd == 0x99)) - goto start_over; // only for this device -> when INCREMENT or DECREMENT the master can issue another cmd right away + goto start_over; // only for this device -> when INCREMENT or DECREMENT the OneWire-Host can issue another cmd right away } diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index 82cd05b..b831ee8 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -7,14 +7,14 @@ OneWireHub::OneWireHub(const uint8_t pin) { _error = Error::NO_ERROR; - slave_count = 0; - slave_selected = nullptr; + device_count = 0; + device_selected = nullptr; #if OVERDRIVE_ENABLE od_mode = false; #endif - for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) { slave_list[i] = nullptr; } + for (uint8_t i = 0; i < _ONEWIREHUB_DEVICE_LIMIT; ++i) { device_list[i] = nullptr; } // prepare pin pin_bitMask = PIN_TO_BITMASK(pin); @@ -44,7 +44,7 @@ OneWireHub::OneWireHub(const uint8_t pin) // attach a sensor to the hub uint8_t OneWireHub::attach(OneWireItem &sensor) { - if (slave_count >= ONEWIRESLAVE_LIMIT) return 255; // hub is full + if (device_count >= _ONEWIREHUB_DEVICE_LIMIT) return 255; // hub is full // demonstrate an 1ms-Low-State on the debug pin (only if bus stays high during this time) // done here because this FN is always called before hub is used @@ -60,18 +60,18 @@ uint8_t OneWireHub::attach(OneWireItem &sensor) // find position of next free storage-position uint8_t position = 255; - for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) + for (uint8_t i = 0; i < _ONEWIREHUB_DEVICE_LIMIT; ++i) { // check for already attached sensors - if (slave_list[i] == &sensor) { return i; } + if (device_list[i] == &sensor) { return i; } // store position of first empty space - if ((position > ONEWIRESLAVE_LIMIT) && (slave_list[i] == nullptr)) { position = i; } + if ((position > _ONEWIREHUB_DEVICE_LIMIT) && (device_list[i] == nullptr)) { position = i; } } if (position == 255) return 255; - slave_list[position] = &sensor; - slave_count++; + device_list[position] = &sensor; + device_count++; buildIDTree(); return position; } @@ -80,9 +80,9 @@ bool OneWireHub::detach(const OneWireItem &sensor) { // find position of sensor uint8_t position = 255; - for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) + for (uint8_t i = 0; i < _ONEWIREHUB_DEVICE_LIMIT; ++i) { - if (slave_list[i] == &sensor) + if (device_list[i] == &sensor) { position = i; break; @@ -94,26 +94,26 @@ bool OneWireHub::detach(const OneWireItem &sensor) return false; } -bool OneWireHub::detach(const uint8_t slave_number) +bool OneWireHub::detach(const uint8_t device_number) { - if (slave_list[slave_number] == nullptr) return false; - if (slave_count == 0) return false; - if (slave_number >= ONEWIRESLAVE_LIMIT) return false; + if (device_list[device_number] == nullptr) return false; + if (device_count == 0) return false; + if (device_number >= _ONEWIREHUB_DEVICE_LIMIT) return false; - slave_list[slave_number] = nullptr; - slave_count--; + device_list[device_number] = nullptr; + device_count--; buildIDTree(); return true; } -// just look through each bit of each ID and build a tree, so there are n=slaveCount decision-points -// trade-off: more online calculation, but @4Slave 16byte storage instead of 3*256 byte +// just look through each bit of each ID and build a tree, so there are n=DeviceCount decision-points +// trade-off: more online calculation, but @4Devices 16byte storage instead of 3*256 byte uint8_t OneWireHub::getNrOfFirstBitSet(const mask_t mask) const { mask_t _mask = mask; - for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) + for (uint8_t i = 0; i < _ONEWIREHUB_DEVICE_LIMIT; ++i) { if ((_mask & 1) != 0) return i; _mask >>= 1; @@ -121,12 +121,12 @@ uint8_t OneWireHub::getNrOfFirstBitSet(const mask_t mask) const return 0; } -// return next not empty element in slave-list +// return next not empty element in device-list uint8_t OneWireHub::getIndexOfNextSensorInList(const uint8_t index_start) const { for (uint8_t i = index_start; i < ONEWIRE_TREE_SIZE; ++i) { - if (slave_list[i] != nullptr) return i; + if (device_list[i] != nullptr) return i; } return 0; } @@ -144,28 +144,28 @@ uint8_t OneWireHub::getNrOfFirstFreeIDTreeElement(void) const // initial FN to build the ID-Tree uint8_t OneWireHub::buildIDTree(void) { - mask_t mask_slaves = 0; - mask_t bit_mask = 0x01; + mask_t mask_devices = 0; + mask_t bit_mask = 0x01; // build mask - for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) + for (uint8_t i = 0; i < _ONEWIREHUB_DEVICE_LIMIT; ++i) { - if (slave_list[i] != nullptr) mask_slaves |= bit_mask; + if (device_list[i] != nullptr) mask_devices |= bit_mask; bit_mask <<= 1; } for (uint8_t i = 0; i < ONEWIRE_TREE_SIZE; ++i) { idTree[i].id_position = 255; } // begin with root-element - buildIDTree(0, mask_slaves); // goto branch + buildIDTree(0, mask_devices); // goto branch return 0; } // returns the branch that this iteration has worked on -uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves) +uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_devices) { - if (mask_slaves == 0) return (255); + if (mask_devices == 0) return (255); while (position_IDBit < 64) { @@ -175,13 +175,13 @@ uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves const uint8_t mask_bit{static_cast(1 << (position_IDBit & 7))}; mask_t mask_id{1}; - // searchIDTree through all active slaves - for (uint8_t id = 0; id < ONEWIRESLAVE_LIMIT; ++id) + // searchIDTree through all active emulated devices + for (uint8_t id = 0; id < _ONEWIREHUB_DEVICE_LIMIT; ++id) { - if ((mask_slaves & mask_id) != 0) + if ((mask_devices & mask_id) != 0) { - // if slave is in mask differentiate the bitValue - if ((slave_list[id]->ID[pos_byte] & mask_bit) != 0) mask_pos |= mask_id; + // if device is in mask differentiate the bitValue + if ((device_list[id]->ID[pos_byte] & mask_bit) != 0) mask_pos |= mask_id; else mask_neg |= mask_id; } mask_id <<= 1; @@ -192,8 +192,8 @@ uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves // there was found a junction const uint8_t active_element = getNrOfFirstFreeIDTreeElement(); - idTree[active_element].id_position = position_IDBit; - idTree[active_element].slave_selected = getNrOfFirstBitSet(mask_slaves); + idTree[active_element].id_position = position_IDBit; + idTree[active_element].device_selected = getNrOfFirstBitSet(mask_devices); position_IDBit++; idTree[active_element].got_one = buildIDTree(position_IDBit, mask_pos); idTree[active_element].got_zero = buildIDTree(position_IDBit, mask_neg); @@ -206,10 +206,10 @@ uint8_t OneWireHub::buildIDTree(uint8_t position_IDBit, const mask_t mask_slaves // gone through the address, store this result uint8_t active_element = getNrOfFirstFreeIDTreeElement(); - idTree[active_element].id_position = 128; - idTree[active_element].slave_selected = getNrOfFirstBitSet(mask_slaves); - idTree[active_element].got_one = 255; - idTree[active_element].got_zero = 255; + idTree[active_element].id_position = 128; + idTree[active_element].device_selected = getNrOfFirstBitSet(mask_devices); + idTree[active_element].got_one = 255; + idTree[active_element].got_zero = 255; return active_element; } @@ -222,15 +222,15 @@ bool OneWireHub::poll(void) while (true) { // this additional check prevents an infinite loop when calling this FN without sensors attached - if (slave_count == 0) return true; + if (device_count == 0) return true; // Once reset is done, go to next step if (checkReset()) return false; - // Reset is complete, tell the master we are present + // Reset is complete, tell the OneWire-Host we are present if (showPresence()) return false; - // Now that the master should know we are here, we will get a command from the master + // Now that the OneWire-Host should know we are here, we will get a command from the Host if (recvAndProcessCmd()) return false; // on total success we want to start again, because the next reset could only be ~125 us away @@ -288,7 +288,7 @@ bool OneWireHub::checkReset( if (!DIRECT_READ(pin_baseReg, pin_bitMask)) return true; // just leave if pin is Low, don't bother to wait, TODO: really needed? - // wait for the bus to become low (master-controlled), since we are polling we don't know for how long it was zero + // wait for the bus to become low (host-controlled), since we are polling we don't know for how long it was zero if (waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_TIMEOUT, true) == 0) { //_error = Error::WAIT_RESET_TIMEOUT; @@ -297,7 +297,7 @@ bool OneWireHub::checkReset( const timeOW_t loops_remaining = waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MAX[0], false); - // wait for bus-release by master + // wait for bus-release by OneWire-Host if (loops_remaining == 0) { _error = Error::VERY_LONG_RESET; @@ -311,7 +311,7 @@ bool OneWireHub::checkReset( }; #endif - // If the master pulled low for to short this will trigger an error + // If the OneWire-Host pulled low for to short this will trigger an error //if (loops_remaining > (ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[od_mode])) _error = Error::VERY_SHORT_RESET; // could be activated again, like the error above, errorhandling is mature enough now return (loops_remaining > (ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[od_mode])); @@ -325,7 +325,7 @@ bool OneWireHub::showPresence(void) static_assert(ONEWIRE_TIME_PRESENCE_MAX[1] > ONEWIRE_TIME_PRESENCE_MIN[1], "Timings are wrong"); #endif - // Master will delay it's "Presence" check (bus-read) after the reset + // OneWire-Host will delay it's "Presence" check (bus-read) after the reset waitLoopsWhilePinIs(ONEWIRE_TIME_PRESENCE_TIMEOUT, true); // no pinCheck demanded, but this additional check can cut waitTime @@ -342,7 +342,7 @@ bool OneWireHub::showPresence(void) if (USE_GPIO_DEBUG) DIRECT_WRITE_LOW(debug_baseReg, debug_bitMask); - // When the master or other slaves release the bus within a given time everything is fine + // When the OneWire-Host or other devices release the bus within a given time everything is fine if (waitLoopsWhilePinIs( (ONEWIRE_TIME_PRESENCE_MAX[od_mode] - ONEWIRE_TIME_PRESENCE_MIN[od_mode]), false) == 0) @@ -359,7 +359,7 @@ void OneWireHub::searchIDTree(void) { uint8_t position_IDBit = 0; uint8_t trigger_pos = 0; - uint8_t active_slave = idTree[trigger_pos].slave_selected; + uint8_t active_device = idTree[trigger_pos].device_selected; uint8_t trigger_bit = idTree[trigger_pos].id_position; while (position_IDBit < 64) @@ -376,7 +376,7 @@ void OneWireHub::searchIDTree(void) // switch to next junction trigger_pos = bit_recv ? idTree[trigger_pos].got_one : idTree[trigger_pos].got_zero; - active_slave = idTree[trigger_pos].slave_selected; + active_device = idTree[trigger_pos].device_selected; trigger_bit = (trigger_pos == 255) ? uint8_t(255) : idTree[trigger_pos].id_position; } @@ -386,7 +386,7 @@ void OneWireHub::searchIDTree(void) const uint8_t mask_bit = (static_cast(1) << (position_IDBit & (7))); bool bit_send; - if ((slave_list[active_slave]->ID[pos_byte] & mask_bit) != 0) + if ((device_list[active_device]->ID[pos_byte] & mask_bit) != 0) { bit_send = true; if (sendBit(true)) return; @@ -407,25 +407,25 @@ void OneWireHub::searchIDTree(void) position_IDBit++; } - slave_selected = slave_list[active_slave]; + device_selected = device_list[active_device]; } bool OneWireHub::recvAndProcessCmd(void) { - // If the only slave is not multidrop compatible, pass all data handling to the slave - if (slave_count == 1u) + // If the only peripheral device is not multidrop compatible, pass all data handling to the device + if (device_count == 1u) { - slave_selected = slave_list[getIndexOfNextSensorInList()]; + device_selected = device_list[getIndexOfNextSensorInList()]; // TODO: this might be expensive for weak uC and OW in Overdrive and only one device emulated // -> look into optimizations, i.e.: // - preselect when only one device present? // - move that at the end of switch in default (less impact for all other hosts) - if (slave_selected->skip_multidrop) + if (device_selected->skip_multidrop) { - slave_selected->duty(this); + device_selected->duty(this); return false; // TODO: Find the root-cause. This fixes the issue but may cause other problems. // -> correct exit would be: return (_error != Error::NO_ERROR); @@ -445,16 +445,16 @@ bool OneWireHub::recvAndProcessCmd(void) { case 0xF0: // Search rom - slave_selected = nullptr; + device_selected = nullptr; noInterrupts(); searchIDTree(); interrupts(); // most ICs allow going for duty() right after search - if ((_error == Error::NO_ERROR) && (slave_selected != nullptr) && - slave_selected->fast_search_rom) + if ((_error == Error::NO_ERROR) && (device_selected != nullptr) && + device_selected->fast_search_rom) { - slave_selected->duty(this); + device_selected->duty(this); } return false; // always trigger a re-init after searchIDTree @@ -468,18 +468,18 @@ bool OneWireHub::recvAndProcessCmd(void) case 0x55: // MATCH ROM - Choose/Select ROM - slave_selected = nullptr; + device_selected = nullptr; if (recv(address, 8)) { break; } - for (uint8_t i = 0; i < ONEWIRESLAVE_LIMIT; ++i) + for (uint8_t i = 0; i < _ONEWIREHUB_DEVICE_LIMIT; ++i) { - if (slave_list[i] == nullptr) continue; + if (device_list[i] == nullptr) continue; flag = true; for (uint8_t j = 0; j < 8; ++j) { - if (slave_list[i]->ID[j] != address[j]) + if (device_list[i]->ID[j] != address[j]) { flag = false; break; @@ -488,17 +488,17 @@ bool OneWireHub::recvAndProcessCmd(void) if (flag) { - slave_selected = slave_list[i]; + device_selected = device_list[i]; break; } } if (!flag) { return true; } - if (slave_selected != nullptr) + if (device_selected != nullptr) { if (USE_GPIO_DEBUG) DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); - slave_selected->duty(this); + device_selected->duty(this); } break; @@ -510,39 +510,39 @@ bool OneWireHub::recvAndProcessCmd(void) #endif case 0xCC: // SKIP ROM - // NOTE: If more than one slave is present on the bus, + // NOTE: If more than one peripheral device is present on the bus, // and a read command is issued following the Skip ROM command, - // data collision will occur on the bus as multiple slaves transmit simultaneously - if ((slave_selected == nullptr) && (slave_count == 1)) + // data collision will occur on the bus as multiple peripheral devices transmit simultaneously + if ((device_selected == nullptr) && (device_count == 1)) { - slave_selected = slave_list[getIndexOfNextSensorInList()]; + device_selected = device_list[getIndexOfNextSensorInList()]; } - if (slave_selected != nullptr) + if (device_selected != nullptr) { if (USE_GPIO_DEBUG) DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); - slave_selected->duty(this); + device_selected->duty(this); } break; case 0x0F: // OLD READ ROM - // only usable when there is ONE slave on the bus --> continue to current readRom + // only usable when there is ONE peripheral device on the bus --> continue to current readRom case 0x33: // READ ROM - // only usable when there is ONE slave on the bus - if ((slave_selected == nullptr) && (slave_count == 1)) + // only usable when there is ONE peripheral device on the bus + if ((device_selected == nullptr) && (device_count == 1)) { - slave_selected = slave_list[getIndexOfNextSensorInList()]; + device_selected = device_list[getIndexOfNextSensorInList()]; } - if (slave_selected != nullptr) + if (device_selected != nullptr) { - slave_selected->sendID(this); + device_selected->sendID(this); // most ICs allow to go to duty() without reset - if ((_error == Error::NO_ERROR) && slave_selected->fast_read_rom) + if ((_error == Error::NO_ERROR) && device_selected->fast_read_rom) { - slave_selected->duty(this); + device_selected->duty(this); } } return false; @@ -550,14 +550,14 @@ bool OneWireHub::recvAndProcessCmd(void) case 0xEC: // ALARM SEARCH // TODO: Alarm searchIDTree command, respond if flag is set - // is like searchIDTree-rom, but only slaves with triggered alarm will appear + // is like searchIDTree-rom, but only peripheral devices with triggered alarm will appear break; case 0xA5: // RESUME COMMAND - if (slave_selected == nullptr) return true; + if (device_selected == nullptr) return true; if (USE_GPIO_DEBUG) DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); - slave_selected->duty(this); + device_selected->duty(this); break; default: // Unknown command @@ -961,8 +961,8 @@ void OneWireHub::printError(void) const else if (_error == Error::AWAIT_TIMESLOT_TIMEOUT_HIGH) Serial.print("await timeout high"); else if (_error == Error::PRESENCE_HIGH_ON_LINE) Serial.print("presence high on line"); else if (_error == Error::INCORRECT_ONEWIRE_CMD) Serial.print("incorrect onewire command"); - else if (_error == Error::INCORRECT_SLAVE_USAGE) - Serial.print("slave was used in incorrect way"); + else if (_error == Error::INCORRECT_DEVICE_USAGE) + Serial.print("peripheral device was used in incorrect way"); else if (_error == Error::TRIED_INCORRECT_WRITE) Serial.print("tried to write in read-slot"); else if (_error == Error::FIRST_TIMESLOT_TIMEOUT) @@ -970,7 +970,7 @@ void OneWireHub::printError(void) const else if (_error == Error::FIRST_BIT_OF_BYTE_TIMEOUT) Serial.print("first bit of byte timeout"); - if ((_error == Error::INCORRECT_ONEWIRE_CMD) || (_error == Error::INCORRECT_SLAVE_USAGE)) + if ((_error == Error::INCORRECT_ONEWIRE_CMD) || (_error == Error::INCORRECT_DEVICE_USAGE)) { Serial.print(" [0x"); Serial.print(_error_cmd, HEX); @@ -984,9 +984,9 @@ Error OneWireHub::getError(void) const { return (_error); } bool OneWireHub::hasError(void) const { return (_error != Error::NO_ERROR); } -void OneWireHub::raiseSlaveError(const uint8_t cmd) +void OneWireHub::raiseDeviceError(const uint8_t cmd) { - _error = Error::INCORRECT_SLAVE_USAGE; + _error = Error::INCORRECT_DEVICE_USAGE; _error_cmd = cmd; } diff --git a/src/OneWireHub.h b/src/OneWireHub.h index 50a81a8..f31ad34 100644 --- a/src/OneWireHub.h +++ b/src/OneWireHub.h @@ -25,18 +25,18 @@ constexpr timeOW_t timeUsToLoops(const uint16_t time_us) #include "OneWireHub_config.h" // outsource configfile -#ifndef HUB_SLAVE_LIMIT - #error "Slavelimit not defined (why?)" -#elif (HUB_SLAVE_LIMIT > 32) - #error "Slavelimit is set too high (32)" -#elif (HUB_SLAVE_LIMIT > 16) +#ifndef ONEWIREHUB_DEVICE_LIMIT + #error "DeviceLimit not defined (why?)" +#elif (ONEWIREHUB_DEVICE_LIMIT > 32) + #error "DeviceLimit is set too high (32)" +#elif (ONEWIREHUB_DEVICE_LIMIT > 16) using mask_t = uint32_t; -#elif (HUB_SLAVE_LIMIT > 8) +#elif (ONEWIREHUB_DEVICE_LIMIT > 8) using mask_t = uint16_t; -#elif (HUB_SLAVE_LIMIT > 0) +#elif (ONEWIREHUB_DEVICE_LIMIT > 0) using mask_t = uint8_t; #else - #error "Slavelimit is set to zero (why?)" + #error "DeviceLimit is set to zero (why?)" #endif constexpr timeOW_t VALUE1k{1000}; // commonly used constant @@ -55,7 +55,7 @@ enum class Error : uint8_t AWAIT_TIMESLOT_TIMEOUT_HIGH = 8, PRESENCE_HIGH_ON_LINE = 9, INCORRECT_ONEWIRE_CMD = 10, - INCORRECT_SLAVE_USAGE = 11, + INCORRECT_DEVICE_USAGE = 11, TRIED_INCORRECT_WRITE = 12, FIRST_TIMESLOT_TIMEOUT = 13, FIRST_BIT_OF_BYTE_TIMEOUT = 14, @@ -68,8 +68,8 @@ class OneWireItem; class OneWireHub { private: - static constexpr uint8_t ONEWIRESLAVE_LIMIT{HUB_SLAVE_LIMIT}; - static constexpr uint8_t ONEWIRE_TREE_SIZE{(2 * ONEWIRESLAVE_LIMIT) - 1}; + static constexpr uint8_t _ONEWIREHUB_DEVICE_LIMIT{ONEWIREHUB_DEVICE_LIMIT}; + static constexpr uint8_t ONEWIRE_TREE_SIZE{(2 * _ONEWIREHUB_DEVICE_LIMIT) - 1}; // TODO: add _ #if OVERDRIVE_ENABLE bool od_mode; @@ -88,20 +88,20 @@ class OneWireHub volatile io_reg_t *debug_baseReg; #endif - uint8_t slave_count; - OneWireItem *slave_list[ONEWIRESLAVE_LIMIT]; // private slave-list (use attach/detach) - OneWireItem *slave_selected; + uint8_t device_count; + OneWireItem *device_list[_ONEWIREHUB_DEVICE_LIMIT]; // private device-list (use attach/detach) + OneWireItem *device_selected; struct IDTree { - uint8_t slave_selected; // for which slave is this jump-command relevant - uint8_t id_position; // where does the algorithm has to look for a junction - uint8_t got_zero; // if 0 switch to which tree branch - uint8_t got_one; // if 1 switch to which tree branch + uint8_t device_selected; // for which device is this jump-command relevant + uint8_t id_position; // where does the algorithm has to look for a junction + uint8_t got_zero; // if 0 switch to which tree branch + uint8_t got_one; // if 1 switch to which tree branch } idTree[ONEWIRE_TREE_SIZE]; uint8_t buildIDTree(void); - uint8_t buildIDTree(uint8_t position_IDBit, mask_t slave_mask); + uint8_t buildIDTree(uint8_t position_IDBit, mask_t device_mask); void searchIDTree(void); uint8_t getNrOfFirstBitSet(mask_t mask) const; @@ -130,7 +130,7 @@ class OneWireHub uint8_t attach(OneWireItem &sensor); bool detach(const OneWireItem &sensor); - bool detach(uint8_t slave_number); + bool detach(uint8_t device_number); uint8_t getIndexOfNextSensorInList(uint8_t index_start = 0) const; @@ -157,7 +157,7 @@ class OneWireHub void printError(void) const; Error getError(void) const; // returns Error bool hasError(void) const; // returns true if Error occurred - void raiseSlaveError(uint8_t cmd = 0); + void raiseDeviceError(uint8_t cmd = 0); Error clearError(void); }; diff --git a/src/OneWireHub_config.h b/src/OneWireHub_config.h index aadf144..16bb2dd 100644 --- a/src/OneWireHub_config.h +++ b/src/OneWireHub_config.h @@ -7,8 +7,9 @@ ///////////////////////////////////////////////////// // INFO: had to go with a define because some compilers use constexpr as simple const --> massive problems -#define HUB_SLAVE_LIMIT 8 // set the limit of the hub HERE, max is 32 devices -#define OVERDRIVE_ENABLE 0 // support overdrive for the slaves +#define ONEWIREHUB_DEVICE_LIMIT \ + 8 // set the limit of the hub HERE, max is 32 devices, TODO: ifnotdef +#define OVERDRIVE_ENABLE 0 // support overdrive for the peripheral devices, TODO: ONEWIREHUB_ constexpr bool USE_SERIAL_DEBUG{ false}; // give debug messages when printError() is called (be aware! it may produce heisenbugs, timing is critical) SHOULD NOT be enabled with < 20 MHz uC @@ -29,13 +30,13 @@ static_assert(!(USE_GPIO_DEBUG && (microsecondsToClockCycles(1) < 20) && (OVERDR // should be --> datasheet // was --> shagrat-legacy -// Reset: every low-state of the master between MIN & MAX microseconds will be recognized as a Reset -constexpr timeOW_t ONEWIRE_TIME_RESET_TIMEOUT = { +// Reset: every low-state of the OneWire-Host between MIN & MAX microseconds will be recognized as a Reset +constexpr timeOW_t ONEWIRE_TIME_RESET_TIMEOUT = { // TODO: rename HUB_ 5000_us}; // for not hanging to long in reset-detection, lower value is better for more responsive applications, but can miss resets -constexpr timeOW_t ONEWIRE_TIME_RESET_MIN[2] = {430_us, 48_us}; // should be 480 -constexpr timeOW_t ONEWIRE_TIME_RESET_MAX[2] = {960_us, 80_us}; // from ds2413 +constexpr timeOW_t ONEWIRE_TIME_RESET_MIN[2] = {430_us, 48_us}; // should be 480 +constexpr timeOW_t ONEWIRE_TIME_RESET_MAX[2] = {960_us, 80_us}; // from ds2413 -// Presence: slave waits TIMEOUT and emits a low state after the reset with ~MIN length, if the bus stays low after that and exceeds MAX the hub will issue an error +// Presence: peripheral device waits TIMEOUT and emits a low state after the reset with ~MIN length, if the bus stays low after that and exceeds MAX the hub will issue an error constexpr timeOW_t ONEWIRE_TIME_PRESENCE_TIMEOUT = { 20_us}; // probe measures 25us, duration of high state between reset and presence constexpr timeOW_t ONEWIRE_TIME_PRESENCE_MIN[2] = {160_us, 8_us}; // was 125 @@ -47,11 +48,11 @@ constexpr timeOW_t ONEWIRE_TIME_MSG_HIGH_TIMEOUT = { constexpr timeOW_t ONEWIRE_TIME_SLOT_MAX[2] = { 135_us, 30_us}; // should be 120, measured from falling edge to next falling edge -// read and write from the viewpoint of the slave!!!! +// read and write from the viewpoint of the peripheral device!!!! constexpr timeOW_t ONEWIRE_TIME_READ_MIN[2] = { 20_us, 4_us}; // should be 15, was 30, says when it is safe to read a valid bit constexpr timeOW_t ONEWIRE_TIME_READ_MAX[2] = { - 60_us, 10_us}; // low states (zeros) of a master should not exceed this time in a slot + 60_us, 10_us}; // low states (zeros) of a OneWire-Host should not exceed this time in a slot constexpr timeOW_t ONEWIRE_TIME_WRITE_ZERO[2] = {30_us, 8_us}; // the hub holds a zero for this long // VALUES FOR STATIC ASSERTS From f67ebe848f9086f735441e874db715d0da40775d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 13:58:46 +0200 Subject: [PATCH 18/29] reduce possible name-collisions and simplify hub-config --- README.md | 16 ++++- src/OneWireHub.cpp | 128 +++++++++++++++++++++------------------- src/OneWireHub.h | 16 +++-- src/OneWireHub_config.h | 74 +++++++++++++---------- 4 files changed, 134 insertions(+), 100 deletions(-) diff --git a/README.md b/README.md index 626da95..9351bad 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,17 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### Features -- supports up to 32 peripheral devices simultaneously (8 is standard setting), adjust `ONEWIREHUB_DEVICE_LIMIT` in `src/OneWireHub_config.h` to safe RAM & program space +- supports up to 32 peripheral devices simultaneously -> 8 is default setting to safe RAM & program space + - just add custom `#define ONEWIREHUB_DEVICE_LIMIT (32)` in your source file + - TODO: add example - implementation-overhead for the hub is minimal and even saves resources for >1 emulated device - hot-plug: add and remove devices as needed during operation + - TODO: add example - support for most onewire-features: `MATCH ROM` (0x55), `SKIP ROM` (0xCC), `READ ROM` (0x0F,0x33), `RESUME COMMAND` (0xA5) - - **OVERDRIVE-Mode**: OneWire-Host can issue `OD SKIP ROM` (0x13) or `OD MATCH ROM` (0x69) and peripheral device stays in this mode till it sees a long reset -> OD-feature must be activated in config - `ALARM SEARCH` (0xEC) is NOT implemented yet! +- **OVERDRIVE-Mode**: + - OneWire-Host can issue `OD SKIP ROM` (0x13) or `OD MATCH ROM` (0x69) and peripheral device stays in this mode till it sees a long reset + - OD-feature must be activated manually by adding `#define ONEWIREHUB_OVERDRIVE_ENABLE (1)` in your source file - cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=2.0.0 recommended)** - use of constexpr instead of #define for better compiler-messages and cleaner code - use static-assertions for compile-time plausibility checks @@ -130,7 +135,7 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - is there more than one OneWire-Host on the bus? It won't work! - has any other sensor (real or emulated) ever worked with this OneWire-Host? -> the simplest device would be a ds2401 - if communication works, but is unstable please check with logic analyzer - - maybe your OneWire-Host is slow and just needs a higher ONEWIRE_TIME_MSG_HIGH_TIMEOUT-value (see OneWireHub_config.h line 37) + - maybe your OneWire-Host is slow and just needs a higher ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT-value (see OneWireHub_config.h line 37) - make sure that serial- and gpio-debugging is disabled (see src/OneWireHub_config.h), especially when using overdrive (be aware! it may produce heisenbugs, timing is critical) - on a slow arduino it can be helpful to disable the serial port completely to get reliable results -> at least comment out serial.begin() - if you can provide a recording via logic-analyzer (logic 8 or similar) there should be chance we can help you @@ -180,6 +185,11 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a - test each example with real OneWire-Hosts, for now it's tested with the onewire-lib and a loxone-system (ds18b20 passed) - [List of all Family-Codes](http://owfs.sourceforge.net/family.html) - [List of Maxim Sensors](https://www.maximintegrated.com/en/app-notes/index.mvp/id/3989) (at the bottom) +- add examples for + - more devices + - overdrive mode + - hw dependent code + ### Connecting the HUB with the Network diff --git a/src/OneWireHub.cpp b/src/OneWireHub.cpp index b831ee8..ca7e5fb 100644 --- a/src/OneWireHub.cpp +++ b/src/OneWireHub.cpp @@ -10,7 +10,7 @@ OneWireHub::OneWireHub(const uint8_t pin) device_count = 0; device_selected = nullptr; -#if OVERDRIVE_ENABLE +#if ONEWIREHUB_OVERDRIVE_ENABLE od_mode = false; #endif @@ -35,7 +35,7 @@ OneWireHub::OneWireHub(const uint8_t pin) static_assert(VALUE_IPL, "Your architecture has not been calibrated yet, please run " "examples/debug/calibrate_by_bus_timing and report instructions per " "loop (IPL) to https://github.com/orgua/OneWireHub"); - static_assert(ONEWIRE_TIME_VALUE_MIN > 2, + static_assert(ONEWIREHUB_TIME_VALUE_MIN > 2, "YOUR ARCHITECTURE IS TOO SLOW, THIS MAY RESULT IN " "TIMING-PROBLEMS"); // it could work though, never tested } @@ -124,7 +124,7 @@ uint8_t OneWireHub::getNrOfFirstBitSet(const mask_t mask) const // return next not empty element in device-list uint8_t OneWireHub::getIndexOfNextSensorInList(const uint8_t index_start) const { - for (uint8_t i = index_start; i < ONEWIRE_TREE_SIZE; ++i) + for (uint8_t i = index_start; i < _ONEWIREHUB_TREE_SIZE; ++i) { if (device_list[i] != nullptr) return i; } @@ -134,7 +134,7 @@ uint8_t OneWireHub::getIndexOfNextSensorInList(const uint8_t index_start) const // gone through the address, store this result uint8_t OneWireHub::getNrOfFirstFreeIDTreeElement(void) const { - for (uint8_t i = 0; i < ONEWIRE_TREE_SIZE; ++i) + for (uint8_t i = 0; i < _ONEWIREHUB_TREE_SIZE; ++i) { if (idTree[i].id_position == 255) return i; } @@ -154,7 +154,7 @@ uint8_t OneWireHub::buildIDTree(void) bit_mask <<= 1; } - for (uint8_t i = 0; i < ONEWIRE_TREE_SIZE; ++i) { idTree[i].id_position = 255; } + for (uint8_t i = 0; i < _ONEWIREHUB_TREE_SIZE; ++i) { idTree[i].id_position = 255; } // begin with root-element buildIDTree(0, mask_devices); // goto branch @@ -242,19 +242,23 @@ bool OneWireHub::checkReset( void) // there is a specific high-time needed before a reset may occur --> >120us { static_assert( - ONEWIRE_TIME_RESET_MIN[0] > (ONEWIRE_TIME_SLOT_MAX[0] + ONEWIRE_TIME_READ_MAX[0]), - "Timings are wrong"); // last number should read: max(ONEWIRE_TIME_WRITE_ZERO,ONEWIRE_TIME_READ_MAX) - static_assert(ONEWIRE_TIME_READ_MAX[0] > ONEWIRE_TIME_WRITE_ZERO[0], - "switch ONEWIRE_TIME_WRITE_ZERO with ONEWIRE_TIME_READ_MAX in checkReset(), " - "because it is bigger (worst case)"); - static_assert(ONEWIRE_TIME_RESET_MAX[0] > ONEWIRE_TIME_RESET_MIN[0], "Timings are wrong"); -#if OVERDRIVE_ENABLE - static_assert(ONEWIRE_TIME_RESET_MIN[1] > (ONEWIRE_TIME_SLOT_MAX[1] + ONEWIRE_TIME_READ_MAX[1]), + ONEWIREHUB_TIME_RESET_MIN[0] > + (ONEWIREHUB_TIME_SLOT_MAX[0] + ONEWIREHUB_TIME_READ_MAX[0]), + "Timings are wrong"); // last number should read: max(ONEWIREHUB_TIME_WRITE_ZERO,ONEWIREHUB_TIME_READ_MAX) + static_assert( + ONEWIREHUB_TIME_READ_MAX[0] > ONEWIREHUB_TIME_WRITE_ZERO[0], + "switch ONEWIREHUB_TIME_WRITE_ZERO with ONEWIREHUB_TIME_READ_MAX in checkReset(), " + "because it is bigger (worst case)"); + static_assert(ONEWIREHUB_TIME_RESET_MAX[0] > ONEWIREHUB_TIME_RESET_MIN[0], "Timings are wrong"); +#if ONEWIREHUB_OVERDRIVE_ENABLE + static_assert(ONEWIREHUB_TIME_RESET_MIN[1] > + (ONEWIREHUB_TIME_SLOT_MAX[1] + ONEWIREHUB_TIME_READ_MAX[1]), "Timings are wrong"); - static_assert(ONEWIRE_TIME_READ_MAX[1] > ONEWIRE_TIME_WRITE_ZERO[1], - "switch ONEWIRE_TIME_WRITE_ZERO with ONEWIRE_TIME_READ_MAX in checkReset(), " - "because it is bigger (worst case)"); - static_assert(ONEWIRE_TIME_RESET_MAX[0] > ONEWIRE_TIME_RESET_MIN[1], "Timings are wrong"); + static_assert( + ONEWIREHUB_TIME_READ_MAX[1] > ONEWIREHUB_TIME_WRITE_ZERO[1], + "switch ONEWIREHUB_TIME_WRITE_ZERO with ONEWIREHUB_TIME_READ_MAX in checkReset(), " + "because it is bigger (worst case)"); + static_assert(ONEWIREHUB_TIME_RESET_MAX[0] > ONEWIREHUB_TIME_RESET_MIN[1], "Timings are wrong"); #endif DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); @@ -263,22 +267,23 @@ bool OneWireHub::checkReset( if (_error == Error::RESET_IN_PROGRESS) { _error = Error::NO_ERROR; - if (waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MIN[od_mode] - ONEWIRE_TIME_SLOT_MAX[od_mode] - - ONEWIRE_TIME_READ_MAX[od_mode], + if (waitLoopsWhilePinIs(ONEWIREHUB_TIME_RESET_MIN[od_mode] - + ONEWIREHUB_TIME_SLOT_MAX[od_mode] - + ONEWIREHUB_TIME_READ_MAX[od_mode], false) == - 0) // last number should read: max(ONEWIRE_TIME_WRITE_ZERO,ONEWIRE_TIME_READ_MAX) + 0) // last number should read: max(ONEWIREHUB_TIME_WRITE_ZERO,ONEWIREHUB_TIME_READ_MAX) { -#if OVERDRIVE_ENABLE +#if ONEWIREHUB_OVERDRIVE_ENABLE const timeOW_t loops_remaining = waitLoopsWhilePinIs( - ONEWIRE_TIME_RESET_MAX[0], + ONEWIREHUB_TIME_RESET_MAX[0], false); // showPresence() wants to start at high, so wait for it - if (od_mode && - ((ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[od_mode]) > loops_remaining)) + if (od_mode && ((ONEWIREHUB_TIME_RESET_MAX[0] - ONEWIREHUB_TIME_RESET_MIN[od_mode]) > + loops_remaining)) { od_mode = false; // normal reset detected, so leave OD-Mode }; #else - waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MAX[0], + waitLoopsWhilePinIs(ONEWIREHUB_TIME_RESET_MAX[0], false); // showPresence() wants to start at high, so wait for it #endif return false; @@ -289,13 +294,13 @@ bool OneWireHub::checkReset( return true; // just leave if pin is Low, don't bother to wait, TODO: really needed? // wait for the bus to become low (host-controlled), since we are polling we don't know for how long it was zero - if (waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_TIMEOUT, true) == 0) + if (waitLoopsWhilePinIs(ONEWIREHUB_TIME_RESET_TIMEOUT, true) == 0) { //_error = Error::WAIT_RESET_TIMEOUT; return true; } - const timeOW_t loops_remaining = waitLoopsWhilePinIs(ONEWIRE_TIME_RESET_MAX[0], false); + const timeOW_t loops_remaining = waitLoopsWhilePinIs(ONEWIREHUB_TIME_RESET_MAX[0], false); // wait for bus-release by OneWire-Host if (loops_remaining == 0) @@ -304,29 +309,32 @@ bool OneWireHub::checkReset( return true; } -#if OVERDRIVE_ENABLE - if (od_mode && ((ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[0]) > loops_remaining)) +#if ONEWIREHUB_OVERDRIVE_ENABLE + if (od_mode && + ((ONEWIREHUB_TIME_RESET_MAX[0] - ONEWIREHUB_TIME_RESET_MIN[0]) > loops_remaining)) { od_mode = false; // normal reset detected, so leave OD-Mode }; #endif // If the OneWire-Host pulled low for to short this will trigger an error - //if (loops_remaining > (ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[od_mode])) _error = Error::VERY_SHORT_RESET; // could be activated again, like the error above, errorhandling is mature enough now + //if (loops_remaining > (ONEWIREHUB_TIME_RESET_MAX[0] - ONEWIREHUB_TIME_RESET_MIN[od_mode])) _error = Error::VERY_SHORT_RESET; // could be activated again, like the error above, errorhandling is mature enough now - return (loops_remaining > (ONEWIRE_TIME_RESET_MAX[0] - ONEWIRE_TIME_RESET_MIN[od_mode])); + return (loops_remaining > (ONEWIREHUB_TIME_RESET_MAX[0] - ONEWIREHUB_TIME_RESET_MIN[od_mode])); } bool OneWireHub::showPresence(void) { - static_assert(ONEWIRE_TIME_PRESENCE_MAX[0] > ONEWIRE_TIME_PRESENCE_MIN[0], "Timings are wrong"); -#if OVERDRIVE_ENABLE - static_assert(ONEWIRE_TIME_PRESENCE_MAX[1] > ONEWIRE_TIME_PRESENCE_MIN[1], "Timings are wrong"); + static_assert(ONEWIREHUB_TIME_PRESENCE_MAX[0] > ONEWIREHUB_TIME_PRESENCE_MIN[0], + "Timings are wrong"); +#if ONEWIREHUB_OVERDRIVE_ENABLE + static_assert(ONEWIREHUB_TIME_PRESENCE_MAX[1] > ONEWIREHUB_TIME_PRESENCE_MIN[1], + "Timings are wrong"); #endif // OneWire-Host will delay it's "Presence" check (bus-read) after the reset - waitLoopsWhilePinIs(ONEWIRE_TIME_PRESENCE_TIMEOUT, + waitLoopsWhilePinIs(ONEWIREHUB_TIME_PRESENCE_TIMEOUT, true); // no pinCheck demanded, but this additional check can cut waitTime if (USE_GPIO_DEBUG) DIRECT_WRITE_HIGH(debug_baseReg, debug_bitMask); @@ -335,7 +343,7 @@ bool OneWireHub::showPresence(void) DIRECT_WRITE_LOW(pin_baseReg, pin_bitMask); DIRECT_MODE_OUTPUT(pin_baseReg, pin_bitMask); // drive output low - wait(ONEWIRE_TIME_PRESENCE_MIN + wait(ONEWIREHUB_TIME_PRESENCE_MIN [od_mode]); // stays till the end, because it drives the bus low itself DIRECT_MODE_INPUT(pin_baseReg, pin_bitMask); // allow it to float @@ -344,8 +352,8 @@ bool OneWireHub::showPresence(void) // When the OneWire-Host or other devices release the bus within a given time everything is fine if (waitLoopsWhilePinIs( - (ONEWIRE_TIME_PRESENCE_MAX[od_mode] - ONEWIRE_TIME_PRESENCE_MIN[od_mode]), false) == - 0) + (ONEWIREHUB_TIME_PRESENCE_MAX[od_mode] - ONEWIREHUB_TIME_PRESENCE_MIN[od_mode]), + false) == 0) { _error = Error::PRESENCE_LOW_ON_LINE; return true; @@ -461,9 +469,9 @@ bool OneWireHub::recvAndProcessCmd(void) case 0x69: // overdrive MATCH ROM -#if OVERDRIVE_ENABLE +#if ONEWIREHUB_OVERDRIVE_ENABLE od_mode = true; - waitLoopsWhilePinIs(ONEWIRE_TIME_READ_MAX[0], false); + waitLoopsWhilePinIs(ONEWIREHUB_TIME_READ_MAX[0], false); #endif case 0x55: // MATCH ROM - Choose/Select ROM @@ -504,9 +512,9 @@ bool OneWireHub::recvAndProcessCmd(void) case 0x3C: // overdrive SKIP ROM -#if OVERDRIVE_ENABLE +#if ONEWIREHUB_OVERDRIVE_ENABLE od_mode = true; - waitLoopsWhilePinIs(ONEWIRE_TIME_READ_MAX[0], false); + waitLoopsWhilePinIs(ONEWIREHUB_TIME_READ_MAX[0], false); #endif case 0xCC: // SKIP ROM @@ -579,7 +587,7 @@ bool OneWireHub::sendBit(const bool value) const bool writeZero = !value; // Wait for bus to rise HIGH, signaling end of last timeslot - timeOW_t retries = ONEWIRE_TIME_SLOT_MAX[od_mode]; + timeOW_t retries = ONEWIREHUB_TIME_SLOT_MAX[od_mode]; while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) ; if (retries == 0) @@ -589,7 +597,7 @@ bool OneWireHub::sendBit(const bool value) } // Wait for bus to fall LOW, start of new timeslot - retries = ONEWIRE_TIME_MSG_HIGH_TIMEOUT; + retries = ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT; while ((DIRECT_READ(pin_baseReg, pin_bitMask) != 0) && (--retries != 0)) ; if (retries == 0) @@ -602,9 +610,9 @@ bool OneWireHub::sendBit(const bool value) if (writeZero) { DIRECT_MODE_OUTPUT(pin_baseReg, pin_bitMask); - retries = ONEWIRE_TIME_WRITE_ZERO[od_mode]; + retries = ONEWIREHUB_TIME_WRITE_ZERO[od_mode]; } - else { retries = ONEWIRE_TIME_READ_MAX[od_mode]; } + else { retries = ONEWIREHUB_TIME_READ_MAX[od_mode]; } while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) ; // TODO: we should check for (!retries) because there could be a reset in progress... @@ -688,7 +696,7 @@ bool OneWireHub::send(const uint8_t dataByte) { return send(&dataByte, 1); } bool OneWireHub::recvBit(void) { // Wait for bus to rise HIGH, signaling end of last timeslot - timeOW_t retries = ONEWIRE_TIME_SLOT_MAX[od_mode]; + timeOW_t retries = ONEWIREHUB_TIME_SLOT_MAX[od_mode]; while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) ; if (retries == 0) @@ -698,7 +706,7 @@ bool OneWireHub::recvBit(void) } // Wait for bus to fall LOW, start of new timeslot - retries = ONEWIRE_TIME_MSG_HIGH_TIMEOUT; + retries = ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT; while ((DIRECT_READ(pin_baseReg, pin_bitMask) != 0) && (--retries != 0)) ; if (retries == 0) @@ -708,7 +716,7 @@ bool OneWireHub::recvBit(void) } // wait a specific time to do a read (data is valid by then), // first difference to inner-loop of write() - retries = ONEWIRE_TIME_READ_MIN[od_mode]; + retries = ONEWIREHUB_TIME_READ_MIN[od_mode]; while ((DIRECT_READ(pin_baseReg, pin_bitMask) == 0) && (--retries != 0)) ; @@ -920,27 +928,27 @@ void OneWireHub::waitLoopsDebug(void) const Serial.print(VALUE_IPL * VALUE1k / microsecondsToClockCycles(1)); Serial.println(" nanoseconds per loop"); Serial.print("reset min : \t"); - Serial.println(ONEWIRE_TIME_RESET_MIN[od_mode]); + Serial.println(ONEWIREHUB_TIME_RESET_MIN[od_mode]); Serial.print("reset max : \t"); - Serial.println(ONEWIRE_TIME_RESET_MAX[od_mode]); + Serial.println(ONEWIREHUB_TIME_RESET_MAX[od_mode]); Serial.print("reset tout : \t"); - Serial.println(ONEWIRE_TIME_RESET_TIMEOUT); + Serial.println(ONEWIREHUB_TIME_RESET_TIMEOUT); Serial.print("presence min : \t"); - Serial.println(ONEWIRE_TIME_PRESENCE_TIMEOUT); + Serial.println(ONEWIREHUB_TIME_PRESENCE_TIMEOUT); Serial.print("presence low : \t"); - Serial.println(ONEWIRE_TIME_PRESENCE_MIN[od_mode]); + Serial.println(ONEWIREHUB_TIME_PRESENCE_MIN[od_mode]); Serial.print("presence low max : \t"); - Serial.println(ONEWIRE_TIME_PRESENCE_MAX[od_mode]); + Serial.println(ONEWIREHUB_TIME_PRESENCE_MAX[od_mode]); Serial.print("msg hi timeout : \t"); - Serial.println(ONEWIRE_TIME_MSG_HIGH_TIMEOUT); + Serial.println(ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT); Serial.print("slot max : \t"); - Serial.println(ONEWIRE_TIME_SLOT_MAX[od_mode]); + Serial.println(ONEWIREHUB_TIME_SLOT_MAX[od_mode]); Serial.print("read1low : \t"); - Serial.println(ONEWIRE_TIME_READ_MAX[od_mode]); + Serial.println(ONEWIREHUB_TIME_READ_MAX[od_mode]); Serial.print("read std : \t"); - Serial.println(ONEWIRE_TIME_READ_MIN[od_mode]); + Serial.println(ONEWIREHUB_TIME_READ_MIN[od_mode]); Serial.print("write zero : \t"); - Serial.println(ONEWIRE_TIME_WRITE_ZERO[od_mode]); + Serial.println(ONEWIREHUB_TIME_WRITE_ZERO[od_mode]); Serial.flush(); } } diff --git a/src/OneWireHub.h b/src/OneWireHub.h index f31ad34..b5151f3 100644 --- a/src/OneWireHub.h +++ b/src/OneWireHub.h @@ -26,9 +26,9 @@ constexpr timeOW_t timeUsToLoops(const uint16_t time_us) #include "OneWireHub_config.h" // outsource configfile #ifndef ONEWIREHUB_DEVICE_LIMIT - #error "DeviceLimit not defined (why?)" + #error "ONEWIREHUB_DEVICE_LIMIT not defined (why?)" #elif (ONEWIREHUB_DEVICE_LIMIT > 32) - #error "DeviceLimit is set too high (32)" + #error "ONEWIREHUB_DEVICE_LIMIT is set too high (>32)" #elif (ONEWIREHUB_DEVICE_LIMIT > 16) using mask_t = uint32_t; #elif (ONEWIREHUB_DEVICE_LIMIT > 8) @@ -39,6 +39,12 @@ using mask_t = uint8_t; #error "DeviceLimit is set to zero (why?)" #endif +#ifndef ONEWIREHUB_OVERDRIVE_ENABLE + #error "ONEWIREHUB_OVERDRIVE_ENABLE not defined (why?)" +#elif !((ONEWIREHUB_OVERDRIVE_ENABLE >= 0) && (ONEWIREHUB_OVERDRIVE_ENABLE <= 1)) + #error "ONEWIREHUB_OVERDRIVE_ENABLE must be 0 or 1" +#endif + constexpr timeOW_t VALUE1k{1000}; // commonly used constant constexpr timeOW_t TIMEOW_MAX{4294967295}; // arduino does not support std-lib... @@ -69,9 +75,9 @@ class OneWireHub { private: static constexpr uint8_t _ONEWIREHUB_DEVICE_LIMIT{ONEWIREHUB_DEVICE_LIMIT}; - static constexpr uint8_t ONEWIRE_TREE_SIZE{(2 * _ONEWIREHUB_DEVICE_LIMIT) - 1}; // TODO: add _ + static constexpr uint8_t _ONEWIREHUB_TREE_SIZE{(2 * _ONEWIREHUB_DEVICE_LIMIT) - 1}; -#if OVERDRIVE_ENABLE +#if ONEWIREHUB_OVERDRIVE_ENABLE bool od_mode; #else static constexpr bool od_mode{false}; @@ -98,7 +104,7 @@ class OneWireHub uint8_t id_position; // where does the algorithm has to look for a junction uint8_t got_zero; // if 0 switch to which tree branch uint8_t got_one; // if 1 switch to which tree branch - } idTree[ONEWIRE_TREE_SIZE]; + } idTree[_ONEWIREHUB_TREE_SIZE]; uint8_t buildIDTree(void); uint8_t buildIDTree(uint8_t position_IDBit, mask_t device_mask); diff --git a/src/OneWireHub_config.h b/src/OneWireHub_config.h index 16bb2dd..db12010 100644 --- a/src/OneWireHub_config.h +++ b/src/OneWireHub_config.h @@ -6,22 +6,30 @@ // CONFIG /////////////////////////////////////////// ///////////////////////////////////////////////////// -// INFO: had to go with a define because some compilers use constexpr as simple const --> massive problems -#define ONEWIREHUB_DEVICE_LIMIT \ - 8 // set the limit of the hub HERE, max is 32 devices, TODO: ifnotdef -#define OVERDRIVE_ENABLE 0 // support overdrive for the peripheral devices, TODO: ONEWIREHUB_ - -constexpr bool USE_SERIAL_DEBUG{ - false}; // give debug messages when printError() is called (be aware! it may produce heisenbugs, timing is critical) SHOULD NOT be enabled with < 20 MHz uC -constexpr bool USE_GPIO_DEBUG{ - false}; // is a better alternative to serial debug (see readme.md for info) SHOULD NOT be enabled with < 20 MHz uC and Overdrive enabled -constexpr uint8_t GPIO_DEBUG_PIN{7}; // digital pin -constexpr uint32_t REPETITIONS{ - 5000}; // for measuring the loop-delay --> 10000L takes ~110ms on atmega328p@16Mhz +// INFO: had to go with #define because some compilers use constexpr as simple const --> massive problems +#ifndef ONEWIREHUB_DEVICE_LIMIT + // set the limit of the hub HERE, max is 32 devices + #define ONEWIREHUB_DEVICE_LIMIT (8) +#endif + +#ifndef ONEWIREHUB_OVERDRIVE_ENABLE + // support overdrive for the peripheral devices + #define ONEWIREHUB_OVERDRIVE_ENABLE (0) +#endif + +// Serial Debug: give debug messages when printError() is called (be aware! it may produce heisenbugs, timing is critical) SHOULD NOT be enabled with < 20 MHz uC +constexpr bool USE_SERIAL_DEBUG{false}; +// Gpio Debug: is a better alternative to serial debug (see readme.md for info) SHOULD NOT be enabled with < 20 MHz uC and Overdrive enabled +constexpr bool USE_GPIO_DEBUG{false}; +constexpr uint8_t GPIO_DEBUG_PIN{7}; // digital pin + +constexpr uint32_t REPETITIONS{5000}; +// ⤷ for measuring the loop-delay --> 10000L takes ~110ms on atmega328p@16Mhz static_assert(!(USE_SERIAL_DEBUG && (microsecondsToClockCycles(1) < 20)), "Serial debug is enabled in OW-Config. SHOULD NOT be enabled with < 20 MHz uC"); -static_assert(!(USE_GPIO_DEBUG && (microsecondsToClockCycles(1) < 20) && (OVERDRIVE_ENABLE != 0)), +static_assert(!(USE_GPIO_DEBUG && (microsecondsToClockCycles(1) < 20) && + (ONEWIREHUB_OVERDRIVE_ENABLE != 0)), "Gpio debug is enabled in OW-Config. SHOULD NOT be enabled with < 20 MHz uC and " "Overdrive enabled"); @@ -31,33 +39,35 @@ static_assert(!(USE_GPIO_DEBUG && (microsecondsToClockCycles(1) < 20) && (OVERDR // was --> shagrat-legacy // Reset: every low-state of the OneWire-Host between MIN & MAX microseconds will be recognized as a Reset -constexpr timeOW_t ONEWIRE_TIME_RESET_TIMEOUT = { // TODO: rename HUB_ - 5000_us}; // for not hanging to long in reset-detection, lower value is better for more responsive applications, but can miss resets -constexpr timeOW_t ONEWIRE_TIME_RESET_MIN[2] = {430_us, 48_us}; // should be 480 -constexpr timeOW_t ONEWIRE_TIME_RESET_MAX[2] = {960_us, 80_us}; // from ds2413 +constexpr timeOW_t ONEWIREHUB_TIME_RESET_TIMEOUT = {5000_us}; +// ⤷ for not hanging to long in reset-detection, lower value is better for more responsive applications, but can miss resets +constexpr timeOW_t ONEWIREHUB_TIME_RESET_MIN[2] = {430_us, 48_us}; // should be 480 +constexpr timeOW_t ONEWIREHUB_TIME_RESET_MAX[2] = {960_us, 80_us}; // from ds2413 // Presence: peripheral device waits TIMEOUT and emits a low state after the reset with ~MIN length, if the bus stays low after that and exceeds MAX the hub will issue an error -constexpr timeOW_t ONEWIRE_TIME_PRESENCE_TIMEOUT = { - 20_us}; // probe measures 25us, duration of high state between reset and presence -constexpr timeOW_t ONEWIRE_TIME_PRESENCE_MIN[2] = {160_us, 8_us}; // was 125 -constexpr timeOW_t ONEWIRE_TIME_PRESENCE_MAX[2] = {480_us, 32_us}; // should be 280, was 480 +constexpr timeOW_t ONEWIREHUB_TIME_PRESENCE_TIMEOUT = {20_us}; +// ⤷ probe measures 25us, duration of high state between reset and presence +constexpr timeOW_t ONEWIREHUB_TIME_PRESENCE_MIN[2] = {160_us, 8_us}; // was 125 +constexpr timeOW_t ONEWIREHUB_TIME_PRESENCE_MAX[2] = {480_us, 32_us}; // should be 280, was 480 -constexpr timeOW_t ONEWIRE_TIME_MSG_HIGH_TIMEOUT = { - 15000_us}; // there can be these inactive / high timeperiods after reset / presence, this value defines the timeout for these -constexpr timeOW_t ONEWIRE_TIME_SLOT_MAX[2] = { - 135_us, 30_us}; // should be 120, measured from falling edge to next falling edge +constexpr timeOW_t ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT = {15000_us}; +// ⤷ there can be these inactive / high timeperiods after reset / presence, this value defines the timeout for these +constexpr timeOW_t ONEWIREHUB_TIME_SLOT_MAX[2] = {135_us, 30_us}; +// ⤷ should be 120, measured from falling edge to next falling edge // read and write from the viewpoint of the peripheral device!!!! -constexpr timeOW_t ONEWIRE_TIME_READ_MIN[2] = { - 20_us, 4_us}; // should be 15, was 30, says when it is safe to read a valid bit -constexpr timeOW_t ONEWIRE_TIME_READ_MAX[2] = { - 60_us, 10_us}; // low states (zeros) of a OneWire-Host should not exceed this time in a slot -constexpr timeOW_t ONEWIRE_TIME_WRITE_ZERO[2] = {30_us, 8_us}; // the hub holds a zero for this long +constexpr timeOW_t ONEWIREHUB_TIME_READ_MIN[2] = {20_us, 4_us}; +// ⤷ should be 15, was 30, says when it is safe to read a valid bit +constexpr timeOW_t ONEWIREHUB_TIME_READ_MAX[2] = {60_us, 10_us}; +// ⤷ low states (zeros) of a OneWire-Host should not exceed this time in a slot +constexpr timeOW_t ONEWIREHUB_TIME_WRITE_ZERO[2] = {30_us, 8_us}; +// ⤷ the hub holds a zero for this long // VALUES FOR STATIC ASSERTS -constexpr timeOW_t ONEWIRE_TIME_VALUE_MAX = {ONEWIRE_TIME_MSG_HIGH_TIMEOUT}; -constexpr timeOW_t ONEWIRE_TIME_VALUE_MIN = {ONEWIRE_TIME_READ_MIN[OVERDRIVE_ENABLE]}; +constexpr timeOW_t ONEWIREHUB_TIME_VALUE_MAX = {ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT}; +constexpr timeOW_t ONEWIREHUB_TIME_VALUE_MIN = { + ONEWIREHUB_TIME_READ_MIN[ONEWIREHUB_OVERDRIVE_ENABLE]}; // TODO: several compilers have problems with constexpress-FN in unified initializers of constexpr, will be removed for now -> test with arduino due, esp32, ... From 51cbb2ce0fc0de5313d85f7388dc964092a69016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 14:30:07 +0200 Subject: [PATCH 19/29] improve documentation --- .bumpversion.cfg | 14 ++ CONTRIBUTING.md | 31 ++- Pipfile | 1 + Pipfile.lock | 503 ++--------------------------------------------- README.md | 11 +- 5 files changed, 64 insertions(+), 496 deletions(-) create mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..db1b617 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,14 @@ +[bumpversion] +current_version = 3.0.0 # major.minor.patch +commit = False +tag = False + +[bumpversion:file:doc/source/conf.py] + +[bumpversion:file:README.md] + +[bumpversion:file:docs/build/html/_static/documentation_options.js] + +[bumpversion:file:library.json] + +[bumpversion:file:library.properties] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6bbb3c2..6d1285a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,13 +86,28 @@ Once your PR is merged, your contributions will be publicly visible on the [GitH Now that you are part of the GitHub docs community, see how else you can [contribute to the docs](/contributing/types-of-contributions.md). -## Windows +### Releasing a new Version -This site can be developed on Windows, however a few potential gotchas need to be kept in mind: +The needed tools get installed automatically with the provided dev-environment (python and pipenv required), example call for ubuntu -1. Regular Expressions: Windows uses `\r\n` for line endings, while Unix based systems use `\n`. Therefore when working on Regular Expressions, use `\r?\n` instead of `\n` in order to support both environments. The Node.js [`os.EOL`](https://nodejs.org/api/os.html#os_os_eol) property can be used to get an OS-specific end-of-line marker. -2. Paths: Windows systems use `\` for the path separator, which would be returned by `path.join` and others. You could use `path.posix`, `path.posix.join` etc and the [slash](https://ghub.io/slash) module, if you need forward slashes - like for constructing URLs - or ensure your code works with either. -3. Bash: Not every Windows developer has a terminal that fully supports Bash, so it's generally preferred to write [scripts](/script) in JavaScript instead of Bash. -4. Filename too long error: There is a 260 character limit for a filename when Git is compiled with `msys`. While the suggestions below are not guaranteed to work and could possibly cause other issues, a few workarounds include: - - Update Git configuration: `git config --system core.longpaths true` - - Consider using a different Git client on Windows +```Shell +pipenv shell +# & at first usage +pipenv install +sudo apt install cppcheck +``` + +Make sure Pre-Commit-Tests run through without new problems + +```Shell + +pre-commit run -a +````` + +Increment Version and decide if changes justify major, minor or patch-release + +```Shell +bump2version --tag patch +``` + +Prepare a Release on Github with Changelog. diff --git a/Pipfile b/Pipfile index 37bfdaf..fa59525 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ sphinx = "*" sphinxawesome-theme = "*" sphinx-sitemap = "*" myst-parser = "*" +bump2version = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 2a4e774..00e04bc 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,491 +1,20 @@ { - "_meta" : { - "hash": {"sha256": "6110fac66c942db3f9eb60d07efbee27f5c22a1e0f87a79a464388c6cd68aa59"}, + "_meta": { + "hash": { + "sha256": "0b0aa517d0a57e17f566e3621de5a2aa346de0de473e3f50ea82c530a734bc6c" + }, "pipfile-spec": 6, - "requires": {"python_version": "3.11"}, - "sources": [{"name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true}] - }, - "default" - : { - "alabaster": { - "hashes": [ - "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3", - "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2" - ], - "markers": "python_version >= '3.6'", - "version": "==0.7.13" - }, - "babel": { - "hashes": [ - "sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610", - "sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455" - ], - "markers": "python_version >= '3.7'", - "version": "==2.12.1" - }, - "beautifulsoup4": { - "hashes": [ - "sha256:492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da", - "sha256:bd2520ca0d9d7d12694a53d44ac482d181b4ec1888909b035a3dbf40d0f57d4a" - ], - "markers": "python_full_version >= '3.6.0'", - "version": "==4.12.2" - }, - "certifi": { - "hashes": [ - "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7", - "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716" - ], - "markers": "python_version >= '3.6'", - "version": "==2023.5.7" - }, - "cfgv": { - "hashes": [ - "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426", - "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736" - ], - "markers": "python_full_version >= '3.6.1'", - "version": "==3.3.1" - }, - "charset-normalizer": { - "hashes": [ - "sha256:04e57ab9fbf9607b77f7d057974694b4f6b142da9ed4a199859d9d4d5c63fe96", - "sha256:09393e1b2a9461950b1c9a45d5fd251dc7c6f228acab64da1c9c0165d9c7765c", - "sha256:0b87549028f680ca955556e3bd57013ab47474c3124dc069faa0b6545b6c9710", - "sha256:1000fba1057b92a65daec275aec30586c3de2401ccdcd41f8a5c1e2c87078706", - "sha256:1249cbbf3d3b04902ff081ffbb33ce3377fa6e4c7356f759f3cd076cc138d020", - "sha256:1920d4ff15ce893210c1f0c0e9d19bfbecb7983c76b33f046c13a8ffbd570252", - "sha256:193cbc708ea3aca45e7221ae58f0fd63f933753a9bfb498a3b474878f12caaad", - "sha256:1a100c6d595a7f316f1b6f01d20815d916e75ff98c27a01ae817439ea7726329", - "sha256:1f30b48dd7fa1474554b0b0f3fdfdd4c13b5c737a3c6284d3cdc424ec0ffff3a", - "sha256:203f0c8871d5a7987be20c72442488a0b8cfd0f43b7973771640fc593f56321f", - "sha256:246de67b99b6851627d945db38147d1b209a899311b1305dd84916f2b88526c6", - "sha256:2dee8e57f052ef5353cf608e0b4c871aee320dd1b87d351c28764fc0ca55f9f4", - "sha256:2efb1bd13885392adfda4614c33d3b68dee4921fd0ac1d3988f8cbb7d589e72a", - "sha256:2f4ac36d8e2b4cc1aa71df3dd84ff8efbe3bfb97ac41242fbcfc053c67434f46", - "sha256:3170c9399da12c9dc66366e9d14da8bf7147e1e9d9ea566067bbce7bb74bd9c2", - "sha256:3b1613dd5aee995ec6d4c69f00378bbd07614702a315a2cf6c1d21461fe17c23", - "sha256:3bb3d25a8e6c0aedd251753a79ae98a093c7e7b471faa3aa9a93a81431987ace", - "sha256:3bb7fda7260735efe66d5107fb7e6af6a7c04c7fce9b2514e04b7a74b06bf5dd", - "sha256:41b25eaa7d15909cf3ac4c96088c1f266a9a93ec44f87f1d13d4a0e86c81b982", - "sha256:45de3f87179c1823e6d9e32156fb14c1927fcc9aba21433f088fdfb555b77c10", - "sha256:46fb8c61d794b78ec7134a715a3e564aafc8f6b5e338417cb19fe9f57a5a9bf2", - "sha256:48021783bdf96e3d6de03a6e39a1171ed5bd7e8bb93fc84cc649d11490f87cea", - "sha256:4957669ef390f0e6719db3613ab3a7631e68424604a7b448f079bee145da6e09", - "sha256:5e86d77b090dbddbe78867a0275cb4df08ea195e660f1f7f13435a4649e954e5", - "sha256:6339d047dab2780cc6220f46306628e04d9750f02f983ddb37439ca47ced7149", - "sha256:681eb3d7e02e3c3655d1b16059fbfb605ac464c834a0c629048a30fad2b27489", - "sha256:6c409c0deba34f147f77efaa67b8e4bb83d2f11c8806405f76397ae5b8c0d1c9", - "sha256:7095f6fbfaa55defb6b733cfeb14efaae7a29f0b59d8cf213be4e7ca0b857b80", - "sha256:70c610f6cbe4b9fce272c407dd9d07e33e6bf7b4aa1b7ffb6f6ded8e634e3592", - "sha256:72814c01533f51d68702802d74f77ea026b5ec52793c791e2da806a3844a46c3", - "sha256:7a4826ad2bd6b07ca615c74ab91f32f6c96d08f6fcc3902ceeedaec8cdc3bcd6", - "sha256:7c70087bfee18a42b4040bb9ec1ca15a08242cf5867c58726530bdf3945672ed", - "sha256:855eafa5d5a2034b4621c74925d89c5efef61418570e5ef9b37717d9c796419c", - "sha256:8700f06d0ce6f128de3ccdbc1acaea1ee264d2caa9ca05daaf492fde7c2a7200", - "sha256:89f1b185a01fe560bc8ae5f619e924407efca2191b56ce749ec84982fc59a32a", - "sha256:8b2c760cfc7042b27ebdb4a43a4453bd829a5742503599144d54a032c5dc7e9e", - "sha256:8c2f5e83493748286002f9369f3e6607c565a6a90425a3a1fef5ae32a36d749d", - "sha256:8e098148dd37b4ce3baca71fb394c81dc5d9c7728c95df695d2dca218edf40e6", - "sha256:94aea8eff76ee6d1cdacb07dd2123a68283cb5569e0250feab1240058f53b623", - "sha256:95eb302ff792e12aba9a8b8f8474ab229a83c103d74a750ec0bd1c1eea32e669", - "sha256:9bd9b3b31adcb054116447ea22caa61a285d92e94d710aa5ec97992ff5eb7cf3", - "sha256:9e608aafdb55eb9f255034709e20d5a83b6d60c054df0802fa9c9883d0a937aa", - "sha256:a103b3a7069b62f5d4890ae1b8f0597618f628b286b03d4bc9195230b154bfa9", - "sha256:a386ebe437176aab38c041de1260cd3ea459c6ce5263594399880bbc398225b2", - "sha256:a38856a971c602f98472050165cea2cdc97709240373041b69030be15047691f", - "sha256:a401b4598e5d3f4a9a811f3daf42ee2291790c7f9d74b18d75d6e21dda98a1a1", - "sha256:a7647ebdfb9682b7bb97e2a5e7cb6ae735b1c25008a70b906aecca294ee96cf4", - "sha256:aaf63899c94de41fe3cf934601b0f7ccb6b428c6e4eeb80da72c58eab077b19a", - "sha256:b0dac0ff919ba34d4df1b6131f59ce95b08b9065233446be7e459f95554c0dc8", - "sha256:baacc6aee0b2ef6f3d308e197b5d7a81c0e70b06beae1f1fcacffdbd124fe0e3", - "sha256:bf420121d4c8dce6b889f0e8e4ec0ca34b7f40186203f06a946fa0276ba54029", - "sha256:c04a46716adde8d927adb9457bbe39cf473e1e2c2f5d0a16ceb837e5d841ad4f", - "sha256:c0b21078a4b56965e2b12f247467b234734491897e99c1d51cee628da9786959", - "sha256:c1c76a1743432b4b60ab3358c937a3fe1341c828ae6194108a94c69028247f22", - "sha256:c4983bf937209c57240cff65906b18bb35e64ae872da6a0db937d7b4af845dd7", - "sha256:c4fb39a81950ec280984b3a44f5bd12819953dc5fa3a7e6fa7a80db5ee853952", - "sha256:c57921cda3a80d0f2b8aec7e25c8aa14479ea92b5b51b6876d975d925a2ea346", - "sha256:c8063cf17b19661471ecbdb3df1c84f24ad2e389e326ccaf89e3fb2484d8dd7e", - "sha256:ccd16eb18a849fd8dcb23e23380e2f0a354e8daa0c984b8a732d9cfaba3a776d", - "sha256:cd6dbe0238f7743d0efe563ab46294f54f9bc8f4b9bcf57c3c666cc5bc9d1299", - "sha256:d62e51710986674142526ab9f78663ca2b0726066ae26b78b22e0f5e571238dd", - "sha256:db901e2ac34c931d73054d9797383d0f8009991e723dab15109740a63e7f902a", - "sha256:e03b8895a6990c9ab2cdcd0f2fe44088ca1c65ae592b8f795c3294af00a461c3", - "sha256:e1c8a2f4c69e08e89632defbfabec2feb8a8d99edc9f89ce33c4b9e36ab63037", - "sha256:e4b749b9cc6ee664a3300bb3a273c1ca8068c46be705b6c31cf5d276f8628a94", - "sha256:e6a5bf2cba5ae1bb80b154ed68a3cfa2fa00fde979a7f50d6598d3e17d9ac20c", - "sha256:e857a2232ba53ae940d3456f7533ce6ca98b81917d47adc3c7fd55dad8fab858", - "sha256:ee4006268ed33370957f55bf2e6f4d263eaf4dc3cfc473d1d90baff6ed36ce4a", - "sha256:eef9df1eefada2c09a5e7a40991b9fc6ac6ef20b1372abd48d2794a316dc0449", - "sha256:f058f6963fd82eb143c692cecdc89e075fa0828db2e5b291070485390b2f1c9c", - "sha256:f25c229a6ba38a35ae6e25ca1264621cc25d4d38dca2942a7fce0b67a4efe918", - "sha256:f2a1d0fd4242bd8643ce6f98927cf9c04540af6efa92323e9d3124f57727bfc1", - "sha256:f7560358a6811e52e9c4d142d497f1a6e10103d3a6881f18d04dbce3729c0e2c", - "sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac", - "sha256:f87f746ee241d30d6ed93969de31e5ffd09a2961a051e60ae6bddde9ec3583aa" - ], - "markers": "python_full_version >= '3.7.0'", - "version": "==3.2.0" - }, - "distlib": { - "hashes": [ - "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46", - "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e" - ], - "version": "==0.3.6" - }, - "docutils": { - "hashes": [ - "sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6", - "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b" - ], - "markers": "python_version >= '3.7'", - "version": "==0.20.1" - }, - "filelock": { - "hashes": [ - "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81", - "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec" - ], - "markers": "python_version >= '3.7'", - "version": "==3.12.2" - }, - "identify": { - "hashes": [ - "sha256:0aac67d5b4812498056d28a9a512a483f5085cc28640b02b258a59dac34301d4", - "sha256:986dbfb38b1140e763e413e6feb44cd731faf72d1909543178aa79b0e258265d" - ], - "markers": "python_version >= '3.7'", - "version": "==2.5.24" - }, - "idna": { - "hashes": [ - "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", - "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" - ], - "markers": "python_version >= '3.5'", - "version": "==3.4" - }, - "imagesize": { - "hashes": [ - "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b", - "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.4.1" - }, - "jinja2": { - "hashes": [ - "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852", - "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61" - ], - "markers": "python_version >= '3.7'", - "version": "==3.1.2" - }, - "markdown-it-py": { - "hashes": [ - "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", - "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb" - ], - "markers": "python_version >= '3.8'", - "version": "==3.0.0" - }, - "markupsafe": { - "hashes": [ - "sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e", - "sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e", - "sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431", - "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686", - "sha256:1577735524cdad32f9f694208aa75e422adba74f1baee7551620e43a3141f559", - "sha256:1b40069d487e7edb2676d3fbdb2b0829ffa2cd63a2ec26c4938b2d34391b4ecc", - "sha256:282c2cb35b5b673bbcadb33a585408104df04f14b2d9b01d4c345a3b92861c2c", - "sha256:2c1b19b3aaacc6e57b7e25710ff571c24d6c3613a45e905b1fde04d691b98ee0", - "sha256:2ef12179d3a291be237280175b542c07a36e7f60718296278d8593d21ca937d4", - "sha256:338ae27d6b8745585f87218a3f23f1512dbf52c26c28e322dbe54bcede54ccb9", - "sha256:3c0fae6c3be832a0a0473ac912810b2877c8cb9d76ca48de1ed31e1c68386575", - "sha256:3fd4abcb888d15a94f32b75d8fd18ee162ca0c064f35b11134be77050296d6ba", - "sha256:42de32b22b6b804f42c5d98be4f7e5e977ecdd9ee9b660fda1a3edf03b11792d", - "sha256:504b320cd4b7eff6f968eddf81127112db685e81f7e36e75f9f84f0df46041c3", - "sha256:525808b8019e36eb524b8c68acdd63a37e75714eac50e988180b169d64480a00", - "sha256:56d9f2ecac662ca1611d183feb03a3fa4406469dafe241673d521dd5ae92a155", - "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac", - "sha256:65c1a9bcdadc6c28eecee2c119465aebff8f7a584dd719facdd9e825ec61ab52", - "sha256:68e78619a61ecf91e76aa3e6e8e33fc4894a2bebe93410754bd28fce0a8a4f9f", - "sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8", - "sha256:6b2b56950d93e41f33b4223ead100ea0fe11f8e6ee5f641eb753ce4b77a7042b", - "sha256:787003c0ddb00500e49a10f2844fac87aa6ce977b90b0feaaf9de23c22508b24", - "sha256:7ef3cb2ebbf91e330e3bb937efada0edd9003683db6b57bb108c4001f37a02ea", - "sha256:8023faf4e01efadfa183e863fefde0046de576c6f14659e8782065bcece22198", - "sha256:8758846a7e80910096950b67071243da3e5a20ed2546e6392603c096778d48e0", - "sha256:8afafd99945ead6e075b973fefa56379c5b5c53fd8937dad92c662da5d8fd5ee", - "sha256:8c41976a29d078bb235fea9b2ecd3da465df42a562910f9022f1a03107bd02be", - "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2", - "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707", - "sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6", - "sha256:9dcdfd0eaf283af041973bff14a2e143b8bd64e069f4c383416ecd79a81aab58", - "sha256:aa7bd130efab1c280bed0f45501b7c8795f9fdbeb02e965371bbef3523627779", - "sha256:ab4a0df41e7c16a1392727727e7998a467472d0ad65f3ad5e6e765015df08636", - "sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c", - "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad", - "sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee", - "sha256:b7ff0f54cb4ff66dd38bebd335a38e2c22c41a8ee45aa608efc890ac3e3931bc", - "sha256:bfce63a9e7834b12b87c64d6b155fdd9b3b96191b6bd334bf37db7ff1fe457f2", - "sha256:c011a4149cfbcf9f03994ec2edffcb8b1dc2d2aede7ca243746df97a5d41ce48", - "sha256:c9c804664ebe8f83a211cace637506669e7890fec1b4195b505c214e50dd4eb7", - "sha256:ca379055a47383d02a5400cb0d110cef0a776fc644cda797db0c5696cfd7e18e", - "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b", - "sha256:cd0f502fe016460680cd20aaa5a76d241d6f35a1c3350c474bac1273803893fa", - "sha256:ceb01949af7121f9fc39f7d27f91be8546f3fb112c608bc4029aef0bab86a2a5", - "sha256:d080e0a5eb2529460b30190fcfcc4199bd7f827663f858a226a81bc27beaa97e", - "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb", - "sha256:df0be2b576a7abbf737b1575f048c23fb1d769f267ec4358296f31c2479db8f9", - "sha256:e09031c87a1e51556fdcb46e5bd4f59dfb743061cf93c4d6831bf894f125eb57", - "sha256:e4dd52d80b8c83fdce44e12478ad2e85c64ea965e75d66dbeafb0a3e77308fcc", - "sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2" - ], - "markers": "python_version >= '3.7'", - "version": "==2.1.3" - }, - "mdit-py-plugins": { - "hashes": [ - "sha256:b51b3bb70691f57f974e257e367107857a93b36f322a9e6d44ca5bf28ec2def9", - "sha256:d8ab27e9aed6c38aa716819fedfde15ca275715955f8a185a8e1cf90fb1d2c1b" - ], - "markers": "python_version >= '3.8'", - "version": "==0.4.0" - }, - "mdurl": { - "hashes": [ - "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", - "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" - ], - "markers": "python_version >= '3.7'", - "version": "==0.1.2" - }, - "myst-parser": { - "hashes": [ - "sha256:7c36344ae39c8e740dad7fdabf5aa6fc4897a813083c6cc9990044eb93656b14", - "sha256:ea929a67a6a0b1683cdbe19b8d2e724cd7643f8aa3e7bb18dd65beac3483bead" - ], - "index": "pypi", - "version": "==2.0.0" - }, - "nodeenv": { - "hashes": [ - "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2", - "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, " - "3.4, 3.5, 3.6'", - "version": "==1.8.0" - }, - "packaging": { - "hashes": [ - "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61", - "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f" - ], - "markers": "python_version >= '3.7'", - "version": "==23.1" - }, - "platformdirs": { - "hashes": [ - "sha256:cec7b889196b9144d088e4c57d9ceef7374f6c39694ad1577a0aab50d27ea28c", - "sha256:f87ca4fcff7d2b0f81c6a748a77973d7af0f4d526f98f308477c3c436c74d528" - ], - "markers": "python_version >= '3.7'", - "version": "==3.8.1" - }, - "pre-commit": { - "hashes": [ - "sha256:10badb65d6a38caff29703362271d7dca483d01da88f9d7e05d0b97171c136cb", - "sha256:a2256f489cd913d575c145132ae196fe335da32d91a8294b7afe6622335dd023" - ], - "index": "pypi", - "version": "==3.3.3" - }, - "pygments": { - "hashes": [ - "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c", - "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1" - ], - "markers": "python_version >= '3.7'", - "version": "==2.15.1" - }, - "python-dotenv": { - "hashes": [ - "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba", - "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a" - ], - "markers": "python_version >= '3.8'", - "version": "==1.0.0" - }, - "pyyaml": { - "hashes": [ - "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf", - "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", - "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b", - "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57", - "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b", - "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4", - "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07", - "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba", - "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9", - "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287", - "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513", - "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0", - "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782", - "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0", - "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92", - "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f", - "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2", - "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc", - "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1", - "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c", - "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86", - "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4", - "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c", - "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34", - "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b", - "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d", - "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c", - "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb", - "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7", - "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737", - "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3", - "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d", - "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358", - "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53", - "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78", - "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803", - "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a", - "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f", - "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", - "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" - ], - "markers": "python_version >= '3.6'", - "version": "==6.0" - }, - "requests": { - "hashes": [ - "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", - "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" - ], - "markers": "python_version >= '3.7'", - "version": "==2.31.0" - }, - "setuptools": { - "hashes": [ - "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f", - "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235" - ], - "markers": "python_version >= '3.7'", - "version": "==68.0.0" - }, - "snowballstemmer": { - "hashes": [ - "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1", - "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a" - ], - "version": "==2.2.0" - }, - "soupsieve": { - "hashes": [ - "sha256:1c1bfee6819544a3447586c889157365a27e10d88cde3ad3da0cf0ddf646feb8", - "sha256:89d12b2d5dfcd2c9e8c22326da9d9aa9cb3dfab0a83a024f05704076ee8d35ea" - ], - "markers": "python_version >= '3.7'", - "version": "==2.4.1" - }, - "sphinx": { - "hashes": [ - "sha256:60c5e04756c1709a98845ed27a2eed7a556af3993afb66e77fec48189f742616", - "sha256:61e025f788c5977d9412587e733733a289e2b9fdc2fef8868ddfbfc4ccfe881d" - ], - "index": "pypi", - "version": "==7.0.1" - }, - "sphinx-sitemap": { - "hashes": [ - "sha256:95101f622d0d594161720cbe92a39d353efae9382f7f3563f06d150b1146fef6", - "sha256:98a7e3bb25acb467037b56f3585fc38d53d5a274542b1497393a66f71b79b125" - ], - "index": "pypi", - "version": "==2.5.0" - }, - "sphinxawesome-theme": { - "hashes": [ - "sha256:827b810ce314adb3146ccbce4787d6a6fa94de6dea7c61ef081a239ba70a1d25", - "sha256:fb6b4ba63583199d6c1d837ffc0fea8d63e4bc3537be9b27c563d82dcf3b25c2" - ], - "index": "pypi", - "version": "==4.1.0" - }, - "sphinxcontrib-applehelp": { - "hashes": [ - "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228", - "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e" - ], - "markers": "python_version >= '3.8'", - "version": "==1.0.4" - }, - "sphinxcontrib-devhelp": { - "hashes": [ - "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e", - "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4" - ], - "markers": "python_version >= '3.5'", - "version": "==1.0.2" - }, - "sphinxcontrib-htmlhelp": { - "hashes": [ - "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff", - "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903" - ], - "markers": "python_version >= '3.8'", - "version": "==2.0.1" - }, - "sphinxcontrib-jsmath": { - "hashes": [ - "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", - "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" - ], - "markers": "python_version >= '3.5'", - "version": "==1.0.1" - }, - "sphinxcontrib-qthelp": { - "hashes": [ - "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72", - "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6" - ], - "markers": "python_version >= '3.5'", - "version": "==1.0.3" - }, - "sphinxcontrib-serializinghtml": { - "hashes": [ - "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd", - "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952" - ], - "markers": "python_version >= '3.5'", - "version": "==1.1.5" - }, - "urllib3": { - "hashes": [ - "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1", - "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825" - ], - "markers": "python_version >= '3.7'", - "version": "==2.0.3" - }, - "virtualenv": { - "hashes": [ - "sha256:34da10f14fea9be20e0fd7f04aba9732f84e593dac291b757ce42e3368a39419", - "sha256:8ff19a38c1021c742148edc4f81cb43d7f8c6816d2ede2ab72af5b84c749ade1" - ], - "markers": "python_version >= '3.7'", - "version": "==20.23.1" - } + "requires": { + "python_version": "3.11" }, - "develop": - {} + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": {} } diff --git a/README.md b/README.md index 9351bad..ccf83e3 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### HELP - What to do if things don't work as expected? - check if your arduino software up to date (>v1.8.0) -- update this lib to the latest release (v3.0.0) +- update this lib to the latest release (3.0.0) - if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation - check if clock-speed of the µC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical - begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the OneWire-Host won't switch to higher data rates @@ -145,6 +145,15 @@ Note: **Bold printed devices are feature-complete and were mostly tested with a ### Recent development (latest at the top) +v3.0.0 + +- improve documentation +- replace discriminatory language +- reduce name-collision +- improve config for hub (adjust device_limit & overdrive directly in main source-file) + +v2.0.0 + - travis CI and unittests - more explicit coding, a lot of bugfixes with the help of unit tests (mainly esp8266, bea910, ds18b20) - interface of hub and devices has changed, check header-file or examples for more info From 181a189a54c3cb9f66bf2fb0bd1448bdadfb5674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 14:30:11 +0200 Subject: [PATCH 20/29] Update compile.yml --- .github/workflows/compile.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index 411531b..eebe940 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -16,6 +16,12 @@ jobs: - uno example: - ./examples/BAE910_device/BAE910_device.ino + - ./examples/debug/attiny85-4devices/attiny85-4devices.ino + - ./examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino + - ./examples/debug/CRC-Comparison/CRC-Comparison.ino + - ./examples/debug/irq-driven-playground/irq-driven-playground.ino + - ./examples/debug/optimize_pinAccess/optimize_pinAccess.ino + - ./examples/debug/programsize_documentation/programsize_documentation.ino # - ./examples/DS18B20_asInterface/DS18B20_asInterface.ino # needs I2C - ./examples/DS18B20_thermometer/DS18B20_thermometer.ino - ./examples/DS2401_serial/DS2401_serial.ino From b570dba93fd8210191c329dc7edb2575ef9bcc60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 21:54:42 +0200 Subject: [PATCH 21/29] further reduce possible name-collisions --- examples/OneWireHubTest/OneWireHubTest.ino | 3 +- .../debug/CRC-Comparison/CRC-Comparison.ino | 4 +- src/BAE910.h | 4 +- src/DS18B20.h | 4 +- src/DS2401.h | 4 +- src/DS2405.h | 4 +- src/DS2408.h | 4 +- src/DS2413.h | 4 +- src/DS2423.h | 4 +- src/DS2430.h | 4 +- src/DS2431.h | 4 +- src/DS2433.h | 4 +- src/DS2438.h | 4 +- src/DS2450.h | 4 +- src/DS2502.h | 4 +- src/DS2506.h | 4 +- src/DS2890.h | 4 +- src/OneWireHub.h | 4 +- src/platform.h | 43 ++++++++++++------- 19 files changed, 64 insertions(+), 50 deletions(-) diff --git a/examples/OneWireHubTest/OneWireHubTest.ino b/examples/OneWireHubTest/OneWireHubTest.ino index 06b3dcb..0b5a417 100644 --- a/examples/OneWireHubTest/OneWireHubTest.ino +++ b/examples/OneWireHubTest/OneWireHubTest.ino @@ -9,7 +9,8 @@ * 9232 & 706 byte with arduino 1.6.10 and onewirehub 2.0.1 for UNO * 9272 & 708 byte with arduino 1.8.03 and onewirehub 2.0.1 for UNO * 9288 & 708 byte with arduino 1.8.03 and onewirehub 2.0.2 for UNO - * 9028 & 708 byte with arduino 2.0.00 and onewirehub 2.2.1 for UNO (gcc 7.3) + * 9028 & 708 byte with arduino 2.0.0 and onewirehub 2.2.1 for UNO (gcc 7.3) + * 9096 & 742 byte with arduino 2.1.1 and onewirehub 2.2.4 for UNO (gcc 7.3) */ #include "OneWireHub.h" diff --git a/examples/debug/CRC-Comparison/CRC-Comparison.ino b/examples/debug/CRC-Comparison/CRC-Comparison.ino index ae41369..11a9c05 100644 --- a/examples/debug/CRC-Comparison/CRC-Comparison.ino +++ b/examples/debug/CRC-Comparison/CRC-Comparison.ino @@ -203,7 +203,7 @@ uint16_t v1A_crc16_get(void) { return crc16; } bool v1B_crc16_update(uint8_t dataByte, uint16_t &crc16) { - //_error = ONEWIRE_NO_ERROR; + //_error = ONEWIREHUB_NO_ERROR; for (uint8_t counter = 0; counter < 8; ++counter) { //sendBit((bitMask & dataByte) ? 1 : 0); @@ -222,7 +222,7 @@ bool v1B_crc16_update(uint8_t dataByte, uint16_t &crc16) uint16_t v1C_crc16_update(uint8_t dataByte, uint16_t crc16) { - //_error = ONEWIRE_NO_ERROR; + //_error = ONEWIREHUB_NO_ERROR; for (uint8_t counter = 0; counter < 8; ++counter) { //sendBit((bitMask & dataByte) ? 1 : 0); diff --git a/src/BAE910.h b/src/BAE910.h index 77e9d81..9ff1879 100644 --- a/src/BAE910.h +++ b/src/BAE910.h @@ -2,8 +2,8 @@ // works, basic functionality // native bus-features: unknown -#ifndef ONEWIRE_BAE910_H -#define ONEWIRE_BAE910_H +#ifndef ONEWIREHUB_BAE910_H +#define ONEWIREHUB_BAE910_H #include "OneWireItem.h" diff --git a/src/DS18B20.h b/src/DS18B20.h index 9f9c715..99bf442 100644 --- a/src/DS18B20.h +++ b/src/DS18B20.h @@ -5,8 +5,8 @@ // DS1822: 9-12bit, -55 - +125 degC // native bus-features: alarm search -#ifndef ONEWIRE_DS18B20_H -#define ONEWIRE_DS18B20_H +#ifndef ONEWIREHUB_DS18B20_H +#define ONEWIREHUB_DS18B20_H #include "OneWireItem.h" diff --git a/src/DS2401.h b/src/DS2401.h index f0d2a23..de7a7c1 100644 --- a/src/DS2401.h +++ b/src/DS2401.h @@ -2,8 +2,8 @@ // Works // native bus-features: none -#ifndef ONEWIRE_DS2401_H -#define ONEWIRE_DS2401_H +#ifndef ONEWIREHUB_DS2401_H +#define ONEWIREHUB_DS2401_H #include "OneWireItem.h" diff --git a/src/DS2405.h b/src/DS2405.h index a923a44..0682909 100644 --- a/src/DS2405.h +++ b/src/DS2405.h @@ -3,8 +3,8 @@ // this IC is not using standard protocol - it sends data after searchRom and alarmSearch // native bus-features: alarm search -#ifndef ONEWIRE_DS2405_H -#define ONEWIRE_DS2405_H +#ifndef ONEWIREHUB_DS2405_H +#define ONEWIREHUB_DS2405_H #include "OneWireItem.h" diff --git a/src/DS2408.h b/src/DS2408.h index 1aa8401..9167233 100644 --- a/src/DS2408.h +++ b/src/DS2408.h @@ -2,8 +2,8 @@ // works, but no alarm search and higher logic / output / control register-action // native bus-features: Overdrive capable, alarm search -#ifndef ONEWIRE_DS2408_H -#define ONEWIRE_DS2408_H +#ifndef ONEWIREHUB_DS2408_H +#define ONEWIREHUB_DS2408_H #include "OneWireItem.h" diff --git a/src/DS2413.h b/src/DS2413.h index e5360b3..4b57049 100644 --- a/src/DS2413.h +++ b/src/DS2413.h @@ -2,8 +2,8 @@ // Works, OneWire-Host can latch the pin and pull it thereby down // native bus-features: Overdrive capable -#ifndef ONEWIRE_DS2413_H -#define ONEWIRE_DS2413_H +#ifndef ONEWIREHUB_DS2413_H +#define ONEWIREHUB_DS2413_H #include "OneWireItem.h" diff --git a/src/DS2423.h b/src/DS2423.h index 4b7c89b..9f7d0cd 100644 --- a/src/DS2423.h +++ b/src/DS2423.h @@ -2,8 +2,8 @@ // works // native bus-features: Overdrive capable -#ifndef ONEWIRE_DS2423_H -#define ONEWIRE_DS2423_H +#ifndef ONEWIREHUB_DS2423_H +#define ONEWIREHUB_DS2423_H #include "OneWireItem.h" diff --git a/src/DS2430.h b/src/DS2430.h index 282c4ad..2d43820 100644 --- a/src/DS2430.h +++ b/src/DS2430.h @@ -1,8 +1,8 @@ // 256bit 1-Wire EEPROM & 64bit OTP // works -#ifndef ONEWIRE_DS2430_H -#define ONEWIRE_DS2430_H +#ifndef ONEWIREHUB_DS2430_H +#define ONEWIREHUB_DS2430_H #include "OneWireItem.h" diff --git a/src/DS2431.h b/src/DS2431.h index b4378af..41e71eb 100644 --- a/src/DS2431.h +++ b/src/DS2431.h @@ -3,8 +3,8 @@ // note: datasheet is fuzzy, but device is similar to ds2433 // native bus-features: Overdrive capable -#ifndef ONEWIRE_DS2431_H -#define ONEWIRE_DS2431_H +#ifndef ONEWIREHUB_DS2431_H +#define ONEWIREHUB_DS2431_H #include "OneWireItem.h" diff --git a/src/DS2433.h b/src/DS2433.h index 795d2e2..8086114 100644 --- a/src/DS2433.h +++ b/src/DS2433.h @@ -2,8 +2,8 @@ // works // native bus-features: Overdrive capable -#ifndef ONEWIRE_DS2433_H -#define ONEWIRE_DS2433_H +#ifndef ONEWIREHUB_DS2433_H +#define ONEWIREHUB_DS2433_H #include "OneWireItem.h" diff --git a/src/DS2438.h b/src/DS2438.h index cbe3ba1..28e567e 100644 --- a/src/DS2438.h +++ b/src/DS2438.h @@ -2,8 +2,8 @@ // works, but without real EPROM copy/recall functionality, Timer, // native bus-features: none -#ifndef ONEWIRE_DS2438_H -#define ONEWIRE_DS2438_H +#ifndef ONEWIREHUB_DS2438_H +#define ONEWIREHUB_DS2438_H #include "OneWireItem.h" diff --git a/src/DS2450.h b/src/DS2450.h index a63b62e..feb09b7 100644 --- a/src/DS2450.h +++ b/src/DS2450.h @@ -2,8 +2,8 @@ // works, but without alarm features and other controllable functions beside ADC-Reading // native bus-features: Overdrive capable, alarm search -#ifndef ONEWIRE_DS2450_H -#define ONEWIRE_DS2450_H +#ifndef ONEWIREHUB_DS2450_H +#define ONEWIREHUB_DS2450_H #include "OneWireItem.h" diff --git a/src/DS2502.h b/src/DS2502.h index 49fc1e7..145bb15 100644 --- a/src/DS2502.h +++ b/src/DS2502.h @@ -2,8 +2,8 @@ // works, writing could not be tested (DS9490 does not support hi-voltage mode and complains) // native bus-features: none -#ifndef ONEWIRE_DS2502_H -#define ONEWIRE_DS2502_H +#ifndef ONEWIREHUB_DS2502_H +#define ONEWIREHUB_DS2502_H #include "OneWireItem.h" diff --git a/src/DS2506.h b/src/DS2506.h index cdb1864..5b51f45 100644 --- a/src/DS2506.h +++ b/src/DS2506.h @@ -3,8 +3,8 @@ // note: not available memory will be redirected or faked // native bus-features: Overdrive capable -#ifndef ONEWIRE_DS2506_H -#define ONEWIRE_DS2506_H +#ifndef ONEWIREHUB_DS2506_H +#define ONEWIREHUB_DS2506_H #include "OneWireItem.h" diff --git a/src/DS2890.h b/src/DS2890.h index aea01ad..bab3350 100644 --- a/src/DS2890.h +++ b/src/DS2890.h @@ -2,8 +2,8 @@ // Works, is prepared for four channels // native bus-features: Overdrive capable -#ifndef ONEWIRE_DS2890_H -#define ONEWIRE_DS2890_H +#ifndef ONEWIREHUB_DS2890_H +#define ONEWIREHUB_DS2890_H #include "OneWireItem.h" diff --git a/src/OneWireHub.h b/src/OneWireHub.h index b5151f3..2ad9aa4 100644 --- a/src/OneWireHub.h +++ b/src/OneWireHub.h @@ -1,5 +1,5 @@ -#ifndef ONEWIRE_HUB_H -#define ONEWIRE_HUB_H +#ifndef ONEWIREHUB_HUB_H +#define ONEWIREHUB_HUB_H #include "platform.h" // code for compatibility diff --git a/src/platform.h b/src/platform.h index 371dbea..e096382 100644 --- a/src/platform.h +++ b/src/platform.h @@ -10,9 +10,9 @@ // determine gcc version, will produce number like 40803 for gcc 4.8.3 #if defined(__GNUC__) - #define ONEWIRE_GCC_VERSION ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) + #define ONEWIREHUB_GCC_VERSION ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) #else - #define ONEWIRE_GCC_VERSION 0 + #define ONEWIREHUB_GCC_VERSION 0 #endif #if defined(__AVR__) /* arduino (all with atmega, atiny) */ @@ -26,7 +26,8 @@ #define DIRECT_WRITE_HIGH(base, mask) ((*((base) + 2)) |= (mask)) using io_reg_t = uint8_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{ - 13}; // instructions per loop, compare 0 takes 11, compare 1 takes 13 cycles + 13}; +// ⤷ instructions per loop, compare 0 takes 11, compare 1 takes 13 cycles #elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || \ defined(__MK64FX512__) /* teensy 3.2 to 3.6 */ @@ -38,7 +39,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_WRITE_LOW(base, mask) (*((base) + 256) = 1) #define DIRECT_WRITE_HIGH(base, mask) (*((base) + 128) = 1) using io_reg_t = uint8_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{8}; // instructions per loop +constexpr uint8_t VALUE_IPL{8}; +// ⤷ instructions per loop #elif defined(__MKL26Z64__) /* teensy LC */ @@ -51,7 +53,8 @@ constexpr uint8_t VALUE_IPL{8}; // instructions per loop #define DIRECT_WRITE_HIGH(base, mask) (*((base) + 4) = (mask)) using io_reg_t = uint8_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{ - 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 0}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) /* arduino due */ @@ -70,7 +73,8 @@ constexpr uint8_t VALUE_IPL{ #endif using io_reg_t = uint32_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{ - 22}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 22}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__PIC32MX__) @@ -83,7 +87,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_WRITE_HIGH(base, mask) ((*(base + 8 + 2)) = (mask)) //LATXSET + 0x28 using io_reg_t = uint32_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{ - 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 0}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(ARDUINO_ARCH_ESP8266) /* nodeMCU, ESPduino, ... */ @@ -97,7 +102,8 @@ constexpr uint8_t VALUE_IPL{ using io_reg_t = uint32_t; // define special datatype for register-access // The ESP8266 has two possible CPU frequencies: 160 MHz (26 IPL) and 80 MHz (22 IPL) -> something influences the IPL-Value constexpr uint8_t VALUE_IPL{(microsecondsToClockCycles(1) > 120) ? 26 - : 22}; // instructions per loop + : 22}; +// ⤷ instructions per loop #elif defined(ARDUINO_ARCH_ESP32) || defined(ESP32) /* ESP32 Family */ @@ -111,7 +117,8 @@ constexpr uint8_t VALUE_IPL{(microsecondsToClockCycles(1) > 120) ? 26 #define DELAY_MICROSECONDS(us) delayMicroseconds(us) using io_reg_t = uint32_t; // define special data type for register-access constexpr uint8_t VALUE_IPL{ - 39}; // instructions per loop, for 40 and 80 MHz (see esp8266 difference) + 39}; +// ⤷ instructions per loop, for 40 and 80 MHz (see esp8266 difference) #elif defined(ARDUINO_ARCH_SAMD) /* arduino family samd */ // arduino-zero is defined(__SAMD21G18A__) @@ -138,7 +145,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_WRITE_LOW(base, mask) ((*((base) + 5)) = (mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*((base) + 6)) = (mask)) using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{18}; // instructions per loop +constexpr uint8_t VALUE_IPL{18}; +// ⤷ instructions per loop #elif defined(NRF52) /* arduino primo */ @@ -151,7 +159,8 @@ constexpr uint8_t VALUE_IPL{18}; // instructions per loop #define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) using io_reg_t = uint32_t; // define special data type for register-access constexpr uint8_t VALUE_IPL{ - 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 0}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(NRF51) /* red bear blend, should be good for all nrf51x chips */ @@ -168,7 +177,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) using io_reg_t = uint32_t; // define special data type for register-access constexpr uint8_t VALUE_IPL{ - 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 0}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__RFduino__) /* rf51 chip with special implementation */ @@ -181,7 +191,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) using io_reg_t = uint32_t; // define special data type for register-access constexpr uint8_t VALUE_IPL{ - 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 0}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__arc__) /* Arduino101/Genuino101 specifics */ @@ -202,7 +213,8 @@ constexpr uint8_t VALUE_IPL{ #define PIN_TO_BITMASK(pin) pin using io_reg_t = uint32_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{ - 0}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 0}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation static inline __attribute__((always_inline)) io_reg_t directRead(volatile io_reg_t *base, io_reg_t pin) @@ -274,7 +286,8 @@ static inline __attribute__((always_inline)) void directWriteHigh(volatile io_re #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) using io_reg_t = uint32_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{ - 10}; // instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation + 10}; +// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #warning \ "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture." From 3319fca562f1bcb3df1ce55805daddc7a379590b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 23:42:17 +0200 Subject: [PATCH 22/29] separate & update documentation --- .bumpversion.cfg | 4 +- .github/ISSUE_TEMPLATE/bug_report.md | 9 +- CONTRIBUTING.md | 24 --- README.md | 213 +-------------------------- docs/source/changelog.md | 55 +++++++ docs/source/contributing.md | 64 ++++++++ docs/source/device_support.md | 34 +++++ docs/source/features_hub.md | 30 ++++ docs/source/help_me_help_you.md | 23 +++ docs/source/how_hub_works.md | 27 ++++ docs/source/index.rst | 9 ++ docs/source/introduction.md | 14 ++ docs/source/setup.md | 19 +++ docs/source/test_setup.md | 51 +++++++ 14 files changed, 338 insertions(+), 238 deletions(-) create mode 100644 docs/source/changelog.md create mode 100644 docs/source/contributing.md create mode 100644 docs/source/device_support.md create mode 100644 docs/source/features_hub.md create mode 100644 docs/source/help_me_help_you.md create mode 100644 docs/source/how_hub_works.md create mode 100644 docs/source/introduction.md create mode 100644 docs/source/setup.md create mode 100644 docs/source/test_setup.md diff --git a/.bumpversion.cfg b/.bumpversion.cfg index db1b617..17aa5a4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -5,9 +5,7 @@ tag = False [bumpversion:file:doc/source/conf.py] -[bumpversion:file:README.md] - -[bumpversion:file:docs/build/html/_static/documentation_options.js] +[bumpversion:file:docs/source/help_me_help_you.md] [bumpversion:file:library.json] diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index fad775f..3e8871e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,7 +8,7 @@ assignees: '' --- **IMPORTANT READ FIRST** -Please make sure to read through help-section of [readme](https://github.com/orgua/OneWireHub/blob/main/README.md#help---what-to-do-if-things-dont-work-as-expected) and try to help yourself first. +Please make sure to read through help-section of [readme](https://orgua.github.io/OneWireHub/help_me_help_you.html) and try to help yourself first. **Describe the bug** A clear and concise description of what the bug is. @@ -24,10 +24,11 @@ If applicable, add screenshots to help explain your problem. **Dev-Environment:** Give some information about your setup, like: -- microcontroller used for the hub -- onewire-host to talk to the hub -- software and version used to compile +- microcontroller and board used for running the hub +- onewire-host used to talk to the hub +- software and version used to compile (OS, Arduino or other toolchain) - which device is emulated, what works, what doesn't +- please be precise **Additional context** Add any other context about the problem here. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d1285a..12a3474 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,28 +86,4 @@ Once your PR is merged, your contributions will be publicly visible on the [GitH Now that you are part of the GitHub docs community, see how else you can [contribute to the docs](/contributing/types-of-contributions.md). -### Releasing a new Version -The needed tools get installed automatically with the provided dev-environment (python and pipenv required), example call for ubuntu - -```Shell -pipenv shell -# & at first usage -pipenv install -sudo apt install cppcheck -``` - -Make sure Pre-Commit-Tests run through without new problems - -```Shell - -pre-commit run -a -````` - -Increment Version and decide if changes justify major, minor or patch-release - -```Shell -bump2version --tag patch -``` - -Prepare a Release on Github with Changelog. diff --git a/README.md b/README.md index ccf83e3..4ab852b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -OneWireHub -========== +# OneWireHub The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Periphery with support for various devices & sensors. The motivation is to offer a shared code base for all OneWire-Periphery-Devices. With a small overhead one µC can emulate up to 32 ICs simultaneously. The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iLib) or SPI interface) and transfer their measurements into one or more emulated ds2438 which have 4x16bit registers for values. This feature removes the limitations of modern house-automation-systems. Add humidity, light and other sensors easy to your home automation environment. @@ -7,214 +6,14 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL [![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) [![Documentation](https://github.com/orgua/OneWireHub/actions/workflows/sphinx_to_pages.yml/badge.svg)](https://orgua.github.io/OneWireHub/) -**Links** +## Links -- [Main-Repository](https://github.com/orgua/OneWireHub) - [Documentation](https://orgua.github.io/OneWireHub/) +- [Main-Repository](https://github.com/orgua/OneWireHub) +- [Issue-Tracker](https://github.com/orgua/OneWireHub/issues) +- [Releases](https://github.com/orgua/OneWireHub/releases) - -### Implemented peripheral Devices - -- **BAE0910 (0xFC) multi purpose device (ADC, Clock, GPIO, PWM, EEPROM)** -- **DS1822 (0x22) Digital Thermometer, 12bit** -> use DS18B20 with different family code -- **DS18B20 (0x28) Digital Thermometer, 12bit** (also known as DS1820) -- **DS18S20 (0x10) Digital Thermometer, 9bit** (also known as DS1920, use DS18B20 with different family code) -- **DS1990 (0x01) iButton** (DS2401 with same family code) -- **DS1990A (0x81) iButton** (DS2401 with different family code) -- **DS2401 (0x01) Serial Number** -- **DS2405 (0x05) Single address switch** -- **DS2408 (0x29) 8-Channel Addressable Switch**, GPIO Port-expander -- **DS2411 (0x01) Serial Number** -> use DS2401 with same family code -- **DS2413 (0x3A) Dual channel addressable switch with input-sensing** -- **DS2423 (0x1D) 4kbit RAM with Counter** -- **DS2430A (0x14) 256bit EEPROM & 64bit OTP** (also known as DS1971) -- **DS2431 (0x2D) 1kbit protected EEPROM** (also known as DS1972 or DS28E07, same FC) -- DS2432 (0x33) 1kbit protected EEPROM (basically a ds2431 with extra sha-engine) -- **DS2433 (0x23) 4Kbit EEPROM** (also known as DS1973) -- DS2434 BatteryManagement used in some IBM Notebook-Batteries -> moved to [special branch of the OWHub](https://github.com/orgua/OneWireHub/tree/tiny-ds2434) -- **DS2438 (0x26) Smart Battery Monitor, measures temperature, 2x voltage and current, 10bit** -- **DS2450 (0x20) 4 channel A/D** -- **DS2501 (0x11, 0x91) 512bit EEPROM** -> use DS2502 with different family code -- **DS2502 (0x09, 0x89) 1kbit EEPROM, Add Only Memory** (also known as DS1982, same FC) -- **DS2503 (0x13) 4kbit EEPROM, Add Only Memory** (also known as DS1983, same FC) -> use DS2506 with different family code -- **DS2505 (0x0B) 16kbit EEPROM, Add Only Memory** (also known as DS1985, same FC) -> use DS2506 with different family code -- **DS2506 (0x0F) 64kbit EEPROM, Add Only Memory** (also known as DS1986, same FC) -- **DS2890 (0x2C) Single channel digital potentiometer - extended to 1-4 CH** -- **DellAC (0x28) Dell Power Supply** (use DS2502 with different family code) - -Note: **Bold printed devices are feature-complete and were mostly tested with a DS9490 (look into the regarding example-file for more information) and a loxone system (when supported).** - -### Features - -- supports up to 32 peripheral devices simultaneously -> 8 is default setting to safe RAM & program space - - just add custom `#define ONEWIREHUB_DEVICE_LIMIT (32)` in your source file - - TODO: add example - - implementation-overhead for the hub is minimal and even saves resources for >1 emulated device -- hot-plug: add and remove devices as needed during operation - - TODO: add example -- support for most onewire-features: `MATCH ROM` (0x55), `SKIP ROM` (0xCC), `READ ROM` (0x0F,0x33), `RESUME COMMAND` (0xA5) - - `ALARM SEARCH` (0xEC) is NOT implemented yet! -- **OVERDRIVE-Mode**: - - OneWire-Host can issue `OD SKIP ROM` (0x13) or `OD MATCH ROM` (0x69) and peripheral device stays in this mode till it sees a long reset - - OD-feature must be activated manually by adding `#define ONEWIREHUB_OVERDRIVE_ENABLE (1)` in your source file -- cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=2.0.0 recommended)** - - use of constexpr instead of #define for better compiler-messages and cleaner code - - use static-assertions for compile-time plausibility checks - - user defined literals convert constants into needed format / unit -- hardware-dependencies are combined in `platform.h`, synced with [Onewire-Lib](https://github.com/PaulStoffregen/OneWire) - - supported: arduino zero, teensy, pic32, [ATtiny](https://github.com/damellis/attiny), esp8266, esp32, raspberry (...) - - tested architectures: atmega328 @ 16 MHz / arduino Uno, teensy3.2 - - for portability and tests the hub can be compiled on a PC with the supplied mock-up functions in platform.h - - at the moment the lib relies sole on loop-counting for timing, no direct access to interrupt or timers, **NOTE:** if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation -- hub and emulated devices are unit tested and run for each supported architecture through travis CI -- Serial-Debug output can be enabled in src/OneWireHub_config.h: set USE_SERIAL_DEBUG to 1 (be aware! it may produce heisenbugs, timing is critical) -- GPIO-Debug output - shows status by issuing high-states (activate in src/OneWireHub_config.h, is a better alternative to serial debug) - - during presence detection (after reset), - - after receiving / sending a whole byte (not during `SEARCH ROM`) - - when duty()-subroutines of an attached device get called - - during hub-startup it issues a 1ms long high-state (you can check the instruction-per-loop-value for your architecture with this) -- provide documentation, numerous examples, easy interface for hub and sensors - -### Supported and tested Hardware - -- embedded real life test - - setup: run test-example, use ds9490-OneWire-Host, arduino 1.8.3, Windows 10 and the board-library named in the brackets - - Arduino Uno ([Arduino AVR Boards](https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr)) - - Teensy 3.2 ([teensyduino](https://github.com/PaulStoffregen/cores)) - - Wemos D1 Mini ESP32S ([esp32](https://github.com/espressif/arduino-esp32)) - - Wemos Wifi & BT ESP32 ([esp32](https://github.com/espressif/arduino-esp32)) - - Wemos D1 R2 ([esp8266](https://github.com/esp8266/Arduino)) - - nodeMCU 1.0 ESP-12E ([esp8266](https://github.com/esp8266/Arduino)) - - ATtiny 84, 88 ([attiny](https://github.com/damellis/attiny)) -- Travis CI (automated Continuous Integration) for different platforms - - Arduino Uno ([Arduino AVR Boards](https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr)) - - Teensy 3.0, 3.1, 3.2, LC, 3.5, 3.6 ([teensyduino](https://github.com/PaulStoffregen/cores)) - - generic ESP8266 ([esp8266](https://github.com/esp8266/Arduino)) - - nodeMCU V2 ([esp8266](https://github.com/esp8266/Arduino)) - - espduino ([esp8266](https://github.com/esp8266/Arduino)) - - ESP32 dev module ([esp32](https://github.com/espressif/arduino-esp32)) - - Digispark tiny ([DigistumpArduino](https://github.com/digistump/DigistumpArduino)) -- failing platforms - - reason: current tick-counting implementation is not compatible with variable clock-speed - - Arduino Due ([Arduino SAMD Boards (32-bits ARM Cortex-M3)](https://github.com/arduino/ArduinoCore-sam)) - - Arduino MKRZero ([Arduino SAMD Boards (32-bits ARM Cortex-M0+)](https://github.com/arduino/ArduinoCore-samd)) - - reason: gcc 4.8.3 is artificially limited to c++98 - - Arduino Primo ([Arduino nRF52 Boards](https://github.com/arduino-org/arduino-core-nrf52)) - - RedBear [nRF51](https://github.com/RedBearLab/nRF51822-Arduino) - - reason: value_ipl is unknown for this hardware - - Arduino 101 ([Intel Curie Boards](https://github.com/01org/corelibs-arduino101)) - -### How does the Hub work - -- this layered description gives you a basic idea of how the functions inside the hub work together -- this will not tell you how the [onewire protocol](https://en.wikipedia.org/wiki/1-Wire) works - read a device datasheet or the link for that -- Low Level - hardware access - - macros like DIRECT_READ() and DIRECT_WRITE() handle bus-access (platform.h) - - checkReset() and showPresence() are used to react to a beginning OW-Message - - sendBit(), recvBit() manage the information inside each timeslot issued by the OneWire-Host -- Mid Level - onewire protocol logic - - send() and recv() can process data between device and OneWire-Host on byte-level (and do a CRC if needed) - - recvAndProcessCmd() handles basic commands of the OneWire-Host like: search-rom, match-rom, skip-rom, read-rom -- High Level - user interaction - - attach() adds an instance of a ow-device to the hub so the OneWire-Host can find it on the bus. there is a lot to do here. the device ID must be integrated into the tree-structure so that the hub knows how to react during a search-rom-command - - detach() takes the selected emulated device offline and restructures the search-tree - - poll() lets the hub listen to the bus. If there is a reset within a given time-frame it will continue to handle the message (show presence and receive commands), otherwise it will exit and you can do other stuff. the user should call this function as often as possible to intercept every message and therefore stay visible on the bus -- Device Level: - - device.duty() gets automatically called when the OneWire-Host sends special commands (for example match-rom). now it is possible to handle device specific commands like "read memory" or "do temperature measurement". These commands deviate for each device. - - device.setTemperature() and device.writeMemory() for example are individual functions that handle core-functionality of the device and can be called by the user -- for further details try reading the header-files or check the examples - -### HELP - What to do if things don't work as expected? - -- check if your arduino software up to date (>v1.8.0) -- update this lib to the latest release (3.0.0) -- if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation -- check if clock-speed of the µC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical -- begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the OneWire-Host won't switch to higher data rates -- check if your setup is right: you need at least external power for your µC and a data line with ground line to your OneWire-Host (see section below) -- is there more than one OneWire-Host on the bus? It won't work! -- has any other sensor (real or emulated) ever worked with this OneWire-Host? -> the simplest device would be a ds2401 -- if communication works, but is unstable please check with logic analyzer - - maybe your OneWire-Host is slow and just needs a higher ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT-value (see OneWireHub_config.h line 37) -- make sure that serial- and gpio-debugging is disabled (see src/OneWireHub_config.h), especially when using overdrive (be aware! it may produce heisenbugs, timing is critical) -- on a slow arduino it can be helpful to disable the serial port completely to get reliable results -> at least comment out serial.begin() -- if you can provide a recording via logic-analyzer (logic 8 or similar) there should be chance we can help you - - additional gpio-debug output can be enabled in src/OneWireHub_config.h: set USE_GPIO_DEBUG to 1 (it helps tracking state changes of the hub) -- if you checked all these points feel free to open an issue at [Github](https://github.com/orgua/OneWireHub) and describe your troubleshooting process - - please provide the following basic info: which µC and OneWire-Host do you use, software versions, what device do you try to emulate, what works, what doesn't - -### Recent development (latest at the top) - -v3.0.0 - -- improve documentation -- replace discriminatory language -- reduce name-collision -- improve config for hub (adjust device_limit & overdrive directly in main source-file) - -v2.0.0 - -- travis CI and unittests -- more explicit coding, a lot of bugfixes with the help of unit tests (mainly esp8266, bea910, ds18b20) -- interface of hub and devices has changed, check header-file or examples for more info -- rework / clean handling of timing-constants with user defined literals. -- extend const-correctness to all onewire-devices and unify naming of functions across similar devices -- include tests into each device-example and add a lot of get()/set() for internal device-states -- full support for ds2423, ds2450 and ds2503/5/6 -- fix and enhance ds2431, ds2433, ds2502, ds2890, probably every device got a rework / optimization -- overdrive-support! must be enabled in config file - works with atmega328@16MHz -- rework send() and recv(), much more efficient -> less time without interrupts (no missing time with millis())! AND code is more compact (ds2433.cpp shrinks from 176 to 90 LOC) -- rework Error-Handling-System (reduced a lot of overhead) -- no return value for hub.searchIDTree() or item.duty() needed anymore -- returns 1 if error occurred in the following functions: recv(buf[]), send(), awaitTimeslot(), sendBit(), checkReset(), showPresence(), recvAndProzessCmd() -- support for ds2408 (thanks to vytautassurvila) and ds2450 -- offline calibration by watching the bus (examples/debug/calibrate_by_bus_timing) - - branch for online calibration was abandoned because it took to much resources (DS18B20-Sketch compiled to 8434 // 482 bytes instead of 7026 // 426 bytes now) -- cleaned up timing-fn (no guessing, no micros(), no delayMicroseconds()) -- debug-pin shows state by issuing high-states - see explanation in "features" -- teensy3.2 tested: cleaned warnings, fixed port access, cleaned examples -- added or extended the ds2431, ds2431, ds2501, ds2502 (also tested) -- added ds2431 (thanks to j-langlois) and BAE910 (thanks to Giermann), Dell Power Supply (thanks to Kondi) -- prepare new timing-method which will replace the old one in the next couple of weeks (a 6µs millis() call at 8MHz is not suitable for OW) -- support for skipROM-cmd if only one device is present (thanks to Giermann) -- speed up atmel-crc-functions -- rework of error system, switch to enum, peripheral devices can raise errors now & and Serial interferes less with OW-timings -- raise the maximal peripheral device limit from 8 to 32, code adapts via variable dataTypes -- per-bit-CRC16 with sendAndCRC16() and sendAndCRC16() for load-balancing, 900ns/bit instead of 7µs/byte on Atmega328@16MHz -- faster CRC16 (ds2450 and ds2408 and ds2423), takes 5-7µs/byte instead of 10µs -- replace searchIDTree() algorithm, safes a lot of ram (debug-codeSize-4devices.ino needs 3986 & 155 byte instead of 3928 & 891 byte) and allows >4 devices - -### Plans for the future - -- alarm / conditional search -- switch to delay() for fast enough controllers (instead of tick-counting) -- debug tool to determine timings of exotic OneWire-Hosts -- better interrupt-handling (save the state before disabling) -- irq-handled hub on supported ports, split lib into onewire() and onewireIRQ() -- test each example with real OneWire-Hosts, for now it's tested with the onewire-lib and a loxone-system (ds18b20 passed) -- [List of all Family-Codes](http://owfs.sourceforge.net/family.html) -- [List of Maxim Sensors](https://www.maximintegrated.com/en/app-notes/index.mvp/id/3989) (at the bottom) -- add examples for - - more devices - - overdrive mode - - hw dependent code - - -### Connecting the HUB with the Network - -![Onewire-Schematic](http://wiki.lvl1.org/images/1/15/Onewire.gif) - -[read more](http://wiki.lvl1.org/DS1820_Temp_sensor) - -### Parasite Power with two wires - -![Parasite-Power-Schematic](http://i.stack.imgur.com/0MeGL.jpg) - -**Note:** this will certainly not work with an emulated device. Powering a µController via GPIO is sometimes possible, but needs preparation and tests. - -[read more](http://electronics.stackexchange.com/questions/193300/digital-ic-that-draws-power-from-data-pins) - -### Ancestors of this Lib +## Ancestors of this Lib - 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) diff --git a/docs/source/changelog.md b/docs/source/changelog.md new file mode 100644 index 0000000..d7d0e1c --- /dev/null +++ b/docs/source/changelog.md @@ -0,0 +1,55 @@ +# Recent Changes + +v3.0.0 + +- improve documentation +- replace discriminatory language +- reduce name-collision +- improve config for hub (adjust device_limit & overdrive directly in main source-file) + +v2.0.0 + +- travis CI and unittests +- more explicit coding, a lot of bugfixes with the help of unit tests (mainly esp8266, bea910, ds18b20) +- interface of hub and devices has changed, check header-file or examples for more info +- rework / clean handling of timing-constants with user defined literals. +- extend const-correctness to all onewire-devices and unify naming of functions across similar devices +- include tests into each device-example and add a lot of get()/set() for internal device-states +- full support for ds2423, ds2450 and ds2503/5/6 +- fix and enhance ds2431, ds2433, ds2502, ds2890, probably every device got a rework / optimization +- overdrive-support! must be enabled in config file - works with atmega328@16MHz +- rework send() and recv(), much more efficient -> less time without interrupts (no missing time with millis())! AND code is more compact (ds2433.cpp shrinks from 176 to 90 LOC) +- rework Error-Handling-System (reduced a lot of overhead) +- no return value for hub.searchIDTree() or item.duty() needed anymore +- returns 1 if error occurred in the following functions: recv(buf[]), send(), awaitTimeslot(), sendBit(), checkReset(), showPresence(), recvAndProzessCmd() +- support for ds2408 (thanks to vytautassurvila) and ds2450 +- offline calibration by watching the bus (examples/debug/calibrate_by_bus_timing) + - branch for online calibration was abandoned because it took too many resources (DS18B20-Sketch compiled to 8434 // 482 bytes instead of 7026 // 426 bytes now) +- cleaned up timing-fn (no guessing, no micros(), no delayMicroseconds()) +- debug-pin shows state by issuing high-states - see explanation in "features" +- teensy3.2 tested: cleaned warnings, fixed port access, cleaned examples +- added or extended the ds2431, ds2431, ds2501, ds2502 (also tested) +- added ds2431 (thanks to j-langlois) and BAE910 (thanks to Giermann), Dell Power Supply (thanks to Kondi) +- prepare new timing-method which will replace the old one in the next couple of weeks (a 6µs millis() call at 8MHz is not suitable for OW) +- support for skipROM-cmd if only one device is present (thanks to Giermann) +- speed up atmel-crc-functions +- rework of error system, switch to enum, peripheral devices can raise errors now & and Serial interferes less with OW-timings +- raise the maximal peripheral device limit from 8 to 32, code adapts via variable dataTypes +- per-bit-CRC16 with sendAndCRC16() and sendAndCRC16() for load-balancing, 900ns/bit instead of 7µs/byte on Atmega328@16MHz +- faster CRC16 (ds2450 and ds2408 and ds2423), takes 5-7µs/byte instead of 10µs +- replace searchIDTree() algorithm, safes a lot of ram (debug-codeSize-4devices.ino needs 3986 & 155 byte instead of 3928 & 891 byte) and allows >4 devices + +## Roadmap - Plans for the future + +- alarm / conditional search +- switch to delay() for fast enough controllers (instead of tick-counting) +- debug tool to determine timings of exotic OneWire-Hosts +- better interrupt-handling (save the state before disabling) +- irq-handled hub on supported ports, split lib into onewire() and onewireIRQ() +- test each example with real OneWire-Hosts, for now it's tested with the onewire-lib and a loxone-system (ds18b20 passed) +- [List of all Family-Codes](http://owfs.sourceforge.net/family.html) +- [List of Maxim Sensors](https://www.maximintegrated.com/en/app-notes/index.mvp/id/3989) (at the bottom) +- add examples for + - more devices + - overdrive mode + - hw dependent code diff --git a/docs/source/contributing.md b/docs/source/contributing.md new file mode 100644 index 0000000..b4ea0bb --- /dev/null +++ b/docs/source/contributing.md @@ -0,0 +1,64 @@ +# Contributing + +Help is always welcome! Either by finding and [reporting Bugs](./help_me_help_you.md), suggesting new features or better by proposing already working code as pull request. + +## Setting up the Dev-Environment + +First clone and enter the project directory + +```Shell +git clone https://github.com/orgua/OneWireHub.git +cd OneWireHub +``` + +The project uses `pipenv` (and [Python](https://www.python.org/)) to provide a reproducible environment (optional). +First make sure `pipenv` is installed and after that initialize & enter the environment. +The most common shell-commands for Ubuntu are + +```Shell +pip install pipenv +sudo apt install cppcheck +pipenv install +# later only the following cmd is needed: +pipenv shell +# to exit this environment send +exit +``` + +Your current command line should have an additional `(OneWireHub)` in front when inside the environment. + +## Code-Quality + +A set of linters and formatters are ensuring the quality of the codebase. Some of these change the code automatically, others only produce warnings. To run the tests execute + +```Shell +pre-commit run -a +``` + +in the project directory. + +## Unittests + +There are several options you can test new code - see [Test](./test_setup.md)-Section for more details. In short + +- try to test new code with a real physical OneWire-Host +- new peripheral device? please provide an [example](https://github.com/orgua/OneWireHub/tree/main/examples) +- a new example? please add it to the [compile-action](https://github.com/orgua/OneWireHub/blob/main/.github/workflows/compile.yml) +- compile-actions test code automatically when opening a PR + +## Preparing a Pull Request + +Before submitting code, please work through the previous two sections QA and Unittests. Your PR will probably be stalled when the tests fail as these will be run automatically by GitHub Actions. + +## Preparing a new Version + +Before releasing a new version, please work through the two sections QA and Unittests. + +Increment Version and decide if changes justify major, minor or patch-release + +```Shell +bump2version --tag patch +``` + +Assemble a changelog and add it to the [documentation](./changelog.md). +Issue a release on GitHub and attach the new changelog-section. diff --git a/docs/source/device_support.md b/docs/source/device_support.md new file mode 100644 index 0000000..6a3f8e3 --- /dev/null +++ b/docs/source/device_support.md @@ -0,0 +1,34 @@ +# Implemented Devices + +The following list gives a compact overview for implemented peripheral devices that can be emulated by the OneWireHub-Library. The device-name is followed by the family code (in brackets) and a short description of the functionality. + +- **BAE0910 (0xFC) multi purpose device (ADC, Clock, GPIO, PWM, EEPROM)** +- **DS1822 (0x22) Digital Thermometer, 12bit** -> use DS18B20 with different family code +- **DS18B20 (0x28) Digital Thermometer, 12bit** (also known as DS1820) +- **DS18S20 (0x10) Digital Thermometer, 9bit** (also known as DS1920, use DS18B20 with different family code) +- **DS1990 (0x01) iButton** (DS2401 with same family code) +- **DS1990A (0x81) iButton** (DS2401 with different family code) +- **DS2401 (0x01) Serial Number** +- **DS2405 (0x05) Single address switch** +- **DS2408 (0x29) 8-Channel Addressable Switch**, GPIO Port-expander +- **DS2411 (0x01) Serial Number** -> use DS2401 with same family code +- **DS2413 (0x3A) Dual channel addressable switch with input-sensing** +- **DS2423 (0x1D) 4kbit RAM with Counter** +- **DS2430A (0x14) 256bit EEPROM & 64bit OTP** (also known as DS1971) +- **DS2431 (0x2D) 1kbit protected EEPROM** (also known as DS1972 or DS28E07, same FC) +- DS2432 (0x33) 1kbit protected EEPROM (basically a ds2431 with extra sha-engine) +- **DS2433 (0x23) 4kbit EEPROM** (also known as DS1973) +- DS2434 BatteryManagement used in some IBM Notebook-Batteries -> moved to [special branch of the Hub](https://github.com/orgua/OneWireHub/tree/tiny-ds2434) +- **DS2438 (0x26) Smart Battery Monitor, measures temperature, 2x voltage and current, 10bit** +- **DS2450 (0x20) 4 channel A/D** +- **DS2501 (0x11, 0x91) 512bit EEPROM** -> use DS2502 with different family code +- **DS2502 (0x09, 0x89) 1kbit EEPROM, Add Only Memory** (also known as DS1982, same FC) +- **DS2503 (0x13) 4kbit EEPROM, Add Only Memory** (also known as DS1983, same FC) -> use DS2506 with different family code +- **DS2505 (0x0B) 16kbit EEPROM, Add Only Memory** (also known as DS1985, same FC) -> use DS2506 with different family code +- **DS2506 (0x0F) 64kbit EEPROM, Add Only Memory** (also known as DS1986, same FC) +- **DS2890 (0x2C) Single channel digital potentiometer - extended to 1-4 CH** +- **DellAC (0x28) Dell Power Supply** (use DS2502 with different family code) + +```{Note} +**Bold** printed devices are feature-complete and were mostly tested with a DS9490 (look into the regarding example-file for more information) and a loxone system (when supported). +``` \ No newline at end of file diff --git a/docs/source/features_hub.md b/docs/source/features_hub.md new file mode 100644 index 0000000..88b34dc --- /dev/null +++ b/docs/source/features_hub.md @@ -0,0 +1,30 @@ +# Features + +- supports up to 32 peripheral devices simultaneously -> 8 is default setting to safe RAM & program space + - just add custom `#define ONEWIREHUB_DEVICE_LIMIT (32)` in your source file + - TODO: add example + - implementation-overhead for the hub is minimal and even saves resources for >1 emulated device +- hot-plug: add and remove devices as needed during operation + - TODO: add example +- support for most onewire-features: `MATCH ROM` (0x55), `SKIP ROM` (0xCC), `READ ROM` (0x0F,0x33), `RESUME COMMAND` (0xA5) + - `ALARM SEARCH` (0xEC) is NOT implemented yet! +- **OVERDRIVE-Mode**: + - OneWire-Host can issue `OD SKIP ROM` (0x13) or `OD MATCH ROM` (0x69) and peripheral device stays in this mode till it sees a long reset + - OD-feature must be activated manually by adding `#define ONEWIREHUB_OVERDRIVE_ENABLE (1)` in your source file +- cleaner, faster code with c++11 features **(requires arduino sw 1.6.x or higher, >=2.0.0 recommended)** + - use of `constexpr` instead of `#define` for better compiler-messages and cleaner code + - use static-assertions for compile-time plausibility checks + - user defined literals convert constants into needed format / unit +- hardware-dependencies are combined in [platform.h](https://github.com/orgua/OneWireHub/blob/main/src/platform.h), loosely synced with [Onewire-Lib](https://github.com/PaulStoffregen/OneWire) + - supported: arduino zero, teensy, pic32, [ATtiny](https://github.com/damellis/attiny), esp8266, esp32, raspberry (...) + - tested architectures: atmega328 @ 16 MHz / arduino Uno, teensy3.2 + - for portability and tests the hub can be compiled on a PC with the supplied mock-up functions in `platform.h` + - at the moment the lib relies sole on loop-counting for timing, no direct access to interrupt or timers, **NOTE:** if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation +- hub and emulated devices are unit tested and run for each supported architecture through travis CI +- Serial-Debug output can be enabled in src/OneWireHub_config.h: set USE_SERIAL_DEBUG to 1 (be aware! it may produce heisenbugs, timing is critical) +- GPIO-Debug output - shows status by issuing high-states (activate in src/OneWireHub_config.h, is a better alternative to serial debug), TODO: simplify + - during presence detection (after reset), + - after receiving / sending a whole byte (not during `SEARCH ROM`) + - when `duty()`-subroutines of an attached device get called + - during hub-startup it issues a 1ms long high-state (you can check the instruction-per-loop-value for your architecture with this) +- provide documentation, numerous examples, easy interface for hub and sensors diff --git a/docs/source/help_me_help_you.md b/docs/source/help_me_help_you.md new file mode 100644 index 0000000..1ffe724 --- /dev/null +++ b/docs/source/help_me_help_you.md @@ -0,0 +1,23 @@ +# HELP + +What to do if things don't work as expected? + +- check if your arduino software up to date ([>v1.8.0](https://www.arduino.cc/en/software)) +- update this lib to the latest release ([3.0.0](https://github.com/orgua/OneWireHub/releases)) +- if you use an uncalibrated architecture the compilation-process will fail with an error, look at ./examples/debug/calibrate_by_bus_timing for an explanation +- check if clock-speed of the µC is set correctly (if possible) - test with simple blink example, 1sec ON should really need 1sec. timing is critical +- begin with a simple example like the ds18b20 (if possible). the ds18b20 doesn't support overdrive, so the OneWire-Host won't switch to higher data rates +- check if your setup is right: you need at least external power for your µC and a data line with ground line to your OneWire-Host (see section below) +- is there more than one OneWire-Host on the bus? It won't work! +- has any other sensor (real or emulated) ever worked with this OneWire-Host? -> the simplest device would be a ds2401 +- if communication works, but is unstable please check with logic analyzer + - maybe your OneWire-Host is slow and just needs a higher ONEWIREHUB_TIME_MSG_HIGH_TIMEOUT-value (see [OneWireHub_config.h line 37](https://github.com/orgua/OneWireHub/blob/main/src/OneWireHub_config.h#L37) ) +- make sure that serial- and gpio-debugging is disabled (see [OneWireHub_config.h](https://github.com/orgua/OneWireHub/blob/main/src/OneWireHub_config.h)), especially when using overdrive (be aware! it may produce heisenbugs, timing is critical) +- on a slow arduino it can be helpful to disable the serial port completely to get reliable results -> at least comment out `serial.begin()` +- if you can provide a recording via logic-analyzer ([Logic 8](https://usd.saleae.com/products/saleae-logic-8) or similar) there should be chance we can help you + - additional gpio-debug output can be enabled in [OneWireHub_config.h](https://github.com/orgua/OneWireHub/blob/main/src/OneWireHub_config.h): set USE_GPIO_DEBUG to 1 (it helps to track state changes of the hub) + +```{Note} +If you checked all these points feel free to open an issue at [GitHub](https://github.com/orgua/OneWireHub) and describe your troubleshooting process. +Templates for a bug-report are provided - please provide that extra info and help the developer help you +``` diff --git a/docs/source/how_hub_works.md b/docs/source/how_hub_works.md new file mode 100644 index 0000000..8f9c5c4 --- /dev/null +++ b/docs/source/how_hub_works.md @@ -0,0 +1,27 @@ +# How the Hub works + +- this layered description gives you a basic idea of how the functions inside the hub work together +- this will not tell you how the [onewire protocol](https://en.wikipedia.org/wiki/1-Wire) works - read a device datasheet or the link for that +- for further details try reading the header-files or check the examples + +## Low Level - Hardware Access + +- macros like `DIRECT_READ()` and `DIRECT_WRITE()` handle bus-access ([platform.h](https://github.com/orgua/OneWireHub/blob/main/src/platform.h)) +- `checkReset()` and `showPresence()` are used to react to a beginning OneWire-Message +- `sendBit()`, `recvBit()` manage the information inside each timeslot issued by the OneWire-Host + +## Mid Level - Onewire Protocol Logic + +- `send()` and `recv()` can process data between device and OneWire-Host on byte-level (and do a CRC if needed) +- `recvAndProcessCmd()` handles basic commands of the OneWire-Host like: `search-rom`, `match-rom`, `skip-rom`, `read-rom` + +## High Level - User Interaction + +- `attach()` adds an instance of a device to the hub so the OneWire-Host can find it on the bus. there is a lot to do here. the device ID must be integrated into the tree-structure so that the hub knows how to react during a `search-rom`-command +- `detach()` takes the selected emulated device offline and restructures the search-tree +- `poll()` lets the hub listen to the bus. If there is a reset within a given time-frame it will continue to handle the message (show presence and receive commands), otherwise it will exit and you can do other stuff. the user should call this function as often as possible to intercept every message and therefore stay visible on the bus + +## Device Level + +- `device.duty()` gets automatically called when the OneWire-Host sends special commands (for example `match-rom`). now it is possible to handle device specific commands like "read memory" or "do temperature measurement". These commands deviate for each device. +- `device.setTemperature()` and `device.writeMemory()` for example are individual functions that handle core-functionality of the device and can be called by the user diff --git a/docs/source/index.rst b/docs/source/index.rst index 93409fd..f859d6a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -9,6 +9,15 @@ Welcome to OnewireHub's documentation! :maxdepth: 2 :caption: Contents: + introduction.md + setup.md + device_support.md + features_hub.md + how_hub_works.md + help_me_help_you.md + changelog.md + test_setup.md + contributing.md Indices and tables diff --git a/docs/source/introduction.md b/docs/source/introduction.md new file mode 100644 index 0000000..d42c7ec --- /dev/null +++ b/docs/source/introduction.md @@ -0,0 +1,14 @@ +# Introduction + +The OneWireHub is a sleek Arduino compatible (and many more platforms) library to emulate OneWire-Periphery with support for various devices & sensors. The motivation is to offer a shared code base for all OneWire-Periphery-Devices. With a small overhead one µC can emulate up to 32 ICs simultaneously. +The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iLib) or SPI interface) and transfer their measurements into one or more emulated ds2438 which have 4x16bit registers for values. This feature removes the limitations of modern house-automation-systems. Add humidity, light and other sensors easy to your home automation environment. + +[![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) +[![Documentation](https://github.com/orgua/OneWireHub/actions/workflows/sphinx_to_pages.yml/badge.svg)](https://orgua.github.io/OneWireHub/) + +## Links + +- [Documentation](https://orgua.github.io/OneWireHub/) +- [Main-Repository](https://github.com/orgua/OneWireHub) +- [Issue-Tracker](https://github.com/orgua/OneWireHub/issues) +- [Releases](https://github.com/orgua/OneWireHub/releases) \ No newline at end of file diff --git a/docs/source/setup.md b/docs/source/setup.md new file mode 100644 index 0000000..34aec53 --- /dev/null +++ b/docs/source/setup.md @@ -0,0 +1,19 @@ +# Setup + +TODO + +## Connecting the HUB with the Network + +![Onewire-Schematic](http://wiki.lvl1.org/images/1/15/Onewire.gif) + +[read more](http://wiki.lvl1.org/DS1820_Temp_sensor) + +## Parasite Power with two wires + +![Parasite-Power-Schematic](http://i.stack.imgur.com/0MeGL.jpg) + +```{Warning} +This will certainly not work with an emulated device. Powering a µController via GPIO is sometimes possible, but needs preparation and tests. +``` + +[read more](http://electronics.stackexchange.com/questions/193300/digital-ic-that-draws-power-from-data-pins) diff --git a/docs/source/test_setup.md b/docs/source/test_setup.md new file mode 100644 index 0000000..a925856 --- /dev/null +++ b/docs/source/test_setup.md @@ -0,0 +1,51 @@ +# Supported & tested Hardware + +## Embedded real life Tests + +### Setup + +- manual process of the developer +- used software: arduino 1.8.3 or newer, Windows 10 and the board-library named in the brackets (below) +- flash [test-example](https://github.com/orgua/OneWireHub/blob/main/examples/OneWireHubTest/OneWireHubTest.ino), +- use DS9490 as OneWire-Host + +### Tested MCU-Boards + +- Arduino Uno ([Arduino AVR Boards](https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr)) +- Teensy 3.2 ([teensyduino](https://github.com/PaulStoffregen/cores)) +- Wemos D1 Mini ESP32S ([esp32](https://github.com/espressif/arduino-esp32)) +- Wemos Wifi & BT ESP32 ([esp32](https://github.com/espressif/arduino-esp32)) +- Wemos D1 R2 ([esp8266](https://github.com/esp8266/Arduino)) +- nodeMCU 1.0 ESP-12E ([esp8266](https://github.com/esp8266/Arduino)) +- ATtiny 84, 88 ([attiny](https://github.com/damellis/attiny)) + +## Automated Continuous Integration + +[![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) + +### Setup + +Platform-IO is used to compile the examples for different target-architectures. For details see the Action-Script (Badge above). + +### Tested MCU-Architectures + +- Arduino Uno ([Arduino AVR Boards](https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr)) +- Teensy 3.0, 3.1, 3.2, LC, 3.5, 3.6 ([teensyduino](https://github.com/PaulStoffregen/cores)) +- generic ESP8266 ([esp8266](https://github.com/esp8266/Arduino)) +- nodeMCU V2 ([esp8266](https://github.com/esp8266/Arduino)) +- espduino ([esp8266](https://github.com/esp8266/Arduino)) +- ESP32 dev module ([esp32](https://github.com/espressif/arduino-esp32)) +- Digispark tiny ([DigistumpArduino](https://github.com/digistump/DigistumpArduino)) + +## Failing Platforms + +TODO: this will change with V3 of the hub + +- reason: current tick-counting implementation is not compatible with variable clock-speed + - Arduino Due ([Arduino SAMD Boards (32-bits ARM Cortex-M3)](https://github.com/arduino/ArduinoCore-sam)) + - Arduino MKRZero ([Arduino SAMD Boards (32-bits ARM Cortex-M0+)](https://github.com/arduino/ArduinoCore-samd)) +- reason: gcc 4.8.3 is artificially limited to c++98 + - Arduino Primo ([Arduino nRF52 Boards](https://github.com/arduino-org/arduino-core-nrf52)) + - RedBear [nRF51](https://github.com/RedBearLab/nRF51822-Arduino) +- reason: value_ipl is unknown for this hardware + - Arduino 101 ([Intel Curie Boards](https://github.com/01org/corelibs-arduino101)) From 069e37a5d25b38beeaa99a8a90ef69a94b8f2c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 23:42:45 +0200 Subject: [PATCH 23/29] Update OneWireHub_config.h --- src/OneWireHub_config.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/OneWireHub_config.h b/src/OneWireHub_config.h index db12010..2cc17dc 100644 --- a/src/OneWireHub_config.h +++ b/src/OneWireHub_config.h @@ -17,6 +17,11 @@ #define ONEWIREHUB_OVERDRIVE_ENABLE (0) #endif +#ifndef ONEWIREHUB_HW_LEVEL_CODE + // create support for faster, but more hw-specific code for timekeeping, TODO: not working yet +#define ONEWIREHUB_HW_LEVEL_CODE (false) +#endif + // Serial Debug: give debug messages when printError() is called (be aware! it may produce heisenbugs, timing is critical) SHOULD NOT be enabled with < 20 MHz uC constexpr bool USE_SERIAL_DEBUG{false}; // Gpio Debug: is a better alternative to serial debug (see readme.md for info) SHOULD NOT be enabled with < 20 MHz uC and Overdrive enabled From 7a72cbca150fa1cf9fb31577c19c54ed4147a131 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 23:47:22 +0200 Subject: [PATCH 24/29] reformat code --- .github/workflows/compile.yml | 12 +++---- CONTRIBUTING.md | 2 -- Pipfile.lock | 23 ++++--------- docs/source/device_support.md | 2 +- docs/source/help_me_help_you.md | 4 +-- docs/source/introduction.md | 2 +- docs/source/test_setup.md | 6 ++-- src/OneWireHub_config.h | 2 +- src/platform.h | 61 ++++++++++++++------------------- 9 files changed, 46 insertions(+), 68 deletions(-) diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index eebe940..ff5c428 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -16,12 +16,12 @@ jobs: - uno example: - ./examples/BAE910_device/BAE910_device.ino - - ./examples/debug/attiny85-4devices/attiny85-4devices.ino - - ./examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino - - ./examples/debug/CRC-Comparison/CRC-Comparison.ino - - ./examples/debug/irq-driven-playground/irq-driven-playground.ino - - ./examples/debug/optimize_pinAccess/optimize_pinAccess.ino - - ./examples/debug/programsize_documentation/programsize_documentation.ino +# - ./examples/debug/attiny85-4devices/attiny85-4devices.ino +# - ./examples/debug/calibrate_by_bus_timing/calibrate_by_bus_timing.ino +# - ./examples/debug/CRC-Comparison/CRC-Comparison.ino +# - ./examples/debug/irq-driven-playground/irq-driven-playground.ino +# - ./examples/debug/optimize_pinAccess/optimize_pinAccess.ino +# - ./examples/debug/programsize_documentation/programsize_documentation.ino # - ./examples/DS18B20_asInterface/DS18B20_asInterface.ino # needs I2C - ./examples/DS18B20_thermometer/DS18B20_thermometer.ino - ./examples/DS2401_serial/DS2401_serial.ino diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 12a3474..0502596 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -85,5 +85,3 @@ Congratulations :tada::tada: The GitHub team thanks you :sparkles:. Once your PR is merged, your contributions will be publicly visible on the [GitHub docs](https://docs.github.com/en). Now that you are part of the GitHub docs community, see how else you can [contribute to the docs](/contributing/types-of-contributions.md). - - diff --git a/Pipfile.lock b/Pipfile.lock index 00e04bc..af1dd61 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,20 +1,11 @@ { - "_meta": { - "hash": { - "sha256": "0b0aa517d0a57e17f566e3621de5a2aa346de0de473e3f50ea82c530a734bc6c" - }, + "_meta" : { + "hash": {"sha256": "0b0aa517d0a57e17f566e3621de5a2aa346de0de473e3f50ea82c530a734bc6c"}, "pipfile-spec": 6, - "requires": { - "python_version": "3.11" - }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] + "requires": {"python_version": "3.11"}, + "sources": [{"name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true}] }, - "default": {}, - "develop": {} + "default" : {}, + "develop": + {} } diff --git a/docs/source/device_support.md b/docs/source/device_support.md index 6a3f8e3..f47a88f 100644 --- a/docs/source/device_support.md +++ b/docs/source/device_support.md @@ -31,4 +31,4 @@ The following list gives a compact overview for implemented peripheral devices t ```{Note} **Bold** printed devices are feature-complete and were mostly tested with a DS9490 (look into the regarding example-file for more information) and a loxone system (when supported). -``` \ No newline at end of file +``` diff --git a/docs/source/help_me_help_you.md b/docs/source/help_me_help_you.md index 1ffe724..3e25f74 100644 --- a/docs/source/help_me_help_you.md +++ b/docs/source/help_me_help_you.md @@ -1,5 +1,5 @@ -# HELP - +# HELP + What to do if things don't work as expected? - check if your arduino software up to date ([>v1.8.0](https://www.arduino.cc/en/software)) diff --git a/docs/source/introduction.md b/docs/source/introduction.md index d42c7ec..64fdfc6 100644 --- a/docs/source/introduction.md +++ b/docs/source/introduction.md @@ -11,4 +11,4 @@ The main goal is to use modern sensors (mainly [I2C](https://github.com/orgua/iL - [Documentation](https://orgua.github.io/OneWireHub/) - [Main-Repository](https://github.com/orgua/OneWireHub) - [Issue-Tracker](https://github.com/orgua/OneWireHub/issues) -- [Releases](https://github.com/orgua/OneWireHub/releases) \ No newline at end of file +- [Releases](https://github.com/orgua/OneWireHub/releases) diff --git a/docs/source/test_setup.md b/docs/source/test_setup.md index a925856..3b6bf13 100644 --- a/docs/source/test_setup.md +++ b/docs/source/test_setup.md @@ -2,11 +2,11 @@ ## Embedded real life Tests -### Setup +### Setup - manual process of the developer - used software: arduino 1.8.3 or newer, Windows 10 and the board-library named in the brackets (below) -- flash [test-example](https://github.com/orgua/OneWireHub/blob/main/examples/OneWireHubTest/OneWireHubTest.ino), +- flash [test-example](https://github.com/orgua/OneWireHub/blob/main/examples/OneWireHubTest/OneWireHubTest.ino), - use DS9490 as OneWire-Host ### Tested MCU-Boards @@ -19,7 +19,7 @@ - nodeMCU 1.0 ESP-12E ([esp8266](https://github.com/esp8266/Arduino)) - ATtiny 84, 88 ([attiny](https://github.com/damellis/attiny)) -## Automated Continuous Integration +## Automated Continuous Integration [![CompileTests](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml/badge.svg)](https://github.com/orgua/OneWireHub/actions/workflows/compile.yml) diff --git a/src/OneWireHub_config.h b/src/OneWireHub_config.h index 2cc17dc..2b8602a 100644 --- a/src/OneWireHub_config.h +++ b/src/OneWireHub_config.h @@ -19,7 +19,7 @@ #ifndef ONEWIREHUB_HW_LEVEL_CODE // create support for faster, but more hw-specific code for timekeeping, TODO: not working yet -#define ONEWIREHUB_HW_LEVEL_CODE (false) + #define ONEWIREHUB_HW_LEVEL_CODE (false) #endif // Serial Debug: give debug messages when printError() is called (be aware! it may produce heisenbugs, timing is critical) SHOULD NOT be enabled with < 20 MHz uC diff --git a/src/platform.h b/src/platform.h index e096382..5ffefb1 100644 --- a/src/platform.h +++ b/src/platform.h @@ -25,9 +25,8 @@ #define DIRECT_WRITE_LOW(base, mask) ((*((base) + 2)) &= ~(mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*((base) + 2)) |= (mask)) using io_reg_t = uint8_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{ - 13}; -// ⤷ instructions per loop, compare 0 takes 11, compare 1 takes 13 cycles +constexpr uint8_t VALUE_IPL{13}; + // ⤷ instructions per loop, compare 0 takes 11, compare 1 takes 13 cycles #elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK66FX1M0__) || \ defined(__MK64FX512__) /* teensy 3.2 to 3.6 */ @@ -38,9 +37,9 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_MODE_OUTPUT(base, mask) (*((base) + 640) = 1) #define DIRECT_WRITE_LOW(base, mask) (*((base) + 256) = 1) #define DIRECT_WRITE_HIGH(base, mask) (*((base) + 128) = 1) -using io_reg_t = uint8_t; // define special datatype for register-access +using io_reg_t = uint8_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{8}; -// ⤷ instructions per loop + // ⤷ instructions per loop #elif defined(__MKL26Z64__) /* teensy LC */ @@ -52,9 +51,8 @@ constexpr uint8_t VALUE_IPL{8}; #define DIRECT_WRITE_LOW(base, mask) (*((base) + 8) = (mask)) #define DIRECT_WRITE_HIGH(base, mask) (*((base) + 4) = (mask)) using io_reg_t = uint8_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{ - 0}; -// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{0}; + // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__SAM3X8E__) || defined(__SAM3A8C__) || defined(__SAM3A4C__) /* arduino due */ @@ -72,9 +70,8 @@ constexpr uint8_t VALUE_IPL{ #define pgm_read_byte(address) (*(const uint8_t *) (address)) #endif using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{ - 22}; -// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{22}; + // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__PIC32MX__) @@ -86,9 +83,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_WRITE_LOW(base, mask) ((*(base + 8 + 1)) = (mask)) //LATXCLR + 0x24 #define DIRECT_WRITE_HIGH(base, mask) ((*(base + 8 + 2)) = (mask)) //LATXSET + 0x28 using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{ - 0}; -// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{0}; + // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(ARDUINO_ARCH_ESP8266) /* nodeMCU, ESPduino, ... */ @@ -101,9 +97,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_WRITE_HIGH(base, mask) (GPOS = (mask)) //GPIO_OUT_W1TS_ADDRESS using io_reg_t = uint32_t; // define special datatype for register-access // The ESP8266 has two possible CPU frequencies: 160 MHz (26 IPL) and 80 MHz (22 IPL) -> something influences the IPL-Value -constexpr uint8_t VALUE_IPL{(microsecondsToClockCycles(1) > 120) ? 26 - : 22}; -// ⤷ instructions per loop +constexpr uint8_t VALUE_IPL{(microsecondsToClockCycles(1) > 120) ? 26 : 22}; + // ⤷ instructions per loop #elif defined(ARDUINO_ARCH_ESP32) || defined(ESP32) /* ESP32 Family */ @@ -116,9 +111,8 @@ constexpr uint8_t VALUE_IPL{(microsecondsToClockCycles(1) > 120) ? 26 #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) #define DELAY_MICROSECONDS(us) delayMicroseconds(us) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL{ - 39}; -// ⤷ instructions per loop, for 40 and 80 MHz (see esp8266 difference) +constexpr uint8_t VALUE_IPL{39}; + // ⤷ instructions per loop, for 40 and 80 MHz (see esp8266 difference) #elif defined(ARDUINO_ARCH_SAMD) /* arduino family samd */ // arduino-zero is defined(__SAMD21G18A__) @@ -144,9 +138,9 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_MODE_OUTPUT(base, mask) ((*((base) + 2)) = (mask)) #define DIRECT_WRITE_LOW(base, mask) ((*((base) + 5)) = (mask)) #define DIRECT_WRITE_HIGH(base, mask) ((*((base) + 6)) = (mask)) -using io_reg_t = uint32_t; // define special datatype for register-access +using io_reg_t = uint32_t; // define special datatype for register-access constexpr uint8_t VALUE_IPL{18}; -// ⤷ instructions per loop + // ⤷ instructions per loop #elif defined(NRF52) /* arduino primo */ @@ -158,9 +152,8 @@ constexpr uint8_t VALUE_IPL{18}; #define DIRECT_MODE_INPUT(base, pin) nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL) #define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL{ - 0}; -// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{0}; + // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(NRF51) /* red bear blend, should be good for all nrf51x chips */ @@ -176,9 +169,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_MODE_INPUT(base, pin) nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_NOPULL) #define DIRECT_MODE_OUTPUT(base, pin) nrf_gpio_cfg_output(pin) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL{ - 0}; -// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{0}; + // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__RFduino__) /* rf51 chip with special implementation */ @@ -190,9 +182,8 @@ constexpr uint8_t VALUE_IPL{ #define DIRECT_MODE_INPUT(base, pin) pinMode(pin, INPUT) #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL{ - 0}; -// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{0}; + // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #elif defined(__arc__) /* Arduino101/Genuino101 specifics */ @@ -212,8 +203,7 @@ constexpr uint8_t VALUE_IPL{ #define PIN_TO_BASEREG(pin) ((volatile uint32_t *) g_APinDescription[pin].ulGPIOBase) #define PIN_TO_BITMASK(pin) pin using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{ - 0}; +constexpr uint8_t VALUE_IPL{0}; // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation static inline __attribute__((always_inline)) io_reg_t directRead(volatile io_reg_t *base, @@ -285,9 +275,8 @@ static inline __attribute__((always_inline)) void directWriteHigh(volatile io_re #define DIRECT_MODE_INPUT(base, pin) pinMode(pin, INPUT) #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) using io_reg_t = uint32_t; // define special datatype for register-access -constexpr uint8_t VALUE_IPL{ - 10}; -// ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation +constexpr uint8_t VALUE_IPL{10}; + // ⤷ instructions per loop, uncalibrated so far - see ./examples/debug/calibrate_by_bus_timing for an explanation #warning \ "OneWire. Fallback mode. Using API calls for pinMode,digitalRead and digitalWrite. Operation of this library is not guaranteed on this architecture." From ff2d539128b21c8f44e6cd681ba1e1596d8d99ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Sun, 9 Jul 2023 23:57:13 +0200 Subject: [PATCH 25/29] Update sphinx_to_pages.yml --- .github/workflows/sphinx_to_pages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/sphinx_to_pages.yml b/.github/workflows/sphinx_to_pages.yml index 770c9c0..dc32ae9 100644 --- a/.github/workflows/sphinx_to_pages.yml +++ b/.github/workflows/sphinx_to_pages.yml @@ -22,6 +22,8 @@ jobs: # - name: Run Pre-Commit Tests 🧪 # uses: pre-commit/action@v3.0.0 + - name: Install dependencies 🔧 + run: pip3 install pipenv - name: Install dependencies 🔧 run: pipenv shell From 2670ce0972501fdbd3ba58f2a6769138805301b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 10 Jul 2023 00:01:23 +0200 Subject: [PATCH 26/29] update env --- Pipfile | 4 +- Pipfile.lock | 496 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 494 insertions(+), 6 deletions(-) diff --git a/Pipfile b/Pipfile index fa59525..115080b 100644 --- a/Pipfile +++ b/Pipfile @@ -13,5 +13,5 @@ bump2version = "*" [dev-packages] -[requires] -python_version = "3.11" +[pipenv] +allow_prereleases = false diff --git a/Pipfile.lock b/Pipfile.lock index af1dd61..78f1d12 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,499 @@ { "_meta" : { - "hash": {"sha256": "0b0aa517d0a57e17f566e3621de5a2aa346de0de473e3f50ea82c530a734bc6c"}, + "hash": {"sha256": "f79f046b7daf059e562ecca277d7016c0b75a6a142605f79ce6067731a4566e9"}, "pipfile-spec": 6, - "requires": {"python_version": "3.11"}, + "requires": {}, "sources": [{"name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true}] }, - "default" : {}, - "develop": + "default" + : { + "alabaster": { + "hashes": [ + "sha256:1ee19aca801bbabb5ba3f5f258e4422dfa86f82f3e9cefb0859b283cdd7f62a3", + "sha256:a27a4a084d5e690e16e01e03ad2b2e552c61a65469419b907243193de1a84ae2" + ], + "markers": "python_version >= '3.6'", + "version": "==0.7.13" + }, + "babel": { + "hashes": [ + "sha256:b4246fb7677d3b98f501a39d43396d3cafdc8eadb045f4a31be01863f655c610", + "sha256:cc2d99999cd01d44420ae725a21c9e3711b3aadc7976d6147f622d8581963455" + ], + "markers": "python_version >= '3.7'", + "version": "==2.12.1" + }, + "beautifulsoup4": { + "hashes": [ + "sha256:492bbc69dca35d12daac71c4db1bfff0c876c00ef4a2ffacce226d4638eb72da", + "sha256:bd2520ca0d9d7d12694a53d44ac482d181b4ec1888909b035a3dbf40d0f57d4a" + ], + "markers": "python_full_version >= '3.6.0'", + "version": "==4.12.2" + }, + "bump2version": { + "hashes": [ + "sha256:37f927ea17cde7ae2d7baf832f8e80ce3777624554a653006c9144f8017fe410", + "sha256:762cb2bfad61f4ec8e2bdf452c7c267416f8c70dd9ecb1653fd0bbb01fa936e6" + ], + "index": "pypi", + "version": "==1.0.1" + }, + "certifi": { + "hashes": [ + "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7", + "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716" + ], + "markers": "python_version >= '3.6'", + "version": "==2023.5.7" + }, + "cfgv": { + "hashes": [ + "sha256:c6a0883f3917a037485059700b9e75da2464e6c27051014ad85ba6aaa5884426", + "sha256:f5a830efb9ce7a445376bb66ec94c638a9787422f96264c98edc6bdeed8ab736" + ], + "markers": "python_full_version >= '3.6.1'", + "version": "==3.3.1" + }, + "charset-normalizer": { + "hashes": [ + "sha256:04e57ab9fbf9607b77f7d057974694b4f6b142da9ed4a199859d9d4d5c63fe96", + "sha256:09393e1b2a9461950b1c9a45d5fd251dc7c6f228acab64da1c9c0165d9c7765c", + "sha256:0b87549028f680ca955556e3bd57013ab47474c3124dc069faa0b6545b6c9710", + "sha256:1000fba1057b92a65daec275aec30586c3de2401ccdcd41f8a5c1e2c87078706", + "sha256:1249cbbf3d3b04902ff081ffbb33ce3377fa6e4c7356f759f3cd076cc138d020", + "sha256:1920d4ff15ce893210c1f0c0e9d19bfbecb7983c76b33f046c13a8ffbd570252", + "sha256:193cbc708ea3aca45e7221ae58f0fd63f933753a9bfb498a3b474878f12caaad", + "sha256:1a100c6d595a7f316f1b6f01d20815d916e75ff98c27a01ae817439ea7726329", + "sha256:1f30b48dd7fa1474554b0b0f3fdfdd4c13b5c737a3c6284d3cdc424ec0ffff3a", + "sha256:203f0c8871d5a7987be20c72442488a0b8cfd0f43b7973771640fc593f56321f", + "sha256:246de67b99b6851627d945db38147d1b209a899311b1305dd84916f2b88526c6", + "sha256:2dee8e57f052ef5353cf608e0b4c871aee320dd1b87d351c28764fc0ca55f9f4", + "sha256:2efb1bd13885392adfda4614c33d3b68dee4921fd0ac1d3988f8cbb7d589e72a", + "sha256:2f4ac36d8e2b4cc1aa71df3dd84ff8efbe3bfb97ac41242fbcfc053c67434f46", + "sha256:3170c9399da12c9dc66366e9d14da8bf7147e1e9d9ea566067bbce7bb74bd9c2", + "sha256:3b1613dd5aee995ec6d4c69f00378bbd07614702a315a2cf6c1d21461fe17c23", + "sha256:3bb3d25a8e6c0aedd251753a79ae98a093c7e7b471faa3aa9a93a81431987ace", + "sha256:3bb7fda7260735efe66d5107fb7e6af6a7c04c7fce9b2514e04b7a74b06bf5dd", + "sha256:41b25eaa7d15909cf3ac4c96088c1f266a9a93ec44f87f1d13d4a0e86c81b982", + "sha256:45de3f87179c1823e6d9e32156fb14c1927fcc9aba21433f088fdfb555b77c10", + "sha256:46fb8c61d794b78ec7134a715a3e564aafc8f6b5e338417cb19fe9f57a5a9bf2", + "sha256:48021783bdf96e3d6de03a6e39a1171ed5bd7e8bb93fc84cc649d11490f87cea", + "sha256:4957669ef390f0e6719db3613ab3a7631e68424604a7b448f079bee145da6e09", + "sha256:5e86d77b090dbddbe78867a0275cb4df08ea195e660f1f7f13435a4649e954e5", + "sha256:6339d047dab2780cc6220f46306628e04d9750f02f983ddb37439ca47ced7149", + "sha256:681eb3d7e02e3c3655d1b16059fbfb605ac464c834a0c629048a30fad2b27489", + "sha256:6c409c0deba34f147f77efaa67b8e4bb83d2f11c8806405f76397ae5b8c0d1c9", + "sha256:7095f6fbfaa55defb6b733cfeb14efaae7a29f0b59d8cf213be4e7ca0b857b80", + "sha256:70c610f6cbe4b9fce272c407dd9d07e33e6bf7b4aa1b7ffb6f6ded8e634e3592", + "sha256:72814c01533f51d68702802d74f77ea026b5ec52793c791e2da806a3844a46c3", + "sha256:7a4826ad2bd6b07ca615c74ab91f32f6c96d08f6fcc3902ceeedaec8cdc3bcd6", + "sha256:7c70087bfee18a42b4040bb9ec1ca15a08242cf5867c58726530bdf3945672ed", + "sha256:855eafa5d5a2034b4621c74925d89c5efef61418570e5ef9b37717d9c796419c", + "sha256:8700f06d0ce6f128de3ccdbc1acaea1ee264d2caa9ca05daaf492fde7c2a7200", + "sha256:89f1b185a01fe560bc8ae5f619e924407efca2191b56ce749ec84982fc59a32a", + "sha256:8b2c760cfc7042b27ebdb4a43a4453bd829a5742503599144d54a032c5dc7e9e", + "sha256:8c2f5e83493748286002f9369f3e6607c565a6a90425a3a1fef5ae32a36d749d", + "sha256:8e098148dd37b4ce3baca71fb394c81dc5d9c7728c95df695d2dca218edf40e6", + "sha256:94aea8eff76ee6d1cdacb07dd2123a68283cb5569e0250feab1240058f53b623", + "sha256:95eb302ff792e12aba9a8b8f8474ab229a83c103d74a750ec0bd1c1eea32e669", + "sha256:9bd9b3b31adcb054116447ea22caa61a285d92e94d710aa5ec97992ff5eb7cf3", + "sha256:9e608aafdb55eb9f255034709e20d5a83b6d60c054df0802fa9c9883d0a937aa", + "sha256:a103b3a7069b62f5d4890ae1b8f0597618f628b286b03d4bc9195230b154bfa9", + "sha256:a386ebe437176aab38c041de1260cd3ea459c6ce5263594399880bbc398225b2", + "sha256:a38856a971c602f98472050165cea2cdc97709240373041b69030be15047691f", + "sha256:a401b4598e5d3f4a9a811f3daf42ee2291790c7f9d74b18d75d6e21dda98a1a1", + "sha256:a7647ebdfb9682b7bb97e2a5e7cb6ae735b1c25008a70b906aecca294ee96cf4", + "sha256:aaf63899c94de41fe3cf934601b0f7ccb6b428c6e4eeb80da72c58eab077b19a", + "sha256:b0dac0ff919ba34d4df1b6131f59ce95b08b9065233446be7e459f95554c0dc8", + "sha256:baacc6aee0b2ef6f3d308e197b5d7a81c0e70b06beae1f1fcacffdbd124fe0e3", + "sha256:bf420121d4c8dce6b889f0e8e4ec0ca34b7f40186203f06a946fa0276ba54029", + "sha256:c04a46716adde8d927adb9457bbe39cf473e1e2c2f5d0a16ceb837e5d841ad4f", + "sha256:c0b21078a4b56965e2b12f247467b234734491897e99c1d51cee628da9786959", + "sha256:c1c76a1743432b4b60ab3358c937a3fe1341c828ae6194108a94c69028247f22", + "sha256:c4983bf937209c57240cff65906b18bb35e64ae872da6a0db937d7b4af845dd7", + "sha256:c4fb39a81950ec280984b3a44f5bd12819953dc5fa3a7e6fa7a80db5ee853952", + "sha256:c57921cda3a80d0f2b8aec7e25c8aa14479ea92b5b51b6876d975d925a2ea346", + "sha256:c8063cf17b19661471ecbdb3df1c84f24ad2e389e326ccaf89e3fb2484d8dd7e", + "sha256:ccd16eb18a849fd8dcb23e23380e2f0a354e8daa0c984b8a732d9cfaba3a776d", + "sha256:cd6dbe0238f7743d0efe563ab46294f54f9bc8f4b9bcf57c3c666cc5bc9d1299", + "sha256:d62e51710986674142526ab9f78663ca2b0726066ae26b78b22e0f5e571238dd", + "sha256:db901e2ac34c931d73054d9797383d0f8009991e723dab15109740a63e7f902a", + "sha256:e03b8895a6990c9ab2cdcd0f2fe44088ca1c65ae592b8f795c3294af00a461c3", + "sha256:e1c8a2f4c69e08e89632defbfabec2feb8a8d99edc9f89ce33c4b9e36ab63037", + "sha256:e4b749b9cc6ee664a3300bb3a273c1ca8068c46be705b6c31cf5d276f8628a94", + "sha256:e6a5bf2cba5ae1bb80b154ed68a3cfa2fa00fde979a7f50d6598d3e17d9ac20c", + "sha256:e857a2232ba53ae940d3456f7533ce6ca98b81917d47adc3c7fd55dad8fab858", + "sha256:ee4006268ed33370957f55bf2e6f4d263eaf4dc3cfc473d1d90baff6ed36ce4a", + "sha256:eef9df1eefada2c09a5e7a40991b9fc6ac6ef20b1372abd48d2794a316dc0449", + "sha256:f058f6963fd82eb143c692cecdc89e075fa0828db2e5b291070485390b2f1c9c", + "sha256:f25c229a6ba38a35ae6e25ca1264621cc25d4d38dca2942a7fce0b67a4efe918", + "sha256:f2a1d0fd4242bd8643ce6f98927cf9c04540af6efa92323e9d3124f57727bfc1", + "sha256:f7560358a6811e52e9c4d142d497f1a6e10103d3a6881f18d04dbce3729c0e2c", + "sha256:f779d3ad205f108d14e99bb3859aa7dd8e9c68874617c72354d7ecaec2a054ac", + "sha256:f87f746ee241d30d6ed93969de31e5ffd09a2961a051e60ae6bddde9ec3583aa" + ], + "markers": "python_full_version >= '3.7.0'", + "version": "==3.2.0" + }, + "distlib": { + "hashes": [ + "sha256:14bad2d9b04d3a36127ac97f30b12a19268f211063d8f8ee4f47108896e11b46", + "sha256:f35c4b692542ca110de7ef0bea44d73981caeb34ca0b9b6b2e6d7790dda8f80e" + ], + "version": "==0.3.6" + }, + "docutils": { + "hashes": [ + "sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6", + "sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b" + ], + "markers": "python_version >= '3.7'", + "version": "==0.20.1" + }, + "filelock": { + "hashes": [ + "sha256:002740518d8aa59a26b0c76e10fb8c6e15eae825d34b6fdf670333fd7b938d81", + "sha256:cbb791cdea2a72f23da6ac5b5269ab0a0d161e9ef0100e653b69049a7706d1ec" + ], + "markers": "python_version >= '3.7'", + "version": "==3.12.2" + }, + "identify": { + "hashes": [ + "sha256:0aac67d5b4812498056d28a9a512a483f5085cc28640b02b258a59dac34301d4", + "sha256:986dbfb38b1140e763e413e6feb44cd731faf72d1909543178aa79b0e258265d" + ], + "markers": "python_version >= '3.7'", + "version": "==2.5.24" + }, + "idna": { + "hashes": [ + "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4", + "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2" + ], + "markers": "python_version >= '3.5'", + "version": "==3.4" + }, + "imagesize": { + "hashes": [ + "sha256:0d8d18d08f840c19d0ee7ca1fd82490fdc3729b7ac93f49870406ddde8ef8d8b", + "sha256:69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.4.1" + }, + "jinja2": { + "hashes": [ + "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852", + "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61" + ], + "markers": "python_version >= '3.7'", + "version": "==3.1.2" + }, + "markdown-it-py": { + "hashes": [ + "sha256:355216845c60bd96232cd8d8c40e8f9765cc86f46880e43a8fd22dc1a1a8cab1", + "sha256:e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb" + ], + "markers": "python_version >= '3.8'", + "version": "==3.0.0" + }, + "markupsafe": { + "hashes": [ + "sha256:05fb21170423db021895e1ea1e1f3ab3adb85d1c2333cbc2310f2a26bc77272e", + "sha256:0a4e4a1aff6c7ac4cd55792abf96c915634c2b97e3cc1c7129578aa68ebd754e", + "sha256:10bbfe99883db80bdbaff2dcf681dfc6533a614f700da1287707e8a5d78a8431", + "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686", + "sha256:1577735524cdad32f9f694208aa75e422adba74f1baee7551620e43a3141f559", + "sha256:1b40069d487e7edb2676d3fbdb2b0829ffa2cd63a2ec26c4938b2d34391b4ecc", + "sha256:282c2cb35b5b673bbcadb33a585408104df04f14b2d9b01d4c345a3b92861c2c", + "sha256:2c1b19b3aaacc6e57b7e25710ff571c24d6c3613a45e905b1fde04d691b98ee0", + "sha256:2ef12179d3a291be237280175b542c07a36e7f60718296278d8593d21ca937d4", + "sha256:338ae27d6b8745585f87218a3f23f1512dbf52c26c28e322dbe54bcede54ccb9", + "sha256:3c0fae6c3be832a0a0473ac912810b2877c8cb9d76ca48de1ed31e1c68386575", + "sha256:3fd4abcb888d15a94f32b75d8fd18ee162ca0c064f35b11134be77050296d6ba", + "sha256:42de32b22b6b804f42c5d98be4f7e5e977ecdd9ee9b660fda1a3edf03b11792d", + "sha256:504b320cd4b7eff6f968eddf81127112db685e81f7e36e75f9f84f0df46041c3", + "sha256:525808b8019e36eb524b8c68acdd63a37e75714eac50e988180b169d64480a00", + "sha256:56d9f2ecac662ca1611d183feb03a3fa4406469dafe241673d521dd5ae92a155", + "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac", + "sha256:65c1a9bcdadc6c28eecee2c119465aebff8f7a584dd719facdd9e825ec61ab52", + "sha256:68e78619a61ecf91e76aa3e6e8e33fc4894a2bebe93410754bd28fce0a8a4f9f", + "sha256:69c0f17e9f5a7afdf2cc9fb2d1ce6aabdb3bafb7f38017c0b77862bcec2bbad8", + "sha256:6b2b56950d93e41f33b4223ead100ea0fe11f8e6ee5f641eb753ce4b77a7042b", + "sha256:787003c0ddb00500e49a10f2844fac87aa6ce977b90b0feaaf9de23c22508b24", + "sha256:7ef3cb2ebbf91e330e3bb937efada0edd9003683db6b57bb108c4001f37a02ea", + "sha256:8023faf4e01efadfa183e863fefde0046de576c6f14659e8782065bcece22198", + "sha256:8758846a7e80910096950b67071243da3e5a20ed2546e6392603c096778d48e0", + "sha256:8afafd99945ead6e075b973fefa56379c5b5c53fd8937dad92c662da5d8fd5ee", + "sha256:8c41976a29d078bb235fea9b2ecd3da465df42a562910f9022f1a03107bd02be", + "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2", + "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707", + "sha256:962f82a3086483f5e5f64dbad880d31038b698494799b097bc59c2edf392fce6", + "sha256:9dcdfd0eaf283af041973bff14a2e143b8bd64e069f4c383416ecd79a81aab58", + "sha256:aa7bd130efab1c280bed0f45501b7c8795f9fdbeb02e965371bbef3523627779", + "sha256:ab4a0df41e7c16a1392727727e7998a467472d0ad65f3ad5e6e765015df08636", + "sha256:ad9e82fb8f09ade1c3e1b996a6337afac2b8b9e365f926f5a61aacc71adc5b3c", + "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad", + "sha256:b076b6226fb84157e3f7c971a47ff3a679d837cf338547532ab866c57930dbee", + "sha256:b7ff0f54cb4ff66dd38bebd335a38e2c22c41a8ee45aa608efc890ac3e3931bc", + "sha256:bfce63a9e7834b12b87c64d6b155fdd9b3b96191b6bd334bf37db7ff1fe457f2", + "sha256:c011a4149cfbcf9f03994ec2edffcb8b1dc2d2aede7ca243746df97a5d41ce48", + "sha256:c9c804664ebe8f83a211cace637506669e7890fec1b4195b505c214e50dd4eb7", + "sha256:ca379055a47383d02a5400cb0d110cef0a776fc644cda797db0c5696cfd7e18e", + "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b", + "sha256:cd0f502fe016460680cd20aaa5a76d241d6f35a1c3350c474bac1273803893fa", + "sha256:ceb01949af7121f9fc39f7d27f91be8546f3fb112c608bc4029aef0bab86a2a5", + "sha256:d080e0a5eb2529460b30190fcfcc4199bd7f827663f858a226a81bc27beaa97e", + "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb", + "sha256:df0be2b576a7abbf737b1575f048c23fb1d769f267ec4358296f31c2479db8f9", + "sha256:e09031c87a1e51556fdcb46e5bd4f59dfb743061cf93c4d6831bf894f125eb57", + "sha256:e4dd52d80b8c83fdce44e12478ad2e85c64ea965e75d66dbeafb0a3e77308fcc", + "sha256:fec21693218efe39aa7f8599346e90c705afa52c5b31ae019b2e57e8f6542bb2" + ], + "markers": "python_version >= '3.7'", + "version": "==2.1.3" + }, + "mdit-py-plugins": { + "hashes": [ + "sha256:b51b3bb70691f57f974e257e367107857a93b36f322a9e6d44ca5bf28ec2def9", + "sha256:d8ab27e9aed6c38aa716819fedfde15ca275715955f8a185a8e1cf90fb1d2c1b" + ], + "markers": "python_version >= '3.8'", + "version": "==0.4.0" + }, + "mdurl": { + "hashes": [ + "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8", + "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba" + ], + "markers": "python_version >= '3.7'", + "version": "==0.1.2" + }, + "myst-parser": { + "hashes": [ + "sha256:7c36344ae39c8e740dad7fdabf5aa6fc4897a813083c6cc9990044eb93656b14", + "sha256:ea929a67a6a0b1683cdbe19b8d2e724cd7643f8aa3e7bb18dd65beac3483bead" + ], + "index": "pypi", + "version": "==2.0.0" + }, + "nodeenv": { + "hashes": [ + "sha256:d51e0c37e64fbf47d017feac3145cdbb58836d7eee8c6f6d3b6880c5456227d2", + "sha256:df865724bb3c3adc86b3876fa209771517b0cfe596beff01a92700e0e8be4cec" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, " + "3.4, 3.5, 3.6'", + "version": "==1.8.0" + }, + "packaging": { + "hashes": [ + "sha256:994793af429502c4ea2ebf6bf664629d07c1a9fe974af92966e4b8d2df7edc61", + "sha256:a392980d2b6cffa644431898be54b0045151319d1e7ec34f0cfed48767dd334f" + ], + "markers": "python_version >= '3.7'", + "version": "==23.1" + }, + "platformdirs": { + "hashes": [ + "sha256:cec7b889196b9144d088e4c57d9ceef7374f6c39694ad1577a0aab50d27ea28c", + "sha256:f87ca4fcff7d2b0f81c6a748a77973d7af0f4d526f98f308477c3c436c74d528" + ], + "markers": "python_version >= '3.7'", + "version": "==3.8.1" + }, + "pre-commit": { + "hashes": [ + "sha256:10badb65d6a38caff29703362271d7dca483d01da88f9d7e05d0b97171c136cb", + "sha256:a2256f489cd913d575c145132ae196fe335da32d91a8294b7afe6622335dd023" + ], + "index": "pypi", + "version": "==3.3.3" + }, + "pygments": { + "hashes": [ + "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c", + "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1" + ], + "markers": "python_version >= '3.7'", + "version": "==2.15.1" + }, + "python-dotenv": { + "hashes": [ + "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba", + "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a" + ], + "markers": "python_version >= '3.8'", + "version": "==1.0.0" + }, + "pyyaml": { + "hashes": [ + "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf", + "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293", + "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b", + "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57", + "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b", + "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4", + "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07", + "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba", + "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9", + "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287", + "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513", + "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0", + "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782", + "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0", + "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92", + "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f", + "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2", + "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc", + "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1", + "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c", + "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86", + "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4", + "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c", + "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34", + "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b", + "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d", + "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c", + "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb", + "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7", + "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737", + "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3", + "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d", + "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358", + "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53", + "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78", + "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803", + "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a", + "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f", + "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174", + "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5" + ], + "markers": "python_version >= '3.6'", + "version": "==6.0" + }, + "requests": { + "hashes": [ + "sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f", + "sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1" + ], + "markers": "python_version >= '3.7'", + "version": "==2.31.0" + }, + "setuptools": { + "hashes": [ + "sha256:11e52c67415a381d10d6b462ced9cfb97066179f0e871399e006c4ab101fc85f", + "sha256:baf1fdb41c6da4cd2eae722e135500da913332ab3f2f5c7d33af9b492acb5235" + ], + "markers": "python_version >= '3.7'", + "version": "==68.0.0" + }, + "snowballstemmer": { + "hashes": [ + "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1", + "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a" + ], + "version": "==2.2.0" + }, + "soupsieve": { + "hashes": [ + "sha256:1c1bfee6819544a3447586c889157365a27e10d88cde3ad3da0cf0ddf646feb8", + "sha256:89d12b2d5dfcd2c9e8c22326da9d9aa9cb3dfab0a83a024f05704076ee8d35ea" + ], + "markers": "python_version >= '3.7'", + "version": "==2.4.1" + }, + "sphinx": { + "hashes": [ + "sha256:60c5e04756c1709a98845ed27a2eed7a556af3993afb66e77fec48189f742616", + "sha256:61e025f788c5977d9412587e733733a289e2b9fdc2fef8868ddfbfc4ccfe881d" + ], + "index": "pypi", + "version": "==7.0.1" + }, + "sphinx-sitemap": { + "hashes": [ + "sha256:95101f622d0d594161720cbe92a39d353efae9382f7f3563f06d150b1146fef6", + "sha256:98a7e3bb25acb467037b56f3585fc38d53d5a274542b1497393a66f71b79b125" + ], + "index": "pypi", + "version": "==2.5.0" + }, + "sphinxawesome-theme": { + "hashes": [ + "sha256:827b810ce314adb3146ccbce4787d6a6fa94de6dea7c61ef081a239ba70a1d25", + "sha256:fb6b4ba63583199d6c1d837ffc0fea8d63e4bc3537be9b27c563d82dcf3b25c2" + ], + "index": "pypi", + "version": "==4.1.0" + }, + "sphinxcontrib-applehelp": { + "hashes": [ + "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228", + "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e" + ], + "markers": "python_version >= '3.8'", + "version": "==1.0.4" + }, + "sphinxcontrib-devhelp": { + "hashes": [ + "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e", + "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.2" + }, + "sphinxcontrib-htmlhelp": { + "hashes": [ + "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff", + "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903" + ], + "markers": "python_version >= '3.8'", + "version": "==2.0.1" + }, + "sphinxcontrib-jsmath": { + "hashes": [ + "sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178", + "sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.1" + }, + "sphinxcontrib-qthelp": { + "hashes": [ + "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72", + "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6" + ], + "markers": "python_version >= '3.5'", + "version": "==1.0.3" + }, + "sphinxcontrib-serializinghtml": { + "hashes": [ + "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd", + "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952" + ], + "markers": "python_version >= '3.5'", + "version": "==1.1.5" + }, + "urllib3": { + "hashes": [ + "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1", + "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825" + ], + "markers": "python_version >= '3.7'", + "version": "==2.0.3" + }, + "virtualenv": { + "hashes": [ + "sha256:34da10f14fea9be20e0fd7f04aba9732f84e593dac291b757ce42e3368a39419", + "sha256:8ff19a38c1021c742148edc4f81cb43d7f8c6816d2ede2ab72af5b84c749ade1" + ], + "markers": "python_version >= '3.7'", + "version": "==20.23.1" + } + }, + "develop": {} } From 4f6dfe2509b9a89b4516f7d179f214445e44402e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 10 Jul 2023 00:05:22 +0200 Subject: [PATCH 27/29] try fixing doc-action --- .github/workflows/sphinx_to_pages.yml | 4 +--- src/platform.h | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sphinx_to_pages.yml b/.github/workflows/sphinx_to_pages.yml index dc32ae9..ac00970 100644 --- a/.github/workflows/sphinx_to_pages.yml +++ b/.github/workflows/sphinx_to_pages.yml @@ -23,9 +23,7 @@ jobs: # uses: pre-commit/action@v3.0.0 - name: Install dependencies 🔧 - run: pip3 install pipenv - - name: Install dependencies 🔧 - run: pipenv shell + run: pip3 install sphinx sphinxawesome-theme sphinx-sitemap myst-parser - name: Build Documentation 🧱 uses: sphinx-notes/pages@v2 diff --git a/src/platform.h b/src/platform.h index f33c225..87c4421 100644 --- a/src/platform.h +++ b/src/platform.h @@ -111,8 +111,8 @@ constexpr uint8_t VALUE_IPL{(microsecondsToClockCycles(1) > 120) ? 26 : 22}; #define DIRECT_MODE_OUTPUT(base, pin) pinMode(pin, OUTPUT) #define DELAY_MICROSECONDS(us) delayMicroseconds(us) using io_reg_t = uint32_t; // define special data type for register-access -constexpr uint8_t VALUE_IPL { 51 }; -// ⤷ instructions per loop, for 40 and 80 MHz (see esp8266 difference), was 39 +constexpr uint8_t VALUE_IPL{51}; + // ⤷ instructions per loop, for 40 and 80 MHz (see esp8266 difference), was 39 #elif defined(ARDUINO_ARCH_SAMD) /* arduino family samd */ // arduino-zero is defined(__SAMD21G18A__) From 2f9636a358f8b393f62fd787339ae0bc5b52002e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 10 Jul 2023 00:14:59 +0200 Subject: [PATCH 28/29] Update sphinx_to_pages.yml --- .github/workflows/sphinx_to_pages.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sphinx_to_pages.yml b/.github/workflows/sphinx_to_pages.yml index ac00970..0b5bef5 100644 --- a/.github/workflows/sphinx_to_pages.yml +++ b/.github/workflows/sphinx_to_pages.yml @@ -26,7 +26,11 @@ jobs: run: pip3 install sphinx sphinxawesome-theme sphinx-sitemap myst-parser - name: Build Documentation 🧱 - uses: sphinx-notes/pages@v2 + uses: sphinx-notes/pages@v3 + with: + checkout: false + publish: false + - name: Push changes 📌 uses: ad-m/github-push-action@master with: From ff07e6f8a29f962403a5e7bf738c690d71827d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingmar=20In=CA=92o=20Splitt?= Date: Mon, 10 Jul 2023 00:19:25 +0200 Subject: [PATCH 29/29] Update sphinx_to_pages.yml --- .github/workflows/sphinx_to_pages.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/sphinx_to_pages.yml b/.github/workflows/sphinx_to_pages.yml index 0b5bef5..c41f761 100644 --- a/.github/workflows/sphinx_to_pages.yml +++ b/.github/workflows/sphinx_to_pages.yml @@ -3,9 +3,6 @@ on: push: branches: - main - pull_request: - branches: - - main jobs: build: @@ -30,6 +27,7 @@ jobs: with: checkout: false publish: false + documentation_path: "./docs/source" - name: Push changes 📌 uses: ad-m/github-push-action@master