Skip to content

drivers/ioexapnder/mcp23x17 : Fix write gpio output values on OLAT registers#18246

Merged
simbit18 merged 1 commit intoapache:masterfrom
paolovolpi:patch-7
Jan 30, 2026
Merged

drivers/ioexapnder/mcp23x17 : Fix write gpio output values on OLAT registers#18246
simbit18 merged 1 commit intoapache:masterfrom
paolovolpi:patch-7

Conversation

@paolovolpi
Copy link
Contributor

@paolovolpi paolovolpi commented Jan 28, 2026

Summary

Gpio output value must be set on OLATA and OLATB registers.

Why is this change necessary?
This is a bug fix. The MCP23x17 driver was writing GPIO output values to incorrect registers, causing output
pins to not behave as expected.

What functional part of the code is being changed?
The MCP23x17 I/O expander driver (drivers/ioexpander/mcp23x17.c).

How does the change work?
The fix ensures GPIO output values are written to the OLATA and OLATB (Output Latch) registers instead of the
incorrect registers. The OLAT registers are the proper registers for controlling the actual output pin
states on the MCP23x17.

Impact

  • User experience: No adaptation required. This fix corrects existing broken behavior.
  • Build: No impact.
  • Hardware: Affects boards using the MCP23x17 I/O expander.
  • Documentation: None required.
  • Security: No impact.
  • Compatibility: Backward compatible - fixes incorrect behavior.

Testing

Build Host:

  • OS: Ubuntu 22.04
  • Compiler: arm-none-eabi-gcc

Target:

  • Architecture: ARM (RP2350)
  • Board: RP2350-based board
  • Configuration: Custom config with MCP23x17 enabled over I2C0

Testing performed:

  • Connected MCP23x17 to RP2350 via I2C0
  • Attached an LED array to all 16 GPIO pins of the MCP23x17
  • Configured all 16 GPIO as outputs
  • Wrote a simple test application to toggle the LEDs on and off
  • Before fix: LEDs did not respond correctly to output commands
  • After fix: All 16 LEDs toggle on/off as expected

@github-actions github-actions bot added Area: Drivers Drivers issues Size: XS The size of the change in this PR is very small labels Jan 28, 2026
@acassis
Copy link
Contributor

acassis commented Jan 28, 2026

@paolovolpi please follow to Contributing guide, add Summary, Impact and Testing to this PR. Could you please show the testing before and after your PR?

Copy link
Contributor

@acassis acassis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paolovolpi please fix the PR to follow the Contributing guide and add the testing results (assuming you have a MCP23x17 module to test it)

Copy link
Contributor

@linguini1 linguini1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please adhere to the contributing guidelines.

@acassis
Copy link
Contributor

acassis commented Jan 30, 2026

@paolovolpi your commit is missing your signature:

❌ Missing Signed-off-by
Used config files:
1: .codespellrc
Some checks failed. For contributing guidelines, see:
https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md
Error: Process completed with exit code 1.

…gisters

Gpio output value must be set on OLATA and OLATB registers.

Summary

Why is this change necessary?
This is a bug fix. The MCP23x17 driver was writing GPIO output values to incorrect registers, causing output
pins to not behave as expected.

What functional part of the code is being changed?
The MCP23x17 I/O expander driver (drivers/ioexpander/mcp23x17.c).

How does the change work?
The fix ensures GPIO output values are written to the OLATA and OLATB (Output Latch) registers instead of the
incorrect registers. The OLAT registers are the proper registers for controlling the actual output pin
states on the MCP23x17.

Impact

- User experience: No adaptation required. This fix corrects existing broken behavior.
- Build: No impact.
- Hardware: Affects boards using the MCP23x17 I/O expander.
- Documentation: None required.
- Security: No impact.
- Compatibility: Backward compatible - fixes incorrect behavior.

Testing

Build Host:
- OS: Ubuntu 22.04
- Compiler: arm-none-eabi-gcc

Target:
- Architecture: ARM (RP2350)
- Board: RP2350-based board
- Configuration: Custom config with MCP23x17 enabled over I2C0

Testing performed:
- Connected MCP23x17 to RP2350 via I2C0
- Attached an LED array to all 16 GPIO pins of the MCP23x17
- Configured all 16 GPIO as outputs
- Wrote a simple test application to toggle the LEDs on and off
- Before fix: LEDs did not respond correctly to output commands
- After fix: All 16 LEDs toggle on/off as expected

Signed-off-by: paolo <paolo.volpi@gmail.com>
@simbit18 simbit18 changed the title drivers/ioexapnder/mcp23x17 : Fix write gpio output values on OLAT re… drivers/ioexapnder/mcp23x17 : Fix write gpio output values on OLAT registers Jan 30, 2026
@simbit18
Copy link
Contributor

simbit18 commented Jan 30, 2026

Hi @paolovolpi, I copied your commit description into the PR summary.

@acassis
Copy link
Contributor

acassis commented Jan 30, 2026

@linguini1 PTAL

@simbit18 simbit18 merged commit db50f04 into apache:master Jan 30, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants