mirror of
https://github.com/eclipse/upm.git
synced 2025-03-14 20:47:30 +03:00
ms5611: Fix for i2cbus assignment
Make sure I2c bus is initialized with provided bus number. Removed unnecessary mraa::Result variable in favor of immediate checks. Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
parent
01036f7dae
commit
f92c0c120e
@ -53,13 +53,11 @@ using namespace upm;
|
||||
|
||||
MS5611::MS5611(int i2cBus, int address)
|
||||
{
|
||||
status = mraa::ERROR_INVALID_RESOURCE;
|
||||
i2c = new mraa::I2c(2);
|
||||
i2c = new mraa::I2c(i2cBus);
|
||||
this->address = address;
|
||||
i2c->address(address);
|
||||
prom = new uint16_t[MS5611_PROM_SIZE];
|
||||
status = i2c->writeByte(MS5611_CMD_RESET);
|
||||
if (status != mraa::SUCCESS)
|
||||
if (i2c->writeByte(MS5611_CMD_RESET != mraa::SUCCESS))
|
||||
UPM_THROW("Reset failed.");
|
||||
delayms(5);
|
||||
for (int i = 0; i < MS5611_PROM_SIZE; ++i) {
|
||||
@ -154,8 +152,7 @@ uint32_t MS5611::readADC(int adcReg)
|
||||
{
|
||||
uint32_t value;
|
||||
uint8_t buf[3];
|
||||
status = i2c->writeByte(adcReg + osr);
|
||||
if (status != mraa::SUCCESS)
|
||||
if (i2c->writeByte(adcReg + osr) != mraa::SUCCESS)
|
||||
UPM_THROW("Convert D2 failed");
|
||||
delayms(100);
|
||||
int bytesRead = i2c->readBytesReg(MS5611_CMD_ADC_READ, buf, 3);
|
||||
|
@ -84,7 +84,6 @@ private:
|
||||
uint32_t readRawPressure();
|
||||
uint32_t readRawTemperature();
|
||||
|
||||
mraa::Result status;
|
||||
mraa::I2c* i2c;
|
||||
int address;
|
||||
uint16_t *prom;
|
||||
|
Loading…
x
Reference in New Issue
Block a user