Skip to content

Guru meditation error on 1.17, but not on 1.16 #141

@bolkedebruin

Description

@bolkedebruin

While using the older, retired, MCP23008 driver but also the newer MCP23017 driver I get the following stack trace on 1.17. With the older driver this happens immediately with the newer it happens less often but conistently.

0x421675e4: Adafruit_GenericDevice::readRegister(unsigned char*, unsigned char, unsigned char*, unsigned short) at [REDACTED]/Adafruit BusIO/Adafruit_GenericDevice.cpp:60
0x4213a0a2: Adafruit_BusIO_Register::read(unsigned char*, unsigned char) at [REDACTED]/Adafruit BusIO/Adafruit_BusIO_Register.cpp:250
0x4213a0b9: Adafruit_BusIO_Register::read() at [REDACTED]/Adafruit BusIO/Adafruit_BusIO_Register.cpp:189
0x42046e4b: Adafruit_MCP23008::read8(unsigned char) at [REDACTED]/Adafruit MCP23008 library/Adafruit_MCP23008.cpp:177
0x42046e5d: Adafruit_MCP23008::readGPIO() at [REDACTED]/Adafruit MCP23008 library/Adafruit_MCP23008.cpp:98

The offending line is return _genericdevice->readRegister(addrbuffer, _addrwidth, buffer, len); in the function below. The device is set as a I2C device some I am not quite sure why the generic function is called. For now I am reverting to the older version.

bool Adafruit_BusIO_Register::read(uint8_t *buffer, uint8_t len) {
  uint8_t addrbuffer[2] = {(uint8_t)(_address & 0xFF),
                           (uint8_t)(_address >> 8)};
  if (_i2cdevice) {
    return _i2cdevice->write_then_read(addrbuffer, _addrwidth, buffer, len);
  }
  if (_spidevice) {
    if (_spiregtype == ADDRESSED_OPCODE_BIT0_LOW_TO_WRITE) {
      // very special case!
      // pass the special opcode address which we set as the high byte of the
      // regaddr
      addrbuffer[0] =
          (uint8_t)(_address >> 8) | 0x01; // set bottom bit high to read
      // the 'actual' reg addr is the second byte then
      addrbuffer[1] = (uint8_t)(_address & 0xFF);
      // the address appears to be a byte longer
      return _spidevice->write_then_read(addrbuffer, _addrwidth + 1, buffer,
                                         len);
    }
    if (_spiregtype == ADDRBIT8_HIGH_TOREAD) {
      addrbuffer[0] |= 0x80;
    }
    if (_spiregtype == ADDRBIT8_HIGH_TOWRITE) {
      addrbuffer[0] &= ~0x80;
    }
    if (_spiregtype == AD8_HIGH_TOREAD_AD7_HIGH_TOINC) {
      addrbuffer[0] |= 0x80 | 0x40;
    }
    return _spidevice->write_then_read(addrbuffer, _addrwidth, buffer, len);
  }
  if (_genericdevice) {
    return _genericdevice->readRegister(addrbuffer, _addrwidth, buffer, len);
  }
  return false;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions