-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from cparata/master
First release
- Loading branch information
Showing
9 changed files
with
14,433 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
# LSM6DSR | ||
Arduino library to support the LSM6DSR 3D accelerometer and 3D gyroscope | ||
Arduino library to support the LSM6DSR automotive 3D accelerometer and 3D gyroscope | ||
|
||
## API | ||
|
||
This sensor uses I2C or SPI to communicate. | ||
For I2C it is then required to create a TwoWire interface before accessing to the sensors: | ||
|
||
dev_i2c = new TwoWire(I2C_SDA, I2C_SCL); | ||
dev_i2c->begin(); | ||
|
||
For SPI it is then required to create a SPI interface before accessing to the sensors: | ||
|
||
dev_spi = new SPIClass(SPI_MOSI, SPI_MISO, SPI_SCK); | ||
dev_spi->begin(); | ||
|
||
An instance can be created and enbaled when the I2C bus is used following the procedure below: | ||
|
||
AccGyr = new LSM6DSRSensor(dev_i2c); | ||
AccGyr->Enable_X(); | ||
AccGyr->Enable_G(); | ||
|
||
An instance can be created and enbaled when the SPI bus is used following the procedure below: | ||
|
||
AccGyr = new LSM6DSRSensor(dev_spi, CS_PIN); | ||
AccGyr->Enable_X(); | ||
AccGyr->Enable_G(); | ||
|
||
The access to the sensor values is done as explained below: | ||
|
||
Read accelerometer and gyroscope. | ||
|
||
AccGyr->Get_X_Axes(accelerometer); | ||
AccGyr->Get_G_Axes(gyroscope); | ||
|
||
## Documentation | ||
|
||
You can find the source files at | ||
https://github.com/stm32duino/LSM6DSR | ||
|
||
The LSM6DSR datasheet is available at | ||
https://www.st.com/content/st_com/en/products/mems-and-sensors/inemo-inertial-modules/lsm6dsr.html |
110 changes: 110 additions & 0 deletions
110
examples/LSM6DSR_I2C_HelloWorld/LSM6DSR_I2C_HelloWorld.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/** | ||
****************************************************************************** | ||
* @file LSM6DSR_I2C_HelloWorld.ino | ||
* @author SRA | ||
* @version V1.0.0 | ||
* @date March 2020 | ||
* @brief Arduino test application for the STMicrolectronics STEVAL-MKI194V1 | ||
* adapter board via I2C. | ||
* This application makes use of C++ classes obtained from the C | ||
* components' drivers. | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* <h2><center>© COPYRIGHT(c) 2020 STMicroelectronics</center></h2> | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3. Neither the name of STMicroelectronics nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************** | ||
*/ | ||
// In order to test this sketch you need to plug a STEVAL-MKI194V1 in the DIL24 adapter of the X-NUCLEO-IKS01A3 | ||
|
||
// Includes | ||
#include <LSM6DSRSensor.h> | ||
|
||
#ifdef ARDUINO_SAM_DUE | ||
#define DEV_I2C Wire1 | ||
#elif defined(ARDUINO_ARCH_STM32) | ||
#define DEV_I2C Wire | ||
#elif defined(ARDUINO_ARCH_AVR) | ||
#define DEV_I2C Wire | ||
#else | ||
#define DEV_I2C Wire | ||
#endif | ||
#define SerialPort Serial | ||
|
||
#define INT_1 A5 | ||
|
||
// Components | ||
LSM6DSRSensor *AccGyr; | ||
|
||
void setup() { | ||
// Led. | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
|
||
// Force INT1 of LSM6DSR low in order to enable I2C | ||
pinMode(INT_1, OUTPUT); | ||
|
||
digitalWrite(INT_1, LOW); | ||
|
||
delay(200); | ||
|
||
// Initialize serial for output. | ||
SerialPort.begin(115200); | ||
|
||
// Initialize I2C bus. | ||
DEV_I2C.begin(); | ||
|
||
AccGyr = new LSM6DSRSensor (&DEV_I2C, LSM6DSR_I2C_ADD_L); | ||
AccGyr->Enable_X(); | ||
AccGyr->Enable_G(); | ||
} | ||
|
||
void loop() { | ||
// Led blinking. | ||
digitalWrite(LED_BUILTIN, HIGH); | ||
delay(250); | ||
digitalWrite(LED_BUILTIN, LOW); | ||
delay(250); | ||
|
||
// Read accelerometer and gyroscope. | ||
int32_t accelerometer[3]; | ||
int32_t gyroscope[3]; | ||
AccGyr->Get_X_Axes(accelerometer); | ||
AccGyr->Get_G_Axes(gyroscope); | ||
|
||
// Output data. | ||
SerialPort.print("LSM6DSR: | Acc[mg]: "); | ||
SerialPort.print(accelerometer[0]); | ||
SerialPort.print(" "); | ||
SerialPort.print(accelerometer[1]); | ||
SerialPort.print(" "); | ||
SerialPort.print(accelerometer[2]); | ||
SerialPort.print(" | Gyr[mdps]: "); | ||
SerialPort.print(gyroscope[0]); | ||
SerialPort.print(" "); | ||
SerialPort.print(gyroscope[1]); | ||
SerialPort.print(" "); | ||
SerialPort.print(gyroscope[2]); | ||
SerialPort.println(" |"); | ||
} |
97 changes: 97 additions & 0 deletions
97
examples/LSM6DSR_SPI_HelloWorld/LSM6DSR_SPI_HelloWorld.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
****************************************************************************** | ||
* @file LSM6DSR_SPI_HelloWorld.ino | ||
* @author SRA | ||
* @version V1.0.0 | ||
* @date March 2020 | ||
* @brief Arduino test application for the STMicrolectronics STEVAL-MKI194V1 | ||
* adapter board via SPI. | ||
* This application makes use of C++ classes obtained from the C | ||
* components' drivers. | ||
****************************************************************************** | ||
* @attention | ||
* | ||
* <h2><center>© COPYRIGHT(c) 2020 STMicroelectronics</center></h2> | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, | ||
* are permitted provided that the following conditions are met: | ||
* 1. Redistributions of source code must retain the above copyright notice, | ||
* this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, | ||
* this list of conditions and the following disclaimer in the documentation | ||
* and/or other materials provided with the distribution. | ||
* 3. Neither the name of STMicroelectronics nor the names of its contributors | ||
* may be used to endorse or promote products derived from this software | ||
* without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
****************************************************************************** | ||
*/ | ||
// In order to test this sketch you need to plug a STEVAL-MKI194V1 in the DIL24 adapter of the X-NUCLEO-IKS01A3 | ||
// In order to configure the X-NUCLEO-IKS01A3 DIL24 adapter in SPI mode you need to unsolder SB5, SB12, SB19 and SB23 and solder SB6, SB10, SB18 and SB22 | ||
|
||
// Includes | ||
#include <LSM6DSRSensor.h> | ||
|
||
#define SerialPort Serial | ||
|
||
// SPI | ||
SPIClass *dev_spi; | ||
|
||
// Components | ||
LSM6DSRSensor *AccGyr; | ||
|
||
void setup() { | ||
// Led. | ||
pinMode(LED_BUILTIN, OUTPUT); | ||
|
||
// Initialize serial for output. | ||
SerialPort.begin(115200); | ||
|
||
// Initialize SPI bus. | ||
dev_spi = new SPIClass(D11, D12, D3); | ||
dev_spi->begin(); | ||
|
||
AccGyr = new LSM6DSRSensor (dev_spi, D10); | ||
AccGyr->Enable_X(); | ||
AccGyr->Enable_G(); | ||
} | ||
|
||
void loop() { | ||
// Led blinking. | ||
digitalWrite(LED_BUILTIN, HIGH); | ||
delay(250); | ||
digitalWrite(LED_BUILTIN, LOW); | ||
delay(250); | ||
|
||
// Read accelerometer and gyroscope. | ||
int32_t accelerometer[3]; | ||
int32_t gyroscope[3]; | ||
AccGyr->Get_X_Axes(accelerometer); | ||
AccGyr->Get_G_Axes(gyroscope); | ||
|
||
// Output data. | ||
SerialPort.print("LSM6DSR: | Acc[mg]: "); | ||
SerialPort.print(accelerometer[0]); | ||
SerialPort.print(" "); | ||
SerialPort.print(accelerometer[1]); | ||
SerialPort.print(" "); | ||
SerialPort.print(accelerometer[2]); | ||
SerialPort.print(" | Gyr[mdps]: "); | ||
SerialPort.print(gyroscope[0]); | ||
SerialPort.print(" "); | ||
SerialPort.print(gyroscope[1]); | ||
SerialPort.print(" "); | ||
SerialPort.print(gyroscope[2]); | ||
SerialPort.println(" |"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
####################################### | ||
# Syntax Coloring Map For LSM6DSR | ||
####################################### | ||
|
||
####################################### | ||
# Datatypes (KEYWORD1) | ||
####################################### | ||
|
||
LSM6DSRSensor KEYWORD1 | ||
|
||
####################################### | ||
# Methods and Functions (KEYWORD2) | ||
####################################### | ||
|
||
ReadID KEYWORD2 | ||
Enable_X KEYWORD2 | ||
Disable_X KEYWORD2 | ||
Get_X_Sensitivity KEYWORD2 | ||
Get_X_ODR KEYWORD2 | ||
Set_X_ODR KEYWORD2 | ||
Set_X_ODR_With_Mode KEYWORD2 | ||
Get_X_FS KEYWORD2 | ||
Set_X_FS KEYWORD2 | ||
Get_X_AxesRaw KEYWORD2 | ||
Get_X_Axes KEYWORD2 | ||
Get_X_DRDY_Status KEYWORD2 | ||
Enable_G KEYWORD2 | ||
Disable_G KEYWORD2 | ||
Get_G_Sensitivity KEYWORD2 | ||
Get_G_ODR KEYWORD2 | ||
Set_G_ODR KEYWORD2 | ||
Set_G_ODR_With_Mode KEYWORD2 | ||
Get_G_FS KEYWORD2 | ||
Set_G_FS KEYWORD2 | ||
Get_G_AxesRaw KEYWORD2 | ||
Get_G_Axes KEYWORD2 | ||
Get_G_DRDY_Status KEYWORD2 | ||
Read_Reg KEYWORD2 | ||
Write_Reg KEYWORD2 | ||
|
||
####################################### | ||
# Constants (LITERAL1) | ||
####################################### | ||
|
||
LSM6DSR_OK LITERAL1 | ||
LSM6DSR_ERROR LITERAL1 | ||
LSM6DSR_ACC_HIGH_PERFORMANCE_MODE LITERAL1 | ||
LSM6DSR_ACC_LOW_POWER_NORMAL_MODE LITERAL1 | ||
LSM6DSR_GYRO_HIGH_PERFORMANCE_MODE LITERAL1 | ||
LSM6DSR_GYRO_LOW_POWER_NORMAL_MODE LITERAL1 | ||
LSM6DSR_ACC_SENSITIVITY_FS_2G LITERAL1 | ||
LSM6DSR_ACC_SENSITIVITY_FS_4G LITERAL1 | ||
LSM6DSR_ACC_SENSITIVITY_FS_8G LITERAL1 | ||
LSM6DSR_ACC_SENSITIVITY_FS_16G LITERAL1 | ||
LSM6DSR_GYRO_SENSITIVITY_FS_125DPS LITERAL1 | ||
LSM6DSR_GYRO_SENSITIVITY_FS_250DPS LITERAL1 | ||
LSM6DSR_GYRO_SENSITIVITY_FS_500DPS LITERAL1 | ||
LSM6DSR_GYRO_SENSITIVITY_FS_1000DPS LITERAL1 | ||
LSM6DSR_GYRO_SENSITIVITY_FS_2000DPS LITERAL1 | ||
LSM6DSR_GYRO_SENSITIVITY_FS_4000DPS LITERAL1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name=STM32duino LSM6DSR | ||
version=1.0.0 | ||
author=SRA | ||
maintainer=stm32duino | ||
sentence=iNEMO inertial measurement unit. | ||
paragraph=This library provides Arduino support for the LSM6DSR iNEMO inertial sensor for STM32 boards. | ||
category=Sensors | ||
url=https://github.com/stm32duino/LSM6DSR | ||
architectures=stm32, avr, sam |
Oops, something went wrong.