43 #include <px4_platform_common/px4_config.h> 44 #include <px4_platform_common/log.h> 45 #include <px4_platform_common/time.h> 55 _interface(interface),
110 if (
data.st2 & 0x08) {
175 px4_usleep(25 + 25 * size);
261 for (
int i = 0; i < 3; i++) {
262 if (0 != response[i] && 0xff != response[i]) {
263 ak8963_ASA[i] = ((float)(response[i] - 128) / 256.0f) + 1.0
f;
310 PX4_WARN(
"AK8963: bad id %d retries %d",
id, retries);
313 }
while (retries > 0);
320 PX4_ERR(
"AK8963: failed to read adjustment data. Retries %d", retries);
330 PX4_ERR(
"AK8963: failed to initialize, disabled!");
void modify_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
Modify a register in the mpu.
#define MPUREG_I2C_SLV0_D0
void _measure(hrt_abstime timestamp_sample, ak8963_regs data)
MPU9250_mag(MPU9250 *parent, device::Device *interface, enum Rotation rotation)
device::Device * _interface
void set_device_type(uint8_t devtype)
void set_error_count(uint64_t error_count)
static constexpr float MPU9250_MAG_RANGE_GA
#define BIT_I2C_MST_WAIT_FOR_ES
device::Device * _interface
void read_block(uint8_t reg, uint8_t *val, uint8_t count)
#define MPUREG_I2C_SLV0_CTRL
void write_reg(unsigned reg, uint8_t value)
#define AK8963_CONTINUOUS_MODE2
void modify_checked_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
Modify a checked register in the mpu.
count the number of times an event occurs
int ak8963_setup_master_i2c()
perf_counter_t _mag_errors
High-resolution timer with callouts and timekeeping.
#define MPUREG_I2C_SLV0_REG
void passthrough_write(uint8_t reg, uint8_t val)
void set_external(bool external)
#define BITS_I2C_MST_CLOCK_400HZ
perf_counter_t _mag_overruns
void perf_count(perf_counter_t handle)
Count a performance event.
#define AK8963_POWERDOWN_MODE
void set_sensitivity(float x, float y, float z)
void perf_free(perf_counter_t handle)
Free a counter.
void set_temperature(float temperature)
void update(hrt_abstime timestamp, int16_t x, int16_t y, int16_t z)
Rotation
Enum for board and external compass rotations.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
#define MPUREG_EXT_SENS_DATA_00
uint8_t read_reg(unsigned reg)
#define MPUREG_I2C_MST_CTRL
void passthrough_read(uint8_t reg, uint8_t *buf, uint8_t size)
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
virtual int write(unsigned address, void *data, unsigned count)
Write directly to the device.
void set_scale(float scale)
#define MPUREG_I2C_SLV0_ADDR
perf_counter_t _mag_overflows
#define DRV_MAG_DEVTYPE_MPU9250
bool ak8963_read_adjustments()
uint64_t perf_event_count(perf_counter_t handle)
Return current event_count.
Fundamental base class for all physical drivers (I2C, SPI).
bool is_external()
Get the internal / external state.
void set_passthrough(uint8_t reg, uint8_t size, uint8_t *out=NULL)
#define BIT_I2C_READ_FLAG
void write_reg(unsigned reg, uint8_t value)
Write a register in the mpu.
bool ak8963_check_id(uint8_t &id)
#define MPU9250_LOW_SPEED_OP(r)
#define BIT_I2C_MST_P_NSR
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
virtual int read(unsigned address, void *data, unsigned count)
Read directly from the device.
Performance measuring tools.