From 7454f370021e7f93118b869620247496b0f09516 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 8 Mar 2014 10:57:11 -0600 Subject: Fix some confusion in the code about vectored interrupts; fix so that it builds with prioritized interrutps disabed --- nuttx/arch/arm/src/lpc2378/internal.h | 16 ++++++++-------- nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c | 18 +++++++++++++----- nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c | 14 +++++--------- nuttx/arch/arm/src/lpc2378/lpc23xx_timerisr.c | 10 +++++++--- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/nuttx/arch/arm/src/lpc2378/internal.h b/nuttx/arch/arm/src/lpc2378/internal.h index 5a0e63b62..47bf8b7f5 100644 --- a/nuttx/arch/arm/src/lpc2378/internal.h +++ b/nuttx/arch/arm/src/lpc2378/internal.h @@ -14,14 +14,14 @@ * are met: * * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. + * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. * 3. Neither the name NuttX nor the names of its contributors may be - * used to endorse or promote products derived from this software - * without specific prior written permission. + * used to endorse or promote products derived from this software + * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT @@ -61,8 +61,8 @@ #ifndef __ASSEMBLY__ #ifdef CONFIG_ARCH_LEDS -extern void up_statledoff(void); -extern void up_statledon(void); +extern void lpc2378_statledoff(void); +extern void lpc2378_statledon(void); #endif #endif diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c index 96e94c454..24ed2e7a9 100644 --- a/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c +++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_irq.c @@ -58,7 +58,7 @@ #include "lpc23xx_vic.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -121,22 +121,24 @@ void up_irqinitialize(void) * VIC registers can be accessed in User or privileged mode ***********************************************************************/ +#if 0 /* Not used */ static void up_enable_irq_protect(void) { - // ~ uint32_t reg32 = vic_getreg(VIC_PROTECTION_OFFSET); - // ~ reg32 &= ~(0xFFFFFFFF); vic_putreg(0x01, VIC_PROTECTION_OFFSET); } +#endif /*********************************************************************** * Name: up_disable_irq_protect * VIC registers can only be accessed in privileged mode ***********************************************************************/ +#if 0 /* Not used */ static void up_disable_irq_protect(void) { vic_putreg(0, VIC_PROTECTION_OFFSET); } +#endif /*********************************************************************** * Name: up_disable_irq @@ -227,17 +229,21 @@ void up_maskack_irq(int irq) * MOD ****************************************************************************/ +#ifdef CONFIG_ARCH_IRQPRIO int up_prioritize_irq(int irq, int priority) { /* The default priority on reset is 16 */ + if (irq < NR_IRQS && priority > 0 && priority < 16) { int offset = irq << 2; vic_putreg(priority, VIC_VECTPRIORITY0_OFFSET + offset); return OK; } + return -EINVAL; } +#endif /**************************************************************************** * Name: up_attach_vector @@ -262,11 +268,13 @@ void up_attach_vector(int irq, int vector, vic_vector_t handler) /* Save the vector address */ - vic_putreg((uint32_t) handler, VIC_VECTADDR0_OFFSET + offset); + vic_putreg((uint32_t)handler, VIC_VECTADDR0_OFFSET + offset); +#ifdef CONFIG_ARCH_IRQPRIO /* Set the interrupt priority */ - up_prioritize_irq(irq, vector); + up_prioritize_irq(irq, PRIORITY_HIGHEST); +#endif /* Enable the vectored interrupt */ diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c index fbbebf51b..a7fce9739 100644 --- a/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c +++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c @@ -537,17 +537,13 @@ static int up_attach(struct uart_dev_s *dev) up_enable_irq(priv->irq); - /* Set the uart interrupt priority (the default value is one) */ - if (priv->uartbase == UART0_BASE_ADDR) - { - up_prioritize_irq(priv->irq, PRIORITY_LOWEST); - } - else if (priv->uartbase == UART2_BASE_ADDR) - { - up_prioritize_irq(priv->irq, 10); - } +#ifdef CONFIG_ARCH_IRQPRIO + /* Set the UART interrupt priority */ + up_prioritize_irq(priv->irq, PRIORITY_HIGHEST); +#endif } + return ret; } diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_timerisr.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_timerisr.c index d9e63d6d6..6027bfcd2 100644 --- a/nuttx/arch/arm/src/lpc2378/lpc23xx_timerisr.c +++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_timerisr.c @@ -127,10 +127,12 @@ int up_timerisr(int irq, uint32_t * regs) if (tick++ > 100) { tick = 0; - up_statledoff(); + lpc2378_statledoff(); } else - up_statledon(); + { + lpc2378_statledon(); + } return 0; } @@ -190,10 +192,12 @@ void up_timerinit(void) /* Attach the timer interrupt vector */ #ifdef CONFIG_VECTORED_INTERRUPTS - up_attach_vector(IRQ_SYSTIMER, PRIORITY_HIGHEST, (vic_vector_t) up_timerisr); + up_attach_vector(IRQ_SYSTIMER, ???, (vic_vector_t) up_timerisr); #else (void)irq_attach(IRQ_SYSTIMER, (xcpt_t) up_timerisr); +#ifdef CONFIG_ARCH_IRQPRIO up_prioritize_irq(IRQ_SYSTIMER, PRIORITY_HIGHEST); +#endif #endif /* And enable the system timer interrupt */ -- cgit v1.2.3