mirror of
https://github.com/apache/nuttx.git
synced 2026-08-17 09:33:18 +08:00
arch/arm: Fix LPC2378 to work again
Olimex LPC-2378-STK was the first board I ran NuttX in 2010. Then in 2023 I found this board on eBay and decided to buy it to try NuttX on it again, but for my disappointment it was not working: https://acassis.wordpress.com/2023/04/01/testing-nuttx-again-on-olimex-lpc2378-stk-board/ Then I opened an Issue: https://github.com/apache/nuttx/issues/19201 and Xiang Xiao and ldube helped me to get it working again. Signed-off-by: Alan C. Assis <acassis@gmail.com>
This commit is contained in:
committed by
Xiang Xiao
parent
6e239036bc
commit
d59ab52935
@@ -119,10 +119,8 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_VECTORED_INTERRUPTS
|
||||
void up_attach_vector(int irq, int priority, vic_vector_t handler);
|
||||
void up_detach_vector(int vector);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* #define CONFIG_VECTORED_INTERRUPTS */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* arm_decodeirq() and/or lpc23xx_decodeirq()
|
||||
* arm_decodeirq()
|
||||
*
|
||||
* Description:
|
||||
* The vectored interrupt controller (VIC) takes 32 interrupt request
|
||||
@@ -84,21 +84,11 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_VECTORED_INTERRUPTS
|
||||
uint32_t *arm_decodeirq(uint32_t *regs)
|
||||
#else
|
||||
static uint32_t *lpc23xx_decodeirq(uint32_t *regs)
|
||||
#endif
|
||||
{
|
||||
struct tcb_s *tcb = this_task();
|
||||
|
||||
#ifdef CONFIG_SUPPRESS_INTERRUPTS
|
||||
err("ERROR: Unexpected IRQ\n");
|
||||
|
||||
tcb->xcp.regs = regs;
|
||||
up_set_interrupt_context(true);
|
||||
PANIC();
|
||||
return NULL;
|
||||
#else
|
||||
|
||||
/* Check which IRQ fires */
|
||||
@@ -116,50 +106,13 @@ static uint32_t *lpc23xx_decodeirq(uint32_t *regs)
|
||||
|
||||
/* Verify that the resulting IRQ number is valid */
|
||||
|
||||
if (irq < NR_IRQS) /* redundant check ?? */
|
||||
if (irq < NR_IRQS)
|
||||
{
|
||||
uint32_t *saveregs;
|
||||
bool savestate;
|
||||
|
||||
savestate = up_interrupt_context();
|
||||
saveregs = tcb->xcp.regs;
|
||||
up_set_interrupt_context(true);
|
||||
tcb->xcp.regs = regs;
|
||||
|
||||
/* Acknowledge the interrupt */
|
||||
|
||||
arm_ack_irq(irq);
|
||||
|
||||
/* Deliver the IRQ */
|
||||
|
||||
irq_dispatch(irq, regs);
|
||||
|
||||
/* Restore the previous value of saveregs. */
|
||||
|
||||
up_set_interrupt_context(savestate);
|
||||
tcb->xcp.regs = saveregs;
|
||||
regs = arm_doirq(irq, regs);
|
||||
}
|
||||
|
||||
return NULL; /* Return not used in this architecture */
|
||||
#endif
|
||||
|
||||
return regs;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_VECTORED_INTERRUPTS
|
||||
uint32_t *arm_decodeirq(uint32_t *regs)
|
||||
{
|
||||
vic_vector_t vector = (vic_vector_t) vic_getreg(VIC_ADDRESS_OFFSET);
|
||||
|
||||
/* Acknowledge the interrupt */
|
||||
|
||||
arm_ack_irq(irq);
|
||||
|
||||
/* Valid Interrupt */
|
||||
|
||||
if (vector != NULL)
|
||||
{
|
||||
(vector)(regs);
|
||||
}
|
||||
|
||||
return NULL; /* Return not used in this architecture */
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -193,9 +193,7 @@ void arm_ack_irq(int irq)
|
||||
/* Clear interrupt */
|
||||
|
||||
vic_putreg((1 << irq), VIC_SOFTINTCLEAR_OFFSET);
|
||||
#ifdef CONFIG_VECTORED_INTERRUPTS
|
||||
vic_putreg(0, VIC_ADDRESS_OFFSET); /* dummy write to clear VICADDRESS */
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -230,7 +228,6 @@ int up_prioritize_irq(int irq, int priority)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_VECTORED_INTERRUPTS
|
||||
void up_attach_vector(int irq, int vector, vic_vector_t handler)
|
||||
{
|
||||
/* Verify that the IRQ number and vector number are within range */
|
||||
@@ -255,7 +252,6 @@ void up_attach_vector(int irq, int vector, vic_vector_t handler)
|
||||
leave_critical_section(flags);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_detach_vector
|
||||
@@ -265,7 +261,6 @@ void up_attach_vector(int irq, int vector, vic_vector_t handler)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_VECTORED_INTERRUPTS
|
||||
void up_detach_vector(int vector)
|
||||
{
|
||||
/* Verify that the vector number is within range */
|
||||
@@ -278,4 +273,3 @@ void up_detach_vector(int vector)
|
||||
vic_putreg(0, (VIC_VECTADDR0_OFFSET + offset));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -91,11 +91,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_VECTORED_INTERRUPTS
|
||||
static int lpc23xx_timerisr(uint32_t * regs)
|
||||
#else
|
||||
static int lpc23xx_timerisr(int irq, uint32_t * regs, void *arg)
|
||||
#endif
|
||||
{
|
||||
static uint32_t tick;
|
||||
|
||||
@@ -109,11 +105,9 @@ static int lpc23xx_timerisr(int irq, uint32_t * regs, void *arg)
|
||||
|
||||
/* Reset the VIC as well */
|
||||
|
||||
#ifdef CONFIG_VECTORED_INTERRUPTS
|
||||
/* write any value to VICAddress to acknowledge the interrupt */
|
||||
|
||||
vic_putreg(0, VIC_ADDRESS_OFFSET);
|
||||
#endif
|
||||
|
||||
if (tick++ > 100)
|
||||
{
|
||||
@@ -186,11 +180,7 @@ void up_timer_initialize(void)
|
||||
|
||||
/* Attach the timer interrupt vector */
|
||||
|
||||
#ifdef CONFIG_VECTORED_INTERRUPTS
|
||||
up_attach_vector(IRQ_SYSTIMER, ???, (vic_vector_t) lpc23xx_timerisr);
|
||||
#else
|
||||
irq_attach(IRQ_SYSTIMER, (xcpt_t)lpc23xx_timerisr, NULL);
|
||||
#endif
|
||||
|
||||
/* And enable the system timer interrupt */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user