Skip to content
This repository was archived by the owner on Jan 28, 2022. It is now read-only.

Commit 4744643

Browse files
authored
fix: MCP23017 initialization (#500)
The bitWrite operation had no effect in the setup routine. Fortunately bits 1 and 2 were default values, whereas bit 6 was handled through the connected interrupt lines.
1 parent 7c1908d commit 4744643

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

sources/hardware/linux/arm/mcp23017_handler.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ class MCP23017 {
9494

9595
// set up interrupts
9696
int ioconfValue = wiringPiI2CReadReg8(m_i2cFd, MCP23017_IOCONA);
97-
bitWrite(ioconfValue, 6, true);
98-
bitWrite(ioconfValue, 2, false);
99-
bitWrite(ioconfValue, 1, false);
97+
bitWrite(&ioconfValue, 6, true);
98+
bitWrite(&ioconfValue, 2, false);
99+
bitWrite(&ioconfValue, 1, false);
100100
wiringPiI2CWriteReg8(m_i2cFd, MCP23017_IOCONA, ioconfValue);
101101

102102
ioconfValue = wiringPiI2CReadReg8(m_i2cFd, MCP23017_IOCONB);
103-
bitWrite(ioconfValue, 6, true); // mirror
104-
bitWrite(ioconfValue, 2, false); //
105-
bitWrite(ioconfValue, 1, false); // polarity
103+
bitWrite(&ioconfValue, 6, true); // mirror
104+
bitWrite(&ioconfValue, 2, false); //
105+
bitWrite(&ioconfValue, 1, false); // polarity
106106
wiringPiI2CWriteReg8(m_i2cFd, MCP23017_IOCONB, ioconfValue);
107107

108108
// setup pin for interrupt
@@ -266,12 +266,12 @@ class MCP23017 {
266266
int m_i2cFd;
267267

268268
private:
269-
void bitWrite(int x, int n, bool b) {
269+
void bitWrite(int *x, int n, bool b) {
270270
if (n <= 7 && n >= 0) {
271271
if (b) {
272-
x |= (1u << n);
272+
*x |= (1u << n);
273273
} else {
274-
x &= ~(1u << n);
274+
*x &= ~(1u << n);
275275
}
276276
}
277277
}

0 commit comments

Comments
 (0)