Extracting a magnetic heading from GY-86

According to schematic of GY-86 (http://www.aliexpress.com/store/product/Free-shipping-GY-86-10DOF-modules-MWC-flight-control-sensor-module-With-chips-MPU6050-HMC5883L-MS5611/915786_1044842262.html) magnetometer connected to the auxiliary master I2C bus of MPU5060. But MPU5060 has ability to connect auxiliary I2C bus directly to primary I2C (slave mode) bus via special bypass mux (see section 7.11 of MPU5060 product specification).

There are three steps required to activate the bypass mode of MPU 5060:

  1. set I2C Master enable bit (I2C_MST_EN, bit 5) in user control register (USER_CTRL , 0x6A) to 0 (on MPU5060 power up it is already equeal zero).
  2. set I2C Bypass enable bit (I2C_BYPASS_EN,bit 2) in INT Pin / Bypass Enable Configuration register (INT_PIN_CFG,0x37) to 1.
  3. Turn off sleep mode by reseting SLEEP bit (bit 6) of the power management register #1 (PWR_MGMT_1, 0x6B).

In short, do the folloving:

MPU6050_write_reg (0x6A, 0);
MPU6050_write_reg (0x37, 2);
MPU6050_write_reg (0x6B, 0);

After that you'll be able to communicate to magnetometer by 0x1e address via the same I2C interface that MPU5060 connected.

Note:
MPU5060 can read magnetometer data by itself, (there are 5 sets of registers to control secondary I2C devices which is connected to auxiliary I2C bus (see sections 4.9-4.17 in MPU5060 Register map and description). But I haven't manage yet to configure 5060 to read magnetometer by itself :~
In additional the HMC5883L required to be initialized to work in cycle mode (after power up it works in single measurement mode). MPU5060 can (probably) perform this initialization... but i'm not sure ....
So the bypass mode is required (probably) at least for initialization of HMC5883L.