GithubHelp home page GithubHelp logo

stmicroelectronics / lsm6dsox-pid Goto Github PK

View Code? Open in Web Editor NEW
10.0 10.0 8.0 321 KB

lsm6dsox platform independent driver based on Standard C language and compliant with MISRA standard

License: BSD 3-Clause "New" or "Revised" License

HTML 0.64% CSS 9.18% C 90.17%
mems-sensors stmicroelectronics

lsm6dsox-pid's Introduction

1 - Introduction

Sensor driver for LSM6DSOX sensor written in C programming language. This repository contains the sensor driver files (.h and .c) to be included, or linked directly as a git submodule, in your project. The driver is MISRA compliant and the documentation can be generated using the Doxygen tool.

In order to clone the complete content of the repository folder, use the command:

git clone https://github.com/STMicroelectronics/LSM6DSOX-PID/

Some examples of driver usage can be found here.


2 - Integration details

The driver is platform-independent, you only need to define two functions for read and write transactions from the sensor hardware bus (ie. SPI or I²C). A few devices integrate an extra bit in the communication protocol in order to enable multi read/write access, this bit must be managed in the read and write functions defined by the user. Please refer to the read and write implementation in the reference examples.

2.a Source code integration

  • Include in your project the driver files of the sensor (.h and .c)
  • Define in your code the read and write functions that use the I²C or SPI platform driver like the following:
/** Please note that is MANDATORY: return 0 -> no Error.**/
int32_t platform_write(void *handle, uint8_t Reg, const uint8_t *Bufp, uint16_t len)
int32_t platform_read(void *handle, uint8_t Reg, uint8_t *Bufp, uint16_t len)
  • Declare and initialize the structure of the device interface:
xxxxxxx_ctx_t dev_ctx; /** xxxxxxx is the used part number **/
dev_ctx.write_reg = platform_write;
dev_ctx.read_reg = platform_read;
  • If needed by the platform read and write functions, initialize the handle parameter:
dev_ctx.handle = &platform_handle;

Some integration examples can be found here.

2.b Required properties

  • A standard C language compiler for the target MCU
  • A C library for the target MCU and the desired interface (ie. SPI, I²C)

More Information: http://www.st.com

Copyright (C) 2021 STMicroelectronics

lsm6dsox-pid's People

Contributors

avisconti avatar cparata avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lsm6dsox-pid's Issues

lsm6dsox does not build when optimization level is O2

Device part numbers

lsm6dsox, not sure about other sensors

Type of bug

Build error.

Describe the bug

Project does not build if compiler optimization level is O2.

Additional context

I integrated the driver into an ESP-IDF project of mine. The project builds fine if optimization level is Og, but fails to build when trying to build at level O2.

image

Conversion of gyroscope values

The values used to convert the gyroscope readings from int16 to float have inexplicable values.

When calculating the conversion values myself, I get the correct values for the accelerometer, but not so for the gyroscope.

For example:

float_t lsm6dsox_from_fs16_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.488f;
}

Corresponds nicely to 16/32767 * 1000.

But:

float_t lsm6dsox_from_fs1000_to_mdps(int16_t lsb)
{
  return ((float_t)lsb) * 35.0f;
}

Doesn't correspond to 1000/32767 * 1000 , which yields ~30.5.

Why is this so?
Is it a bug or some kind of special conversion factor I'm not aware of?

The values provided in the Code seem to match the examples from the application note though.
e.g. for 250dps like in the application note example, it would result in a range up to 286dps for that scale (which obviously doesn't make much sense from an outside viewpoint).

lsm6dsox_reg.c/lsm6dsox_all_sources_get() - incorrect block register read?

The function lsm6dsox_all_sources_get() seems incorrect wrt the LSM6dSOX datasheet (DS12814 Rev 3 Jan 2019).
It does a block register read of 12 bytes; the bytecpy() assignment of return values is correct for the first 5 (0x1A-0x1E), but the remaining registers should be copied from 0x35-0x3B.

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.