mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57: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)
|
MS5611::MS5611(int i2cBus, int address)
|
||||||
{
|
{
|
||||||
status = mraa::ERROR_INVALID_RESOURCE;
|
i2c = new mraa::I2c(i2cBus);
|
||||||
i2c = new mraa::I2c(2);
|
|
||||||
this->address = address;
|
this->address = address;
|
||||||
i2c->address(address);
|
i2c->address(address);
|
||||||
prom = new uint16_t[MS5611_PROM_SIZE];
|
prom = new uint16_t[MS5611_PROM_SIZE];
|
||||||
status = i2c->writeByte(MS5611_CMD_RESET);
|
if (i2c->writeByte(MS5611_CMD_RESET != mraa::SUCCESS))
|
||||||
if (status != mraa::SUCCESS)
|
|
||||||
UPM_THROW("Reset failed.");
|
UPM_THROW("Reset failed.");
|
||||||
delayms(5);
|
delayms(5);
|
||||||
for (int i = 0; i < MS5611_PROM_SIZE; ++i) {
|
for (int i = 0; i < MS5611_PROM_SIZE; ++i) {
|
||||||
@ -154,8 +152,7 @@ uint32_t MS5611::readADC(int adcReg)
|
|||||||
{
|
{
|
||||||
uint32_t value;
|
uint32_t value;
|
||||||
uint8_t buf[3];
|
uint8_t buf[3];
|
||||||
status = i2c->writeByte(adcReg + osr);
|
if (i2c->writeByte(adcReg + osr) != mraa::SUCCESS)
|
||||||
if (status != mraa::SUCCESS)
|
|
||||||
UPM_THROW("Convert D2 failed");
|
UPM_THROW("Convert D2 failed");
|
||||||
delayms(100);
|
delayms(100);
|
||||||
int bytesRead = i2c->readBytesReg(MS5611_CMD_ADC_READ, buf, 3);
|
int bytesRead = i2c->readBytesReg(MS5611_CMD_ADC_READ, buf, 3);
|
||||||
|
@ -84,7 +84,6 @@ private:
|
|||||||
uint32_t readRawPressure();
|
uint32_t readRawPressure();
|
||||||
uint32_t readRawTemperature();
|
uint32_t readRawTemperature();
|
||||||
|
|
||||||
mraa::Result status;
|
|
||||||
mraa::I2c* i2c;
|
mraa::I2c* i2c;
|
||||||
int address;
|
int address;
|
||||||
uint16_t *prom;
|
uint16_t *prom;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user