bno055 icon indicating copy to clipboard operation
bno055 copied to clipboard

Feat/configs and interupts

Open elpiel opened this issue 9 months ago • 1 comments

This is continuation of #13 with some additions and organization of the code.

Currently I'm able to write the Enable & Mask Interrupts registries and validate the value (fetching it again from the IC), however, using the GPIO and waiting for Interrupt triggered is not working.

I've also validated the firmware version of the IC for some of the interrupts

Maybe another set of eyes will spot an issue that I'm missing?!

Adds:

  • 6dof & 9dof fns (#39 ) which reads the sequential registers and returns Accel/Gyro and Accel/Gyro/Mag vectors accordingly. (improvement: Maybe add a struct as just knowing the sequence of the returned tuple is now an ideal API)
  • Structs provided by #13 should be reworked to use the same approach as the rest of the crate or vice-versa (I like the FromPrimitive impl approach and the macros from #13 but let me know)

Also, should we add functions to fetch sequential registers with other data like quaternion, gravity vector etc?

Here's part of the code where i'm able to set these interrupts and update both the mask and INT_EN + validate the result at the end.

I've set the mode to NDOF (9DOF) first and update the interrupts below.

let interrupts = BNO055Interrupt::ACC_BSX_DRDY
        | BNO055Interrupt::GYR_DRDY
        | BNO055Interrupt::MAG_DRDY;

        if let Err(err) = imu.set_interrupts_enabled(interrupts) {
            error!(
                "(bno055) Failed to enable interrupts for 9DOF + Gyro High Rate for IMU {:?}",
                interrupts
            );
            continue;
        }
        if let Err(err) = imu.set_interrupts_mask(interrupts) {
            error!("(bno055) Failed to set 9DOF + Gyro High Rate interrupt mask for IMU");
            continue;
        }
        info!("(bno055) Interrupts mask set {:?}!", interrupts);

        let int_en = unwrap!(imu.interrupts_enabled());
        let int_mask = unwrap!(imu.interrupts_mask());
        info!(
            "(bno055) Int enabled: {0=0..8}, Interrupts mask {1=0..8} set bits: {2=0..8} !",
            int_en.bits(),
            int_mask.bits(),
            interrupts.bits()
        );

elpiel avatar Apr 06 '25 09:04 elpiel

Bug: setting up the Accelerometer configuration, makes the sensor return an error.

Primarily I tried to set the range to +- 16G

elpiel avatar Apr 11 '25 11:04 elpiel