GithubHelp home page GithubHelp logo

teamspatzenhirn / bmi088_zephyr_driver Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 16 KB

Zephyr driver for Bosch BMI088 IMU

License: Apache License 2.0

CMake 1.67% C 98.33%
bmi088 bosch-imu-driver bosch-sensor zephyr

bmi088_zephyr_driver's Introduction

BMI088 Zephyr Driver Module

Usage

This is a west module. You can integrate it in your application by adding the project to your west manifest:

manifest:
  remotes:
    - name: teamspatzenhirn
      url-base: https://github.com/teamspatzenhirn
  projects:
    - name: bmi088_zephyr_driver
      remote: teamspatzenhirn
      revision: <current commit hash>
      path: modules/bmi088

Enable the sensor by defining its location and properties in the devicetree (overlay). Gyro and accelerometer are handled separately, since that's how the sensor is built. It would be possible to use just one of the sensors, but it's currently not possible to completely deactivate half of the driver, just because we usually need both sensors.

For sensor configuration the gyro provides the bandwidth devicetree setting, the accelerometer provides oversampling rate osr and output data rate odr, see the datasheet for valid values.

&lpspi4 {
    gyro: bmi088_gyr@0 {
        compatible = "bosch,bmi088-gyr";
        reg = <0>;
        spi-max-frequency = <10000000>;
        // datasheet page 39
        bandwidth = <0x06>; // corner-frequency at 64 Hz
        status = "okay";
    };

    acc: bmi088_acc@1 {
        compatible = "bosch,bmi088-acc";
        reg = <1>;
        spi-max-frequency = <10000000>;
        // datasheet page 16 and 29
        // corner-frequency at 80 Hz
        odr = <0x0B>; // 800 Hz
        osr = <0x08>; // 4 times oversampled
        status = "okay";
    };
};

Example of reading sensor values:

#define GYRO_NODE DT_NODELABEL(gyro)
constexpr const device *gyro_sensor_dev = DEVICE_DT_GET(GYRO_NODE);

#define ACCELEROMETER_NODE DT_NODELABEL(gyro)
constexpr const device *accel_sensor_dev = DEVICE_DT_GET(ACCELEROMETER_NODE);

void sensor_readout() {
    sensor_sample_fetch(gyro_sensor_dev);
    sensor_value gyro[3];
    sensor_channel_get(gyro_sensor_dev, SENSOR_CHAN_GYRO_XYZ, gyro);
    LOG_INF("Gyro x: %f °/s y: %f °/s z: %f °/s",
            sensor_value_to_double(gyro[0]),
            sensor_value_to_double(gyro[1]),
            sensor_value_to_double(gyro[2]));

    sensor_sample_fetch(accel_sensor_dev);
    sensor_value accel[3];
    sensor_channel_get(accel_sensor_dev, SENSOR_CHAN_ACCEL_XYZ, accel);
    LOG_INF("Accelerometer x: %f m/s2 y: %f m/s2 z: %f m/s2",
            sensor_value_to_double(accel[0]),
            sensor_value_to_double(accel[1]),
            sensor_value_to_double(accel[2]));
}

Git history

This driver has been extracted from our Zephyr fork. For the full git history of the driver, refer to this commit in out fork, which is the last version before moving the driver here: https://github.com/teamspatzenhirn/zephyr/tree/858548919eb664fc364dad0226e3dcf71586292b/drivers/sensor/bmi088

Writing Out-Of-Tree Drivers

Since this was kind of a pain to figure out, here are a few helpful links if you want to do this:

bmi088_zephyr_driver's People

Contributors

luisuark avatar ottojo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.