public void Reset() { WriteRegister(Register.RSV, 0x01); _measurementMode = MeasurementMode.PowerDown; _outputBitMode = OutputBitMode.Output14bit; _selfTest = false; // When powering the AK893, doc says 50 ms needed Thread.Sleep(50); }
/// <summary> /// Constructor to use if AK8963 is behind another element and need a special I2C protocol like /// when used with the MPU9250 /// </summary> /// <param name="i2cDevice">The I2C device</param> /// <param name="ak8963Interface">The specific interface to communicate with the AK8963</param> /// <param name="shouldDispose">True to dispose the I2C device when class is disposed</param> public Ak8963(I2cDevice i2cDevice, Ak8963I2cBase ak8963Interface, bool shouldDispose = true) { _i2cDevice = i2cDevice ?? throw new ArgumentNullException(nameof(i2cDevice)); _ak8963Interface = ak8963Interface; // Initialize the default modes _measurementMode = MeasurementMode.PowerDown; _outputBitMode = OutputBitMode.Output14bit; _selfTest = false; _shouldDispose = shouldDispose; byte mode = (byte)((byte)_measurementMode | ((byte)_outputBitMode << 4)); WriteRegister(Register.CNTL, mode); if (!IsVersionCorrect()) { throw new IOException($"This device does not contain the correct signature 0x48 for a AK8963"); } }