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

#include <BMI088_gyro.hpp>

Inheritance diagram for BMI088_gyro:
Collaboration diagram for BMI088_gyro:

Classes

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

Public Member Functions

 BMI088_gyro (int bus, const char *path_gyro, uint32_t device, enum Rotation rotation)
 
virtual ~BMI088_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 BMI088
 BMI088 (const char *name, const char *devname, int bus, uint32_t device, enum spi_mode_e mode, uint32_t frequency, enum Rotation rotation)
 
virtual ~BMI088 ()=default
 

Protected Member Functions

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

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 BMI088_gyro. More...
 
void write_checked_reg (unsigned reg, uint8_t value)
 Write a register in the BMI088_gyro, updating _checked_values. More...
 
int set_gyro_range (unsigned max_dps)
 Set the BMI088_gyro measurement range. More...
 
int gyro_set_sample_rate (float desired_sample_rate_hz)
 
void check_registers (void)
 
 BMI088_gyro (const BMI088_gyro &)
 
BMI088_gyro operator= (const BMI088_gyro &)
 

Static Private Member Functions

static void measure_trampoline (void *arg)
 Static trampoline from the hrt_call context; because we don't have a generic hrt wrapper yet. More...
 

Private Attributes

PX4Gyroscope _px4_gyro
 
perf_counter_t _sample_perf
 
perf_counter_t _bad_transfers
 
perf_counter_t _bad_registers
 
uint8_t _checked_values [BMI088_GYRO_NUM_CHECKED_REGISTERS]
 
uint8_t _checked_bad [BMI088_GYRO_NUM_CHECKED_REGISTERS]
 
float _last_temperature
 

Static Private Attributes

static const uint8_t _checked_registers [BMI088_GYRO_NUM_CHECKED_REGISTERS]
 

Additional Inherited Members

- Protected Attributes inherited from BMI088
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 132 of file BMI088_gyro.hpp.

Constructor & Destructor Documentation

◆ BMI088_gyro() [1/2]

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

Definition at line 58 of file BMI088_gyro.cpp.

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

Here is the call graph for this function:

◆ ~BMI088_gyro()

BMI088_gyro::~BMI088_gyro ( )
virtual

Definition at line 69 of file BMI088_gyro.cpp.

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

Here is the call graph for this function:

◆ BMI088_gyro() [2/2]

BMI088_gyro::BMI088_gyro ( const BMI088_gyro )
private

Member Function Documentation

◆ check_registers()

void BMI088_gyro::check_registers ( void  )
private

Definition at line 296 of file BMI088_gyro.cpp.

References _bad_registers, _checked_bad, BMI088::_checked_next, _checked_registers, _checked_values, BMI088::_register_wait, BMI088::_reset_wait, BMI088_GYR_SOFTRESET, BMI088_GYRO_NUM_CHECKED_REGISTERS, BMI088_SOFT_RESET, hrt_absolute_time(), perf_count(), BMI088::read_reg(), and BMI088::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 BMI088_gyro::gyro_set_sample_rate ( float  desired_sample_rate_hz)
private

Definition at line 153 of file BMI088_gyro.cpp.

References BMI088_GYR_BW, BMI088_GYRO_BW_MASK, BMI088_GYRO_RATE_100, BMI088_GYRO_RATE_1000, BMI088_GYRO_RATE_2000, BMI088_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 BMI088_gyro::init ( )
virtual

Definition at line 81 of file BMI088_gyro.cpp.

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

Here is the call graph for this function:

◆ measure()

void BMI088_gyro::measure ( )
private

Fetch measurements from the sensor and update the report buffers.

Definition at line 339 of file BMI088_gyro.cpp.

References _accel_last_temperature_copy, _bad_registers, _bad_transfers, _last_temperature, _px4_gyro, BMI088::_register_wait, BMI088::_reset_wait, _sample_perf, BMI088_GYR_X_L, check_registers(), BMI088_gyro::BMI_GyroReport::cmd, DIR_READ, hrt_absolute_time(), hrt_abstime, OK, perf_begin(), perf_count(), perf_end(), perf_event_count(), PX4Gyroscope::set_error_count(), PX4Gyroscope::set_temperature(), and PX4Gyroscope::update().

Referenced by measure_trampoline(), and Run().

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

◆ measure_trampoline()

void BMI088_gyro::measure_trampoline ( void *  arg)
staticprivate

Static trampoline from the hrt_call context; because we don't have a generic hrt wrapper yet.

Called by the HRT in interrupt context at the specified rate if automatic polling is enabled.

Parameters
argInstance pointer for the driver that is polling.

Definition at line 287 of file BMI088_gyro.cpp.

References measure().

Here is the call graph for this function:

◆ modify_reg()

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

