Skip to content

Commit

Permalink
bmi055 add measure interval perf counter
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar authored and LorenzMeier committed Jul 8, 2018
1 parent 0da8125 commit e4be8ec
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/drivers/imu/bmi055/BMI055_accel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const uint8_t BMI055_accel::_checked_registers[BMI055_ACCEL_NUM_CHECKED_REGISTER
BMI055_accel::BMI055_accel(int bus, const char *path_accel, uint32_t device, enum Rotation rotation) :
BMI055("BMI055_ACCEL", path_accel, bus, device, SPIDEV_MODE3, BMI055_BUS_SPEED, rotation),
_sample_perf(perf_alloc(PC_ELAPSED, "bmi055_accel_read")),
_measure_interval(perf_alloc(PC_INTERVAL, "bmi055_accel_measure_interval")),
_bad_transfers(perf_alloc(PC_COUNT, "bmi055_accel_bad_transfers")),
_bad_registers(perf_alloc(PC_COUNT, "bmi055_accel_bad_registers")),
_duplicates(perf_alloc(PC_COUNT, "bmi055_accel_duplicates")),
Expand Down Expand Up @@ -96,6 +97,7 @@ BMI055_accel::~BMI055_accel()

/* delete the perf counter */
perf_free(_sample_perf);
perf_free(_measure_interval);
perf_free(_bad_transfers);
perf_free(_bad_registers);
perf_free(_duplicates);
Expand Down Expand Up @@ -637,6 +639,8 @@ BMI055_accel::check_registers(void)
void
BMI055_accel::measure()
{
perf_count(_measure_interval);

uint8_t index = 0, accel_data[7];
uint16_t lsb, msb, msblsb;
uint8_t status_x, status_y, status_z;
Expand Down Expand Up @@ -805,6 +809,7 @@ BMI055_accel::print_info()
PX4_INFO("Accel");

perf_print_counter(_sample_perf);
perf_print_counter(_measure_interval);
perf_print_counter(_bad_transfers);
perf_print_counter(_bad_registers);
perf_print_counter(_duplicates);
Expand Down
1 change: 1 addition & 0 deletions src/drivers/imu/bmi055/BMI055_accel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class BMI055_accel : public BMI055
private:

perf_counter_t _sample_perf;
perf_counter_t _measure_interval;
perf_counter_t _bad_transfers;
perf_counter_t _bad_registers;
perf_counter_t _duplicates;
Expand Down
5 changes: 5 additions & 0 deletions src/drivers/imu/bmi055/BMI055_gyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const uint8_t BMI055_gyro::_checked_registers[BMI055_GYRO_NUM_CHECKED_REGISTERS]
BMI055_gyro::BMI055_gyro(int bus, const char *path_gyro, uint32_t device, enum Rotation rotation) :
BMI055("BMI055_GYRO", path_gyro, bus, device, SPIDEV_MODE3, BMI055_BUS_SPEED, rotation),
_sample_perf(perf_alloc(PC_ELAPSED, "bmi055_gyro_read")),
_measure_interval(perf_alloc(PC_INTERVAL, "bmi055_gyro_measure_interval")),
_bad_transfers(perf_alloc(PC_COUNT, "bmi055_gyro_bad_transfers")),
_bad_registers(perf_alloc(PC_COUNT, "bmi055_gyro_bad_registers")),
_gyro_reports(nullptr),
Expand Down Expand Up @@ -95,6 +96,7 @@ BMI055_gyro::~BMI055_gyro()

/* delete the perf counter */
perf_free(_sample_perf);
perf_free(_measure_interval);
perf_free(_bad_transfers);
perf_free(_bad_registers);
}
Expand Down Expand Up @@ -637,6 +639,8 @@ BMI055_gyro::check_registers(void)
void
BMI055_gyro::measure()
{
perf_count(_measure_interval);

if (hrt_absolute_time() < _reset_wait) {
// we're waiting for a reset to complete
return;
Expand Down Expand Up @@ -779,6 +783,7 @@ BMI055_gyro::print_info()
PX4_INFO("Gyro");

perf_print_counter(_sample_perf);
perf_print_counter(_measure_interval);
perf_print_counter(_bad_transfers);
perf_print_counter(_bad_registers);

Expand Down
1 change: 1 addition & 0 deletions src/drivers/imu/bmi055/BMI055_gyro.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class BMI055_gyro : public BMI055
private:

perf_counter_t _sample_perf;
perf_counter_t _measure_interval;
perf_counter_t _bad_transfers;
perf_counter_t _bad_registers;

Expand Down

0 comments on commit e4be8ec

Please sign in to comment.