コード例 #1
0
/**
 * @brief Claim the SPI bus for flash use and assert CS pin
 * @return 0 for sucess, -1 for failure to get semaphore
 */
static int32_t PIOS_Flash_Jedec_ClaimBus(struct jedec_flash_dev * flash_dev)
{
	if (PIOS_SPI_ClaimBus(flash_dev->spi_id) < 0)
		return -1;

	PIOS_SPI_RC_PinSet(flash_dev->spi_id, flash_dev->slave_num, 0);
	flash_dev->claimed = true;

	return 0;
}
コード例 #2
0
ファイル: pios_mpu6000.c プロジェクト: alibenpeng/TauLabs
/**
 * @brief Claim the SPI bus for the accel communications and select this chip
 * @return 0 if successful, -1 for invalid device, -2 if unable to claim bus
 */
static int32_t PIOS_MPU6000_ClaimBus()
{
	if (PIOS_MPU6000_Validate(pios_mpu6000_dev) != 0)
		return -1;

	if (PIOS_SPI_ClaimBus(pios_mpu6000_dev->spi_id) != 0)
		return -2;

	PIOS_SPI_RC_PinSet(pios_mpu6000_dev->spi_id, pios_mpu6000_dev->slave_num, 0);
	return 0;
}
コード例 #3
0
/**
 * @brief Claim the SPI bus for the accel communications and select this chip
 * @return 0 if successful, -1 for invalid device, -2 if unable to claim bus
 */
static int32_t PIOS_MPU6000_ClaimBus()
{
    if (PIOS_MPU6000_Validate(dev) != 0) {
        return -1;
    }
    if (PIOS_SPI_ClaimBus(dev->spi_id) != 0) {
        return -2;
    }
    PIOS_SPI_RC_PinSet(dev->spi_id, dev->slave_num, 0);
    return 0;
}
コード例 #4
0
/**
 * @brief Claim the SPI bus for flash use and assert CS pin
 * @return 0 for sucess, -1 for failure to get semaphore
 */
static int32_t PIOS_Flash_Jedec_ClaimBus(struct jedec_flash_dev *flash_dev, bool fast)
{
    if (PIOS_SPI_ClaimBus(flash_dev->spi_id) < 0) {
        return -1;
    }
    PIOS_SPI_SetClockSpeed(flash_dev->spi_id, fast ? FLASH_FAST_PRESCALER : FLASH_PRESCALER);
    PIOS_SPI_RC_PinSet(flash_dev->spi_id, flash_dev->slave_num, 0);
    flash_dev->claimed = true;

    return 0;
}
コード例 #5
0
ファイル: pios_l3gd20.c プロジェクト: Crash1/TauLabs
/**
 * @brief Claim the SPI bus for the accel communications and select this chip
 * @return 0 if successful, -1 for invalid device, -2 if unable to claim bus
 */
static int32_t PIOS_L3GD20_ClaimBus()
{
	if(PIOS_L3GD20_Validate(dev) != 0)
		return -1;

	if(PIOS_SPI_ClaimBus(dev->spi_id) != 0)
		return -2;

	PIOS_SPI_RC_PinSet(dev->spi_id,dev->slave_num,0);
	return 0;
}
コード例 #6
0
ファイル: pios_bma180.c プロジェクト: Crash1/TauLabs
/**
 * @brief Claim the SPI bus for the accel communications and select this chip
 * @return 0 if successful, -1 if unable to claim bus
 */
int32_t PIOS_BMA180_ClaimBus()
{
	if(PIOS_BMA180_Validate(dev) != 0)
		return -1;

	if(PIOS_SPI_ClaimBus(dev->spi_id) != 0) {
		return -1;
	}

	PIOS_SPI_RC_PinSet(dev->spi_id,dev->slave_num,0);

	return 0;
}
コード例 #7
0
ファイル: pios_flash_jedec.c プロジェクト: 01iv3r/OpenPilot
/**
 * @brief Claim the SPI bus for flash use and assert CS pin
 * @return 0 for sucess, -1 for failure to get semaphore
 */
static int32_t PIOS_Flash_Jedec_ClaimBus()
{
	if(PIOS_Flash_Jedec_Validate(flash_dev) != 0)
		return -1;

	if(PIOS_SPI_ClaimBus(flash_dev->spi_id) < 0)
		return -1;
		
	PIOS_SPI_RC_PinSet(flash_dev->spi_id, flash_dev->slave_num, 0);
	flash_dev->claimed = true;
	
	return 0;
}
コード例 #8
0
ファイル: pios_mpu9250_spi.c プロジェクト: EvalZero/TauLabs
/**
 * @brief Claim the SPI bus for the communications and select this chip
 * \param[in] flag controls if low speed access for control registers should be used
 * @return 0 if successful, -1 for invalid device, -2 if unable to claim bus
 */
static int32_t PIOS_MPU9250_ClaimBus(bool lowspeed)
{
	if (PIOS_MPU9250_Validate(dev) != 0)
		return -1;

	if (PIOS_SPI_ClaimBus(dev->spi_id) != 0)
		return -2;

	if (lowspeed)
		PIOS_SPI_SetClockSpeed(dev->spi_id, MPU9250_SPI_LOW_SPEED);

	PIOS_SPI_RC_PinSet(dev->spi_id, dev->slave_num, 0);

	return 0;
}
コード例 #9
0
ファイル: pios_flash_w25x.c プロジェクト: jgoppert/openpilot
/** 
 * @brief Claim the SPI bus for flash use and assert CS pin
 * @return 0 for sucess, -1 for failure to get semaphore
 */
static int8_t PIOS_Flash_W25X_ClaimBus() 
{
	int8_t ret = PIOS_SPI_ClaimBus(PIOS_SPI_FLASH);
	PIOS_FLASH_ENABLE;
	return (ret == 0) ? 0 : -1;
}