Example #1
0
xcpt_t up_irqbutton(int id, xcpt_t irqhandler)
{
  xcpt_t oldhandler = NULL;

  if (id == BUTTON_USER1)
    {
      irqstate_t flags;

      /* Disable interrupts until we are done.  This guarantees that the
       * following operations are atomic.
       */

      flags = irqsave();

      /* Get the old button interrupt handler and save the new one */

      oldhandler = *g_irquser1;
      *g_irquser1 = irqhandler;

      /* Configure the interrupt */

      sam_gpioirq(IRQ_USER1);
      (void)irq_attach(IRQ_USER1, irqhandler);
      sam_gpioirqenable(IRQ_USER1);
    }

  /* Return the old button handler (so that it can be restored) */

  return oldhandler;
}
Example #2
0
static xcpt_t board_button_irqx(int irq, xcpt_t irqhandler, xcpt_t *store)
{
  xcpt_t oldhandler;
  irqstate_t flags;

  /* Disable interrupts until we are done.  This guarantees that the following
   * operations are atomic.
   */

  flags = irqsave();

  /* Get the old button interrupt handler and save the new one */

  oldhandler = *store;
  *store = irqhandler;

  /* Configure the interrupt */

  sam_gpioirq(irq);
  (void)irq_attach(irq, irqhandler);
  sam_gpioirqenable(irq);
  irqrestore(flags);

  /* Return the old button handler (so that it can be restored) */

  return oldhandler;
}
Example #3
0
void up_enable_irq(int irq)
{
  uintptr_t regaddr;
  uint32_t regval;
  uint32_t bit;

  if (sam_irqinfo(irq, &regaddr, &bit, NVIC_ENA_OFFSET) == 0)
    {
      /* Modify the appropriate bit in the register to enable the interrupt.
       * For normal interrupts, we need to set the bit in the associated
       * Interrupt Set Enable register.  For other exceptions, we need to
       * set the bit in the System Handler Control and State Register.
       */

      if (irq >= SAM_IRQ_EXTINT)
        {
          putreg32(bit, regaddr);
        }
      else
        {
          regval  = getreg32(regaddr);
          regval |= bit;
          putreg32(regval, regaddr);
        }
    }
#ifdef CONFIG_SAM34_GPIO_IRQ
  else
    {
      /* Maybe it is a (derived) GPIO IRQ */

      sam_gpioirqenable(irq);
    }
#endif
  sam_dumpnvic("enable", irq);
}
Example #4
0
int sam_hsmci_initialize(void)
{
  int ret;
  fdbg("Initializing SDIO\n");

  /* Have we already initialized? */

  if (!g_hsmci.initialized)
    {
      /* Mount the SDIO-based MMC/SD block driver */
      /* First, get an instance of the SDIO interface */

      g_hsmci.hsmci = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
      if (!g_hsmci.hsmci)
        {
          fdbg("Failed to initialize SDIO\n");
          return -ENODEV;
        }

      /* Now bind the SDIO interface to the MMC/SD driver */

      ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_hsmci.hsmci);
      if (ret != OK)
        {
          fdbg("Failed to bind SDIO to the MMC/SD driver: %d\n", ret);
          return ret;
        }

#ifdef CONFIG_MMCSD_HAVECARDDETECT
      /* Initialize card-detect GPIO.  There is no write-protection GPIO. */

      sam_configgpio(GPIO_MCI_CD);

      /* Configure card detect interrupts */

      sam_gpioirq(GPIO_MCI_CD);
      (void)irq_attach(MCI_CD_IRQ, sam_hsmci_cardetect_int);
      g_hsmci.inserted = sam_cardinserted(0);
#else
      g_hsmci.inserted = true; /* An assumption? */
#endif
      /* Then inform the HSMCI driver if there is or is not a card in the slot. */

      sdio_mediachange(g_hsmci.hsmci, g_hsmci.inserted);

      /* Now we are initialized */

      g_hsmci.initialized = true;

      /* Enable card detect interrupts */

#ifdef CONFIG_MMCSD_HAVECARDDETECT
      sam_gpioirqenable(MCI_CD_IRQ);
#endif
    }

  return OK;
}
Example #5
0
static void sam_emac0_phy_enable(bool enable)
{
  phyinfo("IRQ%d: enable=%d\n", IRQ_EMAC0_INT, enable);
  if (enable)
    {
      sam_gpioirqenable(IRQ_EMAC0_INT);
    }
  else
    {
      sam_gpioirqdisable(IRQ_EMAC0_INT);
    }
}
Example #6
0
static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable)
{
    /* Attach and enable, or detach and disable */

    ivdbg("IRQ:%d enable:%d\n", SAM_TSC_IRQ, enable);
    if (enable)
    {
        sam_gpioirqenable(SAM_TSC_IRQ);
    }
    else
    {
        sam_gpioirqdisable(SAM_TSC_IRQ);
    }
}
Example #7
0
xcpt_t board_button_irq(int id, xcpt_t irqhandler)
{
  xcpt_t oldhandler = NULL;

  if (id == BUTTON_SW0)
    {
      irqstate_t flags;

      /* Disable interrupts until we are done.  This guarantees that the
       * following operations are atomic.
       */

      flags = irqsave();

      /* Get the old button interrupt handler and save the new one */

      oldhandler = g_irqsw0;
      g_irqsw0 = irqhandler;

      /* Are we attaching or detaching? */

      if (irqhandler != NULL)
        {
          /* Configure the interrupt */

          sam_gpioirq(GPIO_SW0);
          (void)irq_attach(IRQ_SW0, irqhandler);
          sam_gpioirqenable(IRQ_SW0);
        }
      else
        {
          /* Detach and disable the interrupt */

          (void)irq_detach(IRQ_SW0);
          sam_gpioirqdisable(IRQ_SW0);
        }

      irqrestore(flags);
    }

  /* Return the old button handler (so that it can be restored) */

  return oldhandler;
}
Example #8
0
static xcpt_t board_button_irqx(gpio_pinset_t pinset, int irq,
                                xcpt_t irqhandler, xcpt_t *store)
{
  xcpt_t oldhandler;
  irqstate_t flags;

  /* Disable interrupts until we are done.  This guarantees that the following
   * operations are atomic.
   */

  flags = irqsave();

  /* Get the old button interrupt handler and save the new one */

  oldhandler = *store;
  *store = irqhandler;

  /* Are we attaching or detaching? */

  if (irqhandler != NULL)
    {
      /* Configure the interrupt */

      sam_gpioirq(pinset);
      (void)irq_attach(irq, irqhandler);
      sam_gpioirqenable(irq);
    }
  else
    {
      /* Detach and disable the interrupt */

      (void)irq_detach(irq);
      sam_gpioirqdisable(irq);
    }

  irqrestore(flags);

  /* Return the old button handler (so that it can be restored) */

  return oldhandler;
}