PX4 Firmware
PX4 Autopilot Software http://px4.io
BMI055_gyro Class Reference

#include <BMI055_gyro.hpp>

Inheritance diagram for BMI055_gyro:
Collaboration diagram for BMI055_gyro:

Classes

struct  BMI_GyroReport
 Report conversation within the BMI055_gyro, including command byte and interrupt status. More...
 

Public Member Functions

 BMI055_gyro (int bus, const char *path_gyro, uint32_t device, enum Rotation rotation)
 
virtual ~BMI055_gyro ()
 
virtual int init ()
 
void start ()
 
void print_info ()
 Diagnostics - print some basic information about the driver. More...
 
void print_registers ()
 
void test_error ()
 
- Public Member Functions inherited from BMI055
 BMI055 (const char *name, const char *devname, int bus, uint32_t device, enum spi_mode_e mode, uint32_t frequency, enum Rotation rotation)
 
virtual ~BMI055 ()=default
 

Protected Member Functions

virtual int probe ()
 
- Protected Member Functions inherited from BMI055
uint8_t read_reg (unsigned reg)
 Read a register from the BMI055. More...
 
uint16_t read_reg16 (unsigned reg)
 
void write_reg (unsigned reg, uint8_t value)
 Write a register in the BMI055. More...
 
 BMI055 (const BMI055 &)
 
BMI055 operator= (const BMI055 &)
 

Private Member Functions

void stop ()
 Stop automatic measurement. More...
 
int reset ()
 Reset chip. More...
 
void Run () override
 
void measure ()
 Fetch measurements from the sensor and update the report buffers. More...
 
void modify_reg (unsigned reg, uint8_t clearbits, uint8_t setbits)
 Modify a register in the BMI055_gyro. More...
 
void write_checked_reg (unsigned reg, uint8_t value)
 Write a register in the BMI055_gyro, updating _checked_values. More...
 
int set_gyro_range (unsigned max_dps)
 Set the BMI055_gyro measurement range. More...
 
int gyro_set_sample_rate (float desired_sample_rate_hz)
 
void check_registers (void)
 
 BMI055_gyro (const BMI055_gyro &)
 
BMI055_gyro operator= (const BMI055_gyro &)
 

Private Attributes

PX4Gyroscope _px4_gyro
 
perf_counter_t _sample_perf
 
perf_counter_t _bad_transfers
 
perf_counter_t _bad_registers
 
uint8_t _checked_values [BMI055_GYRO_NUM_CHECKED_REGISTERS]
 
uint8_t _checked_bad [BMI055_GYRO_NUM_CHECKED_REGISTERS]
 

Static Private Attributes

static const uint8_t _checked_registers [BMI055_GYRO_NUM_CHECKED_REGISTERS]
 

Additional Inherited Members

- Protected Attributes inherited from BMI055
uint8_t _whoami
 
uint8_t _register_wait
 whoami result More...
 
uint64_t _reset_wait
 
enum Rotation _rotation
 
uint8_t _checked_next
 

Detailed Description

Definition at line 134 of file BMI055_gyro.hpp.

Constructor & Destructor Documentation

◆ BMI055_gyro() [1/2]

BMI055_gyro::BMI055_gyro ( int  bus,
const char *  path_gyro,
uint32_t  device,
enum Rotation  rotation 
)

Definition at line 50 of file BMI055_gyro.cpp.

References _px4_gyro, DRV_GYR_DEVTYPE_BMI055, and PX4Gyroscope::set_device_type().

Here is the call graph for this function:

◆ ~BMI055_gyro()

BMI055_gyro::~BMI055_gyro ( )
virtual

Definition at line 61 of file BMI055_gyro.cpp.

References _bad_registers, _bad_transfers, _sample_perf, perf_free(), and stop().

Here is the call graph for this function:

◆ BMI055_gyro() [2/2]

BMI055_gyro::BMI055_gyro ( const BMI055_gyro )
private

Member Function Documentation

◆ check_registers()

void BMI055_gyro::check_registers ( void  )
private

Definition at line 278 of file BMI055_gyro.cpp.

