Skip to content

Commit

Permalink
bugfix PortExpander: beginTransmission() / endTransmission() must be …
Browse files Browse the repository at this point in the history
…balanced
  • Loading branch information
tueddy committed Oct 22, 2023
1 parent 16176e8 commit b6deb34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## DEV-branch

* 22.10.2023: bugfix PortExpander: beginTransmission()/endTransmission() must be balanced
* 21.10.2023: Enhanced logging: Show Loglevel
* 14.10.2023: New define NO_SDCARD, enable to start without any SD card, e.g. for a webplayer only.
* 05.10.2023: Enable "Arduino as component" by default
Expand Down
10 changes: 7 additions & 3 deletions src/Port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,14 @@ void Port_Write(const uint8_t _channel, const bool _newState, const bool _initGp
}
#endif

i2cBusTwo.beginTransmission(expanderI2cAddress);
for (uint8_t i = 0; i < 2; i++) {
i2cBusTwo.beginTransmission(expanderI2cAddress);
i2cBusTwo.write(0x00 + i); // Pointer to input-register...
i2cBusTwo.endTransmission();
uint8_t error = i2cBusTwo.endTransmission();
if (error != 0) {
Log_Printf(LOGLEVEL_ERROR, "Error in endTransmission(): %d", error);
return;
}
i2cBusTwo.requestFrom(expanderI2cAddress, 1u); // ...and read its byte

if (i2cBusTwo.available()) {
Expand All @@ -361,8 +365,8 @@ void Port_Write(const uint8_t _channel, const bool _newState, const bool _initGp
// Make sure ports are read finally at shutdown in order to clear any active IRQs that could cause re-wakeup immediately
void Port_Exit(void) {
Port_MakeSomeChannelsOutputForShutdown();
i2cBusTwo.beginTransmission(expanderI2cAddress);
for (uint8_t i = 0; i < 2; i++) {
i2cBusTwo.beginTransmission(expanderI2cAddress);
i2cBusTwo.write(0x00 + i); // Pointer to input-register...
i2cBusTwo.endTransmission();
i2cBusTwo.requestFrom(expanderI2cAddress, 1u); // ...and read its byte
Expand Down
2 changes: 1 addition & 1 deletion src/revision.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#include "gitrevision.h"
constexpr const char softwareRevision[] = "Software-revision: 20231021-2";
constexpr const char softwareRevision[] = "Software-revision: 20231022-2";

0 comments on commit b6deb34

Please sign in to comment.