示例#1
0
文件: max6675.c 项目: dagar/NuttX
static void max6675_lock(FAR struct spi_dev_s *spi)
{
  (void)SPI_LOCK(spi, true);
  SPI_SETMODE(spi, SPIDEV_MODE0);
  SPI_SETBITS(spi, 8);
  (void)SPI_HWFEATURES(spi, 0);
  SPI_SETFREQUENCY(spi, 4000000);
}
示例#2
0
static inline void nrf24l01_configspi(FAR struct spi_dev_s *spi)
{
  /* Configure SPI for the NRF24L01 module. */

  SPI_SELECT(spi, SPIDEV_WIRELESS, true);  /* Useful ? */
  SPI_SETMODE(spi, SPIDEV_MODE0);
  SPI_SETBITS(spi, 8);
  (void)SPI_HWFEATURES(spi, 0);
  (void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ);
  SPI_SELECT(spi, SPIDEV_WIRELESS, false);
}
示例#3
0
static void pga11x_configure(FAR struct spi_dev_s *spi)
{
  spivdbg("MODE: %d BITS: 8 Frequency: %d\n",
          CONFIG_PGA11X_SPIMODE, CONFIG_PGA11X_SPIFREQUENCY);

  /* Call the setfrequency, setbits, and setmode methods to make sure that
   * the SPI is properly configured for the device.
   */

  SPI_SETMODE(spi, CONFIG_PGA11X_SPIMODE);
  SPI_SETBITS(spi, 8);
  (void)SPI_HWFEATURES(spi, 0);
  (void)SPI_SETFREQUENCY(spi, CONFIG_PGA11X_SPIFREQUENCY);
}
示例#4
0
int board_power_off(int status)
{
  struct spi_dev_s *spi = calypso_spibus_initialize(0);
  uint16_t tx;

  SPI_SETBITS(spi, 16);
  (void)SPI_HWFEATURES(spi, 0);

  tx = (1 << 6) | (1 << 1);
  SPI_SNDBLOCK(spi, &tx, 1);

  tx = (1 << 6) | (30 << 1);
  SPI_SNDBLOCK(spi, &tx, 1);

  return 0;
}
示例#5
0
static inline void pn532_configspi(FAR struct spi_dev_s *spi)
{
  int ret;

  /* Configure SPI for the PN532 module. */

  SPI_SETMODE(spi, SPIDEV_MODE0);
  SPI_SETBITS(spi, 8);

  ret = SPI_HWFEATURES(spi, HWFEAT_LSBFIRST);
  if (ret < 0)
    {
      pn532err("ERROR: SPI_HWFEATURES failed to set bit order: %d\n", ret);
    }

  (void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ);
}
示例#6
0
static void pn532_lock(FAR struct spi_dev_s *spi)
{
  int ret;

  (void)SPI_LOCK(spi, true);

  SPI_SETMODE(spi, SPIDEV_MODE0);
  SPI_SETBITS(spi, 8);

  ret = SPI_HWFEATURES(spi, HWFEAT_LSBFIRST);
  if (ret < 0)
    {
      pn532err("ERROR: SPI_HWFEATURES failed to set bit order: %d\n", ret);
    }

  (void)SPI_SETFREQUENCY(spi, CONFIG_PN532_SPI_FREQ);
}
示例#7
0
文件: max11802.c 项目: a1ien/nuttx
static void max11802_lock(FAR struct spi_dev_s *spi)
{
  /* Lock the SPI bus because there are multiple devices competing for the
   * SPI bus
   */

  (void)SPI_LOCK(spi, true);

  /* We have the lock.  Now make sure that the SPI bus is configured for the
   * MAX11802 (it might have gotten configured for a different device while
   * unlocked)
   */

  SPI_SETMODE(spi, CONFIG_MAX11802_SPIMODE);
  SPI_SETBITS(spi, 8);
  (void)SPI_HWFEATURES(spi, 0);
  (void)SPI_SETFREQUENCY(spi, CONFIG_MAX11802_FREQUENCY);
}
示例#8
0
文件: ads7843e.c 项目: dagar/NuttX
static void ads7843e_lock(FAR struct spi_dev_s *spi)
{
  /* Lock the SPI bus because there are multiple devices competing for the
   * SPI bus
   */

  (void)SPI_LOCK(spi, true);

  /* We have the lock.  Now make sure that the SPI bus is configured for the
   * ADS7843 (it might have gotten configured for a different device while
   * unlocked)
   */

  SPI_SELECT(spi, SPIDEV_TOUCHSCREEN(0), true);
  SPI_SETMODE(spi, CONFIG_ADS7843E_SPIMODE);
  SPI_SETBITS(spi, 8);
  (void)SPI_HWFEATURES(spi, 0);
  (void)SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY);
  SPI_SELECT(spi, SPIDEV_TOUCHSCREEN(0), false);
}
示例#9
0
static void nrf24l01_lock(FAR struct spi_dev_s *spi)
{
  /* Lock the SPI bus because there are multiple devices competing for the
   * SPI bus
   */

  (void)SPI_LOCK(spi, true);

  /* We have the lock.  Now make sure that the SPI bus is configured for the
   * NRF24L01 (it might have gotten configured for a different device while
   * unlocked)
   */

  SPI_SELECT(spi, SPIDEV_WIRELESS, true);
  SPI_SETMODE(spi, SPIDEV_MODE0);
  SPI_SETBITS(spi, 8);
  (void)SPI_HWFEATURES(spi, 0);
  (void)SPI_SETFREQUENCY(spi, NRF24L01_SPIFREQ);
  SPI_SELECT(spi, SPIDEV_WIRELESS, false);
}
示例#10
0
static void ssd1351_select(FAR struct ssd1351_dev_s *priv)
{
  FAR struct spi_dev_s *spi = priv->spi;

  /* Select the chip, locking the SPI bus in case there are multiple devices
   * competing for the SPI bus
   */

  gdbg("SELECTED\n");
  SPI_LOCK(spi, true);
  SPI_SELECT(spi, SPIDEV_DISPLAY, true);

  /* Now make sure that the SPI bus is configured for this device (it might
   * have gotten configured for a different device while unlocked)
   */

  SPI_SETMODE(spi, CONFIG_SSD1351_SPIMODE);
  SPI_SETBITS(spi, SSD1351_SPIBITS);
  (void)SPI_HWFEATURES(spi, 0);
  (void)SPI_SETFREQUENCY(spi, CONFIG_SSD1351_SPIFREQ);
}
示例#11
0
static void ee25xx_lock(FAR struct spi_dev_s *dev)
{
  /* On SPI buses where there are multiple devices, it will be necessary to
   * lock SPI to have exclusive access to the buses for a sequence of
   * transfers.  The bus should be locked before the chip is selected.
   *
   * This is a blocking call and will not return until we have exclusive
   * access to the SPI bus.  We will retain that exclusive access until the
   * bus is unlocked.
   */

  (void)SPI_LOCK(dev, true);

  /* After locking the SPI bus, the we also need call the setfrequency,
   * setbits, and setmode methods to make sure that the SPI is properly
   * configured for the device.  If the SPI bus is being shared, then it may
   * have been left in an incompatible state.
   */

  SPI_SETMODE(dev, CONFIG_EE25XX_SPIMODE);
  SPI_SETBITS(dev, 8);
  (void)SPI_HWFEATURES(dev, 0);
  (void)SPI_SETFREQUENCY(dev, 10000000); /* This is the default speed */
}