daniel-p-carvalho opened a new pull request, #20453:
URL: https://github.com/apache/nuttx/pull/20453
## Summary
`GPIO_EDGE_RISING` in `arch/mips/src/pic32mz/pic32mz_gpio.h` was defined as
`(12 << GPIO_CN_SHIFT)`. That sets bits 10 and 11 of the pin encoding,
which are `GPIO_PULLDOWN` and `GPIO_EDGE_DETECT`, instead of the edge type
bit 12 described by its comment (`/* Bit 12: Change notification edge type
*/`).
`pic32mz_gpioirq.c` selects the edge with
`(pinset & GPIO_EDGE_RISING) == GPIO_EDGE_RISING`, so:
* a pin configured with `GPIO_EDGE_RISING` also got the pull-down enabled;
* a falling-edge pin with `GPIO_PULLDOWN` (`GPIO_EDGE_DETECT |
GPIO_EDGE_FALLING | GPIO_PULLDOWN`) was configured as a rising-edge pin.
The fix defines `GPIO_EDGE_RISING` as `(16 << GPIO_CN_SHIFT)` (bit 12).
`GPIO_CN_MASK` already covers bits 8-12.
Found while adding GPIO interrupt support for the PIC32MZ-W1 (draft PR
#20448).
## Impact
* PIC32MZ GPIO change notification interrupts in edge-detect mode: rising
edge pins no longer get an unrequested pull-down, and falling edge pins
with a pull-down are no longer configured for the rising edge.
* No in-tree board uses `GPIO_EDGE_RISING`/`GPIO_EDGE_FALLING`; only
`pic32mz_gpioirq.c` interprets them. No Kconfig or API changes.
## Testing
* checkpatch: `./tools/checkpatch.sh -c -u -m -g upstream/master..HEAD`
passes.
* Build (Pinguino p32-gcc 4.9.2): `pic32mz-starterkit:nsh` with
`CONFIG_PIC32MZ_GPIOIRQ`, `CONFIG_PIC32MZ_GPIOIRQ_PORTA` and
`CONFIG_PIC32MZ_GPIOIRQ_PORTB`. No warnings.
* Hardware: PIC32MZ-W1 (WFI32E01PE) with a falling-edge interrupt
(`GPIO_EDGE_DETECT | GPIO_EDGE_FALLING | GPIO_PULLUP`) on the LAN8720A
nINT output; `CNCON.EDGEDETECT` and `CNNE` are set as expected and the
interrupt fires on link changes. The rising-edge path is not tested on
hardware.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]