arch/arm/rp2040/gpio: Allow simultaneous selection of multiple interrupt modes.

The RP2040 chip supports 4 different GPIO interrupt modes. They can be
configured to be used simultaneously, although previously the NuttX
support only allowed one type of interrupt to be enabled per GPIO pin.
This allows up to all four to be selected without changing previous
behaviour.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
This commit is contained in:
Matteo Golin
2025-04-28 19:10:53 -04:00
committed by Xiang Xiao
parent 5cc7046a7f
commit ac583fc585
2 changed files with 9 additions and 7 deletions
+5 -3
View File
@@ -284,7 +284,8 @@ void rp2040_gpio_init(uint32_t gpio)
* Name: r2040_gpio_irq_attach
*
* Description:
* Configure the interrupt generated by the specified GPIO pin.
* Configure the interrupt generated by the specified GPIO pin. Multiple
* interrupt modes can be set at once by ORing together interrupt modes.
*
****************************************************************************/
@@ -332,11 +333,12 @@ void rp2040_gpio_enable_irq(uint32_t gpio)
if (g_gpio_irq_handlers[gpio] != NULL)
{
/* Set interrupt enable bit */
/* Set interrupt enable bits based on selected modes */
reg = RP2040_IO_BANK0_PROC_INTE(gpio, 0);
clrbits_reg32(0xf << ((gpio % 8) * 4), reg);
setbits_reg32(0x1 << ((gpio % 8) * 4 + g_gpio_irq_modes[gpio]), reg);
setbits_reg32(
((uint8_t)g_gpio_irq_modes[gpio] & 0xf) << ((gpio % 8) * 4), reg);
}
}
+4 -4
View File
@@ -66,10 +66,10 @@
/* GPIO interrupt modes *****************************************************/
#define RP2040_GPIO_INTR_LEVEL_LOW 0
#define RP2040_GPIO_INTR_LEVEL_HIGH 1
#define RP2040_GPIO_INTR_EDGE_LOW 2
#define RP2040_GPIO_INTR_EDGE_HIGH 3
#define RP2040_GPIO_INTR_LEVEL_LOW (0x1)
#define RP2040_GPIO_INTR_LEVEL_HIGH (0x2)
#define RP2040_GPIO_INTR_EDGE_LOW (0x4)
#define RP2040_GPIO_INTR_EDGE_HIGH (0x8)
/****************************************************************************
* Public Types