Example #1
0
void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
  spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");

#if 0 /* Need to study this */
  if (devid == SPIDEV_LCD)
    {
      /* Set the GPIO low to select and high to de-select */

      stm32_gpiowrite(GPIO_LCD_CS, !selected);
    }
  else
#endif
#ifdef CONFIG_ENC28J60
  if (devid == SPIDEV_ETHERNET(0))
    {
      /* Set the GPIO low to select and high to de-select */

      stm32_gpiowrite(GPIO_ENC28J60_CS, !selected);
    }
#else
  if (devid == SPIDEV_FLASH(0))
    {
      /* Set the GPIO low to select and high to de-select */

      stm32_gpiowrite(GPIO_FLASH_CS, !selected);
    }
#endif
}
Example #2
0
void stm32_spi1select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
  spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");

  if (devid == SPIDEV_FLASH(0))
    {
      /* Set the GPIO low to select and high to de-select */

      stm32_gpiowrite(GPIO_FLASH_CS, !selected);
    }
}
Example #3
0
void  pic32mx_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
  spiinfo("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");

  if (devid == SPIDEV_FLASH(0))
    {
      pic32mx_gpiowrite(GPIO_SST25VF032B_CS, !selected);
    }
  else if (devid == SPIDEV_MUX(0))
    {
      pic32mx_gpiowrite(GPIO_PGA117_CS, !selected);
    }
}
Example #4
0
__EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, uint32_t devid, bool selected)
{
	/* SPI select is active low, so write !selected to select the device */

	switch (devid) {
	case SPIDEV_FLASH(0):
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI2_CS_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI2_CS_FRAM, !selected);
		break;

	case PX4_SPIDEV_BARO:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI2_CS_FRAM, 1);
		stm32_gpiowrite(GPIO_SPI2_CS_MS5611, !selected);
		break;

	default:
		break;
	}
}
Example #5
0
__EXPORT int board_app_initialize(uintptr_t arg)
{
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)

	/* run C++ ctors before we go any further */

	up_cxxinitialize();

#       if defined(CONFIG_EXAMPLES_NSH_CXXINITIALIZE)
#               error CONFIG_EXAMPLES_NSH_CXXINITIALIZE Must not be defined! Use CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE.
#       endif

#else
#  error platform is dependent on c++ both CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE must be defined.
#endif

	/* configure the high-resolution time/callout interface */
	hrt_init();

	param_init();

	/* configure the DMA allocator */

	if (board_dma_alloc_init() < 0) {
		message("DMA alloc FAILED");
	}

	/* configure CPU load estimation */
#ifdef CONFIG_SCHED_INSTRUMENTATION
	cpuload_initialize_once();
#endif

	/* set up the serial DMA polling */
	static struct hrt_call serial_dma_call;
	struct timespec ts;

	/*
	 * Poll at 1ms intervals for received bytes that have not triggered
	 * a DMA event.
	 */
	ts.tv_sec = 0;
	ts.tv_nsec = 1000000;

	hrt_call_every(&serial_dma_call,
		       ts_to_abstime(&ts),
		       ts_to_abstime(&ts),
		       (hrt_callout)stm32_serial_dma_poll,
		       NULL);

	/* initial LED state */
	drv_led_start();
	led_off(LED_AMBER);

	/* Configure SPI-based devices */

	spi3 = px4_spibus_initialize(3);

	if (!spi3) {
		message("[boot] FAILED to initialize SPI port 3\n");
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI3 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi3, 10000000);
	SPI_SETBITS(spi3, 8);
	SPI_SETMODE(spi3, SPIDEV_MODE3);
	SPI_SELECT(spi3, PX4_SPIDEV_GYRO, false);
	SPI_SELECT(spi3, PX4_SPIDEV_ACCEL_MAG, false);
	SPI_SELECT(spi3, PX4_SPIDEV_BARO, false);
	up_udelay(20);

	/* Get the SPI port for the FRAM */

	spi4 = px4_spibus_initialize(4);

	if (!spi4) {
		message("[boot] FAILED to initialize SPI port 4\n");
		board_autoled_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI4 to 37.5 MHz (40 MHz rounded to nearest valid divider, F4 max)
	 * and de-assert the known chip selects. */

	// XXX start with 10.4 MHz in FRAM usage and go up to 37.5 once validated
	SPI_SETFREQUENCY(spi4, 12 * 1000 * 1000);
	SPI_SETBITS(spi4, 8);
	SPI_SETMODE(spi4, SPIDEV_MODE3);
	SPI_SELECT(spi4, SPIDEV_FLASH(0), false);

	return OK;
}