References _bad_registers, _checked_bad, BMI055::_checked_next, _checked_registers, _checked_values, BMI055::_register_wait, BMI055::_reset_wait, BMI055_GYR_SOFTRESET, BMI055_GYRO_NUM_CHECKED_REGISTERS, BMI055_SOFT_RESET, hrt_absolute_time(), perf_count(), BMI055::read_reg(), and BMI055::write_reg().

Referenced by measure().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gyro_set_sample_rate()

int BMI055_gyro::gyro_set_sample_rate ( float  desired_sample_rate_hz)
private

Definition at line 144 of file BMI055_gyro.cpp.

References BMI055_GYR_BW, BMI055_GYRO_BW_MASK, BMI055_GYRO_RATE_100, BMI055_GYRO_RATE_1000, BMI055_GYRO_RATE_2000, BMI055_GYRO_RATE_400, modify_reg(), and OK.

Referenced by reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

int BMI055_gyro::init ( )
virtual

Definition at line 73 of file BMI055_gyro.cpp.

References DEVICE_DEBUG, ToneAlarmInterface::init(), OK, and reset().

Here is the call graph for this function:

◆ measure()

void BMI055_gyro::measure ( )
private

Fetch measurements from the sensor and update the report buffers.

Definition at line 321 of file BMI055_gyro.cpp.

References _bad_registers, _bad_transfers, _px4_gyro, BMI055::_register_wait, BMI055::_reset_wait, _sample_perf, BMI055_ACC_TEMP, BMI055_GYR_X_L, check_registers(), BMI055_gyro::BMI_GyroReport::cmd, DIR_READ, hrt_absolute_time(), hrt_abstime, OK, perf_begin(), perf_count(), perf_end(), perf_event_count(), BMI055::read_reg(), PX4Gyroscope::set_error_count(), PX4Gyroscope::set_temperature(), and PX4Gyroscope::update().

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modify_reg()

void BMI055_gyro::modify_reg ( unsigned  reg,
uint8_t  clearbits,
uint8_t  setbits 
)
private

Modify a register in the BMI055_gyro.

Bits are cleared before bits are set.

Parameters
regThe register to modify.
clearbitsBits in the register to clear.
setbitsBits in the register to set.

Definition at line 186 of file BMI055_gyro.cpp.

References BMI055::read_reg(), and write_checked_reg().

Referenced by gyro_set_sample_rate(), and set_gyro_range().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

BMI055_gyro BMI055_gyro::operator= ( const BMI055_gyro )
private

◆ print_info()

void BMI055_gyro::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 415 of file BMI055_gyro.cpp.

References _bad_registers, _bad_transfers, _checked_bad, BMI055::_checked_next, _checked_registers, _checked_values, _px4_gyro, _sample_perf, BMI055_GYRO_NUM_CHECKED_REGISTERS, perf_print_counter(), PX4Gyroscope::print_status(), and BMI055::read_reg().

Here is the call graph for this function:

◆ print_registers()

void BMI055_gyro::print_registers ( )

Definition at line 447 of file BMI055_gyro.cpp.

References _checked_registers, and BMI055::read_reg().

Referenced by test_error().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe()

int BMI055_gyro::probe ( )
protectedvirtual

Definition at line 124 of file BMI055_gyro.cpp.

References _checked_bad, _checked_values, BMI055::_whoami, BMI055_GYR_CHIP_ID, BMI055_GYR_WHO_AM_I, DEVICE_DEBUG, OK, and BMI055::read_reg().

Here is the call graph for this function:

◆ reset()

int BMI055_gyro::reset ( )
private

Reset chip.

Resets the chip and measurements ranges, but not scale and offset.

Definition at line 87 of file BMI055_gyro.cpp.

References _checked_registers, _checked_values, BMI055_GYR_BW, BMI055_GYR_DRDY_INT1, BMI055_GYR_DRDY_INT_EN, BMI055_GYR_INT_EN_0, BMI055_GYR_INT_MAP_1, BMI055_GYR_LPM1, BMI055_GYR_RANGE, BMI055_GYR_SOFTRESET, BMI055_GYRO_DEFAULT_RANGE_DPS, BMI055_GYRO_DEFAULT_RATE, BMI055_GYRO_NORMAL, BMI055_GYRO_NUM_CHECKED_REGISTERS, BMI055_SOFT_RESET, gyro_set_sample_rate(), OK, BMI055::read_reg(), set_gyro_range(), write_checked_reg(), and BMI055::write_reg().

