Skip to content

arch/arm/src/samvX/sam_gpioirq.c: fix pin base address calculation#18494

Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom
michallenc:samv7-gpio-irq-fix
Mar 5, 2026
Merged

arch/arm/src/samvX/sam_gpioirq.c: fix pin base address calculation#18494
xiaoxiang781216 merged 1 commit intoapache:masterfrom
michallenc:samv7-gpio-irq-fix

Conversation

@michallenc
Copy link
Contributor

Summary

GPIO PIN base address calculation had double right shift, thus call to SAM_PION_BASE was always with port = 0 instead of correct port number. As a result, function sam_gpioirq didn't correctly configure additional interrupt modes (only rising or falling edge and level interrupts).

The issue occured on SAMv7 and SAM34 platforms (likely copy-pasted from one to another).

Impact

Allows to use additional interrupts (falling/rising edge, level) on GPIO pins.

Testing

Tested on custom SAMv7 board. I noticed the issue while debugging a custom button on pin PD24 configured as

#define GPIO_PUSHBUTTON     (GPIO_INPUT | GPIO_CFG_DEFAULT | \
                             GPIO_CFG_DEGLITCH | GPIO_INT_FALLING | \
                             GPIO_PORT_PIOD | GPIO_PIN24) /* PD_24 */

The application received the interrupt on both press and release events before the fix, now it correctly reacts only to falling edge.

GPIO PIN base address calculation had double right shift, thus call
to SAM_PION_BASE was always with port = 0 instead of correct port
number. As a result, function sam_gpioirq didn't correctly configure
additional interrupt modes (only rising or falling edge and level
interrupts).

The issue occured on SAMv7 and SAM34 platforms (likely copy-pasted
from one to another).

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
@michallenc michallenc changed the title arch/arm/src/samv7/sam_gpioirq.c: fix pin base address calculation arch/arm/src/samvX/sam_gpioirq.c: fix pin base address calculation Mar 4, 2026
@github-actions github-actions bot added Arch: arm Issues related to ARM (32-bit) architecture Size: XS The size of the change in this PR is very small labels Mar 4, 2026
@xiaoxiang781216 xiaoxiang781216 merged commit b3656d3 into apache:master Mar 5, 2026
45 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture 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.

3 participants