/**************************************************************************/ /*! * @brief Reads the factory-set coefficients */ /**************************************************************************/ private void readCoefficients() { #if BMP085_USE_DATASHEET_VALS _bmp085_coeffs.ac1 = 408; _bmp085_coeffs.ac2 = -72; _bmp085_coeffs.ac3 = -14383; _bmp085_coeffs.ac4 = 32741; _bmp085_coeffs.ac5 = 32757; _bmp085_coeffs.ac6 = 23153; _bmp085_coeffs.b1 = 6190; _bmp085_coeffs.b2 = 4; _bmp085_coeffs.mb = -32768; _bmp085_coeffs.mc = -8711; _bmp085_coeffs.md = 2868; _bmp085Mode = 0; #else //var buffer = new byte[2]; //var result = this.i2c.ReadRegisterBytes(this.Address, (byte)Registers.BMP085_REGISTER_CAL_AC1, buffer); this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_AC1, out this._bmp085_coeffs.ac1); //error this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_AC2, out this._bmp085_coeffs.ac2); this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_AC3, out this._bmp085_coeffs.ac3); this.ReadRegister16Bits((byte)Registers.BMP085_REGISTER_CAL_AC4, out this._bmp085_coeffs.ac4); this.ReadRegister16Bits((byte)Registers.BMP085_REGISTER_CAL_AC5, out this._bmp085_coeffs.ac5); //error this.ReadRegister16Bits((byte)Registers.BMP085_REGISTER_CAL_AC6, out this._bmp085_coeffs.ac6); this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_B1, out this._bmp085_coeffs.b1); //error this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_B2, out this._bmp085_coeffs.b2); this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_MB, out this._bmp085_coeffs.mb); this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_MC, out this._bmp085_coeffs.mc); this.ReadRegisterSigned16Bits((byte)Registers.BMP085_REGISTER_CAL_MD, out this._bmp085_coeffs.md);//error #endif }
/*************************************************************************** * PUBLIC FUNCTIONS ***************************************************************************/ /**************************************************************************/ /*! * @brief Setups the HW */ /**************************************************************************/ public bool begin(bmp085_mode_t mode = bmp085_mode_t.BMP085_MODE_ULTRAHIGHRES) { /* Mode boundary check */ if ((mode > bmp085_mode_t.BMP085_MODE_ULTRAHIGHRES) || (mode < 0)) { mode = bmp085_mode_t.BMP085_MODE_ULTRAHIGHRES; } /* Make sure we have the right device */ byte id = 0; read8(BMP085_REGISTER_CHIPID, ref id); if (id != 0x55) { return(false); } /* Set the mode indicator */ _bmp085Mode = (byte)mode; /* Coefficients need to be read once */ readCoefficients(); return(true); }
/**************************************************************************/ /*! * @brief Setups the HW */ /**************************************************************************/ private bool begin(bmp085_mode_t mode) { this.Debug("Initializing BMP180"); /* Mode boundary check */ if ((mode > bmp085_mode_t.BMP085_MODE_ULTRAHIGHRES) || (mode < 0)) { mode = bmp085_mode_t.BMP085_MODE_ULTRAHIGHRES; } /* Make sure we have the right device */ byte id; this.ReadRegister8Bits((byte)Registers.BMP085_REGISTER_CHIPID, out id); if (id != 0x55) { this.Debug("Error: BMP180 not found."); return(false); } /* Set the mode indicator */ this._bmp085Mode = mode; /* Coefficients need to be read once */ this.readCoefficients(); this.Debug("BMP180 Initialized"); return(true); }