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

Driver for the NXP FXOS8701CQ 6-axis sensor with integrated linear accelerometer and magnetometer connected via SPI. More...

#include <drivers/device/spi.h>
#include <lib/drivers/accelerometer/PX4Accelerometer.hpp>
#include <lib/ecl/geo/geo.h>
#include <lib/perf/perf_counter.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <lib/drivers/magnetometer/PX4Magnetometer.hpp>
Include dependency graph for FXOS8701CQ.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  FXOS8701CQ
 

Macros

#define DIR_READ(a)   ((a) & 0x7f)
 
#define DIR_WRITE(a)   ((a) | (1 << 7))
 
#define ADDR_7(a)   ((a) & (1 << 7))
 
#define swap16(w)   __builtin_bswap16((w))
 
#define swap16RightJustify14(w)   (((int16_t)swap16(w)) >> 2)
 
#define FXOS8701CQ_DR_STATUS   0x00
 
#define DR_STATUS_ZYXDR   (1 << 3)
 
#define FXOS8701CQ_OUT_X_MSB   0x01
 
#define FXOS8701CQ_XYZ_DATA_CFG   0x0e
 
#define XYZ_DATA_CFG_FS_SHIFTS   0
 
#define XYZ_DATA_CFG_FS_MASK   (3 << XYZ_DATA_CFG_FS_SHIFTS)
 
#define XYZ_DATA_CFG_FS_2G   (0 << XYZ_DATA_CFG_FS_SHIFTS)
 
#define XYZ_DATA_CFG_FS_4G   (1 << XYZ_DATA_CFG_FS_SHIFTS)
 
#define XYZ_DATA_CFG_FS_8G   (2 << XYZ_DATA_CFG_FS_SHIFTS)
 
#define FXOS8701CQ_WHOAMI   0x0d
 
#define FXOS8700CQ_WHOAMI_VAL   0xC7
 
#define FXOS8701CQ_WHOAMI_VAL   0xCA
 
#define FXOS8701CQ_CTRL_REG1   0x2a
 
#define CTRL_REG1_ACTIVE   (1 << 0)
 
#define CTRL_REG1_DR_SHIFTS   3
 
#define CTRL_REG1_DR_MASK   (7 << CTRL_REG1_DR_SHIFTS)
 
#define CTRL_REG1_DR(n)   (((n) & 7) << CTRL_REG1_DR_SHIFTS)
 
#define FXOS8701CQ_CTRL_REG2   0x2b
 
#define CTRL_REG2_AUTO_INC   (1 << 5)
 
#define FXOS8701CQ_M_DR_STATUS   0x32
 
#define M_DR_STATUS_ZYXDR   (1 << 3)
 
#define FXOS8701CQ_M_OUT_X_MSB   0x33
 
#define FXOS8701CQ_TEMP   0x51
 
#define FXOS8701CQ_M_CTRL_REG1   0x5b
 
#define M_CTRL_REG1_HMS_SHIFTS   0
 
#define M_CTRL_REG1_HMS_MASK   (3 << M_CTRL_REG1_HMS_SHIFTS)
 
#define M_CTRL_REG1_HMS_A   (0 << M_CTRL_REG1_HMS_SHIFTS)
 
#define M_CTRL_REG1_HMS_M   (1 << M_CTRL_REG1_HMS_SHIFTS)
 
#define M_CTRL_REG1_HMS_AM   (3 << M_CTRL_REG1_HMS_SHIFTS)
 
#define M_CTRL_REG1_OS_SHIFTS   2
 
#define M_CTRL_REG1_OS_MASK   (7 << M_CTRL_REG1_HMS_SHIFTS)
 
#define M_CTRL_REG1_OS(n)   (((n) & 7) << M_CTRL_REG1_OS_SHIFTS)
 
#define FXOS8701CQ_M_CTRL_REG2   0x5c
 
#define FXOS8701CQ_M_CTRL_REG3   0x5d
 
#define DEF_REG(r)   {r, #r}
 
#define FXOS8701C_ACCEL_DEFAULT_RANGE_G   8
 
#define FXOS8701C_ACCEL_DEFAULT_RATE   400 /* ODR is 400 in Hybird mode (accel + mag) */
 
