57 SPI(
"FXOS8701CQ", nullptr, bus, device,
SPIDEV_MODE0, 1 * 1000 * 1000),
58 ScheduledWorkItem(MODULE_NAME,
px4::device_bus_to_wq(get_device_id())),
60 #if !defined(BOARD_HAS_NOISY_FXOS8700_MAG)
72 #if !defined(BOARD_HAS_NOISY_FXOS8700_MAG) 83 #if !defined(BOARD_HAS_NOISY_FXOS8700_MAG) 100 PX4_ERR(
"SPI init failed");
155 transfer(cmd, cmd,
sizeof(cmd));
169 transfer(cmd,
nullptr,
sizeof(cmd));
199 if (max_g == 0 || max_g > 8) {
208 }
else if (max_g > 2) {
228 #if !defined(BOARD_HAS_NOISY_FXOS8700_MAG) 233 float mag_range_scale = 0.001f;
249 if (frequency == 0) {
253 if (frequency <= 25) {
257 }
else if (frequency <= 50) {
261 }
else if (frequency <= 100) {
265 }
else if (frequency <= 200) {
269 }
else if (frequency <= 400) {
320 if (_checked_next != 0) {
337 #pragma pack(push, 1) 347 } raw_accel_mag_report{};
364 transfer((uint8_t *)&raw_accel_mag_report, (uint8_t *)&raw_accel_mag_report,
sizeof(raw_accel_mag_report));
394 #if !defined(BOARD_HAS_NOISY_FXOS8700_MAG) 397 int16_t mag_x =
swap16(raw_accel_mag_report.mx);
398 int16_t mag_y =
swap16(raw_accel_mag_report.my);
399 int16_t mag_z =
swap16(raw_accel_mag_report.mz);
414 #if !defined(BOARD_HAS_NOISY_FXOS8700_MAG) 426 ::printf(
"reg %02x:%02x should be %02x\n",
454 for (uint8_t i = 0; i <
sizeof(regmap) /
sizeof(regmap[0]); i++) {
455 printf(
"0x%02x %s\n",
read_reg(regmap[i].reg), regmap[i].
name);
#define XYZ_DATA_CFG_FS_2G
uint8_t read_reg(unsigned reg)
Read a register from the FXOS8701C.
#define swap16RightJustify14(w)
void write_reg(unsigned reg, uint8_t value)
Write a register in the FXOS8701C.
#define CTRL_REG2_AUTO_INC
static struct vehicle_status_s status
#define DRV_ACC_DEVTYPE_FXOS8701C
#define XYZ_DATA_CFG_FS_4G
measure the time elapsed performing an event
perf_counter_t _accel_duplicates
void set_device_type(uint8_t devtype)
#define FXOS8701CQ_CTRL_REG2
#define FXOS8701CQ_M_CTRL_REG1
void update(hrt_abstime timestamp, float x, float y, float z)
#define FXOS8701CQ_WHOAMI
#define FXOS8701CQ_M_OUT_X_MSB
#define CTRL_REG1_DR_MASK
#define FXOS8701C_ACCEL_DEFAULT_RANGE_G
static constexpr int FXOS8701C_NUM_CHECKED_REGISTERS
#define FXOS8701CQ_DR_STATUS
Namespace encapsulating all device framework classes, functions and data.
count the number of times an event occurs
static constexpr float CONSTANTS_ONE_G
void set_error_count(uint64_t error_count)
#define M_CTRL_REG1_OS(n)
perf_counter_t _mag_sample_perf
FXOS8701CQ(int bus, uint32_t device, enum Rotation rotation)
void write_checked_reg(unsigned reg, uint8_t value)
Write a register in the FXOS8701C, updating _checked_values.
void modify_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
Modify a register in the FXOS8701C.
perf_counter_t _accel_sample_perf
void perf_count(perf_counter_t handle)
Count a performance event.
#define FXOS8701CQ_CTRL_REG1
void perf_free(perf_counter_t handle)
Free a counter.
void init()
Activates/configures the hardware registers.
void set_temperature(float temperature)
void update(hrt_abstime timestamp, int16_t x, int16_t y, int16_t z)
perf_counter_t _bad_registers
Rotation
Enum for board and external compass rotations.
#define FXOS8701CQ_WHOAMI_VAL
#define FXOS8700CQ_WHOAMI_VAL
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
static hrt_abstime hrt_elapsed_time(const hrt_abstime *then)
Compute the delta between a timestamp taken in the past and now.
hrt_abstime _mag_last_measure
void perf_end(perf_counter_t handle)
End a performance event.
#define FXOS8701C_ACCEL_DEFAULT_RATE
#define FXOS8701CQ_OUT_X_MSB
void check_registers()
check key registers for correct values
#define FXOS8701C_TIMER_REDUCTION
Driver for the NXP FXOS8701CQ 6-axis sensor with integrated linear accelerometer and magnetometer con...
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
unsigned _accel_samplerate
void set_scale(float scale)
void set_scale(float scale)
#define XYZ_DATA_CFG_FS_MASK
#define FXOS8701CQ_M_CTRL_REG3
uint8_t _checked_values[FXOS8701C_NUM_CHECKED_REGISTERS]
#define FXOS8701CQ_M_CTRL_REG2
#define M_CTRL_REG1_HMS_AM
void perf_print_counter(perf_counter_t handle)
Print one performance counter to stdout.
uint64_t perf_event_count(perf_counter_t handle)
Return current event_count.
int accel_set_samplerate(unsigned frequency)
Set the FXOS8701C internal accel and mag sampling frequency.
#define XYZ_DATA_CFG_FS_8G
void set_device_type(uint8_t devtype)
static const uint8_t _checked_registers[FXOS8701C_NUM_CHECKED_REGISTERS]
int accel_set_range(unsigned max_g)
Set the FXOS8701C accel measurement range.
PX4Accelerometer _px4_accel
void perf_begin(perf_counter_t handle)
Begin a performance event.
#define FXOS8701CQ_XYZ_DATA_CFG
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
int mag_set_range(unsigned max_g)
Set the FXOS8701C mag measurement range.
#define FXOS8701CQ_M_DR_STATUS