Esempio n. 1
0
static int nsh_sdinitialize(void)
{
  int ret;

#ifdef NSH_HAVE_MMCSD_CD
  /* Configure the SD card detect GPIO */

  lpc17_configgpio(GPIO_SD_CD);

  /* Attach an interrupt handler to get notifications when a card is
   * inserted or deleted.
   */

#if NSH_HAVE_MMCSD_CDINT

   (void)irq_attach(LPC17_IRQ_P0p13, nsh_cdinterrupt);
   up_enable_irq(LPC17_IRQ_P0p13);

#endif
#endif

  /* First, get an instance of the SDIO interface */

  g_sdiodev = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO);
  if (!g_sdiodev)
    {
      message("nsh_archinitialize: Failed to initialize SDIO slot %d\n",
              CONFIG_NSH_MMCSDSLOTNO);
      return -ENODEV;
    }

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

  ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, g_sdiodev);
  if (ret != OK)
    {
      message("nsh_archinitialize: "
              "Failed to bind SDIO to the MMC/SD driver: %d\n",
              ret);

      return ret;
    }

  /* Check if there is a card in the slot and inform the SDCARD driver.  If
   * we do not support the card  detect, then let's assume that there is
   * one.
   */

#ifdef NSH_HAVE_MMCSD_CD
  sdio_mediachange(g_sdiodev, !lpc17_gpioread(GPIO_SD_CD));
#else
  sdio_mediachange(g_sdiodev, true);
#endif
  return OK;
}
Esempio n. 2
0
static int nsh_cdinterrupt(int irq, FAR void *context)
{
  static bool inserted = 0xff; /* Impossible value */
  bool present;

  present = !lpc17_gpioread(GPIO_SD_CD);
  if (present != inserted)
    {
      sdio_mediachange(g_sdiodev, present);
      inserted = present;
    }

  return OK;
}
Esempio n. 3
0
uint8_t lpc17_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
  if (devid == SPIDEV_MMCSD)
    {
      /* Read the state of the card-detect bit */

      if (lpc17_gpioread(ZKITARM_SD_CD) == 0)
        {
          spiinfo("Returning SPI_STATUS_PRESENT\n");
          return SPI_STATUS_PRESENT;
        }
    }

  spiinfo("Returning zero\n");
  return 0;
}
Esempio n. 4
0
uint8_t board_buttons(void)
{
  uint8_t ret = 0;
  bool released;
  int i;

  /* Check that state of each key */

  for (i = 0; i < BOARD_NUM_BUTTONS; i++)
    {
      released = lpc17_gpioread(g_buttons[i]);

       /* Accumulate set of depressed keys */

      if (!released)
        {
          ret |= (1 << i);
        }
    }

  return ret;
}
Esempio n. 5
0
uint8_t up_buttons(void)
{
  uint8_t ret = 0;
  int i;

  /* Check that state of each key */

  for (i = 0; i < BOARD_NUM_BUTTONS; i++)
    {
       /* A LOW value means that the key is pressed. */

       bool released = lpc17_gpioread(g_buttoncfg[i]);

       /* Accumulate the set of depressed (not released) keys */

       if (!released)
         {
            ret |= (1 << i);
         }
    }

  return ret;
}