paparazzi-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Paparazzi-devel] MPU9250 Driver in SPI mode


From: Bubbachuck
Subject: Re: [Paparazzi-devel] MPU9250 Driver in SPI mode
Date: Mon, 25 May 2015 00:53:35 -0700 (MST)

Thanks for your quick response.

I was confused that AK8963 is configured with SLV4 registers but read from
SLV0. See the following codes:


bool_t imu_mpu9250_configure_mag_slave(Mpu9250ConfigSet mpu_set, void *mpu)
{
  // wait before starting the configuration of the mag
  // doing to early may void the mode configuration
  if (get_sys_time_float() < IMU_MPU9250_MAG_STARTUP_DELAY) {
    return FALSE;
  }

  //config AK8963 soft reset
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_ADDR,
(MPU9250_MAG_ADDR >> 1));
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_REG,
AK8963_REG_CNTL2);
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_DO, 1);
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_CTRL, (1 << 7)); //
Slave 4 enable

  mpu_wait_slave4_ready();

  // Set it to continious measuring mode 2
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_ADDR,
(MPU9250_MAG_ADDR >> 1));
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_REG,
AK8963_REG_CNTL1);
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_DO,
AK8963_CNTL1_CM_2);
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV4_CTRL, (1 << 7)); //
Slave 4 enable

  mpu_wait_slave4_ready();

  //Config SLV0 for continus Read
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV0_ADDR,
(MPU9250_MAG_ADDR >> 1) | MPU9250_SPI_READ);
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV0_REG, AK8963_REG_HXL);
  // Put the enable command as last.
  mpu_set_and_wait(mpu_set, mpu, MPU9250_REG_I2C_SLV0_CTRL,
                   (1 << 7) |    // Slave 0 enable
                   (7 << 0));    // Read 7 bytes (mag x,y,z + status)

  return TRUE;
}



Moses wrote
> AK8963 has been accessed as slave device through I2C in the SPI driver.
> 1 pressure sensor(MS5611 IIC) + 1 OSD(MAX7456 SPI) + 1 9DOF(MPU9250 SPI)
> in my autopilot.
> 
> STM32MCU
>  |
>  |---------SPI2----------mpu9250----(IIC)--------AK8963
>  |
>  |---------SPI1---------max7456
>  |
>  |---------IIC-----------ms5611
> 
> 
> btw: SLAVE4 is means the NCS(or NSS)pin of mpu9250 that nothing with IIC
> address. MPU9250 should send back a lot of data in DMA mode, add any other
> extended device in the same SPI bus is not a good idea.





--
View this message in context: 
http://lists.paparazziuav.org/MPU9250-Driver-in-SPI-mode-tp16954p17029.html
Sent from the paparazzi-devel mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]