Beispiel #1
0
static inline int lpc11_configinput(lpc11_pinset_t cfgset, unsigned int port,
                                    unsigned int pin)
{
  uint32_t regval;
  uint32_t gpiobase;
  uint32_t intbase;
  uint32_t pinmask = (1 << pin);

  /* Set up GPIO registers */

  gpiobase = g_gpiobase[port];

  /* Set as input */

  regval = getreg32(gpiobase + LPC11_GPIO_DIR_OFFSET);
  regval &= ~pinmask;
  putreg32(regval, gpiobase + LPC11_GPIO_DIR_OFFSET);

  /* Set up interrupt registers */

  intbase = g_intbase[port];
  if (intbase != 0)
    {
      /* Disable any rising edge interrupts */

      regval = getreg32(intbase + LPC11_GPIO_DIR_OFFSET);
      regval &= ~pinmask;
      putreg32(regval, intbase + LPC11_GPIO_DIR_OFFSET);

      /* Disable any falling edge interrupts */

      regval = getreg32(intbase + LPC11_GPIO_DIR_OFFSET);
      regval &= ~pinmask;
      putreg32(regval, intbase + LPC11_GPIO_DIR_OFFSET);

      /* Forget about any falling/rising edge interrupt enabled */

#ifdef CONFIG_LPC11_GPIOIRQ
      lpc11_setintedge(port, pin, 0);
#endif
    }

  /* Set up IOCON registers */
  /* Configure as GPIO */

  lpc11_pinfunc(port, pin, IOCON_FUNC_GPIO);

  /* Set pull-up mode */

  lpc11_pullup(cfgset, port, pin);

  /* Open drain only applies to outputs */

  lpc11_clropendrain(port, pin);

  return OK;
}
Beispiel #2
0
void lpc11_gpioirqdisable(int irq)
{
  /* Map the IRQ number to a port number */

  int port = lpc11_irq2port(irq);
  if (port >= 0)
    {
      /* The IRQ number does correspond to an interrupt port.  Now get the base
       * address of the GPIOINT registers for the port.
       */

      uint32_t intbase = g_intbase[port];
      if (intbase != 0)
        {
          /* And get the pin number associated with the port */

          unsigned int pin = lpc11_irq2pin(irq);
          lpc11_setintedge(intbase, pin, 0);
        }
    }
}