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

#include <BMI088_accel.hpp>

Inheritance diagram for BMI088_accel:
Collaboration diagram for BMI088_accel:

Public Member Functions

 BMI088_accel (int bus, const char *path_accel, uint32_t device, enum Rotation rotation)
 
virtual ~BMI088_accel ()
 
virtual int init ()
 
void start ()
 
virtual uint8_t read_reg (unsigned reg)
 Read a register from the BMI088. More...
 
virtual uint16_t read_reg16 (unsigned reg)
 
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
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_accel. More...
 
void write_checked_reg (unsigned reg, uint8_t value)
 Write a register in the BMI088_accel, updating _checked_values. More...
 
int set_accel_range (unsigned max_g)
 Set the BMI088_accel measurement range. More...
 
int accel_set_sample_rate (float desired_sample_rate_hz)
 Set accel sample rate. More...
 
void check_registers (void)
 
 BMI088_accel (const BMI088_accel &)
 
BMI088_accel operator= (const BMI088_accel &)
 

Private Attributes

PX4Accelerometer _px4_accel
 
perf_counter_t _sample_perf
 
perf_counter_t _bad_transfers
 
perf_counter_t _bad_registers
 
perf_counter_t _duplicates
 
uint8_t _checked_values [BMI088_ACCEL_NUM_CHECKED_REGISTERS]
 
uint8_t _checked_bad [BMI088_ACCEL_NUM_CHECKED_REGISTERS]
 
bool _got_duplicate
 

Static Private Attributes

static const uint8_t _checked_registers [BMI088_ACCEL_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 157 of file BMI088_accel.hpp.

Constructor & Destructor Documentation

◆ BMI088_accel() [1/2]

BMI088_accel::BMI088_accel ( int  bus,
const char *  path_accel,
uint32_t  device,
enum Rotation  rotation 
)

Definition at line 55 of file BMI088_accel.cpp.

References _px4_accel, DRV_DEVTYPE_BMI088, and PX4Accelerometer::set_device_type().

Here is the call graph for this function:

◆ ~BMI088_accel()

BMI088_accel::~BMI088_accel ( )
virtual

Definition at line 68 of file BMI088_accel.cpp.

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

Here is the call graph for this function:

◆ BMI088_accel() [2/2]

BMI088_accel::BMI088_accel ( const BMI088_accel )
private

Member Function Documentation

◆ accel_set_sample_rate()

int BMI088_accel::accel_set_sample_rate ( float  desired_sample_rate_hz)
private

Set accel sample rate.

Definition at line 203 of file BMI088_accel.cpp.

References BMI088_ACC_CONF, BMI088_ACC_CONF_ODR_100, BMI088_ACC_CONF_ODR_12_5, BMI088_ACC_CONF_ODR_1600, BMI088_ACC_CONF_ODR_200, BMI088_ACC_CONF_ODR_25, BMI088_ACC_CONF_ODR_400, BMI088_ACC_CONF_ODR_50, BMI088_ACC_CONF_ODR_800, modify_reg(), and OK.

Referenced by reset().

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

◆ check_registers()

void BMI088_accel::check_registers ( void  )
private

Definition at line 354 of file BMI088_accel.cpp.

References _bad_registers, _checked_bad, BMI088::_checked_next, _checked_registers, _checked_values, BMI088::_register_wait, BMI088::_reset_wait, BMI088_ACC_SOFTRESET, BMI088_ACCEL_NUM_CHECKED_REGISTERS, BMI088_SOFT_RESET, hrt_absolute_time(), perf_count(), 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:

◆ init()

int BMI088_accel::init ( )
virtual

Definition at line 81 of file BMI088_accel.cpp.

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

Here is the call graph for this function:

◆ measure()

void BMI088_accel::measure ( )
private

Fetch measurements from the sensor and update the report buffers.

Definition at line 397 of file BMI088_accel.cpp.

References _accel_last_temperature_copy, _bad_registers, _bad_transfers, _duplicates, _got_duplicate, _px4_accel, BMI088::_register_wait, BMI088::_reset_wait, _sample_perf, BMI088_ACC_STATUS, BMI088_ACC_STATUS_DRDY, BMI088_ACC_TEMP_H, BMI088_ACC_X_L, check_registers(), DIR_READ, f(), hrt_absolute_time(), hrt_abstime, OK, perf_begin(), perf_count(), perf_end(), perf_event_count(), read_reg(), PX4Accelerometer::set_error_count(), PX4Accelerometer::set_temperature(), status, and PX4Accelerometer::update().

Referenced by Run().

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

◆ modify_reg()

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

Modify a register in the BMI088_accel.

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 263 of file BMI088_accel.cpp.

References read_reg(), and write_checked_reg().

Referenced by accel_set_sample_rate(), and set_accel_range().

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

◆ operator=()

BMI088_accel BMI088_accel::operator= ( const BMI088_accel )
private

◆ print_info()

void BMI088_accel::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 533 of file BMI088_accel.cpp.

References _bad_registers, _bad_transfers, _checked_bad, BMI088::_checked_next, _checked_registers, _checked_values, _duplicates, _px4_accel, _sample_perf, BMI088_ACCEL_NUM_CHECKED_REGISTERS, perf_print_counter(), PX4Accelerometer::print_status(), and read_reg().

Here is the call graph for this function:

◆ print_registers()

void BMI088_accel::print_registers ( )

Definition at line 566 of file BMI088_accel.cpp.

References _checked_registers, and 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_accel::probe ( )
protectedvirtual

Definition at line 178 of file BMI088_accel.cpp.

References _checked_bad, _checked_values, BMI088::_whoami, BMI088_ACC_CHIP_ID, BMI088_ACC_WHO_AM_I, DEVICE_DEBUG, OK, and read_reg().

Here is the call graph for this function:

◆ read_reg()

uint8_t BMI088_accel::read_reg ( unsigned  reg)
virtual

Read a register from the BMI088.

Parameters
Theregister to read.
Returns
The value that was read.

Reimplemented from BMI088.

Definition at line 96 of file BMI088_accel.cpp.

References DIR_READ.

Referenced by check_registers(), measure(), modify_reg(), print_info(), print_registers(), probe(), and reset().

Here is the caller graph for this function:

◆ read_reg16()

uint16_t BMI088_accel::read_reg16 ( unsigned  reg)
virtual

Reimplemented from BMI088.

Definition at line 107 of file BMI088_accel.cpp.

References DIR_READ.

◆ reset()

int BMI088_accel::reset ( )
private

Reset chip.

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

Definition at line 117 of file BMI088_accel.cpp.

References _checked_registers, _checked_values, accel_set_sample_rate(), BMI088_ACC_CHIP_ID, BMI088_ACC_INT1_INT2_MAP_DATA, BMI088_ACC_INT1_INT2_MAP_DATA_INT1_DRDY, BMI088_ACC_INT1_IO_CONF, BMI088_ACC_INT1_IO_CONF_ACTIVE_HIGH, BMI088_ACC_INT1_IO_CONF_INT1_OUT, BMI088_ACC_INT1_IO_CONF_PP, BMI088_ACC_PWR_CONF, BMI088_ACC_PWR_CONF_ACTIVE, BMI088_ACC_PWR_CTRL, BMI088_ACC_PWR_CTRL_EN, BMI088_ACC_SOFTRESET, BMI088_ACCEL_DEFAULT_RANGE_G, BMI088_ACCEL_DEFAULT_RATE, BMI088_ACCEL_NUM_CHECKED_REGISTERS, BMI088_SOFT_RESET, OK, read_reg(), set_accel_range(), write_checked_reg(), and BMI088::write_reg().

Referenced by init(), and start().

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

◆ Run()

void BMI088_accel::Run ( )
overrideprivate

Definition at line 347 of file BMI088_accel.cpp.

References measure().

Here is the call graph for this function:

◆ set_accel_range()

int BMI088_accel::set_accel_range ( unsigned  max_g)
private

Set the BMI088_accel measurement range.

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

Definition at line 285 of file BMI088_accel.cpp.

References _px4_accel, BMI088_ACC_RANGE, BMI088_ACCEL_RANGE_12_G, BMI088_ACCEL_RANGE_24_G, BMI088_ACCEL_RANGE_3_G, BMI088_ACCEL_RANGE_6_G, CONSTANTS_ONE_G, modify_reg(), OK, and PX4Accelerometer::set_scale().

Referenced by reset().

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

◆ start()

void BMI088_accel::start ( )

Definition at line 327 of file BMI088_accel.cpp.

References BMI088_ACCEL_DEFAULT_RATE, BMI088_TIMER_REDUCTION, reset(), and stop().

Here is the call graph for this function:

◆ stop()

void BMI088_accel::stop ( )
private

Stop automatic measurement.

Definition at line 341 of file BMI088_accel.cpp.

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

Here is the caller graph for this function:

◆ test_error()

void BMI088_accel::test_error ( )

Definition at line 255 of file BMI088_accel.cpp.

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

Here is the call graph for this function:

◆ write_checked_reg()

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

Write a register in the BMI088_accel, updating _checked_values.

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

Definition at line 272 of file BMI088_accel.cpp.

References _checked_bad, _checked_registers, _checked_values, BMI088_ACCEL_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_accel::_bad_registers
private

Definition at line 194 of file BMI088_accel.hpp.

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

◆ _bad_transfers

perf_counter_t BMI088_accel::_bad_transfers
private

Definition at line 193 of file BMI088_accel.hpp.

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

◆ _checked_bad

uint8_t BMI088_accel::_checked_bad[BMI088_ACCEL_NUM_CHECKED_REGISTERS]
private

Definition at line 203 of file BMI088_accel.hpp.

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

◆ _checked_registers

◆ _checked_values

uint8_t BMI088_accel::_checked_values[BMI088_ACCEL_NUM_CHECKED_REGISTERS]
private

Definition at line 202 of file BMI088_accel.hpp.

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

◆ _duplicates

perf_counter_t BMI088_accel::_duplicates
private

Definition at line 195 of file BMI088_accel.hpp.

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

◆ _got_duplicate

bool BMI088_accel::_got_duplicate
private

Definition at line 205 of file BMI088_accel.hpp.

Referenced by measure().

◆ _px4_accel

PX4Accelerometer BMI088_accel::_px4_accel
private

Definition at line 190 of file BMI088_accel.hpp.

Referenced by BMI088_accel(), measure(), print_info(), and set_accel_range().

◆ _sample_perf

perf_counter_t BMI088_accel::_sample_perf
private

Definition at line 192 of file BMI088_accel.hpp.

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


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