#define FXOS8701C_TIMER_REDUCTION   240
 

Detailed Description

Driver for the NXP FXOS8701CQ 6-axis sensor with integrated linear accelerometer and magnetometer connected via SPI.

Definition in file FXOS8701CQ.hpp.

Macro Definition Documentation

◆ ADDR_7

#define ADDR_7 (   a)    ((a) & (1 << 7))

Definition at line 55 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::read_reg(), FXOS8701CQ::Run(), and FXOS8701CQ::write_reg().

◆ CTRL_REG1_ACTIVE

#define CTRL_REG1_ACTIVE   (1 << 0)

Definition at line 76 of file FXOS8701CQ.hpp.

◆ CTRL_REG1_DR

#define CTRL_REG1_DR (   n)    (((n) & 7) << CTRL_REG1_DR_SHIFTS)

Definition at line 79 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::accel_set_samplerate(), and FXOS8701CQ::reset().

◆ CTRL_REG1_DR_MASK

#define CTRL_REG1_DR_MASK   (7 << CTRL_REG1_DR_SHIFTS)

Definition at line 78 of file FXOS8701CQ.hpp.

◆ CTRL_REG1_DR_SHIFTS

#define CTRL_REG1_DR_SHIFTS   3

Definition at line 77 of file FXOS8701CQ.hpp.

◆ CTRL_REG2_AUTO_INC

#define CTRL_REG2_AUTO_INC   (1 << 5)

Definition at line 81 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::reset().

◆ DEF_REG

#define DEF_REG (   r)    {r, #r}

Definition at line 100 of file FXOS8701CQ.hpp.

◆ DIR_READ

#define DIR_READ (   a)    ((a) & 0x7f)

Definition at line 53 of file FXOS8701CQ.hpp.

◆ DIR_WRITE

#define DIR_WRITE (   a)    ((a) | (1 << 7))

Definition at line 54 of file FXOS8701CQ.hpp.

◆ DR_STATUS_ZYXDR

#define DR_STATUS_ZYXDR   (1 << 3)

Definition at line 60 of file FXOS8701CQ.hpp.

◆ FXOS8700CQ_WHOAMI_VAL

#define FXOS8700CQ_WHOAMI_VAL   0xC7

Definition at line 72 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::probe().

◆ FXOS8701C_ACCEL_DEFAULT_RANGE_G

#define FXOS8701C_ACCEL_DEFAULT_RANGE_G   8

Definition at line 103 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::reset().

◆ FXOS8701C_ACCEL_DEFAULT_RATE

#define FXOS8701C_ACCEL_DEFAULT_RATE   400 /* ODR is 400 in Hybird mode (accel + mag) */

◆ FXOS8701C_TIMER_REDUCTION

#define FXOS8701C_TIMER_REDUCTION   240

Definition at line 112 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::start().

◆ FXOS8701CQ_CTRL_REG1

#define FXOS8701CQ_CTRL_REG1   0x2a

◆ FXOS8701CQ_CTRL_REG2

#define FXOS8701CQ_CTRL_REG2   0x2b

Definition at line 80 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers().

◆ FXOS8701CQ_DR_STATUS

#define FXOS8701CQ_DR_STATUS   0x00

Definition at line 59 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers(), and FXOS8701CQ::Run().

◆ FXOS8701CQ_M_CTRL_REG1

#define FXOS8701CQ_M_CTRL_REG1   0x5b

Definition at line 87 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers(), and FXOS8701CQ::reset().

◆ FXOS8701CQ_M_CTRL_REG2

#define FXOS8701CQ_M_CTRL_REG2   0x5c

Definition at line 97 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers(), and FXOS8701CQ::reset().

◆ FXOS8701CQ_M_CTRL_REG3

#define FXOS8701CQ_M_CTRL_REG3   0x5d

Definition at line 98 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers().

◆ FXOS8701CQ_M_DR_STATUS

#define FXOS8701CQ_M_DR_STATUS   0x32

Definition at line 83 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers().

◆ FXOS8701CQ_M_OUT_X_MSB

#define FXOS8701CQ_M_OUT_X_MSB   0x33

Definition at line 85 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers().

