Skip to content

Commit

Permalink
Add IO_PCA9554.h to IODevice.h
Browse files Browse the repository at this point in the history
  • Loading branch information
pmantoine committed Sep 18, 2024
1 parent 3b35537 commit 11c5638
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions IODevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ class FLAGS : IODevice {
#include "IO_PCF8574.h"
#include "IO_PCF8575.h"
#include "IO_PCA9555.h"
#include "IO_PCA9554.h"
#include "IO_duinoNodes.h"
#include "IO_EXIOExpander.h"
#include "IO_trainbrains.h"
Expand Down
12 changes: 9 additions & 3 deletions IO_PCA9554.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ class PCA9554 : public GPIOBase<uint8_t> {
PCA9554(VPIN vpin, uint8_t nPins, I2CAddress I2CAddress, int interruptPin=-1)
: GPIOBase<uint8_t>((FSH *)F("PCA9554"), vpin, nPins, I2CAddress, interruptPin)
{
if (nPins > 8)
if (nPins > 8) {
DIAG(F("PCA9554 nPins %d larger than allowed!"));
nPins = 8;
}
requestBlock.setRequestParams(_I2CAddress, inputBuffer, sizeof(inputBuffer),
outputBuffer, sizeof(outputBuffer));
outputBuffer[0] = REG_INPUT_P0;
Expand Down Expand Up @@ -81,8 +83,12 @@ class PCA9554 : public GPIOBase<uint8_t> {
}
// This function is invoked when an I/O operation on the requestBlock completes.
void _processCompletion(uint8_t status) override {
if (status == I2C_STATUS_OK)
_portInputState = inputBuffer[0];
if (status == I2C_STATUS_OK)
{
if (_portInputState != (inputBuffer[0] | _portMode))
DIAG(F("PCA9554 inputs changed, value now %x"), inputBuffer[0]);
_portInputState = inputBuffer[0] | _portMode;
}
else
_portInputState = 0xff;
}
Expand Down

0 comments on commit 11c5638

Please sign in to comment.