fix spi select logic

This commit is contained in:
Mark Whitehorn
2015-12-31 21:57:21 +02:00
committed by Lorenz Meier
parent 4952d05652
commit ab71af6053
2 changed files with 19 additions and 2 deletions
@@ -122,6 +122,7 @@ __BEGIN_DECLS
#define PX4_SPI_BUS_RAMTRON 2
/* Use these in place of the spi_dev_e enumeration to select a specific SPI device on SPI1 */
//#define PX4_SPIDEV_FRAM 0
#define PX4_SPIDEV_GYRO 1
#define PX4_SPIDEV_ACCEL_MAG 2
#define PX4_SPIDEV_BARO 3
+18 -2
View File
@@ -151,8 +151,24 @@ __EXPORT uint8_t stm32_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devi
#ifdef CONFIG_STM32_SPI2
__EXPORT void stm32_spi2select(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_FRAM, !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_MS5611, 1);
stm32_gpiowrite(GPIO_SPI_CS_FRAM, !selected);
break;
case PX4_SPIDEV_BARO:
/* Making sure the other peripherals are not selected */
stm32_gpiowrite(GPIO_SPI_CS_FRAM, 1);
stm32_gpiowrite(GPIO_SPI_CS_MS5611, !selected);
break;
default:
break;
}
}
__EXPORT uint8_t stm32_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)