PX4 Firmware
PX4 Autopilot Software http://px4.io
|
#include <FXOS8701CQ.hpp>
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] |
Definition at line 114 of file FXOS8701CQ.hpp.
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().
|
virtual |
Definition at line 78 of file FXOS8701CQ.cpp.
References _accel_duplicates, _accel_sample_perf, _bad_registers, _mag_sample_perf, perf_free(), and stop().
|
private |
Set the FXOS8701C accel measurement range.
max_g | The measurement range of the accel is in g (9.81m/s^2) Zero selects the maximum supported range. |
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().
|
private |
Set the FXOS8701C internal accel and mag sampling frequency.
frequency | The internal accel and mag sampling frequency is set to not less than this value. Zero selects the maximum rate 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().
|
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().
|
virtual |
Definition at line 94 of file FXOS8701CQ.cpp.
References ToneAlarmInterface::init(), OK, reset(), and start().
Referenced by fxos8701cq::start().
|
private |
Set the FXOS8701C mag measurement range.
max_ga | The measurement range of the mag is in Ga Zero selects the maximum supported range. |
Definition at line 230 of file FXOS8701CQ.cpp.
References _px4_mag, OK, and PX4Magnetometer::set_scale().
|
private |
Modify a register in the FXOS8701C.
Bits are cleared before bits are set.
reg | The register to modify. |
clearbits | Bits in the register to clear. |
setbits | Bits 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().
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().
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().
|
protectedvirtual |
Definition at line 132 of file FXOS8701CQ.cpp.
References _checked_values, FXOS8700CQ_WHOAMI_VAL, FXOS8701CQ_WHOAMI, FXOS8701CQ_WHOAMI_VAL, OK, and read_reg().
|
private |
Read a register from the FXOS8701C.
The | register to 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().
|
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().
|
overrideprivate |
Definition at line 331 of file FXOS8701CQ.cpp.
References _accel_duplicates, _accel_sample_perf, _bad_registers, _mag_last_measure, _px4_accel, _px4_mag, _register_wait, ADDR_7, check_registers(), DIR_READ, DR_STATUS_ZYXDR, f(), FXOS8701CQ_DR_STATUS, FXOS8701CQ_TEMP, hrt_absolute_time(), hrt_abstime, hrt_elapsed_time(), perf_begin(), perf_count(), perf_end(), perf_event_count(), read_reg(), PX4Accelerometer::set_error_count(), PX4Accelerometer::set_temperature(), status, swap16, swap16RightJustify14, PX4Magnetometer::update(), and PX4Accelerometer::update().
|
private |
Definition at line 285 of file FXOS8701CQ.cpp.
References FXOS8701C_ACCEL_DEFAULT_RATE, FXOS8701C_TIMER_REDUCTION, and stop().
Referenced by init().
|
private |
Definition at line 295 of file FXOS8701CQ.cpp.
Referenced by start(), and ~FXOS8701CQ().
void FXOS8701CQ::test_error | ( | ) |
Definition at line 460 of file FXOS8701CQ.cpp.
References FXOS8701CQ_CTRL_REG1, and write_reg().
Referenced by fxos8701cq::test_error().
|
private |
Write a register in the FXOS8701C, updating _checked_values.
reg | The register to write. |
value | The 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().
|
private |
Write a register in the FXOS8701C.
reg | The register to write. |
value | The 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().
|
private |
Definition at line 218 of file FXOS8701CQ.hpp.
Referenced by print_info(), Run(), and ~FXOS8701CQ().
|
private |
Definition at line 216 of file FXOS8701CQ.hpp.
Referenced by print_info(), Run(), and ~FXOS8701CQ().
|
private |
Definition at line 214 of file FXOS8701CQ.hpp.
Referenced by accel_set_samplerate().
|
private |
Definition at line 217 of file FXOS8701CQ.hpp.
Referenced by check_registers(), print_info(), Run(), and ~FXOS8701CQ().
|
private |
Definition at line 228 of file FXOS8701CQ.hpp.
Referenced by check_registers(), and print_info().
|
staticprivate |
Definition at line 226 of file FXOS8701CQ.hpp.
Referenced by check_registers(), print_info(), and write_checked_reg().
|
private |
Definition at line 227 of file FXOS8701CQ.hpp.
Referenced by check_registers(), print_info(), probe(), and write_checked_reg().
|
private |
Definition at line 210 of file FXOS8701CQ.hpp.
Referenced by Run().
|
private |
Definition at line 211 of file FXOS8701CQ.hpp.
Referenced by print_info(), and ~FXOS8701CQ().
|
private |
Definition at line 206 of file FXOS8701CQ.hpp.
Referenced by accel_set_range(), FXOS8701CQ(), and Run().
|
private |
Definition at line 209 of file FXOS8701CQ.hpp.
Referenced by FXOS8701CQ(), mag_set_range(), and Run().
|
private |
Definition at line 220 of file FXOS8701CQ.hpp.
Referenced by check_registers(), and Run().
|
staticprivate |
Definition at line 225 of file FXOS8701CQ.hpp.
Referenced by check_registers(), print_info(), and write_checked_reg().