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

#include <BMI055_accel.hpp>

Inheritance diagram for BMI055_accel:
Collaboration diagram for BMI055_accel:

Public Member Functions

 BMI055_accel (int bus, const char *path_accel, uint32_t device, enum Rotation rotation)
 
virtual ~BMI055_accel ()
 
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_accel. More...
 
void write_checked_reg (unsigned reg, uint8_t value)
 Write a register in the BMI055_accel, updating _checked_values. More...
 
int set_accel_range (unsigned max_g)
 Set the BMI055_accel measurement range. More...
 
void check_registers (void)
 
 BMI055_accel (const BMI055_accel &)
 
BMI055_accel operator= (const BMI055_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 [BMI055_ACCEL_NUM_CHECKED_REGISTERS]
 
uint8_t _checked_bad [BMI055_ACCEL_NUM_CHECKED_REGISTERS]
 
bool _got_duplicate
 

Static Private Attributes

static const uint8_t _checked_registers [BMI055_ACCEL_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 142 of file BMI055_accel.hpp.

Constructor & Destructor Documentation

◆ BMI055_accel() [1/2]

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

Definition at line 47 of file BMI055_accel.cpp.

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

Here is the call graph for this function:

◆ ~BMI055_accel()

BMI055_accel::~BMI055_accel ( )
virtual

Definition at line 60 of file BMI055_accel.cpp.

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

Here is the call graph for this function:

◆ BMI055_accel() [2/2]

BMI055_accel::BMI055_accel ( const BMI055_accel )
private

Member Function Documentation

◆ check_registers()

void BMI055_accel::check_registers ( void  )
private

Definition at line 242 of file BMI055_accel.cpp.

References _bad_registers, _checked_bad, BMI055::_checked_next, _checked_registers, _checked_values, BMI055::_register_wait, BMI055::_reset_wait, BMI055_ACC_SOFTRESET, BMI055_ACCEL_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:

◆ init()

int BMI055_accel::init ( )
virtual

Definition at line 73 of file BMI055_accel.cpp.

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

Here is the call graph for this function:

◆ measure()

void BMI055_accel::measure ( )
private

Fetch measurements from the sensor and update the report buffers.

Definition at line 285 of file BMI055_accel.cpp.

References _bad_registers, _bad_transfers, _duplicates, _got_duplicate, _px4_accel, BMI055::_register_wait, BMI055::_reset_wait, _sample_perf, BMI055_ACC_X_L, BMI055_NEW_DATA_MASK, check_registers(), DIR_READ, hrt_absolute_time(), hrt_abstime, OK, perf_begin(), perf_count(), perf_end(), perf_event_count(), PX4Accelerometer::set_error_count(), PX4Accelerometer::set_temperature(), 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 BMI055_accel::modify_reg ( unsigned  reg,
uint8_t  clearbits,
uint8_t  setbits 
)
private

Modify a register in the BMI055_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 155 of file BMI055_accel.cpp.

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

Referenced by set_accel_range().

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

◆ operator=()

BMI055_accel BMI055_accel::operator= ( const BMI055_accel )
private

◆ print_info()

void BMI055_accel::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 405 of file BMI055_accel.cpp.

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

Here is the call graph for this function:

◆ print_registers()

void BMI055_accel::print_registers ( )

Definition at line 436 of file BMI055_accel.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_accel::probe ( )
protectedvirtual

Definition at line 124 of file BMI055_accel.cpp.

References _checked_bad, _checked_values, BMI055::_whoami, BMI055_ACC_CHIP_ID, BMI055_ACC_WHO_AM_I, DEVICE_DEBUG, OK, and BMI055::read_reg().

Here is the call graph for this function:

◆ reset()

int BMI055_accel::reset ( )
private

Reset chip.

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

Definition at line 87 of file BMI055_accel.cpp.

References _checked_registers, _checked_values, BMI055_ACC_BW, BMI055_ACC_DRDY_INT1, BMI055_ACC_DRDY_INT_EN, BMI055_ACC_INT_EN_1, BMI055_ACC_INT_MAP_1, BMI055_ACC_PMU_LPW, BMI055_ACC_RANGE, BMI055_ACC_SOFTRESET, BMI055_ACCEL_BW_500, BMI055_ACCEL_DEFAULT_RANGE_G, BMI055_ACCEL_NORMAL, BMI055_ACCEL_NUM_CHECKED_REGISTERS, BMI055_ACCEL_RANGE_2_G, BMI055_SOFT_RESET, OK, BMI055::read_reg(), set_accel_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_accel::Run ( )
overrideprivate

Definition at line 235 of file BMI055_accel.cpp.

References measure().

Here is the call graph for this function:

◆ set_accel_range()

int BMI055_accel::set_accel_range ( unsigned  max_g)
private

Set the BMI055_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 177 of file BMI055_accel.cpp.

References _px4_accel, BMI055_ACC_RANGE, BMI055_ACCEL_RANGE_16_G, BMI055_ACCEL_RANGE_2_G, BMI055_ACCEL_RANGE_4_G, BMI055_ACCEL_RANGE_8_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 BMI055_accel::start ( )

Definition at line 219 of file BMI055_accel.cpp.

References BMI055_ACCEL_DEFAULT_RATE, BMI055_TIMER_REDUCTION, and stop().

Here is the call graph for this function:

◆ stop()

void BMI055_accel::stop ( )
private

Stop automatic measurement.

Definition at line 229 of file BMI055_accel.cpp.

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

Here is the caller graph for this function:

◆ test_error()

void BMI055_accel::test_error ( )

Definition at line 147 of file BMI055_accel.cpp.

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

Here is the call graph for this function:

◆ write_checked_reg()

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

Write a register in the BMI055_accel, updating _checked_values.

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

Definition at line 164 of file BMI055_accel.cpp.

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

Definition at line 173 of file BMI055_accel.hpp.

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

◆ _bad_transfers

perf_counter_t BMI055_accel::_bad_transfers
private

Definition at line 172 of file BMI055_accel.hpp.

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

◆ _checked_bad

uint8_t BMI055_accel::_checked_bad[BMI055_ACCEL_NUM_CHECKED_REGISTERS]
private

Definition at line 182 of file BMI055_accel.hpp.

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

◆ _checked_registers

const uint8_t BMI055_accel::_checked_registers
staticprivate

◆ _checked_values

uint8_t BMI055_accel::_checked_values[BMI055_ACCEL_NUM_CHECKED_REGISTERS]
private

Definition at line 181 of file BMI055_accel.hpp.

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

◆ _duplicates

perf_counter_t BMI055_accel::_duplicates
private

Definition at line 174 of file BMI055_accel.hpp.

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

◆ _got_duplicate

bool BMI055_accel::_got_duplicate
private

Definition at line 184 of file BMI055_accel.hpp.

Referenced by measure().

◆ _px4_accel

PX4Accelerometer BMI055_accel::_px4_accel
private

Definition at line 169 of file BMI055_accel.hpp.

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

◆ _sample_perf

perf_counter_t BMI055_accel::_sample_perf
private

Definition at line 171 of file BMI055_accel.hpp.

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


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