Skip to content
Platform-independent drivers source code for STMicroelectronics MEMS motion and environmental sensors, based on C standard.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_prj_MKI109V3 Demoboard MKI109V3: add CubeMX configuration file Nov 23, 2018
_prj_NucleoF411 Demoboard NucleoF411: add CubeMX configuration file (X_NUCLEO_IKS01A2) Feb 19, 2019
a3g4250d_STdC a3g4250d: minor aesthetical changes Jan 11, 2019
ais328dq_STdC ais328dq: modify status_reg_t (replace 'xor' with '_xor') Nov 29, 2018
ais3624dq_STdC ais3624dq: modify status_reg_t (replace 'xor' with '_xor') Nov 29, 2018
asm330lhh_STdC asm330lhh: Updates from datasheet rev.3 May 10, 2019
h3lis331dl_STdC h3lis331dl: modify status_reg_t (replace 'xor' with '_xor') Nov 29, 2018
hts221_STdC hts221: Alignment of "MEMS_SHARED_TYPES" section. Nov 14, 2018
i3g4250d_STdC i3g4250d: first driver release Feb 1, 2019
iis2dh_STdC iis2dh: fix function operating_mode_get Feb 19, 2019
iis2dlpc_STdC iis2dlpc: modify typedef May 23, 2019
iis2mdc_STdC iis2mdc: modify status_reg_t (replace 'xor' with '_xor') Nov 29, 2018
iis328dq_STdC iis328dq: modify status_reg_t (replace 'xor' with '_xor') Nov 29, 2018
iis3dhhc_STdC iis3dhhc: added MISRA compliance Apr 4, 2019
iis3dwb_STdC iis3dwb: type def modification May 24, 2019
ism303dac_STdC ism303dac: examples updated Mar 13, 2019
ism330dlc_STdC ism330dlc: fix function _aux_den_mode_get Apr 1, 2019
l20g20is_STdC l20g20is: first release Jan 11, 2019
l3gd20h_STdC l3gd20h: First driver release Mar 22, 2019
lis2de12_STdC lis2de12: first release Nov 29, 2018
lis2dh12_STdC lis2dh12: fix function operating_mode_get Mar 5, 2019
lis2ds12_STdC lis2ds12: updated examples Apr 4, 2019
lis2dtw12_STdC
lis2dw12_STdC lis2dw12: modify typedef May 23, 2019
lis2hh12_STdC lis2hh12: typedef modifications Nov 29, 2018
lis2mdl_STdC lis2mdl: Updates from datasheet rev.5 May 10, 2019
lis331dlh_STdC lis331dlh: modify _status_reg_t (replace 'xor' with '_xor') Nov 29, 2018
lis3de_STdC lis3de: examples updated Mar 7, 2019
lis3dh_STdC lis3dh: fix function operating_mode_get Mar 5, 2019
lis3dhh_STdC lis3dhh: Updates from datasheet rev.3 Apr 18, 2019
lis3mdl_STdC lis3mdl: modify _status_reg_t (replace 'xor' with '_xor') Nov 29, 2018
lps22hb_STdC lps22hb: modify _from_lsb_to_hpa Mar 5, 2019
lps22hh_STdC lps22hh: fix May 16, 2019
lps25hb_STdC lps25hb: Updaded examples Mar 11, 2019
lps33hw_STdC lps33hw: modify _from_lsb_to_hpa Mar 13, 2019
lps33w_STdC lps33w: First driver release Mar 13, 2019
lsm303agr_STdC lsm303agr: update examples Feb 6, 2019
lsm303ah_STdC lsm303ah: Updates from datasheet rev.7 May 3, 2019
lsm6ds3_STdC lsm6ds3: fix [issue #31] Mar 7, 2019
lsm6dsl_STdC lsm6dsl: Fix + MISRA Compliance extension Dec 6, 2018
lsm6dsm_STdC lsm6dsm: Examples updates Feb 13, 2019
lsm6dso_STdC lsm6dso: Updated examples May 10, 2019
lsm6dsox_STdC lsm6dsox: fix May 16, 2019
lsm6dsr_STdC lsm6dsr: modify function label May 23, 2019
lsm9ds1_STdC lsm9ds1: modify _status_reg_m_t (replace 'xor' with '_xor') Nov 29, 2018
stts751_STdC stts751: Fix + Rename Nov 28, 2018
LICENSE Create LICENSE Mar 7, 2019
README.md

README.md

1 - Introduction

This repository contains platform independent drivers for STMicroelectronics sensors. Sensor drivers and examples were written in C programming language.

This repository contains two types of folders, identifiable using the following naming convention:

  • folder that contains the sensor drivers, named xxxxxxx_STdC where xxxxxxx identifies the a sensor part number

  • folder that contains the demo project, named _prj_XXXXXXXwhere XXXXXXX is the name of the ST evaluation board.

1.a - Sensor driver folder structure

Every sensor driver folder contains:

  • xxxxxxx_STdC\driver : the C sensor driver (.h and .c) to be included in your project. Driver documentation can be generated using the Doxigen tool.
  • xxxxxxx_STdC\example: examples showing how to integrate the C driver in a project. They are written for STM32 Microcontrollers using the STM32CubeMX tool, but they can be used as a guideline for every platform.
  • README: additional info about the specific driver.

1.b - Demo project folder structure

Every demo project folder contains a single configuration file for the STM32CubeMX tool named _prj_XXXXXXX\XXXXXX.iocwhere XXXXXXX is the name of the ST evaluation board.

Using the STM32CubeMX tool ( configured with the related MCU Package ) and the .ioc file, it is possible to create a project in which you can easily run the examples available in each sensor drivers folder.


2 - Integration details

The driver is platform-independent, you only need to define the two functions for read and write transactions from the sensor hardware bus (ie. SPI or I²C).

2.a Source code integration

  • Include in your project the driver files of Sensor (.h and .c) located in the xxxxxxx_STdC\driverfolder of the corresponding product

  • 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, 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 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;

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, I2C)

