예제 #1
0
파일: up_doirq.c 프로젝트: 1015472/PX4NuttX
FAR chipreg_t *up_doirq(uint8_t irq, FAR chipreg_t *regs)
{
  up_ledon(LED_INIRQ);

#ifdef CONFIG_SUPPRESS_INTERRUPTS

  lowsyslog("Unexpected IRQ\n");
  IRQ_ENTER(regs);
  PANIC();
  return NULL; /* Won't get here */

#else
  if (irq < NR_IRQS)
    {
       DECL_SAVESTATE();

       /* Indicate that we have entered IRQ processing logic */

       IRQ_ENTER(irq, regs);

       /* Deliver the IRQ */

       irq_dispatch(irq, regs);

       /* If a context switch occurred, 'regs' will hold the new context */

       regs = IRQ_STATE();

       /* Indicate that we are no longer in interrupt processing logic */

       IRQ_LEAVE(irq);
    }

  up_ledoff(LED_INIRQ);
  return regs;
#endif
}
FAR chipreg_t *up_doirq(uint8_t irq, FAR chipreg_t *regs)
{
  board_led_on(LED_INIRQ);

#ifdef CONFIG_SUPPRESS_INTERRUPTS

  lowsyslog(LOG_ERR, "Unexpected IRQ\n");
  IRQ_ENTER(regs);
  PANIC();
  return NULL; /* Won't get here */

#else
#ifdef CONFIG_ARCH_ADDRENV
  FAR chipreg_t *newregs;
#endif

  if (irq < NR_IRQS)
    {
      DECL_SAVESTATE();

      /* Indicate that we have entered IRQ processing logic */

      IRQ_ENTER(irq, regs);

      /* Deliver the IRQ */

      irq_dispatch(irq, regs);

#ifdef CONFIG_ARCH_ADDRENV
      /* If a context switch occurred, 'newregs' will hold the new context */

      newregs = IRQ_STATE();

      if (newregs != regs)
        {
          /* Make sure that the address environment for the previously
           * running task is closed down gracefully and set up the
           * address environment for the new thread at the head of the
           * ready-to-run list.
           */

          (void)group_addrenv(NULL);
        }

      regs = newregs;

#else
      /* If a context switch occurred, 'regs' will hold the new context */

      regs = IRQ_STATE();
#endif

      /* Indicate that we are no longer in interrupt processing logic */

      IRQ_LEAVE(irq);
    }

  board_led_off(LED_INIRQ);
  return regs;
#endif
}