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) {
174 px4_usleep(25 + 25 * size);
246 float ak09916_ASA[3];
260 for (
int i = 0; i < 3; i++) {
261 if (0 != response[i] && 0xff != response[i]) {
262 ak09916_ASA[i] = ((float)(response[i] - 128) / 256.0f) + 1.0
f;
311 PX4_WARN(
"AK09916: bad id %d retries %d",
id, retries);
314 }
while (retries > 0);
317 PX4_ERR(
"AK09916: failed to initialize, disabled!");
#define ICM_BITS_I2C_MST_CLOCK_400HZ
bool is_external()
Get the internal / external state.
perf_counter_t _mag_errors
uint8_t read_reg(unsigned reg)
device::Device * _interface
void set_device_type(uint8_t devtype)
#define ICMREG_20948_I2C_SLV0_REG
void set_error_count(uint64_t error_count)
static constexpr float ICM20948_MAG_RANGE_GA
ICM20948_mag(ICM20948 *parent, device::Device *interface, enum Rotation rotation)
#define ICM20948_LOW_SPEED_OP(r)
#define ICMREG_20948_USER_CTRL
void modify_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
Modify a register in the mpu.
#define AK09916_FUZE_MODE
void read_block(uint8_t reg, uint8_t *val, uint8_t count)
count the number of times an event occurs
High-resolution timer with callouts and timekeeping.
#define ICMREG_20948_I2C_MST_CTRL
void set_external(bool external)
device::Device * _interface
void write_reg(unsigned reg, uint8_t value)
Write a register in the mpu.
void _measure(hrt_abstime timestamp_sample, ak09916_regs data)
void perf_count(perf_counter_t handle)
Count a performance event.
void set_sensitivity(float x, float y, float z)
void perf_free(perf_counter_t handle)
Free a counter.
void set_temperature(float temperature)
#define AK09916_POWERDOWN_MODE
#define AK09916_CNTL2_CONTINOUS_MODE_100HZ
void passthrough_write(uint8_t reg, uint8_t val)
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 > &)
perf_counter_t _mag_overruns
#define ICMREG_20948_I2C_SLV0_CTRL
int ak09916_setup_master_i2c()
#define ICMREG_20948_EXT_SLV_SENS_DATA_00
__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 AK09916_16BIT_ADC
void modify_checked_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
Modify a checked register in the mpu.
#define ICMREG_20948_I2C_SLV0_ADDR
bool ak09916_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 ak09916_check_id(uint8_t &id)
#define BIT_I2C_READ_FLAG
#define AK09916_DEVICE_ID
void passthrough_read(uint8_t reg, uint8_t *buf, uint8_t size)
void set_passthrough(uint8_t reg, uint8_t size, uint8_t *out=NULL)
#define BIT_I2C_MST_P_NSR
void write_reg(unsigned reg, uint8_t value)
perf_counter_t _mag_overflows
#define ICMREG_20948_I2C_SLV0_DO
#define DRV_MAG_DEVTYPE_AK09916
__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.