◆ FXOS8701CQ_OUT_X_MSB

#define FXOS8701CQ_OUT_X_MSB   0x01

Definition at line 62 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers().

◆ FXOS8701CQ_TEMP

#define FXOS8701CQ_TEMP   0x51

Definition at line 86 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::Run().

◆ FXOS8701CQ_WHOAMI

#define FXOS8701CQ_WHOAMI   0x0d

Definition at line 71 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::print_registers(), and FXOS8701CQ::probe().

◆ FXOS8701CQ_WHOAMI_VAL

#define FXOS8701CQ_WHOAMI_VAL   0xCA

Definition at line 73 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::probe().

◆ FXOS8701CQ_XYZ_DATA_CFG

#define FXOS8701CQ_XYZ_DATA_CFG   0x0e

◆ M_CTRL_REG1_HMS_A

#define M_CTRL_REG1_HMS_A   (0 << M_CTRL_REG1_HMS_SHIFTS)

Definition at line 90 of file FXOS8701CQ.hpp.

◆ M_CTRL_REG1_HMS_AM

#define M_CTRL_REG1_HMS_AM   (3 << M_CTRL_REG1_HMS_SHIFTS)

Definition at line 92 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::reset().

◆ M_CTRL_REG1_HMS_M

#define M_CTRL_REG1_HMS_M   (1 << M_CTRL_REG1_HMS_SHIFTS)

Definition at line 91 of file FXOS8701CQ.hpp.

◆ M_CTRL_REG1_HMS_MASK

#define M_CTRL_REG1_HMS_MASK   (3 << M_CTRL_REG1_HMS_SHIFTS)

Definition at line 89 of file FXOS8701CQ.hpp.

◆ M_CTRL_REG1_HMS_SHIFTS

#define M_CTRL_REG1_HMS_SHIFTS   0

Definition at line 88 of file FXOS8701CQ.hpp.

◆ M_CTRL_REG1_OS

#define M_CTRL_REG1_OS (   n)    (((n) & 7) << M_CTRL_REG1_OS_SHIFTS)

Definition at line 95 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::reset().

◆ M_CTRL_REG1_OS_MASK

#define M_CTRL_REG1_OS_MASK   (7 << M_CTRL_REG1_HMS_SHIFTS)

Definition at line 94 of file FXOS8701CQ.hpp.

◆ M_CTRL_REG1_OS_SHIFTS

#define M_CTRL_REG1_OS_SHIFTS   2

Definition at line 93 of file FXOS8701CQ.hpp.

◆ M_DR_STATUS_ZYXDR

#define M_DR_STATUS_ZYXDR   (1 << 3)

Definition at line 84 of file FXOS8701CQ.hpp.

◆ swap16

#define swap16 (   w)    __builtin_bswap16((w))

Definition at line 56 of file FXOS8701CQ.hpp.

◆ swap16RightJustify14

#define swap16RightJustify14 (   w)    (((int16_t)swap16(w)) >> 2)

Definition at line 57 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::Run().

◆ XYZ_DATA_CFG_FS_2G

#define XYZ_DATA_CFG_FS_2G   (0 << XYZ_DATA_CFG_FS_SHIFTS)

Definition at line 67 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::accel_set_range().

◆ XYZ_DATA_CFG_FS_4G

#define XYZ_DATA_CFG_FS_4G   (1 << XYZ_DATA_CFG_FS_SHIFTS)

Definition at line 68 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::accel_set_range().

◆ XYZ_DATA_CFG_FS_8G

#define XYZ_DATA_CFG_FS_8G   (2 << XYZ_DATA_CFG_FS_SHIFTS)

Definition at line 69 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::accel_set_range().

◆ XYZ_DATA_CFG_FS_MASK

#define XYZ_DATA_CFG_FS_MASK   (3 << XYZ_DATA_CFG_FS_SHIFTS)

Definition at line 66 of file FXOS8701CQ.hpp.

Referenced by FXOS8701CQ::accel_set_range().

◆ XYZ_DATA_CFG_FS_SHIFTS

#define XYZ_DATA_CFG_FS_SHIFTS   0

Definition at line 65 of file FXOS8701CQ.hpp.