3 - Running Examples

They are written for STM32 Microcontrollers using STM32CubeMX tool, but they can be used as a guideline for every platform.

3.a Using a STMicroelectronics evaluation boards

In case of using the supported STMicroelectronics evaluation boards the examples file(.c) can run without applying any modifications (as is).

In order to do that, please follow the following steps:

  1. Download and install STM32CubeMX tool and the related MCU package (i.e. STM32CubeF4 for NucleoF411 and STEVAL_MKI109V3).
  2. Open the .ioc configuration file associated to the selected evaluation board with the STM32CubeMX tool. The .ioc configuration files for the supported evaluation boards can be found in the related ST evaluation board demo project folder.
  3. Generate the project using the STM32CubeMX tool and select your preferred IDE / Toolchain.
  4. Add to your project the STMicroelectronics sensor driver. Driver files are located in the sensor drivers folder atxxxxxxx_STdC\driver\xxxxxxx_reg.c(.h) where xxxxxxx identifies the sensor part number.
  5. Add to your project the example source file (.c) that you are interested in. Example files are located in the sensor drivers folder at xxxxxxx_STdC\example where xxxxxxx identifies a sensor part number.
  6. Uncomment the selected board definition in section /* STMicroelectronics evaluation boards definition */ in the selected example file (.c).
  7. Add the call to the example function inside the while(1) loop in the main() function themain.c file automatically generated by the STM32CubeMX tool.
  8. Enjoy :-)

3.b Running examples using different hardware

If a different MCU is used, please follow these steps:

  1. Add to your project the STMicroelectronics sensor driver. Driver files are located in the sensor drivers folder atxxxxxxx_STdC\driver\xxxxxxx_reg.c(.h) where xxxxxxx identifies a sensor part number.

  2. Add to your project the example source file (.c) that you are interested in. Example files are located in the sensor drivers folder at xxxxxxx_STdC\example where xxxxxxx identifies the sensor part number.

  3. Comment all the definitions of the boards in section `/* STMicroelectronics evaluation boards definition */ in the selected example file(.c).

  4. Add the call to the example function inside the while(1) loop in yourmain() function.

  5. Modify in the selected example file (.c) the hardware-related functions:

    • platform_write(void *handle, uint8_t Reg, uint8_t *Bufp,uint16_t len)
    • platform_read(void *handle, uint8_t Reg, uint8_t *Bufp, uint16_t len)
    • if needed add/replace the hardware-related functions reported in the example file.
  6. Enjoy :-)


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

Copyright (C) 2018 STMicroelectronics

You can’t perform that action at this time.