49 ScheduledWorkItem(MODULE_NAME,
px4::device_bus_to_wq(get_device_id())),
103 uint8_t retries = 10;
150 ::printf(
"error triggered\n");
192 }
else if (max_g <= 4) {
197 }
else if (max_g <= 8) {
202 }
else if (max_g <= 16) {
306 uint8_t accel_data[8] {};
311 if (
OK != transfer(accel_data, accel_data,
sizeof(accel_data))) {
319 uint16_t lsb, msb, msblsb;
321 lsb = (uint16_t)accel_data[index++];
323 msb = (uint16_t)accel_data[index++];
324 msblsb = (msb << 8) | lsb;
325 report.accel_x = ((int16_t)msblsb >> 4);
327 lsb = (uint16_t)accel_data[index++];
329 msb = (uint16_t)accel_data[index++];
330 msblsb = (msb << 8) | lsb;
331 report.accel_y = ((int16_t)msblsb >> 4);
333 lsb = (uint16_t)accel_data[index++];
335 msb = (uint16_t)accel_data[index++];
336 msblsb = (msb << 8) | lsb;
337 report.accel_z = ((int16_t)msblsb >> 4);
340 report.temp = accel_data[index];
343 if ((!status_x) || (!status_y) || (!status_z)) {
353 if (report.accel_x == 0 &&
354 report.accel_y == 0 &&
355 report.accel_z == 0 &&
398 _px4_accel.
update(timestamp_sample, report.accel_x, report.accel_y, report.accel_z);
418 ::printf(
"reg %02x:%02x should be %02x\n",
425 ::printf(
"reg %02x:%02x was bad %02x\n",
439 printf(
"BMI055 accel registers\n");
443 printf(
"Accel Chip Id: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
448 printf(
"Accel Bw: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
453 printf(
"Accel Range: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
458 printf(
"Accel Int-en-1: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
463 printf(
"Accel Int-Map-1: %02x:%02x ", (
unsigned)reg, (
unsigned)v);
#define BMI055_ACC_INT_MAP_1
measure the time elapsed performing an event
#define BMI055_ACC_PMU_LPW
void update(hrt_abstime timestamp, float x, float y, float z)
#define BMI055_ACC_DRDY_INT1
#define BMI055_ACCEL_RANGE_16_G
#define BMI055_SOFT_RESET
void print_info()
Diagnostics - print some basic information about the driver.
#define BMI055_ACCEL_DEFAULT_RATE
uint8_t _checked_values[BMI055_ACCEL_NUM_CHECKED_REGISTERS]
Namespace encapsulating all device framework classes, functions and data.
count the number of times an event occurs
#define BMI055_NEW_DATA_MASK
#define BMI055_TIMER_REDUCTION
static const uint8_t _checked_registers[BMI055_ACCEL_NUM_CHECKED_REGISTERS]
void write_reg(unsigned reg, uint8_t value)
Write a register in the BMI055.
static constexpr float CONSTANTS_ONE_G
void set_error_count(uint64_t error_count)
uint8_t read_reg(unsigned reg)
Read a register from the BMI055.
perf_counter_t _duplicates
perf_counter_t _sample_perf
void perf_count(perf_counter_t handle)
Count a performance event.
#define BMI055_ACC_INT_EN_1
void perf_free(perf_counter_t handle)
Free a counter.
void init()
Activates/configures the hardware registers.
void set_temperature(float temperature)
void modify_reg(unsigned reg, uint8_t clearbits, uint8_t setbits)
Modify a register in the BMI055_accel.
#define BMI055_ACCEL_RANGE_8_G
Rotation
Enum for board and external compass rotations.
uint8_t _checked_bad[BMI055_ACCEL_NUM_CHECKED_REGISTERS]
#define BMI055_ACC_SOFTRESET
void measure()
Fetch measurements from the sensor and update the report buffers.
int set_accel_range(unsigned max_g)
Set the BMI055_accel measurement range.
void perf_end(perf_counter_t handle)
End a performance event.
uint8_t _register_wait
whoami result
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
#define DRV_ACC_DEVTYPE_BMI055
void set_scale(float scale)
void write_checked_reg(unsigned reg, uint8_t value)
Write a register in the BMI055_accel, updating _checked_values.
#define BMI055_ACCEL_DEFAULT_RANGE_G
#define BMI055_ACCEL_RANGE_4_G
PX4Accelerometer _px4_accel
perf_counter_t _bad_registers
#define BMI055_ACCEL_NUM_CHECKED_REGISTERS
void perf_print_counter(perf_counter_t handle)
Print one performance counter to stdout.
#define BMI055_ACC_WHO_AM_I
uint64_t perf_event_count(perf_counter_t handle)
Return current event_count.
#define BMI055_ACCEL_RANGE_2_G
BMI055_accel(int bus, const char *path_accel, uint32_t device, enum Rotation rotation)
#define BMI055_ACCEL_NORMAL
void check_registers(void)
void set_device_type(uint8_t devtype)
#define BMI055_ACC_CHIP_ID
#define BMI055_ACCEL_BW_500
#define BMI055_ACC_DRDY_INT_EN
void perf_begin(perf_counter_t handle)
Begin a performance event.
perf_counter_t _bad_transfers
#define DEVICE_DEBUG(FMT,...)
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
void stop()
Stop automatic measurement.