Esempio n. 1
0
uint8_t pic32mx_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
  uint8_t ret = 0;

  /* Card detect is pull up on-board.  If a low value is sensed then the
   * card must be present.
   */

#ifdef PIC32_HAVE_SD
  if (devid == SPIDEV_MMCSD)
    {
      if (!pic32mx_gpioread(GPIO_SD_CD))
        {
          ret = SPI_STATUS_PRESENT;

          /* It seems that a high value indicates the card is write
           * protected.
           */

          if (pic32mx_gpioread(GPIO_SD_WD))
            {
              ret |= SPI_STATUS_WRPROTECTED;
            }
        }
    }
#endif

#ifdef PIC32_HAVE_SOIC
  if (devid == SPIDEV_FLASH)
    {
      ret = SPI_STATUS_PRESENT;

      /* Write protect is indicated with a low value. */

      if (pic32mx_gpioread(GPIO_SOIC_WP))
        {
          ret |= SPI_STATUS_WRPROTECTED;
        }
    }
#endif

  spivdbg("Returning %d\n", ret);
  return ret;
}
Esempio n. 2
0
uint8_t pic32mx_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
  uint8_t ret = 0;

  /* Card detect active low. */

  if (devid == SPIDEV_MMCSD)
    {
      if (!pic32mx_gpioread(GPIO_SD_CD))
        {
          ret = SPI_STATUS_PRESENT;

          /* A high value indicates the the card is write protected. */

          if (pic32mx_gpioread(GPIO_SD_WP))
            {
              ret |= SPI_STATUS_WRPROTECTED;
            }
        }
    }

  spidbg("Returning %02x\n", ret);
  return ret;
}
Esempio n. 3
0
uint8_t board_buttons(void)
{
  uint8_t ret = 0;
  int id;

  /* Configure input pins */

  for (id = 0; id < NUM_BUTTONS; id++)
    {
      if (pic32mx_gpioread(g_buttonset[id]))
        {
          ret |= (1 << id);
        }
    }

  return ret;
}