MPU6K compile and code style fixes

This commit is contained in:
Lorenz Meier
2016-08-18 13:50:29 +02:00
parent 3d1f1522d9
commit a97c5ec4e1
+13 -11
View File
@@ -168,10 +168,9 @@ private:
* SPI bus based device use hrt * SPI bus based device use hrt
* I2C bus needs to use work queue * I2C bus needs to use work queue
*/ */
bool _use_hrt;
work_s _work; work_s _work;
#endif #endif
bool _use_hrt;
struct hrt_call _call; struct hrt_call _call;
unsigned _call_interval; unsigned _call_interval;
@@ -265,7 +264,7 @@ private:
#if defined(USE_I2C) #if defined(USE_I2C)
/** /**
* When the I2C interfase is cho * When the I2C interfase is on
* Perform a poll cycle; collect from the previous measurement * Perform a poll cycle; collect from the previous measurement
* and start a new one. * and start a new one.
* *
@@ -288,12 +287,12 @@ private:
*/ */
static void cycle_trampoline(void *arg); static void cycle_trampoline(void *arg);
bool is_i2c(void) { return !_use_hrt; }
void use_i2c(bool on_true) { _use_hrt = !on_true; } void use_i2c(bool on_true) { _use_hrt = !on_true; }
#endif #endif
bool is_i2c(void) { return !_use_hrt; }
/** /**
* Static trampoline from the hrt_call context; because we don't have a * Static trampoline from the hrt_call context; because we don't have a
@@ -474,9 +473,9 @@ MPU6000::MPU6000(device::Device *interface, const char *path_accel, const char *
_gyro(new MPU6000_gyro(this, path_gyro)), _gyro(new MPU6000_gyro(this, path_gyro)),
_product(0), _product(0),
#if defined(USE_I2C) #if defined(USE_I2C)
_use_hrt(false), _work {},
_work{},
#endif #endif
_use_hrt(false),
_call {}, _call {},
_call_interval(0), _call_interval(0),
_accel_reports(nullptr), _accel_reports(nullptr),
@@ -710,8 +709,8 @@ int MPU6000::reset()
if (is_i2c()) { if (is_i2c()) {
// Enable I2C bus (recommended on datasheet) // Enable I2C bus (recommended on datasheet)
write_checked_reg(MPUREG_USER_CTRL, 0); write_checked_reg(MPUREG_USER_CTRL, 0);
} else
{ } else {
// Disable I2C bus (recommended on datasheet) // Disable I2C bus (recommended on datasheet)
write_checked_reg(MPUREG_USER_CTRL, BIT_I2C_IF_DIS); write_checked_reg(MPUREG_USER_CTRL, BIT_I2C_IF_DIS);
} }
@@ -1356,8 +1355,7 @@ MPU6000::ioctl(struct file *filp, int cmd, unsigned long arg)
stm32 clock and the mpu6000 clock stm32 clock and the mpu6000 clock
*/ */
if (!is_i2c()) if (!is_i2c()) {
{
_call.period = _call_interval - MPU6000_TIMER_REDUCTION; _call.period = _call_interval - MPU6000_TIMER_REDUCTION;
} }
@@ -1671,8 +1669,10 @@ MPU6000::start()
(hrt_callout)&MPU6000::measure_trampoline, this); (hrt_callout)&MPU6000::measure_trampoline, this);
} else { } else {
#ifdef USE_I2C
/* schedule a cycle to start things */ /* schedule a cycle to start things */
work_queue(HPWORK, &_work, (worker_t)&MPU6000::cycle_trampoline, this, 1); work_queue(HPWORK, &_work, (worker_t)&MPU6000::cycle_trampoline, this, 1);
#endif
} }
} }
@@ -1684,8 +1684,10 @@ MPU6000::stop()
hrt_cancel(&_call); hrt_cancel(&_call);
} else { } else {
#ifdef USE_I2C
_call_interval = 0; _call_interval = 0;
work_cancel(HPWORK, &_work); work_cancel(HPWORK, &_work);
#endif
} }
/* reset internal states */ /* reset internal states */