Referenced by init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Run()

void BMI055_gyro::Run ( )
overrideprivate

Definition at line 271 of file BMI055_gyro.cpp.

References measure().

Here is the call graph for this function:

◆ set_gyro_range()

int BMI055_gyro::set_gyro_range ( unsigned  max_dps)
private

Set the BMI055_gyro measurement range.

Parameters
max_dpsThe maximum DPS value the range must support.
Returns
OK if the value can be supported, -EINVAL otherwise.

Definition at line 208 of file BMI055_gyro.cpp.

References _px4_gyro, BMI055_GYR_RANGE, BMI055_GYRO_RANGE_1000_DPS, BMI055_GYRO_RANGE_125_DPS, BMI055_GYRO_RANGE_2000_DPS, BMI055_GYRO_RANGE_250_DPS, BMI055_GYRO_RANGE_500_DPS, f(), M_PI_F, modify_reg(), OK, and PX4Gyroscope::set_scale().

Referenced by reset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

void BMI055_gyro::start ( )

Definition at line 255 of file BMI055_gyro.cpp.

References BMI055_GYRO_DEFAULT_RATE, BMI055_TIMER_REDUCTION, and stop().

Here is the call graph for this function:

◆ stop()

void BMI055_gyro::stop ( )
private

Stop automatic measurement.

Definition at line 265 of file BMI055_gyro.cpp.

Referenced by start(), and ~BMI055_gyro().

Here is the caller graph for this function:

◆ test_error()

void BMI055_gyro::test_error ( )

Definition at line 178 of file BMI055_gyro.cpp.

References BMI055_GYR_SOFTRESET, BMI055_SOFT_RESET, print_registers(), and BMI055::write_reg().

Here is the call graph for this function:

◆ write_checked_reg()

void BMI055_gyro::write_checked_reg ( unsigned  reg,
uint8_t  value 
)
private

Write a register in the BMI055_gyro, updating _checked_values.

Parameters
regThe register to write.
valueThe new value to write.

Definition at line 195 of file BMI055_gyro.cpp.

References _checked_bad, _checked_registers, _checked_values, BMI055_GYRO_NUM_CHECKED_REGISTERS, and BMI055::write_reg().

Referenced by modify_reg(), and reset().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _bad_registers

perf_counter_t BMI055_gyro::_bad_registers
private

Definition at line 165 of file BMI055_gyro.hpp.

Referenced by check_registers(), measure(), print_info(), and ~BMI055_gyro().

◆ _bad_transfers

perf_counter_t BMI055_gyro::_bad_transfers
private

Definition at line 164 of file BMI055_gyro.hpp.

Referenced by measure(), print_info(), and ~BMI055_gyro().

◆ _checked_bad

uint8_t BMI055_gyro::_checked_bad[BMI055_GYRO_NUM_CHECKED_REGISTERS]
private

Definition at line 173 of file BMI055_gyro.hpp.

Referenced by check_registers(), print_info(), probe(), and write_checked_reg().

◆ _checked_registers

const uint8_t BMI055_gyro::_checked_registers
staticprivate

◆ _checked_values

uint8_t BMI055_gyro::_checked_values[BMI055_GYRO_NUM_CHECKED_REGISTERS]
private

Definition at line 172 of file BMI055_gyro.hpp.

Referenced by check_registers(), print_info(), probe(), reset(), and write_checked_reg().

◆ _px4_gyro

PX4Gyroscope BMI055_gyro::_px4_gyro
private

Definition at line 161 of file BMI055_gyro.hpp.

Referenced by BMI055_gyro(), measure(), print_info(), and set_gyro_range().

◆ _sample_perf

perf_counter_t BMI055_gyro::_sample_perf
private

Definition at line 163 of file BMI055_gyro.hpp.

Referenced by measure(), print_info(), and ~BMI055_gyro().


The documentation for this class was generated from the following files: