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

#include <FXOS8701CQ.hpp>

Inheritance diagram for FXOS8701CQ:
Collaboration diagram for FXOS8701CQ:

Public Member Functions

 FXOS8701CQ (int bus, uint32_t device, enum Rotation rotation)
 
virtual ~FXOS8701CQ ()
 
virtual int init ()
 
void print_info ()
 
void print_registers ()
 
void test_error ()
 

Protected Member Functions

virtual int probe ()
 

Private Member Functions

void Run () override
 
void start ()
 
void stop ()
 
void reset ()
 
void check_registers ()
 check key registers for correct values More...
 
uint8_t read_reg (unsigned reg)
 Read a register from the FXOS8701C. More...
 
void write_reg (unsigned reg, uint8_t value)
 Write a register in the FXOS8701C. More...
 
void modify_reg (unsigned reg, uint8_t clearbits, uint8_t setbits)
 Modify a register in the FXOS8701C. More...
 
void write_checked_reg (unsigned reg, uint8_t value)
 Write a register in the FXOS8701C, updating _checked_values. More...
 
int accel_set_range (unsigned max_g)
 Set the FXOS8701C accel measurement range. More...
 
int mag_set_range (unsigned max_g)
 Set the FXOS8701C mag measurement range. More...
 
int accel_set_samplerate (unsigned frequency)
 Set the FXOS8701C internal accel and mag sampling frequency. More...
 

Private Attributes

PX4Accelerometer _px4_accel
 
PX4Magnetometer _px4_mag
 
hrt_abstime _mag_last_measure {0}
 
perf_counter_t _mag_sample_perf
 
unsigned _accel_samplerate {FXOS8701C_ACCEL_DEFAULT_RATE}
 
perf_counter_t _accel_sample_perf
 
perf_counter_t _bad_registers
 
perf_counter_t _accel_duplicates
 
uint8_t _register_wait {0}
 
uint8_t _checked_values [FXOS8701C_NUM_CHECKED_REGISTERS] {}
 
uint8_t _checked_next {0}
 

Static Private Attributes

static constexpr int FXOS8701C_NUM_CHECKED_REGISTERS {5}
 
static const uint8_t _checked_registers [FXOS8701C_NUM_CHECKED_REGISTERS]
 

Detailed Description

Definition at line 114 of file FXOS8701CQ.hpp.

Constructor & Destructor Documentation

◆ FXOS8701CQ()

FXOS8701CQ::FXOS8701CQ ( int  bus,
uint32_t  device,
enum Rotation  rotation 
)

Definition at line 56 of file FXOS8701CQ.cpp.

References _px4_accel, _px4_mag, DRV_ACC_DEVTYPE_FXOS8701C, f(), PX4Magnetometer::set_device_type(), PX4Accelerometer::set_device_type(), and PX4Magnetometer::set_scale().

Here is the call graph for this function:

◆ ~FXOS8701CQ()

FXOS8701CQ::~FXOS8701CQ ( )
virtual

Definition at line 78 of file FXOS8701CQ.cpp.

References _accel_duplicates, _accel_sample_perf, _bad_registers, _mag_sample_perf, perf_free(), and stop().

Here is the call graph for this function:

Member Function Documentation

◆ accel_set_range()

int FXOS8701CQ::accel_set_range ( unsigned  max_g)
private

Set the FXOS8701C accel measurement range.

Parameters
max_gThe measurement range of the accel is in g (9.81m/s^2) Zero selects the maximum supported range.
Returns
OK if the value can be supported, -ERANGE otherwise.

Definition at line 194 of file FXOS8701CQ.cpp.

References _px4_accel, CONSTANTS_ONE_G, FXOS8701CQ_XYZ_DATA_CFG, modify_reg(), OK, PX4Accelerometer::set_scale(), XYZ_DATA_CFG_FS_2G, XYZ_DATA_CFG_FS_4G, XYZ_DATA_CFG_FS_8G, and XYZ_DATA_CFG_FS_MASK.

Referenced by reset().

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

◆ accel_set_samplerate()

int FXOS8701CQ::accel_set_samplerate ( unsigned  frequency)
private

Set the FXOS8701C internal accel and mag sampling frequency.

Parameters
frequencyThe internal accel and mag sampling frequency is set to not less than this value. Zero selects the maximum rate supported.
Returns
OK if the value can be supported.

Definition at line 242 of file FXOS8701CQ.cpp.

References _accel_samplerate, CTRL_REG1_ACTIVE, CTRL_REG1_DR, CTRL_REG1_DR_MASK, FXOS8701C_ACCEL_DEFAULT_RATE, FXOS8701CQ_CTRL_REG1, modify_reg(), OK, and read_reg().

Referenced by reset().

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

◆ check_registers()

void FXOS8701CQ::check_registers ( void  )
private

check key registers for correct values

Definition at line 301 of file FXOS8701CQ.cpp.

References _bad_registers, _checked_next, _checked_registers, _checked_values, _register_wait, FXOS8701C_NUM_CHECKED_REGISTERS, perf_count(), read_reg(), and write_reg().

Referenced by Run().

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

◆ init()

int FXOS8701CQ::init ( )
virtual

Definition at line 94 of file FXOS8701CQ.cpp.

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

Referenced by fxos8701cq::start().

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

◆ mag_set_range()

int FXOS8701CQ::mag_set_range ( unsigned  max_g)
private

Set the FXOS8701C mag measurement range.

Parameters
max_gaThe measurement range of the mag is in Ga Zero selects the maximum supported range.
Returns
OK if the value can be supported, -ERANGE otherwise.

Definition at line 230 of file FXOS8701CQ.cpp.

References _px4_mag, OK, and PX4Magnetometer::set_scale().

Here is the call graph for this function:

◆ modify_reg()

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

Modify a register in the FXOS8701C.

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 185 of file FXOS8701CQ.cpp.

References read_reg(), and write_checked_reg().

Referenced by accel_set_range(), and accel_set_samplerate().

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

◆ print_info()

void FXOS8701CQ::print_info ( )

Definition at line 410 of file FXOS8701CQ.cpp.

References _accel_duplicates, _accel_sample_perf, _bad_registers, _checked_next, _checked_registers, _checked_values, _mag_sample_perf, FXOS8701C_NUM_CHECKED_REGISTERS, perf_print_counter(), and read_reg().

Referenced by fxos8701cq::info().

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

◆ print_registers()

void FXOS8701CQ::print_registers ( )

Definition at line 435 of file FXOS8701CQ.cpp.

References DEF_REG, FXOS8701CQ_CTRL_REG1, FXOS8701CQ_CTRL_REG2, FXOS8701CQ_DR_STATUS, FXOS8701CQ_M_CTRL_REG1, FXOS8701CQ_M_CTRL_REG2, FXOS8701CQ_M_CTRL_REG3, FXOS8701CQ_M_DR_STATUS, FXOS8701CQ_M_OUT_X_MSB, FXOS8701CQ_OUT_X_MSB, FXOS8701CQ_WHOAMI, FXOS8701CQ_XYZ_DATA_CFG, name, and read_reg().

Referenced by fxos8701cq::regdump().

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

◆ probe()

int FXOS8701CQ::probe ( )
protectedvirtual

Definition at line 132 of file FXOS8701CQ.cpp.

References _checked_values, FXOS8700CQ_WHOAMI_VAL, FXOS8701CQ_WHOAMI, FXOS8701CQ_WHOAMI_VAL, OK, and read_reg().

Here is the call graph for this function:

◆ read_reg()

uint8_t FXOS8701CQ::read_reg ( unsigned  reg)
private

Read a register from the FXOS8701C.

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

Definition at line 147 of file FXOS8701CQ.cpp.

References ADDR_7, and DIR_READ.

Referenced by accel_set_samplerate(), check_registers(), modify_reg(), print_info(), print_registers(), probe(), and Run().

Here is the caller graph for this function:

◆ reset()

void FXOS8701CQ::reset ( )
private

Definition at line 112 of file FXOS8701CQ.cpp.

References accel_set_range(), accel_set_samplerate(), CTRL_REG1_ACTIVE, CTRL_REG1_DR, CTRL_REG2_AUTO_INC, FXOS8701C_ACCEL_DEFAULT_RANGE_G, FXOS8701C_ACCEL_DEFAULT_RATE, FXOS8701CQ_CTRL_REG1, FXOS8701CQ_M_CTRL_REG1, FXOS8701CQ_M_CTRL_REG2, FXOS8701CQ_XYZ_DATA_CFG, M_CTRL_REG1_HMS_AM, M_CTRL_REG1_OS, and write_checked_reg().

Referenced by init().

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

◆ Run()

◆ start()

void FXOS8701CQ::start ( )
private

Definition at line 285 of file FXOS8701CQ.cpp.

References FXOS8701C_ACCEL_DEFAULT_RATE, FXOS8701C_TIMER_REDUCTION, and stop().

Referenced by init().

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

◆ stop()

void FXOS8701CQ::stop ( )
private

Definition at line 295 of file FXOS8701CQ.cpp.

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

Here is the caller graph for this function:

◆ test_error()

void FXOS8701CQ::test_error ( )

Definition at line 460 of file FXOS8701CQ.cpp.

References FXOS8701CQ_CTRL_REG1, and write_reg().

Referenced by fxos8701cq::test_error().

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

◆ write_checked_reg()

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

Write a register in the FXOS8701C, updating _checked_values.

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

Definition at line 173 of file FXOS8701CQ.cpp.

References _checked_registers, _checked_values, FXOS8701C_NUM_CHECKED_REGISTERS, and write_reg().

Referenced by modify_reg(), and reset().

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

◆ write_reg()

void FXOS8701CQ::write_reg ( unsigned  reg,
uint8_t  value 
)
private

Write a register in the FXOS8701C.

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

Definition at line 161 of file FXOS8701CQ.cpp.

References ADDR_7, and DIR_WRITE.

Referenced by check_registers(), test_error(), and write_checked_reg().

Here is the caller graph for this function:

Member Data Documentation

◆ _accel_duplicates

perf_counter_t FXOS8701CQ::_accel_duplicates
private

Definition at line 218 of file FXOS8701CQ.hpp.

Referenced by print_info(), Run(), and ~FXOS8701CQ().

◆ _accel_sample_perf

perf_counter_t FXOS8701CQ::_accel_sample_perf
private

Definition at line 216 of file FXOS8701CQ.hpp.

Referenced by print_info(), Run(), and ~FXOS8701CQ().

◆ _accel_samplerate

unsigned FXOS8701CQ::_accel_samplerate {FXOS8701C_ACCEL_DEFAULT_RATE}
private

Definition at line 214 of file FXOS8701CQ.hpp.

Referenced by accel_set_samplerate().

◆ _bad_registers

perf_counter_t FXOS8701CQ::_bad_registers
private

Definition at line 217 of file FXOS8701CQ.hpp.

Referenced by check_registers(), print_info(), Run(), and ~FXOS8701CQ().

◆ _checked_next

uint8_t FXOS8701CQ::_checked_next {0}
private

Definition at line 228 of file FXOS8701CQ.hpp.

Referenced by check_registers(), and print_info().

◆ _checked_registers

const uint8_t FXOS8701CQ::_checked_registers
staticprivate

◆ _checked_values

uint8_t FXOS8701CQ::_checked_values[FXOS8701C_NUM_CHECKED_REGISTERS] {}
private

Definition at line 227 of file FXOS8701CQ.hpp.

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

◆ _mag_last_measure

hrt_abstime FXOS8701CQ::_mag_last_measure {0}
private

Definition at line 210 of file FXOS8701CQ.hpp.

Referenced by Run().

◆ _mag_sample_perf

perf_counter_t FXOS8701CQ::_mag_sample_perf
private

Definition at line 211 of file FXOS8701CQ.hpp.

Referenced by print_info(), and ~FXOS8701CQ().

◆ _px4_accel

PX4Accelerometer FXOS8701CQ::_px4_accel
private

Definition at line 206 of file FXOS8701CQ.hpp.

Referenced by accel_set_range(), FXOS8701CQ(), and Run().

◆ _px4_mag

PX4Magnetometer FXOS8701CQ::_px4_mag
private

Definition at line 209 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ(), mag_set_range(), and Run().

◆ _register_wait

uint8_t FXOS8701CQ::_register_wait {0}
private

Definition at line 220 of file FXOS8701CQ.hpp.

Referenced by check_registers(), and Run().

◆ FXOS8701C_NUM_CHECKED_REGISTERS

constexpr int FXOS8701CQ::FXOS8701C_NUM_CHECKED_REGISTERS {5}
staticprivate

Definition at line 225 of file FXOS8701CQ.hpp.

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


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