This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 3b7ce364553 arch/arm/src/rp23xx: Fix interrupt disable and priority
bugs
3b7ce364553 is described below
commit 3b7ce364553e84f9a3061513f7319b5f8f348b97
Author: Shubham S Taple <[email protected]>
AuthorDate: Thu Nov 19 14:03:40 2026 +0000
arch/arm/src/rp23xx: Fix interrupt disable and priority bugs
up_disable_irq() had two bugs:
1. The range check was irq - RP23XX_IRQ_EXTINT >= RP23XX_IRQ_EXTINT
which simplifies to irq >= 32, skipping IRQs 16-31 entirely,
while the correct condition would be irq >= RP23XX_IRQ_EXTINT.
2. The NVIC register selection tested the NuttX IRQ number (irq < 32)
instead of the external IRQ number
(irq - RP23XX_IRQ_EXTINT < 32).
up_prioritize_irq() had two bugs:
1. The range check used irq < RP23XX_IRQ_EXTINT + 32, which only
covered external IRQs 0-31. External IRQs 32-51 fell through to
return ERROR and could not be reprioritized.
2. NVIC_IRQ_PRIORITY() was passed the NuttX IRQ number instead of
the external IRQ number.
Also remove stale handler names from the comment block above the
exception handlers: rp23xx_busfault, rp23xx_usagefault and
rp23xx_dbgmonitor are not defined in this file, and rp23xx_pendsv
was listed twice.
Signed-off-by: Shubham S Taple <[email protected]>
---
arch/arm/src/rp23xx/rp23xx_irq.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/arch/arm/src/rp23xx/rp23xx_irq.c b/arch/arm/src/rp23xx/rp23xx_irq.c
index 7bb7681f7b9..54fc7b214ff 100644
--- a/arch/arm/src/rp23xx/rp23xx_irq.c
+++ b/arch/arm/src/rp23xx/rp23xx_irq.c
@@ -145,8 +145,7 @@ static void rp23xx_dumpnvic(const char *msg, int irq)
#endif
/****************************************************************************
- * Name: rp23xx_nmi, rp23xx_busfault, rp23xx_usagefault, rp23xx_pendsv,
- * rp23xx_dbgmonitor, rp23xx_pendsv, rp23xx_reserved
+ * Name: rp23xx_nmi, rp23xx_pendsv, rp23xx_reserved
*
* Description:
* Handlers for various exceptions. None are handled and all are fatal
@@ -365,13 +364,13 @@ void up_disable_irq(int irq)
/* Check for an external interrupt */
- if (irq - RP23XX_IRQ_EXTINT >= RP23XX_IRQ_EXTINT && irq < RP23XX_IRQ_NIRQS)
+ if (irq >= RP23XX_IRQ_EXTINT && irq < RP23XX_IRQ_NIRQS)
{
/* Set the appropriate bit in the ICER register to disable the
* interrupt
*/
- if (irq < 32)
+ if (irq - RP23XX_IRQ_EXTINT < 32)
{
putreg32((1 << (irq - RP23XX_IRQ_EXTINT)), NVIC_IRQ0_31_CLEAR);
}
@@ -478,6 +477,7 @@ int up_prioritize_irq(int irq, int priority)
uint32_t regaddr;
uint32_t regval;
int shift;
+ int irq_ext;
DEBUGASSERT(irq == RP23XX_IRQ_SVCALL ||
irq == RP23XX_IRQ_PENDSV ||
@@ -488,14 +488,15 @@ int up_prioritize_irq(int irq, int priority)
/* Check for external interrupt */
- if (irq >= RP23XX_IRQ_EXTINT && irq < RP23XX_IRQ_EXTINT + 32)
+ if (irq >= RP23XX_IRQ_EXTINT && irq < RP23XX_IRQ_NIRQS)
{
/* NVIC_IRQ_PRIORITY maps register IPR0-IPR7 with four settings per
* register.
*/
- regaddr = NVIC_IRQ_PRIORITY(irq);
- shift = (irq & 3) << 3;
+ irq_ext = irq - RP23XX_IRQ_EXTINT;
+ regaddr = NVIC_IRQ_PRIORITY(irq_ext);
+ shift = (irq_ext & 3) << 3;
}
/* Handle processor exceptions. Only SVCall, PendSV, and SysTick can be