Modify a register in the BMI088_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 195 of file BMI088_gyro.cpp.

References BMI088::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=()

BMI088_gyro BMI088_gyro::operator= ( const BMI088_gyro )
private

◆ print_info()

void BMI088_gyro::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 429 of file BMI088_gyro.cpp.

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

Here is the call graph for this function:

◆ print_registers()

void BMI088_gyro::print_registers ( )

Definition at line 461 of file BMI088_gyro.cpp.

References _checked_registers, and BMI088::read_reg().

Referenced by test_error().

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

◆ probe()

int BMI088_gyro::probe ( )
protectedvirtual

Definition at line 132 of file BMI088_gyro.cpp.

References _checked_bad, _checked_values, BMI088::_whoami, BMI088_GYR_CHIP_ID, BMI088_GYR_WHO_AM_I, DEVICE_DEBUG, OK, and BMI088::read_reg().

Here is the call graph for this function:

◆ reset()

int BMI088_gyro::reset ( )
private

Reset chip.

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

Definition at line 95 of file BMI088_gyro.cpp.

References _checked_registers, _checked_values, BMI088_GYR_BW, BMI088_GYR_DRDY_INT1, BMI088_GYR_DRDY_INT_EN, BMI088_GYR_INT_EN_0, BMI088_GYR_INT_MAP_1, BMI088_GYR_LPM1, BMI088_GYR_RANGE, BMI088_GYR_SOFTRESET, BMI088_GYRO_DEFAULT_RANGE_DPS, BMI088_GYRO_DEFAULT_RATE, BMI088_GYRO_NORMAL, BMI088_GYRO_NUM_CHECKED_REGISTERS, BMI088_SOFT_RESET, gyro_set_sample_rate(), OK, BMI088::read_reg(), set_gyro_range(), write_checked_reg(), and BMI088::write_reg().

Referenced by init().

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

◆ Run()

void BMI088_gyro::Run ( )
overrideprivate

Definition at line 280 of file BMI088_gyro.cpp.

References measure().

Here is the call graph for this function:

◆ set_gyro_range()

int BMI088_gyro::set_gyro_range ( unsigned  max_dps)
private

Set the BMI088_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 217 of file BMI088_gyro.cpp.

References _px4_gyro, BMI088_GYR_RANGE, BMI088_GYRO_RANGE_1000_DPS, BMI088_GYRO_RANGE_125_DPS, BMI088_GYRO_RANGE_2000_DPS, BMI088_GYRO_RANGE_250_DPS, BMI088_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 BMI088_gyro::start ( )

Definition at line 264 of file BMI088_gyro.cpp.

References BMI088_GYRO_DEFAULT_RATE, BMI088_TIMER_REDUCTION, and stop().

Here is the call graph for this function:

◆ stop()

void BMI088_gyro::stop ( )
private

Stop automatic measurement.

Definition at line 274 of file BMI088_gyro.cpp.

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

Here is the caller graph for this function:

◆ test_error()

void BMI088_gyro::test_error ( )

Definition at line 187 of file BMI088_gyro.cpp.

References BMI088_GYR_SOFTRESET, BMI088_SOFT_RESET, print_registers(), and BMI088::write_reg().

Here is the call graph for this function:

◆ write_checked_reg()

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

Write a register in the BMI088_gyro, updating _checked_values.

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

Definition at line 204 of file BMI088_gyro.cpp.

References _checked_bad, _checked_registers, _checked_values, BMI088_GYRO_NUM_CHECKED_REGISTERS, and BMI088::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 BMI088_gyro::_bad_registers
private

Definition at line 163 of file BMI088_gyro.hpp.

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

◆ _bad_transfers

perf_counter_t BMI088_gyro::_bad_transfers
private

Definition at line 162 of file BMI088_gyro.hpp.

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

◆ _checked_bad

uint8_t BMI088_gyro::_checked_bad[BMI088_GYRO_NUM_CHECKED_REGISTERS]
private

Definition at line 171 of file BMI088_gyro.hpp.

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

◆ _checked_registers

const uint8_t BMI088_gyro::_checked_registers
staticprivate

◆ _checked_values

uint8_t BMI088_gyro::_checked_values[BMI088_GYRO_NUM_CHECKED_REGISTERS]
private

Definition at line 170 of file BMI088_gyro.hpp.

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

◆ _last_temperature

float BMI088_gyro::_last_temperature
private

Definition at line 174 of file BMI088_gyro.hpp.

Referenced by measure().

◆ _px4_gyro

PX4Gyroscope BMI088_gyro::_px4_gyro
private

Definition at line 159 of file BMI088_gyro.hpp.

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

◆ _sample_perf

perf_counter_t BMI088_gyro::_sample_perf
private

Definition at line 161 of file BMI088_gyro.hpp.

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


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