Skip to content

Interrupt handler for Mcp23xxx only handles interrupts on first 4 pins #2404

@HakanL

Description

@HakanL

Describe the bug

In the Mcp23xxx driver (used by Mcp23008, Mcp23017, etc) the interrupt handler has a loop where it checks if the mask is matching the pending interrupts, but the loop checks only 4 of the total 8 pins, so interrupts are never working on pins 5-8 (for either port A and B on Mcp23017). This is the code:

int mask = 1;
int pin = 0;

while (mask < 0x10)
{
    if ((interruptPending & mask) != 0)
    {
        CallHandlerOnPin(pin + offset, newValues & mask);
    }

    mask = mask << 1;
    pin++;
}

Steps to reproduce

Hook up a button to pin 5-8 and you'll never receive the interrupts.

Expected behavior

Interrupts should received

Actual behavior

Nothing

Versions used

4.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions