Пример #1
0
void
PX4FMU::gpio_reset(void)
{
	/*
	 * Setup default GPIO config - all pins as GPIOs, input if
	 * possible otherwise output if possible.
	 */
	for (unsigned i = 0; i < _ngpio; i++) {
		if (_gpio_tab[i].input != 0) {
			stm32_configgpio(_gpio_tab[i].input);

		} else if (_gpio_tab[i].output != 0) {
			stm32_configgpio(_gpio_tab[i].output);
		}
	}

#if defined(CONFIG_ARCH_BOARD_PX4FMU_V1)
	/* if we have a GPIO direction control, set it to zero (input) */
	stm32_gpiowrite(GPIO_GPIO_DIR, 0);
	stm32_configgpio(GPIO_GPIO_DIR);
#endif
}
Пример #2
0
__EXPORT void weak_function stm32_spiinitialize(void)
{
	stm32_configgpio(GPIO_SPI_CS_DATAFLASH);
	stm32_configgpio(GPIO_SPI_CS_BMP280);
	stm32_configgpio(GPIO_SPI_CS_MPU6000);
	stm32_configgpio(GPIO_SPI_CS_SDCARD);
	stm32_configgpio(GPIO_SPI_CS_EXP_MPU6000);
	stm32_configgpio(GPIO_SPI_CS_EXP_FREE);
	stm32_configgpio(GPIO_SPI_CS_EXP_HMC5983);

	/* De-activate all peripherals,
	 * required for some peripheral
	 * state machines
	 */
	stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
	stm32_gpiowrite(GPIO_SPI_CS_BMP280, 1);
	stm32_gpiowrite(GPIO_SPI_CS_MPU6000, 1);
	stm32_gpiowrite(GPIO_SPI_CS_SDCARD, 1);
	stm32_gpiowrite(GPIO_SPI_CS_EXP_MPU6000, 1);
	stm32_gpiowrite(GPIO_SPI_CS_EXP_FREE, 1);
	stm32_gpiowrite(GPIO_SPI_CS_EXP_HMC5983, 1);
}
Пример #3
0
__EXPORT void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
	/* SPI select is active low, so write !selected to select the device */

	switch (devid) {
	case SPIDEV_MMCSD:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_SDCARD, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
		break;

	case SPIDEV_FLASH:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
		stm32_gpiowrite(GPIO_SPI_CS_SDCARD, 1);
		break;

	default:
		break;

	}
}
Пример #4
0
void arch_sporadic_lowpriority(FAR struct tcb_s *tcb)
{
  stm32_gpiowrite(GPIO_SCHED_HIGHPRI, false);
}
Пример #5
0
void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
    spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");

    stm32_gpiowrite(GPIO_MEMS_CS, !selected);
}
Пример #6
0
__EXPORT void board_spi_reset(int ms)
{
	// TODO: DRDY
	///* disable SPI bus 1  DRDY */
	//stm32_configgpio(GPIO_DRDY_OFF_PORTD_PIN15);
	//stm32_configgpio(GPIO_DRDY_OFF_PORTC_PIN14);
	//stm32_configgpio(GPIO_DRDY_OFF_PORTE_PIN12);

	//stm32_gpiowrite(GPIO_DRDY_OFF_PORTD_PIN15, 0);
	//stm32_gpiowrite(GPIO_DRDY_OFF_PORTC_PIN14, 0);
	//stm32_gpiowrite(GPIO_DRDY_OFF_PORTE_PIN12, 0);

	/* disable SPI bus 1  CS */
	stm32_configgpio(GPIO_SPI1_CS_MEMS_OFF);
	stm32_gpiowrite(GPIO_SPI1_CS_MEMS_OFF, 0);

	/* disable SPI bus 2  CS */
	stm32_configgpio(GPIO_SPI2_CS_SDCARD_OFF);
	stm32_gpiowrite(GPIO_SPI2_CS_SDCARD_OFF, 0);

	/* disable SPI bus 3  CS */
	stm32_configgpio(GPIO_SPI3_CS_BARO_OFF);
	stm32_gpiowrite(GPIO_SPI3_CS_BARO_OFF, 0);
	stm32_configgpio(GPIO_SPI3_CS_OSD_OFF);
	stm32_gpiowrite(GPIO_SPI3_CS_OSD_OFF, 0);

	/* disable SPI bus 1*/
	stm32_configgpio(GPIO_SPI1_SCK_OFF);
	stm32_configgpio(GPIO_SPI1_MISO_OFF);
	stm32_configgpio(GPIO_SPI1_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI1_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MOSI_OFF, 0);

	/* disable SPI bus 2*/
	stm32_configgpio(GPIO_SPI2_SCK_OFF);
	stm32_configgpio(GPIO_SPI2_MISO_OFF);
	stm32_configgpio(GPIO_SPI2_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI2_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI2_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI2_MOSI_OFF, 0);

	/* disable SPI bus 3*/
	stm32_configgpio(GPIO_SPI3_SCK_OFF);
	stm32_configgpio(GPIO_SPI3_MISO_OFF);
	stm32_configgpio(GPIO_SPI3_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI3_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI3_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI3_MOSI_OFF, 0);

	/* wait a bit before starting SPI, different times didn't influence results */
	usleep(100);

	stm32_spiinitialize();

	stm32_configgpio(GPIO_SPI1_SCK);
	stm32_configgpio(GPIO_SPI1_MISO);
	stm32_configgpio(GPIO_SPI1_MOSI);

	// TODO: why do we not enable SPI2 here?

	stm32_configgpio(GPIO_SPI3_SCK);
	stm32_configgpio(GPIO_SPI3_MISO);
	stm32_configgpio(GPIO_SPI3_MOSI);
}
Пример #7
0
__EXPORT int nsh_archinitialize(void)
{
	int result;

	message("\n");

	/* configure always-on ADC pins */
	stm32_configgpio(GPIO_ADC1_IN0);
	stm32_configgpio(GPIO_ADC1_IN10);
	stm32_configgpio(GPIO_ADC1_IN11);

	stm32_configgpio(GPIO_UART_SBUS_INVERTER);
#ifdef CONFIG_RC_INPUTS_TYPE(RC_INPUT_SBUS)
	stm32_gpiowrite(GPIO_UART_SBUS_INVERTER, 1);
#else
	stm32_gpiowrite(GPIO_UART_SBUS_INVERTER, 0);
#endif

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

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


















	/* initial BUZZER state */
	drv_buzzer_start();
	buzzer_off(BUZZER_EXT);

	/* initial LED state */
	drv_led_start();
	led_off(LED_AMBER);
	led_off(LED_BLUE);
	led_off(LED_GREEN);
	led_off(LED_EXT1);
	led_off(LED_EXT2);



	/* Configure SPI-based devices */

	message("[boot] Initializing SPI port 1\n");
	spi1 = up_spiinitialize(1);

	if (!spi1) {
		message("[boot] FAILED to initialize SPI port 1\r\n");
		led_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI1 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi1, 10000000);
	SPI_SETBITS(spi1, 8);
	SPI_SETMODE(spi1, SPIDEV_MODE3);
	SPI_SELECT(spi1, GPIO_SPI_CS_MS5611, false);
	SPI_SELECT(spi1, GPIO_SPI_CS_EXP_MS5611, false);
	SPI_SELECT(spi1, GPIO_SPI_CS_EXP_MPU6000, false);
	SPI_SELECT(spi1, GPIO_SPI_CS_EXP_HMC5983, false);
	SPI_SELECT(spi1, GPIO_SPI_CS_EXP_WIFI_EEPROM, false);
	up_udelay(20);

	message("[boot] Successfully initialized SPI port 1\r\n");

//	message("[boot] Initializing Wireless Module\n");
//	wireless_archinitialize();

	message("[boot] Initializing SPI port 2\n");
	spi2 = up_spiinitialize(2);

	if (!spi2) {
		message("[boot] FAILED to initialize SPI port 2\r\n");
		led_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI2 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi2, 10000000);
	SPI_SETBITS(spi2, 8);
	SPI_SETMODE(spi2, SPIDEV_MODE3);
	SPI_SELECT(spi2, GPIO_SPI_CS_MPU6000, false);
	SPI_SELECT(spi2, GPIO_SPI_CS_IMU_MS5611, false);
	SPI_SELECT(spi2, GPIO_SPI_CS_IMU_MPU6000, false);
	SPI_SELECT(spi2, GPIO_SPI_CS_IMU_HMC5983, false);
	SPI_SELECT(spi2, GPIO_SPI_CS_IMU_EEPROM, false);

	message("[boot] Successfully initialized SPI port 2\n");

	/* Get the SPI port for the microSD slot */

	message("[boot] Initializing SPI port 3\n");
	spi3 = up_spiinitialize(3);

	if (!spi3) {
		message("[boot] FAILED to initialize SPI port 3\n");
		led_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, GPIO_SPI_CS_DATAFLASH, false);
	SPI_SELECT(spi3, GPIO_SPI_CS_EEPROM, false);
	SPI_SELECT(spi3, GPIO_SPI_CS_SDCARD, false);

	message("[boot] Successfully initialized SPI port 3\n");

	/* Now bind the SPI interface to the MMCSD driver */
	result = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, spi3);

	if (result != OK) {
		message("[boot] FAILED to bind SPI port 3 to the MMCSD driver\n");
		led_on(LED_AMBER);
		return -ENODEV;
	}

	message("[boot] Successfully bound SPI port 3 to the MMCSD driver\n");

	return OK;
}
Пример #8
0
__EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
	/* SPI select is active low, so write !selected to select the device */

	switch (devid) {
	case PX4_SPIDEV_ICM:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
		stm32_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
		stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, !selected);
		break;

	case PX4_SPIDEV_ACCEL_MAG:
		/* Making sure the other peripherals are not selected */
		break;

	case PX4_SPIDEV_BARO:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
		stm32_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
		stm32_gpiowrite(GPIO_SPI_CS_MS5611, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
		break;

	case PX4_SPIDEV_HMC:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU9250, 1);
		stm32_gpiowrite(GPIO_SPI_CS_HMC5983, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
		break;

	case PX4_SPIDEV_MPU:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU9250, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_HMC5983, 1);
		stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI_CS_ICM_20608_G, 1);
		break;

	default:
		break;
	}
}
Пример #9
0
__EXPORT void stm32_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
	/* SPI select is active low, so write !selected to select the device */

	switch (devid) {
	case SPIDEV_FLASH:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, 1);
		break;

	case SPIDEV_EEPROM:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EEPROM, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, 1);
		stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
		break;
	case SPIDEV_DF_EXT1:
			/* Making sure the other peripherals are not selected */
			stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
			stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
			stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, !selected);
			stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, 1);
			stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, 1);
			stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, 1);
			stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, 1);
			stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
			break;
	case SPIDEV_DF_EXT2:
				/* Making sure the other peripherals are not selected */
				stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
				stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, !selected);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, 1);
				stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
				break;
	case SPIDEV_DF_EXT3:
				/* Making sure the other peripherals are not selected */
				stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
				stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, !selected);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, 1);
				stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
				break;
	case SPIDEV_DF_EXT4:
				/* Making sure the other peripherals are not selected */
				stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
				stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, !selected);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, 1);
				stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
				break;
	case SPIDEV_DF_EXT5:
				/* Making sure the other peripherals are not selected */
				stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
				stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, 1);
				stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, !selected);
				stm32_gpiowrite(GPIO_SPI_CS_MS5611, 1);
				break;

	case SPIDEV_MS5611:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MS5611, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_DATAFLASH, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EEPROM, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT1, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT2, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT3, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT4, 1);
		stm32_gpiowrite(GPIO_SPI_CS_DF_EXT5, 1);
		break;

	default:
		break;

	}
}
Пример #10
0
__EXPORT int nsh_archinitialize(void)
{
	int result;

	message("\n");

	/* configure always-on ADC pins */
	stm32_configgpio(GPIO_ADC1_IN10);
	stm32_configgpio(GPIO_ADC1_IN11);
#if APM_BUILD_TYPE(APM_BUILD_ArduPlane)
	stm32_configgpio(GPIO_GPIO0_INPUT);
	stm32_configgpio(GPIO_ADC1_IN14);
#endif

	stm32_configgpio(GPIO_UART_SBUS_INVERTER);
#if CONFIG_RC_INPUTS_TYPE(RC_INPUT_SBUS)
	stm32_gpiowrite(GPIO_UART_SBUS_INVERTER, 1);
#else
	stm32_gpiowrite(GPIO_UART_SBUS_INVERTER, 0);
#endif

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

	/* configure the DMA allocator */
	dma_alloc_init();

	/* 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 BUZZER state */
	drv_buzzer_start();
	buzzer_off(BUZZER_EXT);

	/* initial LED state */
	drv_led_start();
	led_off(LED_AMBER);
	led_off(LED_BLUE);
	led_off(LED_GREEN);
	led_off(LED_EXT1);
	led_off(LED_EXT2);



	/* Configure SPI-based devices */

	message("[boot] Initializing SPI port 1\n");
	spi1 = up_spiinitialize(1);

	if (!spi1) {
		message("[boot] FAILED to initialize SPI port 1\r\n");
		led_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI1 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi1, 10000000);
	SPI_SETBITS(spi1, 8);
	SPI_SETMODE(spi1, SPIDEV_MODE3);
	SPI_SELECT(spi1, SPIDEV_WIRELESS, false);
	SPI_SELECT(spi1, SPIDEV_FLASH, false);
	SPI_SELECT(spi1, SPIDEV_MS5611, false);
	SPI_SELECT(spi1, SPIDEV_EXP_MS5611, false);
	SPI_SELECT(spi1, SPIDEV_EXP_MPU6000, false);
	SPI_SELECT(spi1, SPIDEV_EXP_HMC5983, false);
	up_udelay(20);

	message("[boot] Successfully initialized SPI port 1\r\n");

	message("[boot] Initializing SPI port 2\n");
	spi2 = up_spiinitialize(2);

	if (!spi2) {
		message("[boot] FAILED to initialize SPI port 2\r\n");
		led_on(LED_AMBER);
		return -ENODEV;
	}

	/* Default SPI2 to 1MHz and de-assert the known chip selects. */
	SPI_SETFREQUENCY(spi2, 10000000);
	SPI_SETBITS(spi2, 8);
	SPI_SETMODE(spi2, SPIDEV_MODE3);
	SPI_SELECT(spi2, SPIDEV_MPU6000, false);
	SPI_SELECT(spi2, SPIDEV_IMU_MS5611, false);
	SPI_SELECT(spi2, SPIDEV_IMU_MPU6000, false);
	SPI_SELECT(spi2, SPIDEV_IMU_HMC5983, false);
	SPI_SELECT(spi2, SPIDEV_FLASH, false);

	message("[boot] Successfully initialized SPI port 2\n");

	/* Get the SPI port for the microSD slot */

	message("[boot] Initializing SPI port 3\n");
	spi3 = up_spiinitialize(3);

	if (!spi3) {
		message("[boot] FAILED to initialize SPI port 3\n");
		led_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, SPIDEV_MMCSD, false);
	SPI_SELECT(spi3, SPIDEV_FLASH, false);

	message("[boot] Successfully initialized SPI port 3\n");

	/* Now bind the SPI interface to the MMCSD driver */
	result = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, spi3);

	if (result != OK) {
		message("[boot] FAILED to bind SPI port 3 to the MMCSD driver\n");
		led_on(LED_AMBER);
		return -ENODEV;
	}

	message("[boot] Successfully bound SPI port 3 to the MMCSD driver\n");

	return OK;
}
Пример #11
0
int stm32_usbpullup(FAR struct usbdev_s *dev, bool enable)
{
  usbtrace(TRACE_DEVPULLUP, (uint16_t)enable);
  stm32_gpiowrite(GPIO_USB_PULLUP, !enable);
  return OK;
}
Пример #12
0
static void phy_set_led(int led, bool state)
{
  /* Active High */

  stm32_gpiowrite(g_ledmap[led], state);
}
Пример #13
0
void arch_sporadic_start(FAR struct tcb_s *tcb)
{
  stm32_gpiowrite(GPIO_SCHED_HIGHPRI, true);
}
Пример #14
0
static inline void set_led(bool v)
{
  ledvdbg("Turn LED %s\n", v? "on":"off");
  stm32_gpiowrite(GPIO_LED, v);
}
Пример #15
0
void
PWMIN::_turn_off()
{
	stm32_gpiowrite(GPIO_VDD_RANGEFINDER_EN, 0);
}
Пример #16
0
__EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
	/* SPI select is active low, so write !selected to select the device */

	switch (devid) {
	case SPIDEV_MPU6000:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU6000, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MPU6000, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_HMC5983, 1);
		break;

	case SPIDEV_IMU_MS5611:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU6000, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MS5611, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MPU6000, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_HMC5983, 1);
		break;

	case SPIDEV_IMU_MPU6000:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU6000, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MPU6000, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_HMC5983, 1);
		break;

	case SPIDEV_IMU_HMC5983:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_MPU6000, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MS5611, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_MPU6000, 1);
		stm32_gpiowrite(GPIO_SPI_CS_IMU_HMC5983, !selected);
		break;

	default:
		break;

	}
}
Пример #17
0
__EXPORT int nsh_archinitialize(void)
{
    int result;

    stm32_configgpio(GPIO_SENSOR_PWR_EN);
    stm32_gpiowrite(GPIO_SENSOR_PWR_EN, true);

    stm32_configgpio(GPIO_GPS_PWR_EN);
    stm32_gpiowrite(GPIO_GPS_PWR_EN, true);

    stm32_configgpio(GPIO_TELE_PWR_EN);
    stm32_gpiowrite(GPIO_TELE_PWR_EN, true);

    /* configure always-on ADC pins */
    stm32_configgpio(GPIO_ADC1_IN1);
    stm32_configgpio(GPIO_ADC1_IN11);
    /* IN12 and IN13 further below */

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

    /* 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);
    led_off(LED_BLUE);


    /* Configure SPI-based devices */

    //spi1 = up_spiinitialize(1);

    //if (!spi1) {
    //	message("[boot] FAILED to initialize SPI port 1\r\n");
    //	up_ledon(LED_AMBER);
    //	return -ENODEV;
    //}

    /* Default SPI1 to 1MHz and de-assert the known chip selects. */
    //SPI_SETFREQUENCY(spi1, 10000000);
    //SPI_SETBITS(spi1, 8);
    //SPI_SETMODE(spi1, SPIDEV_MODE3);
    //SPI_SELECT(spi1, PX4_SPIDEV_GYRO, false);
    //SPI_SELECT(spi1, PX4_SPIDEV_ACCEL, false);
    //SPI_SELECT(spi1, PX4_SPIDEV_MPU, false);
    //up_udelay(20);

    //message("[boot] Successfully initialized SPI port 1\r\n");

    /*
     * If SPI2 is enabled in the defconfig, we loose some ADC pins as chip selects.
     * Keep the SPI2 init optional and conditionally initialize the ADC pins
     */

    //#ifdef CONFIG_STM32_SPI2
    //	spi2 = up_spiinitialize(2);
    /* Default SPI2 to 1MHz and de-assert the known chip selects. */
    //	SPI_SETFREQUENCY(spi2, 10000000);
    //	SPI_SETBITS(spi2, 8);
    //	SPI_SETMODE(spi2, SPIDEV_MODE3);
    //	SPI_SELECT(spi2, PX4_SPIDEV_GYRO, false);
    //	SPI_SELECT(spi2, PX4_SPIDEV_ACCEL_MAG, false);

    //	message("[boot] Initialized SPI port2 (ADC IN12/13 blocked)\n");
    //#else
    //	spi2 = NULL;
    //	message("[boot] Enabling IN12/13 instead of SPI2\n");
    //	/* no SPI2, use pins for ADC */
    //	stm32_configgpio(GPIO_ADC1_IN12);
    //	stm32_configgpio(GPIO_ADC1_IN13);	// jumperable to MPU6000 DRDY on some boards
    //#endif

    /* Get the SPI port for the microSD slot */

    message("[boot] Initializing SPI port 2\n");
    spi2 = up_spiinitialize(2);

    if (!spi2) {
        message("[boot] FAILED to initialize SPI port 2\n");
        up_ledon(LED_AMBER);
        return -ENODEV;
    }

    SPI_SELECT(spi2, NAVSTIK_SPIDEV_FLASH, false);
    message("[boot] Successfully initialized SPI port 2\n");

    /* Now bind the SPI interface to the MMCSD driver */
    result = mmcsd_spislotinitialize(CONFIG_NSH_MMCSDMINOR, CONFIG_NSH_MMCSDSLOTNO, spi2);

    if (result != OK) {
        message("[boot] FAILED to bind SPI port 2 to the MMCSD driver\n");
        up_ledon(LED_AMBER);
        return -ENODEV;
    }

    message("[boot] Successfully bound SPI port 2 to the MMCSD driver\n");

    return OK;
}
Пример #18
0
struct ara_board_info *ara_board_init(void) {
    int i;
    enum hwid hwid = board_get_hwid();
    board_info = NULL;

    /* Check HWID, assign board_info struct and the Switch ES revision */
    switch (hwid) {
    case HWID_DB3_0_1:
        board_info = &db3_board_info;
        dbg_info("HWID found as DB3.0/3.1\n");
        break;
    case HWID_DB3_2:
        /* DB3.0/1 with ES3 Switch */
        board_info = &db3_board_info;
        board_info->sw_data.rev = SWITCH_REV_ES3;
        dbg_info("HWID found as DB3.2\n");
        break;
    case HWID_DB3_5:
        /* EVT1.5 + DB3.5 pwrmon + specific mapping of physical interfaces */
        board_info = &evt1_5_board_info;
        board_info->pwrmon = &db3_5_pwrmon;
        board_info->interfaces = db3_5_interfaces;
        board_info->nr_interfaces = db3_5_nr_interfaces;
        dbg_info("HWID found as DB3.5\n");
        break;
    case HWID_EVT1:
        board_info = &evt1_board_info;
        dbg_info("HWID found as EVT1\n");
        break;
    case HWID_EVT1_5:
        board_info = &evt1_5_board_info;
        dbg_info("HWID found as EVT1.5\n");
        break;
    case HWID_EVT1_6:
        board_info = &evt1_5_board_info;
        board_info->sw_data.rev = SWITCH_REV_ES2;
        dbg_info("HWID found as EVT1.6\n");
        break;
    default:
        return NULL;
    }

    /* Disable the I/O Expanders for now */
    for (i = 0; i < board_info->nr_io_expanders; i++) {
        struct io_expander_info *io_exp = &board_info->io_expanders[i];
        stm32_configgpio(io_exp->reset);
        stm32_gpiowrite(io_exp->reset, false);
    }

    /*
     * Register the STM32 GPIOs to Gpio Chip
     *
     * This needs to happen before the I/O Expanders registration, which
     * uses some STM32 pins
     */
    stm32_gpio_init();

    /* Register the TCA64xx I/O Expanders GPIOs to Gpio Chip */
    for (i = 0; i < board_info->nr_io_expanders; i++) {
        struct io_expander_info *io_exp = &board_info->io_expanders[i];

        io_exp->i2c_dev = up_i2cinitialize(io_exp->i2c_bus);
        if (!io_exp->i2c_dev) {
            dbg_error("%s(): Failed to get I/O Expander I2C bus %u\n",
                      __func__, io_exp->i2c_bus);
            goto err_deinit_gpio;
        } else {
            if (tca64xx_init(&io_exp->io_exp_driver_data,
                             io_exp->part,
                             io_exp->i2c_dev,
                             io_exp->i2c_addr,
                             io_exp->reset,
                             io_exp->irq,
                             io_exp->gpio_base) < 0) {
                dbg_error("%s(): Failed to register I/O Expander(0x%02x)\n",
                          __func__, io_exp->i2c_addr);
                goto err_uninit_i2c;
            }
        }
    }

    /* Run the board specific code */
    if (board_info->board_init) {
        if (board_info->board_init(board_info)) {
            dbg_error("%s(): Failed to initalize board\n", __func__);
            goto err_uninit_i2c;
        }
    }

    /* Return the board specific info */
    return board_info;

 err_uninit_i2c:
    /* Done in reverse order to account for possible IRQ chaining. */
    for (i = board_info->nr_io_expanders - 1; i >= 0; i--) {
        struct io_expander_info *io_exp = &board_info->io_expanders[i];
        if (io_exp->i2c_dev) {
            up_i2cuninitialize(io_exp->i2c_dev);
        }
    }
 err_deinit_gpio:
    stm32_gpio_deinit();
    /* Leave the I/O expanders in reset here. */

    return NULL;
}
Пример #19
0
void
PX4FMU::sensor_reset(int ms)
{
#if defined(CONFIG_ARCH_BOARD_PX4FMU_V2)

	if (ms < 1) {
		ms = 1;
	}

	/* disable SPI bus */
	stm32_configgpio(GPIO_SPI_CS_GYRO_OFF);
	stm32_configgpio(GPIO_SPI_CS_ACCEL_MAG_OFF);
	stm32_configgpio(GPIO_SPI_CS_BARO_OFF);
	stm32_configgpio(GPIO_SPI_CS_MPU_OFF);

	stm32_gpiowrite(GPIO_SPI_CS_GYRO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG_OFF, 0);
	stm32_gpiowrite(GPIO_SPI_CS_BARO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI_CS_MPU_OFF, 0);

	stm32_configgpio(GPIO_SPI1_SCK_OFF);
	stm32_configgpio(GPIO_SPI1_MISO_OFF);
	stm32_configgpio(GPIO_SPI1_MOSI_OFF);

	stm32_gpiowrite(GPIO_SPI1_SCK_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MISO_OFF, 0);
	stm32_gpiowrite(GPIO_SPI1_MOSI_OFF, 0);

	stm32_configgpio(GPIO_GYRO_DRDY_OFF);
	stm32_configgpio(GPIO_MAG_DRDY_OFF);
	stm32_configgpio(GPIO_ACCEL_DRDY_OFF);
	stm32_configgpio(GPIO_EXTI_MPU_DRDY_OFF);

	stm32_gpiowrite(GPIO_GYRO_DRDY_OFF, 0);
	stm32_gpiowrite(GPIO_MAG_DRDY_OFF, 0);
	stm32_gpiowrite(GPIO_ACCEL_DRDY_OFF, 0);
	stm32_gpiowrite(GPIO_EXTI_MPU_DRDY_OFF, 0);

	/* set the sensor rail off */
	stm32_configgpio(GPIO_VDD_3V3_SENSORS_EN);
	stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 0);

	/* wait for the sensor rail to reach GND */
	usleep(ms * 1000);
	warnx("reset done, %d ms", ms);

	/* re-enable power */

	/* switch the sensor rail back on */
	stm32_gpiowrite(GPIO_VDD_3V3_SENSORS_EN, 1);

	/* wait a bit before starting SPI, different times didn't influence results */
	usleep(100);

	/* reconfigure the SPI pins */
#ifdef CONFIG_STM32_SPI1
	stm32_configgpio(GPIO_SPI_CS_GYRO);
	stm32_configgpio(GPIO_SPI_CS_ACCEL_MAG);
	stm32_configgpio(GPIO_SPI_CS_BARO);
	stm32_configgpio(GPIO_SPI_CS_MPU);

	/* De-activate all peripherals,
	 * required for some peripheral
	 * state machines
	 */
	stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
	stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1);
	stm32_gpiowrite(GPIO_SPI_CS_BARO, 1);
	stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);

	// // XXX bring up the EXTI pins again
	// stm32_configgpio(GPIO_GYRO_DRDY);
	// stm32_configgpio(GPIO_MAG_DRDY);
	// stm32_configgpio(GPIO_ACCEL_DRDY);
	// stm32_configgpio(GPIO_EXTI_MPU_DRDY);

#endif
#endif
}
Пример #20
0
void arch_sporadic_suspend(FAR struct tcb_s *tcb)
{
  stm32_gpiowrite(GPIO_SCHED_RUNNING, false);
}
Пример #21
0
void stm32_setleds(uint8_t ledset)
{
  stm32_gpiowrite(GPIO_LED_STATUS, (ledset & BOARD_LED1_BIT) != 0);
}
Пример #22
0
void arch_sporadic_resume(FAR struct tcb_s *tcb)
{
  stm32_gpiowrite(GPIO_SCHED_RUNNING, true);
}
Пример #23
0
void stm32_setleds(uint8_t ledset)
{
  stm32_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0);
  stm32_gpiowrite(GPIO_LED2, (ledset & BOARD_LED2_BIT) == 0);
}
Пример #24
0
void board_userled_all(uint8_t ledset)
{
  stm32_gpiowrite(GPIO_LED1, (ledset & BOARD_LED1_BIT) == 0);
  stm32_gpiowrite(GPIO_LED2, (ledset & BOARD_LED2_BIT) == 0);
  stm32_gpiowrite(GPIO_LED3, (ledset & BOARD_LED3_BIT) == 0);
}
Пример #25
0
static void phy_set_led(int led, bool state)
{
	/* Pull Up to switch on */
	stm32_gpiowrite(g_ledmap[led], state);
}
Пример #26
0
int stm32_configgpio(uint32_t cfgset)
{
  uintptr_t base;
  uint32_t regval;
  uint32_t setting;
  unsigned int regoffset;
  unsigned int port;
  unsigned int pin;
  unsigned int pos;
  unsigned int pinmode;
  irqstate_t flags;

  /* Verify that this hardware supports the select GPIO port */

  port = (cfgset & GPIO_PORT_MASK) >> GPIO_PORT_SHIFT;
  if (port >= STM32F7_NGPIO)
    {
      return -EINVAL;
    }

  /* Get the port base address */

  base = g_gpiobase[port];

  /* Get the pin number and select the port configuration register for that
   * pin
   */

  pin = (cfgset & GPIO_PIN_MASK) >> GPIO_PIN_SHIFT;

  /* Set up the mode register (and remember whether the pin mode) */

  switch (cfgset & GPIO_MODE_MASK)
    {
      default:
      case GPIO_INPUT:      /* Input mode */
        pinmode = GPIO_MODER_INPUT;
        break;

      case GPIO_OUTPUT:     /* General purpose output mode */
        stm32_gpiowrite(cfgset, (cfgset & GPIO_OUTPUT_SET) != 0); /* Set the initial output value */
        pinmode = GPIO_MODER_OUTPUT;
        break;

      case GPIO_ALT:        /* Alternate function mode */
        pinmode = GPIO_MODER_ALT;
        break;

      case GPIO_ANALOG:     /* Analog mode */
        pinmode = GPIO_MODER_ANALOG;
        break;
    }

  /* Interrupts must be disabled from here on out so that we have mutually
   * exclusive access to all of the GPIO configuration registers.
   */

  flags = enter_critical_section();

  /* Now apply the configuration to the mode register */

  regval  = getreg32(base + STM32_GPIO_MODER_OFFSET);
  regval &= ~GPIO_MODER_MASK(pin);
  regval |= ((uint32_t)pinmode << GPIO_MODER_SHIFT(pin));
  putreg32(regval, base + STM32_GPIO_MODER_OFFSET);

  /* Set up the pull-up/pull-down configuration (all but analog pins) */

  setting = GPIO_PUPDR_NONE;
  if (pinmode != GPIO_MODER_ANALOG)
    {
      switch (cfgset & GPIO_PUPD_MASK)
        {
          default:
          case GPIO_FLOAT:      /* No pull-up, pull-down */
            break;

          case GPIO_PULLUP:     /* Pull-up */
            setting = GPIO_PUPDR_PULLUP;
            break;

          case GPIO_PULLDOWN:   /* Pull-down */
            setting = GPIO_PUPDR_PULLDOWN;
            break;
        }
    }

  regval  = getreg32(base + STM32_GPIO_PUPDR_OFFSET);
  regval &= ~GPIO_PUPDR_MASK(pin);
  regval |= (setting << GPIO_PUPDR_SHIFT(pin));
  putreg32(regval, base + STM32_GPIO_PUPDR_OFFSET);

  /* Set the alternate function (Only alternate function pins) */

  if (pinmode == GPIO_MODER_ALT)
    {
      setting = (cfgset & GPIO_AF_MASK) >> GPIO_AF_SHIFT;
    }
Пример #27
0
static void up_lcdsetpolarity(bool pol)
{
  stm32_gpiowrite(GPIO_LED, pol);
  stm32_gpiowrite(GPIO_MEMLCD_EXTCOMIN, pol);
}
Пример #28
0
__EXPORT void stm32_spi4select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
	/* SPI select is active low, so write !selected to select the device */

	switch (devid) {
	case PX4_SPIDEV_GYRO:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_GYRO, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1);
		stm32_gpiowrite(GPIO_SPI_CS_BARO, 1);
		stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);
		break;

	case PX4_SPIDEV_ACCEL_MAG:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
		stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_BARO, 1);
		stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);
		break;

	case PX4_SPIDEV_BARO:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
		stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1);
		stm32_gpiowrite(GPIO_SPI_CS_BARO, !selected);
//		stm32_gpiowrite(GPIO_SPI_CS_FRAM,1);
		stm32_gpiowrite(GPIO_SPI_CS_MPU, 1);
		break;

//	case PX4_SPIDEV_FLASH:
//		stm32_gpiowrite(GPIO_SPI_CS_BARO,1);
//		stm32_gpiowrite(GPIO_SPI_CS_FRAM,!selected);
//		break;

	case PX4_SPIDEV_MPU:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_GYRO, 1);
		stm32_gpiowrite(GPIO_SPI_CS_ACCEL_MAG, 1);
		stm32_gpiowrite(GPIO_SPI_CS_BARO, 1);
		stm32_gpiowrite(GPIO_SPI_CS_MPU, !selected);
		break;

	default:
		break;
	}
}
Пример #29
0
__EXPORT void stm32_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
	/* there can only be one device on this bus, so always select it */
	stm32_gpiowrite(GPIO_SPI_CS_SDCARD, !selected);
}
Пример #30
0
__EXPORT void stm32_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
	/* SPI select is active low, so write !selected to select the device */

	switch (devid) {
	case PX4_SPIDEV_EXT0:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_EXT0, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_EXT1, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT2, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT3, 1);
		break;

	case PX4_SPIDEV_EXT1:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_EXT0, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT1, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_EXT2, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT3, 1);
		break;

	case PX4_SPIDEV_EXT2:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_EXT0, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT1, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT2, !selected);
		stm32_gpiowrite(GPIO_SPI_CS_EXT3, 1);
		break;

	case PX4_SPIDEV_EXT3:
		/* Making sure the other peripherals are not selected */
		stm32_gpiowrite(GPIO_SPI_CS_EXT0, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT1, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT2, 1);
		stm32_gpiowrite(GPIO_SPI_CS_EXT3, !selected);
		break;

	default:
		break;

	}
}