57 ScheduledWorkItem(MODULE_NAME,
px4::device_bus_to_wq(get_device_id())),
99 uint8_t cmd[3] = { (uint8_t)(reg |
DIR_READ), 0, 0};
101 transfer(cmd, cmd,
sizeof(cmd));
110 uint8_t cmd[4] = { (uint8_t)(reg |
DIR_READ), 0, 0, 0 };
112 transfer(cmd, cmd,
sizeof(cmd));
114 return (uint16_t)(cmd[2] << 8) | cmd[3];
157 uint8_t retries = 10;
206 uint8_t clearbits = 0x0F;
208 if (frequency < 25) {
212 }
else if (frequency < 50) {
216 }
else if (frequency < 100) {
220 }
else if (frequency < 200) {
224 }
else if (frequency < 400) {
228 }
else if (frequency < 800) {
232 }
else if (frequency < 1600) {
236 }
else if (frequency >= 1600) {
241 printf(
"Set sample rate error \n");
258 ::printf(
"error triggered\n");
298 lsb_per_g = 10922.67;
300 }
else if (max_g <= 6) {
305 }
else if (max_g <= 12) {
310 }
else if (max_g <= 24) {
431 uint8_t accel_data[8];
436 if (
OK != transfer(accel_data, accel_data,
sizeof(accel_data))) {
444 uint16_t lsb, msb, msblsb;
446 lsb = (uint16_t)accel_data[index++];
447 msb = (uint16_t)accel_data[index++];
448 msblsb = (msb << 8) | lsb;
449 report.accel_x = (int16_t)msblsb;
451 lsb = (uint16_t)accel_data[index++];
452 msb = (uint16_t)accel_data[index++];
453 msblsb = (msb << 8) | lsb;
454 report.accel_y = (int16_t)msblsb;
456 lsb = (uint16_t)accel_data[index++];
457 msb = (uint16_t)accel_data[index++];
458 msblsb = (msb << 8) | lsb;
459 report.accel_z = (int16_t)msblsb;
467 if (
OK != transfer(accel_data, accel_data, 4)) {
472 msb = (uint16_t)accel_data[index++];
473 lsb = (uint16_t)accel_data[index++];
474 uint16_t temp = msb * 8 + lsb / 32;
477 report.temp = temp - 2048;
484 if (report.accel_x == 0 &&
485 report.accel_y == 0 &&
486 report.accel_z == 0) {
526 _px4_accel.
update(timestamp_sample, report.accel_x, report.accel_y, report.accel_z);
548 ::printf(
"reg %02x:%02x should be %02x\n",
555 ::printf(
"reg %02x:%02x was bad %02x\n",
569 printf(
"BMI088 accel registers\n");
573 printf(
"Accel Chip Id: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
578 printf(
"Accel Conf: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
583 printf(
"Accel Range: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
588 printf(
"Accel Int1 Conf: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
593 printf(
"Accel Int1-Int2_Map-Data: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
598 printf(
"Accel Pwr Conf: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
603 printf(
"Accel Pwr Ctrl: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
void measure()
Fetch measurements from the sensor and update the report buffers.
virtual uint8_t read_reg(unsigned reg)
Read a register from the BMI088.
#define BMI088_ACCEL_RANGE_24_G
void print_info()
Diagnostics - print some basic information about the driver.
static struct vehicle_status_s status
measure the time elapsed performing an event
#define BMI088_ACCEL_RANGE_3_G
perf_counter_t _bad_registers
void update(hrt_abstime timestamp, float x, float y, float z)
uint8_t _register_wait
whoami result
#define BMI088_ACC_INT1_IO_CONF_ACTIVE_HIGH
#define BMI088_ACC_STATUS
#define BMI088_ACCEL_DEFAULT_RANGE_G
#define BMI088_ACC_INT1_INT2_MAP_DATA_INT1_DRDY
int accel_set_sample_rate(float desired_sample_rate_hz)
Set accel sample rate.
#define BMI088_ACC_INT1_IO_CONF
#define BMI088_ACCEL_RANGE_12_G
#define BMI088_ACC_PWR_CTRL
int set_accel_range(unsigned max_g)
Set the BMI088_accel measurement range.
#define BMI088_ACC_PWR_CONF_ACTIVE
Namespace encapsulating all device framework classes, functions and data.
count the number of times an event occurs
perf_counter_t _duplicates
static constexpr float CONSTANTS_ONE_G
#define BMI088_ACC_STATUS_DRDY
void set_error_count(uint64_t error_count)
BMI088_accel(int bus, const char *path_accel, uint32_t device, enum Rotation rotation)
#define BMI088_ACC_CONF_ODR_200
#define BMI088_ACC_INT1_INT2_MAP_DATA
#define BMI088_ACCEL_NUM_CHECKED_REGISTERS
void perf_count(perf_counter_t handle)
Count a performance event.
uint8_t _checked_bad[BMI088_ACCEL_NUM_CHECKED_REGISTERS]
#define BMI088_ACC_TEMP_H
void perf_free(perf_counter_t handle)
Free a counter.
void init()
Activates/configures the hardware registers.
void set_temperature(float temperature)
Rotation
Enum for board and external compass rotations.
#define BMI088_ACC_SOFTRESET
void write_checked_reg(unsigned reg, uint8_t value)
Write a register in the BMI088_accel, updating _checked_values.
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
perf_counter_t _sample_perf
perf_counter_t _bad_transfers
PX4Accelerometer _px4_accel
void perf_end(perf_counter_t handle)
End a performance event.
#define BMI088_ACC_INT1_IO_CONF_INT1_OUT
#define BMI088_ACC_CONF_ODR_50
#define BMI088_SOFT_RESET
#define BMI088_ACCEL_DEFAULT_RATE
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
#define BMI088_ACC_PWR_CONF
#define BMI088_ACC_CONF_ODR_800
void set_scale(float scale)
#define BMI088_ACC_CONF_ODR_25
static const uint8_t _checked_registers[BMI088_ACCEL_NUM_CHECKED_REGISTERS]
#define BMI088_ACC_WHO_AM_I
void stop()
Stop automatic measurement.
#define BMI088_ACC_INT1_IO_CONF_PP
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.
#define BMI088_ACC_CONF_ODR_400
void check_registers(void)
#define BMI088_ACC_CONF_ODR_100
virtual uint16_t read_reg16(unsigned reg)
void modify_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
Modify a register in the BMI088_accel.
#define BMI088_TIMER_REDUCTION
float _accel_last_temperature_copy
#define BMI088_ACC_CHIP_ID
#define BMI088_ACC_CONF_ODR_12_5
void set_device_type(uint8_t devtype)
#define BMI088_ACCEL_RANGE_6_G
#define BMI088_ACC_CONF_ODR_1600
#define DRV_DEVTYPE_BMI088
uint8_t _checked_values[BMI088_ACCEL_NUM_CHECKED_REGISTERS]
void perf_begin(perf_counter_t handle)
Begin a performance event.
#define BMI088_ACC_PWR_CTRL_EN
#define DEVICE_DEBUG(FMT,...)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
void write_reg(unsigned reg, uint8_t value)
Write a register in the BMI088.