mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
bmx055: fix up some issues reported by static analysis
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
parent
e0ef6eea64
commit
0fb56356fb
@ -40,12 +40,9 @@ static float c2f(float c)
|
||||
return (c * (9.0 / 5.0) + 32.0);
|
||||
}
|
||||
|
||||
BMA250E::BMA250E(int bus, uint8_t addr, int cs) :
|
||||
BMA250E::BMA250E(int bus, int addr, int cs) :
|
||||
m_i2c(0), m_spi(0), m_gpioIntr1(0), m_gpioIntr2(0), m_gpioCS(0)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_isSPI = false;
|
||||
|
||||
m_accX = 0;
|
||||
m_accY = 0;
|
||||
m_accZ = 0;
|
||||
@ -53,7 +50,15 @@ BMA250E::BMA250E(int bus, uint8_t addr, int cs) :
|
||||
m_temperature = 0.0;
|
||||
|
||||
if (addr < 0)
|
||||
m_isSPI = true;
|
||||
{
|
||||
m_addr = 0;
|
||||
m_isSPI = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_addr = uint8_t(addr);
|
||||
m_isSPI = false;
|
||||
}
|
||||
|
||||
if (m_isSPI)
|
||||
{
|
||||
@ -127,6 +132,13 @@ BMA250E::~BMA250E()
|
||||
{
|
||||
uninstallISR(INTERRUPT_INT1);
|
||||
uninstallISR(INTERRUPT_INT2);
|
||||
|
||||
if (m_i2c)
|
||||
delete m_i2c;
|
||||
if (m_spi)
|
||||
delete m_spi;
|
||||
if(m_gpioCS)
|
||||
delete m_gpioCS;
|
||||
}
|
||||
|
||||
void BMA250E::init(POWER_MODE_T pwr, RANGE_T range, BW_T bw)
|
||||
@ -160,20 +172,14 @@ void BMA250E::init(POWER_MODE_T pwr, RANGE_T range, BW_T bw)
|
||||
|
||||
void BMA250E::update()
|
||||
{
|
||||
int bufLen = 0;
|
||||
uint8_t startReg = 0;
|
||||
int bufLen = 7; // max, non-FIFO
|
||||
uint8_t startReg = REG_ACCD_X_LSB;
|
||||
|
||||
if (m_useFIFO)
|
||||
{
|
||||
bufLen = 6;
|
||||
startReg = REG_FIFO_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
// non FIFO, read acc regs directly (including temp)
|
||||
bufLen = 7;
|
||||
startReg = REG_ACCD_X_LSB;
|
||||
}
|
||||
|
||||
uint8_t buf[bufLen];
|
||||
|
||||
|
@ -964,7 +964,7 @@ namespace upm {
|
||||
* @param cs The gpio pin to use for the SPI Chip Select. -1 for
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMA250E(int bus=BMA250E_I2C_BUS, uint8_t addr=BMA250E_DEFAULT_ADDR,
|
||||
BMA250E(int bus=BMA250E_I2C_BUS, int addr=BMA250E_DEFAULT_ADDR,
|
||||
int cs=-1);
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,8 @@
|
||||
using namespace upm;
|
||||
using namespace std;
|
||||
|
||||
BMC150::BMC150(int accelBus, uint8_t accelAddr, int accelCS,
|
||||
int magBus, uint8_t magAddr, int magCS) :
|
||||
BMC150::BMC150(int accelBus, int accelAddr, int accelCS,
|
||||
int magBus, int magAddr, int magCS) :
|
||||
m_accel(0), m_mag(0)
|
||||
{
|
||||
// if -1 is supplied as a bus for any of these, we will not
|
||||
|
@ -93,10 +93,10 @@ namespace upm {
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMC150(int accelBus=BMC150_DEFAULT_BUS,
|
||||
uint8_t accelAddr=BMC150_DEFAULT_ACC_ADDR,
|
||||
int accelAddr=BMC150_DEFAULT_ACC_ADDR,
|
||||
int accelCS=-1,
|
||||
int magBus=BMC150_DEFAULT_BUS,
|
||||
uint8_t magAddr=BMC150_DEFAULT_MAG_ADDR,
|
||||
int magAddr=BMC150_DEFAULT_MAG_ADDR,
|
||||
int magCS=-1);
|
||||
|
||||
/**
|
||||
|
@ -42,12 +42,9 @@ static float c2f(float c)
|
||||
return (c * (9.0 / 5.0) + 32.0);
|
||||
}
|
||||
|
||||
BMG160::BMG160(int bus, uint8_t addr, int cs) :
|
||||
BMG160::BMG160(int bus, int addr, int cs) :
|
||||
m_i2c(0), m_spi(0), m_gpioIntr1(0), m_gpioIntr2(0), m_gpioCS(0)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_isSPI = false;
|
||||
|
||||
m_gyrX = 0;
|
||||
m_gyrY = 0;
|
||||
m_gyrZ = 0;
|
||||
@ -55,7 +52,15 @@ BMG160::BMG160(int bus, uint8_t addr, int cs) :
|
||||
m_temperature = 0.0;
|
||||
|
||||
if (addr < 0)
|
||||
m_isSPI = true;
|
||||
{
|
||||
m_addr = 0;
|
||||
m_isSPI = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_addr = uint8_t(addr);
|
||||
m_isSPI = false;
|
||||
}
|
||||
|
||||
if (m_isSPI)
|
||||
{
|
||||
@ -105,6 +110,13 @@ BMG160::~BMG160()
|
||||
{
|
||||
uninstallISR(INTERRUPT_INT1);
|
||||
uninstallISR(INTERRUPT_INT2);
|
||||
|
||||
if (m_i2c)
|
||||
delete m_i2c;
|
||||
if (m_spi)
|
||||
delete m_spi;
|
||||
if(m_gpioCS)
|
||||
delete m_gpioCS;
|
||||
}
|
||||
|
||||
void BMG160::init(POWER_MODE_T pwr, RANGE_T range, BW_T bw)
|
||||
@ -132,20 +144,14 @@ void BMG160::init(POWER_MODE_T pwr, RANGE_T range, BW_T bw)
|
||||
|
||||
void BMG160::update()
|
||||
{
|
||||
int bufLen = 0;
|
||||
uint8_t startReg = 0;
|
||||
int bufLen = 7; // max, non-FIFO
|
||||
uint8_t startReg = REG_RATE_X_LSB;
|
||||
|
||||
if (m_useFIFO)
|
||||
{
|
||||
bufLen = 6;
|
||||
startReg = REG_FIFO_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
// non FIFO, read acc regs directly (including temp)
|
||||
bufLen = 7;
|
||||
startReg = REG_RATE_X_LSB;
|
||||
}
|
||||
|
||||
uint8_t buf[bufLen];
|
||||
|
||||
|
@ -823,7 +823,7 @@ namespace upm {
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
* @param theChipID The chip ID to use for validation
|
||||
*/
|
||||
BMG160(int bus=BMG160_I2C_BUS, uint8_t addr=BMG160_DEFAULT_ADDR,
|
||||
BMG160(int bus=BMG160_I2C_BUS, int addr=BMG160_DEFAULT_ADDR,
|
||||
int cs=-1);
|
||||
|
||||
/**
|
||||
|
@ -32,8 +32,8 @@
|
||||
using namespace upm;
|
||||
using namespace std;
|
||||
|
||||
BMI055::BMI055(int accelBus, uint8_t accelAddr, int accelCS,
|
||||
int gyroBus, uint8_t gyroAddr, int gyroCS) :
|
||||
BMI055::BMI055(int accelBus, int accelAddr, int accelCS,
|
||||
int gyroBus, int gyroAddr, int gyroCS) :
|
||||
m_accel(0), m_gyro(0)
|
||||
{
|
||||
// if -1 is supplied as a bus for any of these, we will not
|
||||
|
@ -85,10 +85,10 @@ namespace upm {
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMI055(int accelBus=BMA250E_I2C_BUS,
|
||||
uint8_t accelAddr=BMA250E_DEFAULT_ADDR,
|
||||
int accelAddr=BMA250E_DEFAULT_ADDR,
|
||||
int accelCS=-1,
|
||||
int gyroBus=BMG160_I2C_BUS,
|
||||
uint8_t gyroAddr=BMG160_DEFAULT_ADDR,
|
||||
int gyroAddr=BMG160_DEFAULT_ADDR,
|
||||
int gyroCS=-1);
|
||||
|
||||
/**
|
||||
|
@ -92,12 +92,9 @@
|
||||
using namespace upm;
|
||||
using namespace std;
|
||||
|
||||
BMM150::BMM150(int bus, uint8_t addr, int cs) :
|
||||
BMM150::BMM150(int bus, int addr, int cs) :
|
||||
m_i2c(0), m_spi(0), m_gpioIntr(0), m_gpioDR(0), m_gpioCS(0)
|
||||
{
|
||||
m_addr = addr;
|
||||
m_isSPI = false;
|
||||
|
||||
m_magX = 0;
|
||||
m_magY = 0;
|
||||
m_magZ = 0;
|
||||
@ -119,7 +116,16 @@ BMM150::BMM150(int bus, uint8_t addr, int cs) :
|
||||
m_dig_xy1 = 0;
|
||||
|
||||
if (addr < 0)
|
||||
m_isSPI = true;
|
||||
{
|
||||
m_addr = 0;
|
||||
m_isSPI = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_addr = uint8_t(addr);
|
||||
m_isSPI = false;
|
||||
}
|
||||
|
||||
|
||||
if (m_isSPI)
|
||||
{
|
||||
@ -177,6 +183,13 @@ BMM150::~BMM150()
|
||||
{
|
||||
uninstallISR(INTERRUPT_INT);
|
||||
uninstallISR(INTERRUPT_DR);
|
||||
|
||||
if (m_i2c)
|
||||
delete m_i2c;
|
||||
if (m_spi)
|
||||
delete m_spi;
|
||||
if(m_gpioCS)
|
||||
delete m_gpioCS;
|
||||
}
|
||||
|
||||
void BMM150::init(USAGE_PRESETS_T usage)
|
||||
|
@ -320,7 +320,7 @@ namespace upm {
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
* @param theChipID The chip ID to use for validation
|
||||
*/
|
||||
BMM150(int bus=BMM150_I2C_BUS, uint8_t addr=BMM150_DEFAULT_ADDR,
|
||||
BMM150(int bus=BMM150_I2C_BUS, int addr=BMM150_DEFAULT_ADDR,
|
||||
int cs=-1);
|
||||
|
||||
/**
|
||||
|
@ -32,9 +32,9 @@
|
||||
using namespace upm;
|
||||
using namespace std;
|
||||
|
||||
BMX055::BMX055(int accelBus, uint8_t accelAddr, int accelCS,
|
||||
int gyroBus, uint8_t gyroAddr, int gyroCS,
|
||||
int magBus, uint8_t magAddr, int magCS) :
|
||||
BMX055::BMX055(int accelBus, int accelAddr, int accelCS,
|
||||
int gyroBus, int gyroAddr, int gyroCS,
|
||||
int magBus, int magAddr, int magCS) :
|
||||
m_accel(0), m_gyro(0), m_mag(0)
|
||||
{
|
||||
// if -1 is supplied as a bus for any of these, we will not
|
||||
|
@ -100,13 +100,13 @@ namespace upm {
|
||||
* I2C or for SPI with a hardware controlled pin.
|
||||
*/
|
||||
BMX055(int accelBus=BMA250E_I2C_BUS,
|
||||
uint8_t accelAddr=BMA250E_DEFAULT_ADDR,
|
||||
int accelAddr=BMA250E_DEFAULT_ADDR,
|
||||
int accelCS=-1,
|
||||
int gyroBus=BMG160_I2C_BUS,
|
||||
uint8_t gyroAddr=BMG160_DEFAULT_ADDR,
|
||||
int gyroAddr=BMG160_DEFAULT_ADDR,
|
||||
int gyroCS=-1,
|
||||
int magBus=BMM150_I2C_BUS,
|
||||
uint8_t magAddr=BMM150_DEFAULT_ADDR,
|
||||
int magAddr=BMM150_DEFAULT_ADDR,
|
||||
int magCS=-1);
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user