├── Libraries ├── Arduino │ ├── examples │ │ ├── MinimalistExample │ │ │ ├── README.md │ │ │ └── MinimalistExample.ino │ │ ├── README.md │ │ ├── MemoryPagingExample │ │ │ └── MemoryPagingExample.ino │ │ ├── LowLevelExample │ │ │ └── LowLevelExample.ino │ │ ├── Pedometer │ │ │ └── Pedometer.ino │ │ ├── InterruptFreeFallConfig │ │ │ └── InterruptFreeFallConfig.ino │ │ ├── MultiI2C │ │ │ └── MultiI2C.ino │ │ ├── MultiSPI │ │ │ └── MultiSPI.ino │ │ ├── InterruptHWTapConfig │ │ │ └── InterruptHWTapConfig.ino │ │ └── FifoExample │ │ │ └── FifoExample.ino │ ├── extras │ │ └── class diagrams.pdf │ ├── src │ │ ├── README.md │ │ ├── SparkFunLSM6DS3.cpp │ │ └── SparkFunLSM6DS3.h │ ├── library.properties │ ├── .gitattributes │ ├── LICENSE.md │ ├── README.md │ ├── .gitignore │ └── keywords.txt └── README.md ├── Documentation ├── DM00133076.pdf ├── Test Plan.odt ├── Test Record.odt ├── class diagrams.odg ├── class diagrams.pdf ├── AN4650_DM00157511.pdf ├── Layout_CD00134799.pdf └── README.md ├── .gitattributes ├── README.md ├── LICENSE.md ├── .gitignore └── Hardware └── Eagle Library ├── LSM6DS3.l#1 └── LSM6DS3.lbr /Libraries/Arduino/examples/MinimalistExample/README.md: -------------------------------------------------------------------------------- 1 | Minimalist Example 2 | ======= 3 | 4 | Basic read function -------------------------------------------------------------------------------- /Documentation/DM00133076.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Documentation/DM00133076.pdf -------------------------------------------------------------------------------- /Documentation/Test Plan.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Documentation/Test Plan.odt -------------------------------------------------------------------------------- /Documentation/Test Record.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Documentation/Test Record.odt -------------------------------------------------------------------------------- /Documentation/class diagrams.odg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Documentation/class diagrams.odg -------------------------------------------------------------------------------- /Documentation/class diagrams.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Documentation/class diagrams.pdf -------------------------------------------------------------------------------- /Documentation/AN4650_DM00157511.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Documentation/AN4650_DM00157511.pdf -------------------------------------------------------------------------------- /Documentation/Layout_CD00134799.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Documentation/Layout_CD00134799.pdf -------------------------------------------------------------------------------- /Libraries/Arduino/extras/class diagrams.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/LSM6DS3_Breakout/HEAD/Libraries/Arduino/extras/class diagrams.pdf -------------------------------------------------------------------------------- /Libraries/Arduino/src/README.md: -------------------------------------------------------------------------------- 1 | This folder should contain the .cpp and .h files for the library. 2 | 3 | If backward compatibility is needed, source code should be placed in the library root folder and in a "utility" folder. 4 | 5 | Check out the [library specification](https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification) for more details. -------------------------------------------------------------------------------- /Libraries/Arduino/library.properties: -------------------------------------------------------------------------------- 1 | name=SparkFun LSM6DS3 Breakout 2 | version=1.0.0 3 | author=SparkFun Electronics 4 | maintainer=SparkFun Electronics 5 | sentence=A library to drive the STmicro LSM6DS3 by SPI or I2C. 6 | paragraph=Driver handles Mode 1 (slave device) in either SPI or I2C, interrupt readback, and FIFO operation 7 | category=Sensors 8 | url=https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 9 | architectures=* -------------------------------------------------------------------------------- /Documentation/README.md: -------------------------------------------------------------------------------- 1 | SparkFun Documentation 2 | ======================= 3 | 4 | File List 5 | --------- 6 | 7 | * AN4650_DM00157511.pdf - LSM6DS3 application note 8 | * class diagrams.odg - src class diagrams 9 | * class diagrams.pdf - export class diagrams 10 | * DM00133076.pdf - LSM6DS3 datasheet 11 | * Layout_CD00134799.pdf LSM6DS3 footprint information 12 | * README.md - This file 13 | * Test Plan.odt - description of things to test before release 14 | * Test Record.odt - Results and findings of HW test -------------------------------------------------------------------------------- /Libraries/README.md: -------------------------------------------------------------------------------- 1 | SparkFun LSM6DS3 Breakout Libraries 2 | ================================= 3 | 4 | Libraries for use in different environments. 5 | 6 | 7 | Directory Contents 8 | ------------------- 9 | * **/Arduino** - [Arduino IDE](http://www.arduino.cc/en/Main/Software) libraries 10 | 11 | 12 | Update Library Instructions: 13 | ---------------------------- 14 | To get the most up-to-date version of the library, you must run the following git subtree commands. 15 | 16 | $git subtree pull -P Libraries/ --squash master 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /Libraries/Arduino/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/README.md: -------------------------------------------------------------------------------- 1 | SparkFun Arduino Examples 2 | ========================== 3 | 4 | Example Briefs 5 | -------------- 6 | 7 | * FifoExample - Demonstrates using the built-in buffer to burst-collect data - **Good demonstration of settings** 8 | * InterruptFreeFall - Embedded function demonstrating free-fall detection 9 | * InterruptHWTapConfig - Embedded function demonstrating tap and double-tap detection 10 | * LowLevelExample - Demonstrates using only the core driver without math and settings overhead 11 | * MemoryPagingExample - Demonstrates switching between memory pages 12 | * MinimalistExample - The **easiest** configuration 13 | * MultiI2C - Using two LSM6DS3s over I2C 14 | * MultiSPI - Using two LSM6DS3s over SPI 15 | * Pedometer - Embedded function demonstrating step-counting feature 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SparkFun 2 | ======================================== 3 | 4 | ![LSM6DS3 Breakout](https://cdn.sparkfun.com/assets/learn_tutorials/4/1/6/perspective.jpg) 5 | 6 | [*LSM6DS3 Breakout (SEN-13339)*](https://www.sparkfun.com/products/13339) 7 | 8 | The LSM6DS3 Breakout board allows easy connection to the LSM6DS3. 9 | 10 | The LSM6DS3 is a accelerometer, gyroscope, and temperature sensor with embedded functions targeted at cellphones. It can do high sample rates and includes an 8kB FIFO buffer for burst reads. 11 | 12 | Repository Contents 13 | ------------------- 14 | 15 | * **/Documentation** - Data sheets, additional product information 16 | * **/Hardware** - Eagle design files (.brd, .sch) 17 | * **/Libraries** - Libraries for use with the LSM6DS3 Breakout 18 | * **/Production** - Production panel files (.brd) 19 | 20 | Documentation 21 | -------------- 22 | * **[Library](https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library)** - C++ library for the LSM6DS3 Breakout. 23 | * **[Hookup Guide](https://learn.sparkfun.com/tutorials/lsm6ds3-breakout-hookup-guide)** - Basic hookup guide for the LSM6DS3 Breakout. 24 | 25 | Product Versions 26 | ---------------- 27 | * [SEN-13339](https://www.sparkfun.com/products/13339)- LSM6DS3 Breakout board 28 | 29 | Version History 30 | --------------- 31 | * [V_1.0.0](https://github.com/sparkfun/LSM6DS3_Breakout/releases/tag/V_1.0.0) - Initial product release repository 32 | * [V_0.3.0](https://github.com/sparkfun/LSM6DS3_Breakout/releases/tag/V_0.3.0) - HW version 0.3 release 33 | 34 | License Information 35 | ------------------- 36 | 37 | This product is _**open source**_! 38 | 39 | Please review the LICENSE.md file for license information. 40 | 41 | If you have any questions or concerns on licensing, please contact techsupport@sparkfun.com. 42 | 43 | Distributed as-is; no warranty is given. 44 | 45 | - Your friends at SparkFun. 46 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/MinimalistExample/MinimalistExample.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | MinimalistExample.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | Most basic example of use. 11 | 12 | Example using the LSM6DS3 with basic settings. This sketch collects Gyro and 13 | Accelerometer data every second, then presents it on the serial monitor. 14 | 15 | Resources: 16 | Uses Wire.h for i2c operation 17 | Uses SPI.h for SPI operation 18 | Either can be omitted if not used 19 | 20 | Development environment specifics: 21 | Arduino IDE 1.6.4 22 | Teensy loader 1.23 23 | 24 | Hardware connections: 25 | Connect I2C SDA line to A4 26 | Connect I2C SCL line to A5 27 | Connect GND and 3.3v power to the IMU 28 | 29 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 30 | 31 | Please review the LICENSE.md file included with this example. If you have any questions 32 | or concerns with licensing, please contact techsupport@sparkfun.com. 33 | 34 | Distributed as-is; no warranty is given. 35 | ******************************************************************************/ 36 | 37 | #include "SparkFunLSM6DS3.h" 38 | #include "Wire.h" 39 | #include "SPI.h" 40 | 41 | LSM6DS3 myIMU; //Default constructor is I2C, addr 0x6B 42 | 43 | void setup() { 44 | // put your setup code here, to run once: 45 | Serial.begin(9600); 46 | delay(1000); //relax... 47 | Serial.println("Processor came out of reset.\n"); 48 | 49 | //Call .begin() to configure the IMU 50 | myIMU.begin(); 51 | 52 | } 53 | 54 | 55 | void loop() 56 | { 57 | //Get all parameters 58 | Serial.print("\nAccelerometer:\n"); 59 | Serial.print(" X = "); 60 | Serial.println(myIMU.readFloatAccelX(), 4); 61 | Serial.print(" Y = "); 62 | Serial.println(myIMU.readFloatAccelY(), 4); 63 | Serial.print(" Z = "); 64 | Serial.println(myIMU.readFloatAccelZ(), 4); 65 | 66 | Serial.print("\nGyroscope:\n"); 67 | Serial.print(" X = "); 68 | Serial.println(myIMU.readFloatGyroX(), 4); 69 | Serial.print(" Y = "); 70 | Serial.println(myIMU.readFloatGyroY(), 4); 71 | Serial.print(" Z = "); 72 | Serial.println(myIMU.readFloatGyroZ(), 4); 73 | 74 | Serial.print("\nThermometer:\n"); 75 | Serial.print(" Degrees C = "); 76 | Serial.println(myIMU.readTempC(), 4); 77 | Serial.print(" Degrees F = "); 78 | Serial.println(myIMU.readTempF(), 4); 79 | 80 | delay(1000); 81 | } 82 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | SparkFun License Information 2 | ============================ 3 | 4 | SparkFun uses two different licenses for our files — one for hardware and one for code. 5 | 6 | Hardware 7 | --------- 8 | 9 | **SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).** 10 | 11 | Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode). 12 | 13 | You are free to: 14 | 15 | Share — copy and redistribute the material in any medium or format 16 | Adapt — remix, transform, and build upon the material 17 | for any purpose, even commercially. 18 | The licensor cannot revoke these freedoms as long as you follow the license terms. 19 | Under the following terms: 20 | 21 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 22 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 23 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 24 | Notices: 25 | 26 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. 27 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material. 28 | 29 | 30 | Code 31 | -------- 32 | 33 | **SparkFun code, firmware, and software is released under the MIT License(http://opensource.org/licenses/MIT).** 34 | 35 | The MIT License (MIT) 36 | 37 | Copyright (c) 2015 SparkFun Electronics 38 | 39 | Permission is hereby granted, free of charge, to any person obtaining a copy 40 | of this software and associated documentation files (the "Software"), to deal 41 | in the Software without restriction, including without limitation the rights 42 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 43 | copies of the Software, and to permit persons to whom the Software is 44 | furnished to do so, subject to the following conditions: 45 | 46 | The above copyright notice and this permission notice shall be included in all 47 | copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 50 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 51 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 52 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 53 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 54 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 55 | SOFTWARE. 56 | -------------------------------------------------------------------------------- /Libraries/Arduino/LICENSE.md: -------------------------------------------------------------------------------- 1 | SparkFun License Information 2 | ============================ 3 | 4 | SparkFun uses two different licenses for our files - one for hardware and one for code. 5 | 6 | Hardware 7 | --------- 8 | 9 | **SparkFun hardware is released under [Creative Commons Share-alike 4.0 International](http://creativecommons.org/licenses/by-sa/4.0/).** 10 | 11 | Note: This is a human-readable summary of (and not a substitute for) the [license](http://creativecommons.org/licenses/by-sa/4.0/legalcode). 12 | 13 | You are free to: 14 | 15 | Share — copy and redistribute the material in any medium or format 16 | Adapt — remix, transform, and build upon the material 17 | for any purpose, even commercially. 18 | The licensor cannot revoke these freedoms as long as you follow the license terms. 19 | Under the following terms: 20 | 21 | Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 22 | ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 23 | No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. 24 | Notices: 25 | 26 | You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. 27 | No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material. 28 | 29 | 30 | Code 31 | -------- 32 | 33 | **SparkFun code, firmware, and software is released under the [MIT License](http://opensource.org/licenses/MIT).** 34 | 35 | The MIT License (MIT) 36 | 37 | Copyright (c) 2015 SparkFun Electronics 38 | 39 | Permission is hereby granted, free of charge, to any person obtaining a copy 40 | of this software and associated documentation files (the "Software"), to deal 41 | in the Software without restriction, including without limitation the rights 42 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 43 | copies of the Software, and to permit persons to whom the Software is 44 | furnished to do so, subject to the following conditions: 45 | 46 | The above copyright notice and this permission notice shall be included in all 47 | copies or substantial portions of the Software. 48 | 49 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 50 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 51 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 52 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 53 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 54 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 55 | SOFTWARE. 56 | 57 | 58 | -------------------------------------------------------------------------------- /Libraries/Arduino/README.md: -------------------------------------------------------------------------------- 1 | SparkFun LSM6DS3 Arduino Library 2 | ======================================== 3 | 4 | ![LSM6DS3 Breakout](https://cdn.sparkfun.com/assets/learn_tutorials/4/1/6/perspective.jpg) 5 | 6 | [*LSM6DS3 Breakout (SEN-13339)*](https://www.sparkfun.com/products/13339) 7 | 8 | This is an arduino IDE library to control the LSM6DS3. It can be configured to use I2C or SPI with 2 instances per I2C channel or any number of SPI instances. The top-level driver, class LSM6DS3, contains an inner driver LSM6DS3Core, a settings struct, and float-based math functions for conversion from raw to meaningful numbers. 9 | 10 | This has been tested with Arduino Uno and Teensy 3.1 architectures. 11 | 12 | Repository Contents 13 | ------------------- 14 | 15 | * **/examples** - Example sketches for the library (.ino). Run these from the Arduino IDE. 16 | * **/extras** - Contains class diagrams for the driver. Ignored by IDE. 17 | * **/src** - Source files for the library (.cpp, .h). 18 | * **keywords.txt** - Keywords from this library that will be highlighted in the Arduino IDE. 19 | * **library.properties** - General library properties for the Arduino package manager. 20 | 21 | Example Briefs 22 | -------------- 23 | 24 | * FifoExample - Demonstrates using the built-in buffer to burst-collect data - **Good demonstration of settings** 25 | * InterruptFreeFall - Embedded function demonstrating free-fall detection 26 | * InterruptHWTapConfig - Embedded function demonstrating tap and double-tap detection 27 | * LowLevelExample - Demonstrates using only the core driver without math and settings overhead 28 | * MemoryPagingExample - Demonstrates switching between memory pages 29 | * MinimalistExample - The **easiest** configuration 30 | * MultiI2C - Using two LSM6DS3s over I2C 31 | * MultiSPI - Using two LSM6DS3s over SPI 32 | * Pedometer - Embedded function demonstrating step-counting feature 33 | 34 | Documentation 35 | -------------- 36 | 37 | * **[Installing an Arduino Library Guide](https://learn.sparkfun.com/tutorials/installing-an-arduino-library)** - Basic information on how to install an Arduino library. 38 | * **[Product Repository](https://github.com/sparkfun/LSM6DS3_Breakout/)** - Main repository (including hardware files) for the LSM6DS3 Breakout. 39 | * **[Hookup Guide](https://learn.sparkfun.com/tutorials/lsm6ds3-breakout-hookup-guide)** - Basic hookup guide for the LSM6DS3 Breakout. 40 | 41 | Products that use this Library 42 | --------------------------------- 43 | 44 | * [SEN-13339](https://www.sparkfun.com/products/13339)- LSM6DS3 Breakout board 45 | 46 | Version History 47 | --------------- 48 | 49 | * [V 1.0.0](https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library/releases/tag/V_1.0.0) -- Initial commit of Arduino 1.6-compatible library. 50 | 51 | License Information 52 | ------------------- 53 | 54 | This product is _**open source**_! 55 | 56 | Please review the LICENSE.md file for license information. 57 | 58 | If you have any questions or concerns on licensing, please contact techsupport@sparkfun.com. 59 | 60 | Distributed as-is; no warranty is given. 61 | 62 | - Your friends at SparkFun. 63 | 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## SparkFun Useful stuff 3 | ################# 4 | 5 | ## AVR Development 6 | *.eep 7 | *.elf 8 | *.lst 9 | *.lss 10 | *.sym 11 | *.d 12 | *.o 13 | *.srec 14 | *.map 15 | 16 | ## Notepad++ backup files 17 | *.bak 18 | 19 | ## BOM files 20 | *bom* 21 | 22 | ################# 23 | ## Eclipse 24 | ################# 25 | 26 | *.pydevproject 27 | .project 28 | .metadata 29 | bin/ 30 | tmp/ 31 | *.tmp 32 | *.bak 33 | *.swp 34 | *~.nib 35 | local.properties 36 | .classpath 37 | .settings/ 38 | .loadpath 39 | 40 | # External tool builders 41 | .externalToolBuilders/ 42 | 43 | # Locally stored "Eclipse launch configurations" 44 | *.launch 45 | 46 | # CDT-specific 47 | .cproject 48 | 49 | # PDT-specific 50 | .buildpath 51 | 52 | 53 | ############# 54 | ## Eagle 55 | ############# 56 | 57 | # Ignore the board and schematic backup files 58 | *.b#? 59 | *.s#? 60 | 61 | 62 | ################# 63 | ## Visual Studio 64 | ################# 65 | 66 | ## Ignore Visual Studio temporary files, build results, and 67 | ## files generated by popular Visual Studio add-ons. 68 | 69 | # User-specific files 70 | *.suo 71 | *.user 72 | *.sln.docstates 73 | 74 | # Build results 75 | [Dd]ebug/ 76 | [Rr]elease/ 77 | *_i.c 78 | *_p.c 79 | *.ilk 80 | *.meta 81 | *.obj 82 | *.pch 83 | *.pdb 84 | *.pgc 85 | *.pgd 86 | *.rsp 87 | *.sbr 88 | *.tlb 89 | *.tli 90 | *.tlh 91 | *.tmp 92 | *.vspscc 93 | .builds 94 | *.dotCover 95 | 96 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 97 | #packages/ 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opensdf 104 | *.sdf 105 | 106 | # Visual Studio profiler 107 | *.psess 108 | *.vsp 109 | 110 | # ReSharper is a .NET coding add-in 111 | _ReSharper* 112 | 113 | # Installshield output folder 114 | [Ee]xpress 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish 128 | 129 | # Others 130 | [Bb]in 131 | [Oo]bj 132 | sql 133 | TestResults 134 | *.Cache 135 | ClientBin 136 | stylecop.* 137 | ~$* 138 | *.dbmdl 139 | Generated_Code #added for RIA/Silverlight projects 140 | 141 | # Backup & report files from converting an old project file to a newer 142 | # Visual Studio version. Backup files are not needed, because we have git ;-) 143 | _UpgradeReport_Files/ 144 | Backup*/ 145 | UpgradeLog*.XML 146 | 147 | 148 | ############ 149 | ## Windows 150 | ############ 151 | 152 | # Windows image file caches 153 | Thumbs.db 154 | 155 | # Folder config file 156 | Desktop.ini 157 | 158 | 159 | ############# 160 | ## Python 161 | ############# 162 | 163 | *.py[co] 164 | 165 | # Packages 166 | *.egg 167 | *.egg-info 168 | dist 169 | build 170 | eggs 171 | parts 172 | bin 173 | var 174 | sdist 175 | develop-eggs 176 | .installed.cfg 177 | 178 | # Installer logs 179 | pip-log.txt 180 | 181 | # Unit test / coverage reports 182 | .coverage 183 | .tox 184 | 185 | #Translations 186 | *.mo 187 | 188 | #Mr Developer 189 | .mr.developer.cfg 190 | 191 | # Mac crap 192 | .DS_Store 193 | -------------------------------------------------------------------------------- /Libraries/Arduino/.gitignore: -------------------------------------------------------------------------------- 1 | ################# 2 | ## SparkFun Useful stuff 3 | ################# 4 | 5 | ## AVR Development 6 | *.eep 7 | *.elf 8 | *.lst 9 | *.lss 10 | *.sym 11 | *.d 12 | *.o 13 | *.srec 14 | *.map 15 | 16 | ## Notepad++ backup files 17 | *.bak 18 | 19 | ## BOM files 20 | *bom* 21 | 22 | ################# 23 | ## Eclipse 24 | ################# 25 | 26 | *.pydevproject 27 | .project 28 | .metadata 29 | bin/ 30 | tmp/ 31 | *.tmp 32 | *.bak 33 | *.swp 34 | *~.nib 35 | local.properties 36 | .classpath 37 | .settings/ 38 | .loadpath 39 | 40 | # External tool builders 41 | .externalToolBuilders/ 42 | 43 | # Locally stored "Eclipse launch configurations" 44 | *.launch 45 | 46 | # CDT-specific 47 | .cproject 48 | 49 | # PDT-specific 50 | .buildpath 51 | 52 | 53 | ############# 54 | ## Eagle 55 | ############# 56 | 57 | # Ignore the board and schematic backup files 58 | *.b#? 59 | *.s#? 60 | 61 | 62 | ################# 63 | ## Visual Studio 64 | ################# 65 | 66 | ## Ignore Visual Studio temporary files, build results, and 67 | ## files generated by popular Visual Studio add-ons. 68 | 69 | # User-specific files 70 | *.suo 71 | *.user 72 | *.sln.docstates 73 | 74 | # Build results 75 | [Dd]ebug/ 76 | [Rr]elease/ 77 | *_i.c 78 | *_p.c 79 | *.ilk 80 | *.meta 81 | *.obj 82 | *.pch 83 | *.pdb 84 | *.pgc 85 | *.pgd 86 | *.rsp 87 | *.sbr 88 | *.tlb 89 | *.tli 90 | *.tlh 91 | *.tmp 92 | *.vspscc 93 | .builds 94 | *.dotCover 95 | 96 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 97 | #packages/ 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opensdf 104 | *.sdf 105 | 106 | # Visual Studio profiler 107 | *.psess 108 | *.vsp 109 | 110 | # ReSharper is a .NET coding add-in 111 | _ReSharper* 112 | 113 | # Installshield output folder 114 | [Ee]xpress 115 | 116 | # DocProject is a documentation generator add-in 117 | DocProject/buildhelp/ 118 | DocProject/Help/*.HxT 119 | DocProject/Help/*.HxC 120 | DocProject/Help/*.hhc 121 | DocProject/Help/*.hhk 122 | DocProject/Help/*.hhp 123 | DocProject/Help/Html2 124 | DocProject/Help/html 125 | 126 | # Click-Once directory 127 | publish 128 | 129 | # Others 130 | [Bb]in 131 | [Oo]bj 132 | sql 133 | TestResults 134 | *.Cache 135 | ClientBin 136 | stylecop.* 137 | ~$* 138 | *.dbmdl 139 | Generated_Code #added for RIA/Silverlight projects 140 | 141 | # Backup & report files from converting an old project file to a newer 142 | # Visual Studio version. Backup files are not needed, because we have git ;-) 143 | _UpgradeReport_Files/ 144 | Backup*/ 145 | UpgradeLog*.XML 146 | 147 | 148 | ############ 149 | ## Windows 150 | ############ 151 | 152 | # Windows image file caches 153 | Thumbs.db 154 | 155 | # Folder config file 156 | Desktop.ini 157 | 158 | 159 | ############# 160 | ## Python 161 | ############# 162 | 163 | *.py[co] 164 | 165 | # Packages 166 | *.egg 167 | *.egg-info 168 | dist 169 | build 170 | eggs 171 | parts 172 | bin 173 | var 174 | sdist 175 | develop-eggs 176 | .installed.cfg 177 | 178 | # Installer logs 179 | pip-log.txt 180 | 181 | # Unit test / coverage reports 182 | .coverage 183 | .tox 184 | 185 | #Translations 186 | *.mo 187 | 188 | #Mr Developer 189 | .mr.developer.cfg 190 | 191 | # Mac crap 192 | .DS_Store 193 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/MemoryPagingExample/MemoryPagingExample.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | MemoryPagingExample.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | This sketch switches between the base memory page and the embedded page. 11 | 12 | The test writes to a base address, switches pages, writes to a embedded location 13 | at the same numerical address, switches back and reads the original value. 14 | 15 | This sketch doesn't do any meaningful configuration for the LSM6DS3, just tests. 16 | 17 | Resources: 18 | Uses Wire.h for i2c operation 19 | Uses SPI.h for SPI operation 20 | 21 | Development environment specifics: 22 | Arduino IDE 1.6.4 23 | Teensy loader 1.23 24 | 25 | Hardware connections: 26 | Connect I2C SDA line to A4 27 | Connect I2C SCL line to A5 28 | Connect GND and 3.3v power to the IMU 29 | 30 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 31 | 32 | Please review the LICENSE.md file included with this example. If you have any questions 33 | or concerns with licensing, please contact techsupport@sparkfun.com. 34 | 35 | Distributed as-is; no warranty is given. 36 | ******************************************************************************/ 37 | 38 | #include "SparkFunLSM6DS3.h" 39 | #include "Wire.h" 40 | #include "SPI.h" 41 | 42 | uint16_t errorsAndWarnings = 0; 43 | 44 | LSM6DS3Core myIMU( I2C_MODE, 0x6B ); 45 | //LSM6DS3Core myIMU( SPI_MODE, 10 ); 46 | 47 | void setup() 48 | { 49 | Serial.begin(9600); 50 | delay(1000); //relax... 51 | Serial.println("Processor came out of reset.\n"); 52 | 53 | //Call .beginCore() to configure the IMU 54 | if( myIMU.beginCore() != 0 ) 55 | { 56 | Serial.print("Error at beginCore().\n"); 57 | } 58 | else 59 | { 60 | Serial.print("\nbeginCore() passed.\n"); 61 | } 62 | 63 | uint8_t dataVariable = 0; //Temporary variable 64 | 65 | 66 | //Write something to a base page location to make sure it gets preserved 67 | //Then, read it back 68 | if( myIMU.writeRegister( LSM6DS3_ACC_GYRO_FIFO_CTRL1, 0xF0 ) != 0 ) 69 | { 70 | errorsAndWarnings++; 71 | } 72 | if( myIMU.readRegister(&dataVariable, LSM6DS3_ACC_GYRO_FIFO_CTRL1) != 0 ) 73 | { 74 | errorsAndWarnings++; 75 | } 76 | Serial.print("FIFO_CTRL1 (should read 0xF0): 0x"); 77 | Serial.println(dataVariable, HEX); 78 | 79 | 80 | //Switch to the embedded page 81 | if( myIMU.embeddedPage() != 0 ) 82 | { 83 | errorsAndWarnings++; 84 | } 85 | 86 | //Write something to a the embedded page at the same address 87 | //Then, read it back 88 | if( myIMU.writeRegister( LSM6DS3_ACC_GYRO_SLV1_SUBADD, 0xA5 ) != 0 ) 89 | { 90 | errorsAndWarnings++; 91 | } 92 | //Now read it back and display it 93 | if( myIMU.readRegister(&dataVariable, LSM6DS3_ACC_GYRO_SLV1_SUBADD) != 0 ) 94 | { 95 | errorsAndWarnings++; 96 | } 97 | Serial.print("SUBADD (should read 0xA5): 0x"); 98 | Serial.println(dataVariable, HEX); 99 | 100 | //Switch back to the base page 101 | //Then, read back to see if our value has been preserved 102 | if( myIMU.basePage() != 0 ) 103 | { 104 | errorsAndWarnings++; 105 | } 106 | if( myIMU.readRegister(&dataVariable, LSM6DS3_ACC_GYRO_FIFO_CTRL1) != 0 ) 107 | { 108 | errorsAndWarnings++; 109 | } 110 | Serial.print("FIFO_CTRL1 (should read 0xF0): 0x"); 111 | Serial.println(dataVariable, HEX); 112 | 113 | Serial.print("Number of errors: "); 114 | Serial.println(errorsAndWarnings); 115 | } 116 | 117 | 118 | void loop() 119 | { 120 | while(1); 121 | } -------------------------------------------------------------------------------- /Libraries/Arduino/examples/LowLevelExample/LowLevelExample.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | LowLevelExample.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | Example using the LSM6DS3 with ONLY read and write methods. It's up to you to 11 | read the datasheets and get the sensor to behave as you will. 12 | 13 | This sketch saves a significant amount of memory because the settings and complex 14 | math (such as floating point variables) don't exist. The cost of saved memory is 15 | that the values are in 'counts', or raw data from the register. The user is 16 | responsible for converting these raw values into something meaningful. 17 | 18 | Use the register words from SparkFunLSM6DS3.h to manually configure the IC. 19 | 20 | Resources: 21 | Uses Wire.h for i2c operation 22 | Uses SPI.h for SPI operation 23 | 24 | Development environment specifics: 25 | Arduino IDE 1.6.4 26 | Teensy loader 1.23 27 | 28 | Hardware connections: 29 | Connect I2C SDA line to A4 30 | Connect I2C SCL line to A5 31 | Connect GND and 3.3v power to the IMU 32 | 33 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 34 | 35 | Please review the LICENSE.md file included with this example. If you have any questions 36 | or concerns with licensing, please contact techsupport@sparkfun.com. 37 | 38 | Distributed as-is; no warranty is given. 39 | ******************************************************************************/ 40 | 41 | #include "SparkFunLSM6DS3.h" 42 | #include "Wire.h" 43 | #include "SPI.h" 44 | 45 | uint16_t errorsAndWarnings = 0; 46 | 47 | LSM6DS3Core myIMU( I2C_MODE, 0x6B ); 48 | //LSM6DS3Core myIMU( SPI_MODE, 10 ); 49 | 50 | void setup() { 51 | // put your setup code here, to run once: 52 | Serial.begin(9600); 53 | delay(1000); //relax... 54 | Serial.println("Processor came out of reset.\n"); 55 | 56 | //Call .beginCore() to configure the IMU 57 | if( myIMU.beginCore() != 0 ) 58 | { 59 | Serial.print("Error at beginCore().\n"); 60 | } 61 | else 62 | { 63 | Serial.print("\nbeginCore() passed.\n"); 64 | } 65 | 66 | uint8_t dataToWrite = 0; //Temporary variable 67 | 68 | //Setup the accelerometer****************************** 69 | dataToWrite = 0; //Start Fresh! 70 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_100Hz; 71 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_8g; 72 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_104Hz; 73 | 74 | //Now, write the patched together data 75 | errorsAndWarnings += myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, dataToWrite); 76 | 77 | //Set the ODR bit 78 | errorsAndWarnings += myIMU.readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C); 79 | dataToWrite &= ~((uint8_t)LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED); 80 | 81 | } 82 | 83 | 84 | void loop() 85 | { 86 | int16_t temp; 87 | //Get all parameters 88 | Serial.print("\nAccelerometer Counts:\n"); 89 | Serial.print(" X = "); 90 | 91 | //Read a register into the temp variable. 92 | if( myIMU.readRegisterInt16(&temp, LSM6DS3_ACC_GYRO_OUTX_L_XL) != 0 ) 93 | { 94 | errorsAndWarnings++; 95 | } 96 | Serial.println(temp); 97 | Serial.print(" Y = "); 98 | 99 | //Read a register into the temp variable. 100 | if( myIMU.readRegisterInt16(&temp, LSM6DS3_ACC_GYRO_OUTY_L_XL) != 0 ) 101 | { 102 | errorsAndWarnings++; 103 | } 104 | Serial.println(temp); 105 | Serial.print(" Z = "); 106 | 107 | //Read a register into the temp variable. 108 | if( myIMU.readRegisterInt16(&temp, LSM6DS3_ACC_GYRO_OUTZ_L_XL) != 0 ) 109 | { 110 | errorsAndWarnings++; 111 | } 112 | Serial.println(temp); 113 | 114 | Serial.println(); 115 | Serial.print("Total reported Errors and Warnings: "); 116 | Serial.println(errorsAndWarnings); 117 | 118 | delay(1000); 119 | } -------------------------------------------------------------------------------- /Libraries/Arduino/examples/Pedometer/Pedometer.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | Pedometer.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | This sketch counts steps taken. 11 | 12 | Run the sketch and open a serial window at 9600 baud. The sketch will display 13 | the number of steps taken since reset. lightly tap the sensor on something at the 14 | rate of walking to simulate having the device in your pocket. Note that you must 15 | take 7 regularly spaced steps before the counter starts reporting. 16 | 17 | Push the reset button to reset the device and count. 18 | 19 | The configuration is determined by reading the LSM6DS3 datasheet and application 20 | note, then driving hex values to the registers of interest to set the appropriate 21 | bits. The sketch is based of the "LowLevelExampe" sketch. 22 | 23 | Resources: 24 | Uses Wire.h for i2c operation 25 | Uses SPI.h for SPI operation 26 | 27 | Development environment specifics: 28 | Arduino IDE 1.6.4 29 | Teensy loader 1.23 30 | 31 | Hardware connections: 32 | Connect I2C SDA line to A4 33 | Connect I2C SCL line to A5 34 | Connect GND and 3.3v power to the IMU 35 | 36 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 37 | 38 | Please review the LICENSE.md file included with this example. If you have any questions 39 | or concerns with licensing, please contact techsupport@sparkfun.com. 40 | 41 | Distributed as-is; no warranty is given. 42 | ******************************************************************************/ 43 | 44 | #include "SparkFunLSM6DS3.h" 45 | #include "Wire.h" 46 | #include "SPI.h" 47 | 48 | LSM6DS3Core myIMU( I2C_MODE, 0x6B ); 49 | //LSM6DS3Core myIMU( SPI_MODE, 10 ); 50 | 51 | void setup() 52 | { 53 | Serial.begin(9600); 54 | delay(1000); //relax... 55 | Serial.println("Processor came out of reset.\n"); 56 | 57 | //Call .beginCore() to configure the IMU 58 | if( myIMU.beginCore() != 0 ) 59 | { 60 | Serial.print("Error at beginCore().\n"); 61 | } 62 | else 63 | { 64 | Serial.print("\nbeginCore() passed.\n"); 65 | } 66 | 67 | //Error accumulation variable 68 | uint8_t errorAccumulator = 0; 69 | 70 | uint8_t dataToWrite = 0; //Temporary variable 71 | 72 | //Setup the accelerometer****************************** 73 | dataToWrite = 0; //Start Fresh! 74 | // dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_200Hz; 75 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_2g; 76 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_26Hz; 77 | 78 | // //Now, write the patched together data 79 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, dataToWrite); 80 | 81 | //Set the ODR bit 82 | errorAccumulator += myIMU.readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C); 83 | dataToWrite &= ~((uint8_t)LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED); 84 | 85 | 86 | // Enable embedded functions -- ALSO clears the pdeo step count 87 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL10_C, 0x3E); 88 | // Enable pedometer algorithm 89 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_TAP_CFG1, 0x40); 90 | // Step Detector interrupt driven to INT1 pin 91 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_INT1_CTRL, 0x10 ); 92 | 93 | if( errorAccumulator ) 94 | { 95 | Serial.println("Problem configuring the device."); 96 | } 97 | else 98 | { 99 | Serial.println("Device O.K."); 100 | } 101 | delay(200); 102 | } 103 | 104 | void loop() 105 | { 106 | uint8_t readDataByte = 0; 107 | uint16_t stepsTaken = 0; 108 | //Read the 16bit value by two 8bit operations 109 | myIMU.readRegister(&readDataByte, LSM6DS3_ACC_GYRO_STEP_COUNTER_H); 110 | stepsTaken = ((uint16_t)readDataByte) << 8; 111 | 112 | myIMU.readRegister(&readDataByte, LSM6DS3_ACC_GYRO_STEP_COUNTER_L); 113 | stepsTaken |= readDataByte; 114 | 115 | //Display steps taken 116 | Serial.print("Steps taken: "); 117 | Serial.println(stepsTaken); 118 | 119 | //Wait 1 second 120 | delay(1000); 121 | 122 | } 123 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/InterruptFreeFallConfig/InterruptFreeFallConfig.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | InterruptFreeFallConfig.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | This sketch demonstrates detecting the free-fall condition. 11 | 12 | Run the sketch, open a serial window at 9600 baud, then drop your 13 | sensor / arduino (And catch it!). The sketch will report the free-fall to 14 | the monitor. 15 | 16 | The configuration is determined by reading the LSM6DS3 datasheet and application 17 | note, then driving hex values to the registers of interest to set the appropriate 18 | bits. The sketch is based of the "LowLevelExampe" sketch. 19 | 20 | Resources: 21 | Uses Wire.h for i2c operation 22 | Uses SPI.h for SPI operation 23 | 24 | Development environment specifics: 25 | Arduino IDE 1.6.4 26 | Teensy loader 1.23 27 | 28 | Hardware connections: 29 | Connect I2C SDA line to A4 30 | Connect I2C SCL line to A5 31 | Connect GND and 3.3v power to the IMU 32 | 33 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 34 | 35 | Please review the LICENSE.md file included with this example. If you have any questions 36 | or concerns with licensing, please contact techsupport@sparkfun.com. 37 | 38 | Distributed as-is; no warranty is given. 39 | ******************************************************************************/ 40 | 41 | #include "SparkFunLSM6DS3.h" 42 | #include "Wire.h" 43 | #include "SPI.h" 44 | 45 | LSM6DS3Core myIMU( I2C_MODE, 0x6B ); 46 | //LSM6DS3Core myIMU( SPI_MODE, 10 ); 47 | 48 | void setup() { 49 | // put your setup code here, to run once: 50 | Serial.begin(9600); 51 | delay(1000); //relax... 52 | Serial.println("Sketch came out of reset.\n"); 53 | 54 | //Call .beginCore() to configure the IMU 55 | if( myIMU.beginCore() != 0 ) 56 | { 57 | Serial.print("Error at beginCore().\n"); 58 | } 59 | else 60 | { 61 | Serial.print("\nbeginCore() passed.\n"); 62 | } 63 | 64 | //Error accumulation variable 65 | uint8_t errorAccumulator = 0; 66 | 67 | uint8_t dataToWrite = 0; //Temporary variable 68 | 69 | //Setup the accelerometer****************************** 70 | dataToWrite = 0; //Start Fresh! 71 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_200Hz; 72 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_2g; 73 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_416Hz; 74 | 75 | // //Now, write the patched together data 76 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, dataToWrite); 77 | 78 | //Set the ODR bit 79 | errorAccumulator += myIMU.readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C); 80 | dataToWrite &= ~((uint8_t)LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED); 81 | 82 | 83 | // Write 00h into WAKE_UP_DUR 84 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_WAKE_UP_DUR, 0x00 ); 85 | 86 | // Set FF threshold (FF_THS[2:0] = 011b) 87 | // Set six samples event duration (FF_DUR[5:0] = 000110b) 88 | // Write 33h into FREE_FALL 89 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_FREE_FALL, 0x33); 90 | 91 | // FF interrupt driven to INT1 pin 92 | // Write 10h into MD1_CFG 93 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_MD1_CFG, 0x10 ); 94 | // Also route to INT2 pin 95 | // Write 10h into MD1_CFG 96 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_MD2_CFG, 0x10 ); 97 | 98 | // Latch interrupt 99 | // Write 01h into TAP_CFG 100 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_TAP_CFG1, 0x01); 101 | 102 | if( errorAccumulator ) 103 | { 104 | Serial.println("Problem configuring the device."); 105 | } 106 | else 107 | { 108 | Serial.println("Device O.K."); 109 | } 110 | } 111 | 112 | void loop() 113 | { 114 | uint8_t readDataByte = 0; 115 | //Read the wake-up source register 116 | myIMU.readRegister(&readDataByte, LSM6DS3_ACC_GYRO_WAKE_UP_SRC); 117 | //Mask off the FF_IA bit for free-fall detection 118 | readDataByte &= 0x20; 119 | //Check for free-fall 120 | if( readDataByte ) 121 | { 122 | //debounce 123 | delay(10); 124 | Serial.println("Interrupt caught. Free fall detected."); 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/MultiI2C/MultiI2C.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | MultiI2C.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | Example using up to two LSM6DS3s on the same I2C channel. If only one sensor 11 | is attached, this sketch reports failure on that channel and runs with the 12 | single sensor instead. 13 | 14 | Resources: 15 | Uses Wire.h for i2c operation 16 | Uses SPI.h for SPI operation 17 | Either can be omitted if not used 18 | 19 | Development environment specifics: 20 | Arduino IDE 1.6.4 21 | Teensy loader 1.23 22 | 23 | Hardware connections 24 | Connect I2C SDA line to A4 25 | Connect I2C SCL line to A5 26 | Connect GND and ***3.3v*** power to the IMU. The sensors are not 5v tolerant. 27 | 28 | (Multiple I2C devices use the same pins. Up to two LSM6DS3s are allowed. Use 29 | the solder jumper to select address 0x6A or 0x6B) 30 | 31 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 32 | 33 | Please review the LICENSE.md file included with this example. If you have any questions 34 | or concerns with licensing, please contact techsupport@sparkfun.com. 35 | 36 | Distributed as-is; no warranty is given. 37 | ******************************************************************************/ 38 | 39 | #include "SparkFunLSM6DS3.h" 40 | #include "Wire.h" 41 | #include "SPI.h" 42 | 43 | //Create two instances of the driver class 44 | LSM6DS3 SensorOne( I2C_MODE, 0x6A ); 45 | LSM6DS3 SensorTwo( I2C_MODE, 0x6B ); 46 | 47 | 48 | void setup() { 49 | // put your setup code here, to run once: 50 | Serial.begin(9600); 51 | delay(1000); //relax... 52 | Serial.println("Processor came out of reset.\n"); 53 | 54 | //Call .begin() to configure the IMUs 55 | if( SensorOne.begin() != 0 ) 56 | { 57 | Serial.println("Problem starting the sensor at 0x6A."); 58 | } 59 | else 60 | { 61 | Serial.println("Sensor at 0x6A started."); 62 | } 63 | if( SensorTwo.begin() != 0 ) 64 | { 65 | Serial.println("Problem starting the sensor at 0x6B."); 66 | } 67 | else 68 | { 69 | Serial.println("Sensor at 0x6B started."); 70 | } 71 | 72 | } 73 | 74 | 75 | void loop() 76 | { 77 | //Get all parameters 78 | Serial.print("\nAccelerometer:\n"); 79 | Serial.print(" X1 = "); 80 | Serial.println(SensorOne.readFloatAccelX(), 4); 81 | Serial.print(" Y1 = "); 82 | Serial.println(SensorOne.readFloatAccelY(), 4); 83 | Serial.print(" Z1 = "); 84 | Serial.println(SensorOne.readFloatAccelZ(), 4); 85 | Serial.print(" X2 = "); 86 | Serial.println(SensorTwo.readFloatAccelX(), 4); 87 | Serial.print(" Y2 = "); 88 | Serial.println(SensorTwo.readFloatAccelY(), 4); 89 | Serial.print(" Z2 = "); 90 | Serial.println(SensorTwo.readFloatAccelZ(), 4); 91 | 92 | Serial.print("\nGyroscope:\n"); 93 | Serial.print(" X1 = "); 94 | Serial.println(SensorOne.readFloatGyroX(), 4); 95 | Serial.print(" Y1 = "); 96 | Serial.println(SensorOne.readFloatGyroY(), 4); 97 | Serial.print(" Z1 = "); 98 | Serial.println(SensorOne.readFloatGyroZ(), 4); 99 | Serial.print(" X2 = "); 100 | Serial.println(SensorTwo.readFloatGyroX(), 4); 101 | Serial.print(" Y2 = "); 102 | Serial.println(SensorTwo.readFloatGyroY(), 4); 103 | Serial.print(" Z2 = "); 104 | Serial.println(SensorTwo.readFloatGyroZ(), 4); 105 | 106 | Serial.print("\nThermometer:\n"); 107 | Serial.print(" Degrees C1 = "); 108 | Serial.println(SensorOne.readTempC(), 4); 109 | Serial.print(" Degrees C2 = "); 110 | Serial.println(SensorTwo.readTempC(), 4); 111 | Serial.print(" Degrees F1 = "); 112 | Serial.println(SensorOne.readTempF(), 4); 113 | Serial.print(" Degrees F2 = "); 114 | Serial.println(SensorTwo.readTempF(), 4); 115 | 116 | Serial.print("\nSensorOne Bus Errors Reported:\n"); 117 | Serial.print(" All '1's = "); 118 | Serial.println(SensorOne.allOnesCounter); 119 | Serial.print(" Non-success = "); 120 | Serial.println(SensorOne.nonSuccessCounter); 121 | Serial.print("SensorTwo Bus Errors Reported:\n"); 122 | Serial.print(" All '1's = "); 123 | Serial.println(SensorTwo.allOnesCounter); 124 | Serial.print(" Non-success = "); 125 | Serial.println(SensorTwo.nonSuccessCounter); 126 | delay(1000); 127 | } 128 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/MultiSPI/MultiSPI.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | MultiSPI.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | Example using up to two LSM6DS3s on the same SPI channel, with different CS pins. 11 | If only one sensor is attached, this sketch reports failure on that channel and 12 | runs with the single sensor instead. 13 | 14 | Resources: 15 | Uses Wire.h for i2c operation 16 | Uses SPI.h for SPI operation 17 | Either can be omitted if not used 18 | 19 | Development environment specifics: 20 | Arduino IDE 1.6.4 21 | Teensy loader 1.23 22 | 23 | Hardware connections 24 | ***CAUTION -- SPI pins can not be connected directly to 5v IO*** 25 | 26 | Connect SDA/SDI lines to pin 11 through level shifters (MOSI) 27 | Connect SCL pin lines to pin 13 through level shifters (SCLK) 28 | Connect SDO/SA0 lines to pin 12 through level shifters (MISO) 29 | Connect CS to free pins through level shifters. This example uses 9 and 10. 30 | Connect GND and ***3.3v*** power to the IMU. The sensors are not 5v tolerant. 31 | 32 | (Multiple SPI devices share pins except for the Chip Select lines which 33 | are unique for each device on the bus.) 34 | 35 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 36 | 37 | Please review the LICENSE.md file included with this example. If you have any questions 38 | or concerns with licensing, please contact techsupport@sparkfun.com. 39 | 40 | Distributed as-is; no warranty is given. 41 | ******************************************************************************/ 42 | 43 | #include "SparkFunLSM6DS3.h" 44 | #include "Wire.h" 45 | #include "SPI.h" 46 | 47 | //Create two instances of the driver class 48 | LSM6DS3 SensorOne( SPI_MODE, 10 ); 49 | LSM6DS3 SensorTwo( SPI_MODE, 9 ); 50 | 51 | 52 | void setup() { 53 | // put your setup code here, to run once: 54 | Serial.begin(9600); 55 | delay(1000); //relax... 56 | Serial.println("Processor came out of reset.\n"); 57 | 58 | //Call .begin() to configure the IMUs 59 | if( SensorOne.begin() != 0 ) 60 | { 61 | Serial.println("Problem starting the sensor with CS @ Pin 10."); 62 | } 63 | else 64 | { 65 | Serial.println("Sensor with CS @ Pin 10 started."); 66 | } 67 | if( SensorTwo.begin() != 0 ) 68 | { 69 | Serial.println("Problem starting the sensor with CS @ Pin 9."); 70 | } 71 | else 72 | { 73 | Serial.println("Sensor with CS @ Pin 9 started."); 74 | } 75 | 76 | } 77 | 78 | 79 | void loop() 80 | { 81 | //Get all parameters 82 | Serial.print("\nAccelerometer:\n"); 83 | Serial.print(" X1 = "); 84 | Serial.println(SensorOne.readFloatAccelX(), 4); 85 | Serial.print(" Y1 = "); 86 | Serial.println(SensorOne.readFloatAccelY(), 4); 87 | Serial.print(" Z1 = "); 88 | Serial.println(SensorOne.readFloatAccelZ(), 4); 89 | Serial.print(" X2 = "); 90 | Serial.println(SensorTwo.readFloatAccelX(), 4); 91 | Serial.print(" Y2 = "); 92 | Serial.println(SensorTwo.readFloatAccelY(), 4); 93 | Serial.print(" Z2 = "); 94 | Serial.println(SensorTwo.readFloatAccelZ(), 4); 95 | 96 | Serial.print("\nGyroscope:\n"); 97 | Serial.print(" X1 = "); 98 | Serial.println(SensorOne.readFloatGyroX(), 4); 99 | Serial.print(" Y1 = "); 100 | Serial.println(SensorOne.readFloatGyroY(), 4); 101 | Serial.print(" Z1 = "); 102 | Serial.println(SensorOne.readFloatGyroZ(), 4); 103 | Serial.print(" X2 = "); 104 | Serial.println(SensorTwo.readFloatGyroX(), 4); 105 | Serial.print(" Y2 = "); 106 | Serial.println(SensorTwo.readFloatGyroY(), 4); 107 | Serial.print(" Z2 = "); 108 | Serial.println(SensorTwo.readFloatGyroZ(), 4); 109 | 110 | Serial.print("\nThermometer:\n"); 111 | Serial.print(" Degrees C = "); 112 | Serial.println(SensorTwo.readTempC(), 4); 113 | Serial.print(" Degrees F = "); 114 | Serial.println(SensorTwo.readTempF(), 4); 115 | 116 | Serial.print("\nSensorOne Bus Errors Reported:\n"); 117 | Serial.print(" All '1's = "); 118 | Serial.println(SensorOne.allOnesCounter); 119 | Serial.print(" Non-success = "); 120 | Serial.println(SensorOne.nonSuccessCounter); 121 | Serial.print("SensorTwo Bus Errors Reported:\n"); 122 | Serial.print(" All '1's = "); 123 | Serial.println(SensorTwo.allOnesCounter); 124 | Serial.print(" Non-success = "); 125 | Serial.println(SensorTwo.nonSuccessCounter); 126 | delay(1000); 127 | } 128 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/InterruptHWTapConfig/InterruptHWTapConfig.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | InterruptHWTapConfig.ino 3 | 4 | Marshall Taylor @ SparkFun Electronics 5 | May 20, 2015 6 | https://github.com/sparkfun/LSM6DS3_Breakout 7 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 8 | 9 | Description: 10 | Example using the LSM6DS3 interrupts. 11 | 12 | This sketch demonstrates one way to detect single and double-tap events using 13 | hardware interrupt pins. The LSM6DS3 pulses the int1 line once after the first 14 | tap, then again if a second tap comes in. 15 | 16 | The configuration is determined by reading the LSM6DS3 datasheet and application 17 | note, then driving hex values to the registers of interest to set the appropriate 18 | bits. The sketch is based of the "LowLevelExampe" sketch. 19 | 20 | Resources: 21 | Uses Wire.h for i2c operation 22 | Uses SPI.h for SPI operation 23 | 24 | Development environment specifics: 25 | Arduino IDE 1.6.4 26 | Teensy loader 1.23 27 | 28 | Hardware connections: 29 | Connect I2C SDA line to A4 30 | Connect I2C SCL line to A5 31 | Connect GND and 3.3v power to the IMU 32 | Connect INT1 to pin 2 -- Note: the atmega has 5v input and the LSM6DS3 is 3.3v 33 | output. This is OK because the input is high impedance and 3.3v is a logic '1' 34 | for 5v processors. The signal is correctly detected and nothing is damaged. 35 | 36 | Do not configure pin 2 as OUTPUT! 37 | 38 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 39 | 40 | Please review the LICENSE.md file included with this example. If you have any questions 41 | or concerns with licensing, please contact techsupport@sparkfun.com. 42 | 43 | Distributed as-is; no warranty is given. 44 | ******************************************************************************/ 45 | 46 | #include "SparkFunLSM6DS3.h" 47 | #include "Wire.h" 48 | #include "SPI.h" 49 | 50 | //Interrupt variables 51 | #define int1Pin 2 //Use pin 2 for int.0 on uno 52 | uint8_t int1Status = 0; 53 | 54 | LSM6DS3Core myIMU( I2C_MODE, 0x6B ); 55 | //LSM6DS3Core myIMU( SPI_MODE, 10 ); 56 | 57 | void setup() 58 | { 59 | Serial.begin(9600); 60 | delay(1000); //relax... 61 | Serial.println("Processor came out of reset.\n"); 62 | 63 | //Call .beginCore() to configure the IMU 64 | if( myIMU.beginCore() != 0 ) 65 | { 66 | Serial.print("Error at beginCore().\n"); 67 | } 68 | else 69 | { 70 | Serial.print("\nbeginCore() passed.\n"); 71 | } 72 | 73 | //Error accumulation variable 74 | uint8_t errorAccumulator = 0; 75 | 76 | uint8_t dataToWrite = 0; //Temporary variable 77 | 78 | //Setup the accelerometer****************************** 79 | dataToWrite = 0; //Start Fresh! 80 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_200Hz; 81 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_2g; 82 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_416Hz; 83 | 84 | // //Now, write the patched together data 85 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, dataToWrite); 86 | 87 | //Set the ODR bit 88 | errorAccumulator += myIMU.readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C); 89 | dataToWrite &= ~((uint8_t)LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED); 90 | 91 | // Enable tap detection on X, Y, Z axis, but do not latch output 92 | 93 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_TAP_CFG1, 0x0E ); 94 | 95 | // Set tap threshold 96 | // Write 0Ch into TAP_THS_6D 97 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_TAP_THS_6D, 0x03 ); 98 | 99 | // Set Duration, Quiet and Shock time windows 100 | // Write 7Fh into INT_DUR2 101 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_INT_DUR2, 0x7F ); 102 | 103 | // Single & Double tap enabled (SINGLE_DOUBLE_TAP = 1) 104 | // Write 80h into WAKE_UP_THS 105 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_WAKE_UP_THS, 0x80 ); 106 | 107 | // Single tap interrupt driven to INT1 pin -- enable latch 108 | // Write 08h into MD1_CFG 109 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_MD1_CFG, 0x48 ); 110 | 111 | if( errorAccumulator ) 112 | { 113 | Serial.println("Problem configuring the device."); 114 | } 115 | else 116 | { 117 | Serial.println("Device O.K."); 118 | } 119 | 120 | //Configure the atmega interrupt pin 121 | pinMode(int1Pin, INPUT); 122 | attachInterrupt(0, int1ISR, RISING); 123 | 124 | } 125 | 126 | 127 | void loop() 128 | { 129 | if( int1Status > 0 ) //If ISR has been serviced at least once 130 | { 131 | //Wait for a window (in case a second tap is coming) 132 | delay(300); 133 | 134 | //Check if there are more than one interrupt pulse 135 | if( int1Status == 1 ) 136 | { 137 | Serial.print("Single-tap event\n"); 138 | } 139 | if( int1Status > 1 ) 140 | { 141 | Serial.print("Double-tap event\n"); 142 | } 143 | 144 | //Clear the ISR counter 145 | int1Status = 0; 146 | } 147 | 148 | } 149 | 150 | 151 | void int1ISR() 152 | { 153 | //Serial.println("Interrupt serviced."); 154 | int1Status++; 155 | } 156 | 157 | 158 | -------------------------------------------------------------------------------- /Libraries/Arduino/examples/FifoExample/FifoExample.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | FifoExample.ino 3 | Example using the FIFO over SPI. 4 | 5 | Marshall Taylor @ SparkFun Electronics 6 | May 20, 2015 7 | https://github.com/sparkfun/LSM6DS3_Breakout 8 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 9 | 10 | Description: 11 | The FIFO is configured to take readings at 50Hz. When 100 samples have 12 | accumulated (when the "watermark" is reached), the sketch dumps the float values to the serial terminal. 13 | 14 | The FIFO can sample much faster but the serial port isn't fast enough to get 15 | that data out before another 100 samples get queued up. There is a 10ms delay 16 | placed after each line ("1.40,-4.41,-3.22,-0.01,0.01,0.99") so that the 17 | internal serial buffer is guaranteed to empty and not overflow. 18 | 19 | Cranking the sample rate up to 800Hz will result in the FIFO dumping routine 20 | never getting the FIFO back down to zero. 21 | 22 | Removing the 10ms delay allows the FIFO to be emptied, but then too much data 23 | gets placed in the serial write buffer and stability suffers. 24 | 25 | Resources: 26 | Uses Wire.h for I2C operation 27 | Uses SPI.h for SPI operation 28 | Either can be omitted if not used 29 | 30 | Development environment specifics: 31 | Arduino IDE 1.6.4 32 | Teensy loader 1.23 33 | 34 | Hardware connections: 35 | ***CAUTION -- SPI pins can not be connected directly to 5V IO*** 36 | 37 | Connect SDA/SDI line to pin 11 through a level shifter (MOSI) 38 | Connect SCL pin line to pin 13 through a level shifter (SCLK) 39 | Connect SDO/SA0 line to pin 12 through a level shifter (MISO) 40 | Connect CS to a free pin through a level shifter. This example uses pin 10. 41 | Connect GND and ***3.3v*** power to the IMU. The sensors are not 5v tolerant. 42 | 43 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 44 | 45 | Please review the LICENSE.md file included with this example. If you have any questions 46 | or concerns with licensing, please contact techsupport@sparkfun.com. 47 | 48 | Distributed as-is; no warranty is given. 49 | ******************************************************************************/ 50 | 51 | #include "SparkFunLSM6DS3.h" 52 | #include "Wire.h" 53 | #include "SPI.h" 54 | 55 | LSM6DS3 myIMU( SPI_MODE, 10 ); 56 | 57 | void setup( void ) { 58 | //Over-ride default settings if desired 59 | myIMU.settings.gyroEnabled = 1; //Can be 0 or 1 60 | myIMU.settings.gyroRange = 2000; //Max deg/s. Can be: 125, 245, 500, 1000, 2000 61 | myIMU.settings.gyroSampleRate = 833; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666 62 | myIMU.settings.gyroBandWidth = 200; //Hz. Can be: 50, 100, 200, 400; 63 | myIMU.settings.gyroFifoEnabled = 1; //Set to include gyro in FIFO 64 | myIMU.settings.gyroFifoDecimation = 1; //set 1 for on /1 65 | 66 | myIMU.settings.accelEnabled = 1; 67 | myIMU.settings.accelRange = 16; //Max G force readable. Can be: 2, 4, 8, 16 68 | myIMU.settings.accelSampleRate = 833; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666, 3332, 6664, 13330 69 | myIMU.settings.accelBandWidth = 200; //Hz. Can be: 50, 100, 200, 400; 70 | myIMU.settings.accelFifoEnabled = 1; //Set to include accelerometer in the FIFO 71 | myIMU.settings.accelFifoDecimation = 1; //set 1 for on /1 72 | myIMU.settings.tempEnabled = 1; 73 | 74 | //Non-basic mode settings 75 | myIMU.settings.commMode = 1; 76 | 77 | //FIFO control settings 78 | myIMU.settings.fifoThreshold = 100; //Can be 0 to 4096 (16 bit bytes) 79 | myIMU.settings.fifoSampleRate = 50; //Hz. Can be: 10, 25, 50, 100, 200, 400, 800, 1600, 3300, 6600 80 | myIMU.settings.fifoModeWord = 6; //FIFO mode. 81 | //FIFO mode. Can be: 82 | // 0 (Bypass mode, FIFO off) 83 | // 1 (Stop when full) 84 | // 3 (Continuous during trigger) 85 | // 4 (Bypass until trigger) 86 | // 6 (Continous mode) 87 | 88 | 89 | Serial.begin(57600); // start serial for output 90 | delay(1000); //relax... 91 | Serial.println("Processor came out of reset.\n"); 92 | 93 | //Call .begin() to configure the IMUs 94 | if( myIMU.begin() != 0 ) 95 | { 96 | Serial.println("Problem starting the sensor with CS @ Pin 10."); 97 | } 98 | else 99 | { 100 | Serial.println("Sensor with CS @ Pin 10 started."); 101 | } 102 | 103 | Serial.print("Configuring FIFO with no error checking..."); 104 | myIMU.fifoBegin(); 105 | Serial.print("Done!\n"); 106 | 107 | Serial.print("Clearing out the FIFO..."); 108 | myIMU.fifoClear(); 109 | Serial.print("Done!\n"); 110 | 111 | } 112 | 113 | 114 | void loop() 115 | { 116 | float temp; //This is to hold read data 117 | uint16_t tempUnsigned; 118 | 119 | while( ( myIMU.fifoGetStatus() & 0x8000 ) == 0 ) {}; //Wait for watermark 120 | 121 | //Now loop until FIFO is empty. NOTE: As the FIFO is only 8 bits wide, 122 | //the channels must be synchronized to a known position for the data to align 123 | //properly. Emptying the fifo is one way of doing this (this example) 124 | while( ( myIMU.fifoGetStatus() & 0x1000 ) == 0 ) { 125 | 126 | temp = myIMU.calcGyro(myIMU.fifoRead()); 127 | Serial.print(temp); 128 | Serial.print(","); 129 | 130 | temp = myIMU.calcGyro(myIMU.fifoRead()); 131 | Serial.print(temp); 132 | Serial.print(","); 133 | 134 | temp = myIMU.calcGyro(myIMU.fifoRead()); 135 | Serial.print(temp); 136 | Serial.print(","); 137 | 138 | temp = myIMU.calcAccel(myIMU.fifoRead()); 139 | Serial.print(temp); 140 | Serial.print(","); 141 | 142 | temp = myIMU.calcAccel(myIMU.fifoRead()); 143 | Serial.print(temp); 144 | Serial.print(","); 145 | 146 | temp = myIMU.calcAccel(myIMU.fifoRead()); 147 | Serial.print(temp); 148 | Serial.print("\n"); 149 | 150 | delay(10); //Wait for the serial buffer to clear (~50 bytes worth of time @ 57600baud) 151 | 152 | } 153 | 154 | tempUnsigned = myIMU.fifoGetStatus(); 155 | Serial.print("\nFifo Status 1 and 2 (16 bits): 0x"); 156 | Serial.println(tempUnsigned, HEX); 157 | Serial.print("\n"); 158 | 159 | } -------------------------------------------------------------------------------- /Libraries/Arduino/keywords.txt: -------------------------------------------------------------------------------- 1 | ######################################################## 2 | # Syntax Coloring Map for SparkFun LSM6DS3 IMU Library # 3 | ######################################################## 4 | # Class 5 | ################################################################### 6 | 7 | LSM6DS3 KEYWORD1 8 | LSM6DS3Core KEYWORD1 9 | 10 | ################################################################### 11 | # Methods and Functions 12 | ################################################################### 13 | 14 | beginCore KEYWORD2 15 | readRegisterRegion KEYWORD2 16 | readRegister KEYWORD2 17 | readRegisterInt16 KEYWORD2 18 | writeRegister KEYWORD2 19 | embeddedPage KEYWORD2 20 | basePage KEYWORD2 21 | begin KEYWORD2 22 | readRawAccelX KEYWORD2 23 | readRawAccelY KEYWORD2 24 | readRawAccelZ KEYWORD2 25 | readRawGyroX KEYWORD2 26 | readRawGyroY KEYWORD2 27 | readRawGyroZ KEYWORD2 28 | readFloatAccelX KEYWORD2 29 | readFloatAccelY KEYWORD2 30 | readFloatAccelZ KEYWORD2 31 | readFloatGyroX KEYWORD2 32 | readFloatGyroY KEYWORD2 33 | readFloatGyroZ KEYWORD2 34 | readRawTemp KEYWORD2 35 | readTempC KEYWORD2 36 | readTempF KEYWORD2 37 | fifoBegin KEYWORD2 38 | fifoClear KEYWORD2 39 | fifoRead KEYWORD2 40 | fifoGetStatus KEYWORD2 41 | fifoEnd KEYWORD2 42 | calcGyro KEYWORD2 43 | calcAccel KEYWORD2 44 | 45 | ################################################################### 46 | # Constants 47 | ################################################################### 48 | 49 | I2C_MODE LITERAL1 50 | SPI_MODE LITERAL1 51 | IMU_SUCCESS LITERAL1 52 | IMU_HW_ERROR LITERAL1 53 | IMU_NOT_SUPPORTED LITERAL1 54 | IMU_GENERIC_ERROR LITERAL1 55 | IMU_OUT_OF_BOUNDS LITERAL1 56 | IMU_ALL_ONES_WARNING LITERAL1 57 | LSM6DS3_ACC_GYRO_TEST_PAGE LITERAL1 58 | LSM6DS3_ACC_GYRO_RAM_ACCESS LITERAL1 59 | LSM6DS3_ACC_GYRO_SENSOR_SYNC_TIME LITERAL1 60 | LSM6DS3_ACC_GYRO_SENSOR_SYNC_EN LITERAL1 61 | LSM6DS3_ACC_GYRO_FIFO_CTRL1 LITERAL1 62 | LSM6DS3_ACC_GYRO_FIFO_CTRL2 LITERAL1 63 | LSM6DS3_ACC_GYRO_FIFO_CTRL3 LITERAL1 64 | LSM6DS3_ACC_GYRO_FIFO_CTRL4 LITERAL1 65 | LSM6DS3_ACC_GYRO_FIFO_CTRL5 LITERAL1 66 | LSM6DS3_ACC_GYRO_ORIENT_CFG_G LITERAL1 67 | LSM6DS3_ACC_GYRO_REFERENCE_G LITERAL1 68 | LSM6DS3_ACC_GYRO_INT1_CTRL LITERAL1 69 | LSM6DS3_ACC_GYRO_INT2_CTRL LITERAL1 70 | LSM6DS3_ACC_GYRO_WHO_AM_I_REG LITERAL1 71 | LSM6DS3_ACC_GYRO_CTRL1_XL LITERAL1 72 | LSM6DS3_ACC_GYRO_CTRL2_G LITERAL1 73 | LSM6DS3_ACC_GYRO_CTRL3_C LITERAL1 74 | LSM6DS3_ACC_GYRO_CTRL4_C LITERAL1 75 | LSM6DS3_ACC_GYRO_CTRL5_C LITERAL1 76 | LSM6DS3_ACC_GYRO_CTRL6_G LITERAL1 77 | LSM6DS3_ACC_GYRO_CTRL7_G LITERAL1 78 | LSM6DS3_ACC_GYRO_CTRL8_XL LITERAL1 79 | LSM6DS3_ACC_GYRO_CTRL9_XL LITERAL1 80 | LSM6DS3_ACC_GYRO_CTRL10_C LITERAL1 81 | LSM6DS3_ACC_GYRO_MASTER_CONFIG LITERAL1 82 | LSM6DS3_ACC_GYRO_WAKE_UP_SRC LITERAL1 83 | LSM6DS3_ACC_GYRO_TAP_SRC LITERAL1 84 | LSM6DS3_ACC_GYRO_D6D_SRC LITERAL1 85 | LSM6DS3_ACC_GYRO_STATUS_REG LITERAL1 86 | LSM6DS3_ACC_GYRO_OUT_TEMP_L LITERAL1 87 | LSM6DS3_ACC_GYRO_OUT_TEMP_H LITERAL1 88 | LSM6DS3_ACC_GYRO_OUTX_L_G LITERAL1 89 | LSM6DS3_ACC_GYRO_OUTX_H_G LITERAL1 90 | LSM6DS3_ACC_GYRO_OUTY_L_G LITERAL1 91 | LSM6DS3_ACC_GYRO_OUTY_H_G LITERAL1 92 | LSM6DS3_ACC_GYRO_OUTZ_L_G LITERAL1 93 | LSM6DS3_ACC_GYRO_OUTZ_H_G LITERAL1 94 | LSM6DS3_ACC_GYRO_OUTX_L_XL LITERAL1 95 | LSM6DS3_ACC_GYRO_OUTX_H_XL LITERAL1 96 | LSM6DS3_ACC_GYRO_OUTY_L_XL LITERAL1 97 | LSM6DS3_ACC_GYRO_OUTY_H_XL LITERAL1 98 | LSM6DS3_ACC_GYRO_OUTZ_L_XL LITERAL1 99 | LSM6DS3_ACC_GYRO_OUTZ_H_XL LITERAL1 100 | LSM6DS3_ACC_GYRO_SENSORHUB1_REG LITERAL1 101 | LSM6DS3_ACC_GYRO_SENSORHUB2_REG LITERAL1 102 | LSM6DS3_ACC_GYRO_SENSORHUB3_REG LITERAL1 103 | LSM6DS3_ACC_GYRO_SENSORHUB4_REG LITERAL1 104 | LSM6DS3_ACC_GYRO_SENSORHUB5_REG LITERAL1 105 | LSM6DS3_ACC_GYRO_SENSORHUB6_REG LITERAL1 106 | LSM6DS3_ACC_GYRO_SENSORHUB7_REG LITERAL1 107 | LSM6DS3_ACC_GYRO_SENSORHUB8_REG LITERAL1 108 | LSM6DS3_ACC_GYRO_SENSORHUB9_REG LITERAL1 109 | LSM6DS3_ACC_GYRO_SENSORHUB10_REG LITERAL1 110 | LSM6DS3_ACC_GYRO_SENSORHUB11_REG LITERAL1 111 | LSM6DS3_ACC_GYRO_SENSORHUB12_REG LITERAL1 112 | LSM6DS3_ACC_GYRO_FIFO_STATUS1 LITERAL1 113 | LSM6DS3_ACC_GYRO_FIFO_STATUS2 LITERAL1 114 | LSM6DS3_ACC_GYRO_FIFO_STATUS3 LITERAL1 115 | LSM6DS3_ACC_GYRO_FIFO_STATUS4 LITERAL1 116 | LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_L LITERAL1 117 | LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_H LITERAL1 118 | LSM6DS3_ACC_GYRO_TIMESTAMP0_REG LITERAL1 119 | LSM6DS3_ACC_GYRO_TIMESTAMP1_REG LITERAL1 120 | LSM6DS3_ACC_GYRO_TIMESTAMP2_REG LITERAL1 121 | LSM6DS3_ACC_GYRO_STEP_COUNTER_L LITERAL1 122 | LSM6DS3_ACC_GYRO_STEP_COUNTER_H LITERAL1 123 | LSM6DS3_ACC_GYRO_FUNC_SRC LITERAL1 124 | LSM6DS3_ACC_GYRO_TAP_CFG1 LITERAL1 125 | LSM6DS3_ACC_GYRO_TAP_THS_6D LITERAL1 126 | LSM6DS3_ACC_GYRO_INT_DUR2 LITERAL1 127 | LSM6DS3_ACC_GYRO_WAKE_UP_THS LITERAL1 128 | LSM6DS3_ACC_GYRO_WAKE_UP_DUR LITERAL1 129 | LSM6DS3_ACC_GYRO_FREE_FALL LITERAL1 130 | LSM6DS3_ACC_GYRO_MD1_CFG LITERAL1 131 | LSM6DS3_ACC_GYRO_MD2_CFG LITERAL1 132 | LSM6DS3_ACC_GYRO_ADDR0_TO_RW_RAM LITERAL1 133 | LSM6DS3_ACC_GYRO_ADDR1_TO_RW_RAM LITERAL1 134 | LSM6DS3_ACC_GYRO_DATA_TO_WR_RAM LITERAL1 135 | LSM6DS3_ACC_GYRO_DATA_RD_FROM_RAM LITERAL1 136 | LSM6DS3_ACC_GYRO_RAM_SIZE LITERAL1 137 | LSM6DS3_ACC_GYRO_SLV0_ADD LITERAL1 138 | LSM6DS3_ACC_GYRO_SLV0_SUBADD LITERAL1 139 | LSM6DS3_ACC_GYRO_SLAVE0_CONFIG LITERAL1 140 | LSM6DS3_ACC_GYRO_SLV1_ADD LITERAL1 141 | LSM6DS3_ACC_GYRO_SLV1_SUBADD LITERAL1 142 | LSM6DS3_ACC_GYRO_SLAVE1_CONFIG LITERAL1 143 | LSM6DS3_ACC_GYRO_SLV2_ADD LITERAL1 144 | LSM6DS3_ACC_GYRO_SLV2_SUBADD LITERAL1 145 | LSM6DS3_ACC_GYRO_SLAVE2_CONFIG LITERAL1 146 | LSM6DS3_ACC_GYRO_SLV3_ADD LITERAL1 147 | LSM6DS3_ACC_GYRO_SLV3_SUBADD LITERAL1 148 | LSM6DS3_ACC_GYRO_SLAVE3_CONFIG LITERAL1 149 | LSM6DS3_ACC_GYRO_DATAWRITE_SRC_MODE_SUB_SLV0 LITERAL1 150 | LSM6DS3_ACC_GYRO_CONFIG_PEDO_THS_MIN LITERAL1 151 | LSM6DS3_ACC_GYRO_CONFIG_TILT_IIR LITERAL1 152 | LSM6DS3_ACC_GYRO_CONFIG_TILT_ACOS LITERAL1 153 | LSM6DS3_ACC_GYRO_CONFIG_TILT_WTIME LITERAL1 154 | LSM6DS3_ACC_GYRO_SM_STEP_THS LITERAL1 155 | LSM6DS3_ACC_GYRO_MAG_SI_XX LITERAL1 156 | LSM6DS3_ACC_GYRO_MAG_SI_XY LITERAL1 157 | LSM6DS3_ACC_GYRO_MAG_SI_XZ LITERAL1 158 | LSM6DS3_ACC_GYRO_MAG_SI_YX LITERAL1 159 | LSM6DS3_ACC_GYRO_MAG_SI_YY LITERAL1 160 | LSM6DS3_ACC_GYRO_MAG_SI_YZ LITERAL1 161 | LSM6DS3_ACC_GYRO_MAG_SI_ZX LITERAL1 162 | LSM6DS3_ACC_GYRO_MAG_SI_ZY LITERAL1 163 | LSM6DS3_ACC_GYRO_MAG_SI_ZZ LITERAL1 164 | LSM6DS3_ACC_GYRO_MAG_OFFX_L LITERAL1 165 | LSM6DS3_ACC_GYRO_MAG_OFFX_H LITERAL1 166 | LSM6DS3_ACC_GYRO_MAG_OFFY_L LITERAL1 167 | LSM6DS3_ACC_GYRO_MAG_OFFY_H LITERAL1 168 | LSM6DS3_ACC_GYRO_MAG_OFFZ_L LITERAL1 169 | LSM6DS3_ACC_GYRO_MAG_OFFZ_H LITERAL1 170 | -------------------------------------------------------------------------------- /Hardware/Eagle Library/LSM6DS3.l#1: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | <b>Description:</b> This is a datasheet dictated footprint for the LSM6DS3 in the LGA 14L package. 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | >Value 204 | >Name 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | >Value 251 | >Name 252 | 253 | 254 | 255 | 256 | Schematic component for the iNEMO LSM6DS3 accelerometer and gyroscope. 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | >Name 276 | >Value 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | -------------------------------------------------------------------------------- /Hardware/Eagle Library/LSM6DS3.lbr: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | <b>Description:</b> This is a datasheet dictated footprint for the LSM6DS3 in the LGA 14L package. 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | >Value 204 | >Name 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | >Value 251 | >Name 252 | 253 | 254 | 255 | 256 | Schematic component for the iNEMO LSM6DS3 accelerometer and gyroscope. 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | >Name 276 | >Value 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | -------------------------------------------------------------------------------- /Libraries/Arduino/src/SparkFunLSM6DS3.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | SparkFunLSM6DS3.cpp 3 | LSM6DS3 Arduino and Teensy Driver 4 | 5 | Marshall Taylor @ SparkFun Electronics 6 | May 20, 2015 7 | https://github.com/sparkfun/LSM6DS3_Breakout 8 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 9 | 10 | Resources: 11 | Uses Wire.h for i2c operation 12 | Uses SPI.h for SPI operation 13 | Either can be omitted if not used 14 | 15 | Development environment specifics: 16 | Arduino IDE 1.6.4 17 | Teensy loader 1.23 18 | 19 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 20 | 21 | Please review the LICENSE.md file included with this example. If you have any questions 22 | or concerns with licensing, please contact techsupport@sparkfun.com. 23 | 24 | Distributed as-is; no warranty is given. 25 | ******************************************************************************/ 26 | 27 | //See SparkFunLSM6DS3.h for additional topology notes. 28 | 29 | #include "SparkFunLSM6DS3.h" 30 | #include "stdint.h" 31 | 32 | #include "Wire.h" 33 | #include "SPI.h" 34 | 35 | //****************************************************************************// 36 | // 37 | // LSM6DS3Core functions. 38 | // 39 | // Construction arguments: 40 | // ( uint8_t busType, uint8_t inputArg ), 41 | // 42 | // where inputArg is address for I2C_MODE and chip select pin 43 | // number for SPI_MODE 44 | // 45 | // For SPI, construct LSM6DS3Core myIMU(SPI_MODE, 10); 46 | // For I2C, construct LSM6DS3Core myIMU(I2C_MODE, 0x6B); 47 | // 48 | // Default construction is I2C mode, address 0x6B. 49 | // 50 | //****************************************************************************// 51 | LSM6DS3Core::LSM6DS3Core( uint8_t busType, uint8_t inputArg) : commInterface(I2C_MODE), I2CAddress(0x6B), chipSelectPin(10) 52 | { 53 | commInterface = busType; 54 | if( commInterface == I2C_MODE ) 55 | { 56 | I2CAddress = inputArg; 57 | } 58 | if( commInterface == SPI_MODE ) 59 | { 60 | chipSelectPin = inputArg; 61 | } 62 | 63 | } 64 | 65 | status_t LSM6DS3Core::beginCore(void) 66 | { 67 | status_t returnError = IMU_SUCCESS; 68 | 69 | switch (commInterface) { 70 | 71 | case I2C_MODE: 72 | Wire.begin(); 73 | break; 74 | 75 | case SPI_MODE: 76 | // start the SPI library: 77 | SPI.begin(); 78 | // Maximum SPI frequency is 10MHz, could divide by 2 here: 79 | SPI.setClockDivider(SPI_CLOCK_DIV4); 80 | // Data is read and written MSb first. 81 | SPI.setBitOrder(MSBFIRST); 82 | // Data is captured on rising edge of clock (CPHA = 0) 83 | // Base value of the clock is HIGH (CPOL = 1) 84 | 85 | // MODE3 for 328p operation 86 | #ifdef __AVR__ 87 | SPI.setDataMode(SPI_MODE3); 88 | #else 89 | #endif 90 | 91 | // MODE0 for Teensy 3.1 operation 92 | #ifdef __MK20DX256__ 93 | SPI.setDataMode(SPI_MODE0); 94 | #else 95 | #endif 96 | 97 | // initalize the data ready and chip select pins: 98 | pinMode(chipSelectPin, OUTPUT); 99 | digitalWrite(chipSelectPin, HIGH); 100 | break; 101 | default: 102 | break; 103 | } 104 | 105 | //Spin for a few ms 106 | volatile uint8_t temp = 0; 107 | for( uint16_t i = 0; i < 10000; i++ ) 108 | { 109 | temp++; 110 | } 111 | 112 | //Check the ID register to determine if the operation was a success. 113 | uint8_t readCheck; 114 | readRegister(&readCheck, LSM6DS3_ACC_GYRO_WHO_AM_I_REG); 115 | if( readCheck != 0x69 ) 116 | { 117 | returnError = IMU_HW_ERROR; 118 | } 119 | 120 | return returnError; 121 | 122 | } 123 | 124 | //****************************************************************************// 125 | // 126 | // ReadRegisterRegion 127 | // 128 | // Parameters: 129 | // *outputPointer -- Pass &variable (base address of) to save read data to 130 | // offset -- register to read 131 | // length -- number of bytes to read 132 | // 133 | // Note: Does not know if the target memory space is an array or not, or 134 | // if there is the array is big enough. if the variable passed is only 135 | // two bytes long and 3 bytes are requested, this will over-write some 136 | // other memory! 137 | // 138 | //****************************************************************************// 139 | status_t LSM6DS3Core::readRegisterRegion(uint8_t *outputPointer , uint8_t offset, uint8_t length) 140 | { 141 | status_t returnError = IMU_SUCCESS; 142 | 143 | //define pointer that will point to the external space 144 | uint8_t i = 0; 145 | uint8_t c = 0; 146 | uint8_t tempFFCounter = 0; 147 | 148 | switch (commInterface) { 149 | 150 | case I2C_MODE: 151 | Wire.beginTransmission(I2CAddress); 152 | Wire.write(offset); 153 | if( Wire.endTransmission() != 0 ) 154 | { 155 | returnError = IMU_HW_ERROR; 156 | } 157 | else //OK, all worked, keep going 158 | { 159 | // request 6 bytes from slave device 160 | Wire.requestFrom(I2CAddress, length); 161 | while ( (Wire.available()) && (i < length)) // slave may send less than requested 162 | { 163 | c = Wire.read(); // receive a byte as character 164 | *outputPointer = c; 165 | outputPointer++; 166 | i++; 167 | } 168 | } 169 | break; 170 | 171 | case SPI_MODE: 172 | // take the chip select low to select the device: 173 | digitalWrite(chipSelectPin, LOW); 174 | // send the device the register you want to read: 175 | SPI.transfer(offset | 0x80); //Ored with "read request" bit 176 | while ( i < length ) // slave may send less than requested 177 | { 178 | c = SPI.transfer(0x00); // receive a byte as character 179 | if( c == 0xFF ) 180 | { 181 | //May have problem 182 | tempFFCounter++; 183 | } 184 | *outputPointer = c; 185 | outputPointer++; 186 | i++; 187 | } 188 | if( tempFFCounter == i ) 189 | { 190 | //Ok, we've recieved all ones, report 191 | returnError = IMU_ALL_ONES_WARNING; 192 | } 193 | // take the chip select high to de-select: 194 | digitalWrite(chipSelectPin, HIGH); 195 | break; 196 | 197 | default: 198 | break; 199 | } 200 | 201 | return returnError; 202 | } 203 | 204 | //****************************************************************************// 205 | // 206 | // ReadRegister 207 | // 208 | // Parameters: 209 | // *outputPointer -- Pass &variable (address of) to save read data to 210 | // offset -- register to read 211 | // 212 | //****************************************************************************// 213 | status_t LSM6DS3Core::readRegister(uint8_t* outputPointer, uint8_t offset) { 214 | //Return value 215 | uint8_t result; 216 | uint8_t numBytes = 1; 217 | status_t returnError = IMU_SUCCESS; 218 | 219 | switch (commInterface) { 220 | 221 | case I2C_MODE: 222 | Wire.beginTransmission(I2CAddress); 223 | Wire.write(offset); 224 | if( Wire.endTransmission() != 0 ) 225 | { 226 | returnError = IMU_HW_ERROR; 227 | } 228 | Wire.requestFrom(I2CAddress, numBytes); 229 | while ( Wire.available() ) // slave may send less than requested 230 | { 231 | result = Wire.read(); // receive a byte as a proper uint8_t 232 | } 233 | break; 234 | 235 | case SPI_MODE: 236 | // take the chip select low to select the device: 237 | digitalWrite(chipSelectPin, LOW); 238 | // send the device the register you want to read: 239 | SPI.transfer(offset | 0x80); //Ored with "read request" bit 240 | // send a value of 0 to read the first byte returned: 241 | result = SPI.transfer(0x00); 242 | // take the chip select high to de-select: 243 | digitalWrite(chipSelectPin, HIGH); 244 | 245 | if( result == 0xFF ) 246 | { 247 | //we've recieved all ones, report 248 | returnError = IMU_ALL_ONES_WARNING; 249 | } 250 | break; 251 | 252 | default: 253 | break; 254 | } 255 | 256 | *outputPointer = result; 257 | return returnError; 258 | } 259 | 260 | //****************************************************************************// 261 | // 262 | // readRegisterInt16 263 | // 264 | // Parameters: 265 | // *outputPointer -- Pass &variable (base address of) to save read data to 266 | // offset -- register to read 267 | // 268 | //****************************************************************************// 269 | status_t LSM6DS3Core::readRegisterInt16( int16_t* outputPointer, uint8_t offset ) 270 | { 271 | uint8_t myBuffer[2]; 272 | status_t returnError = readRegisterRegion(myBuffer, offset, 2); //Does memory transfer 273 | int16_t output = (int16_t)myBuffer[0] | int16_t(myBuffer[1] << 8); 274 | 275 | *outputPointer = output; 276 | return returnError; 277 | } 278 | 279 | //****************************************************************************// 280 | // 281 | // writeRegister 282 | // 283 | // Parameters: 284 | // offset -- register to write 285 | // dataToWrite -- 8 bit data to write to register 286 | // 287 | //****************************************************************************// 288 | status_t LSM6DS3Core::writeRegister(uint8_t offset, uint8_t dataToWrite) { 289 | status_t returnError = IMU_SUCCESS; 290 | switch (commInterface) { 291 | case I2C_MODE: 292 | //Write the byte 293 | Wire.beginTransmission(I2CAddress); 294 | Wire.write(offset); 295 | Wire.write(dataToWrite); 296 | if( Wire.endTransmission() != 0 ) 297 | { 298 | returnError = IMU_HW_ERROR; 299 | } 300 | break; 301 | 302 | case SPI_MODE: 303 | // take the chip select low to select the device: 304 | digitalWrite(chipSelectPin, LOW); 305 | // send the device the register you want to read: 306 | SPI.transfer(offset); 307 | // send a value of 0 to read the first byte returned: 308 | SPI.transfer(dataToWrite); 309 | // decrement the number of bytes left to read: 310 | // take the chip select high to de-select: 311 | digitalWrite(chipSelectPin, HIGH); 312 | break; 313 | 314 | //No way to check error on this write (Except to read back but that's not reliable) 315 | 316 | default: 317 | break; 318 | } 319 | 320 | return returnError; 321 | } 322 | 323 | status_t LSM6DS3Core::embeddedPage( void ) 324 | { 325 | status_t returnError = writeRegister( LSM6DS3_ACC_GYRO_RAM_ACCESS, 0x80 ); 326 | 327 | return returnError; 328 | } 329 | 330 | status_t LSM6DS3Core::basePage( void ) 331 | { 332 | status_t returnError = writeRegister( LSM6DS3_ACC_GYRO_RAM_ACCESS, 0x00 ); 333 | 334 | return returnError; 335 | } 336 | 337 | 338 | //****************************************************************************// 339 | // 340 | // Main user class -- wrapper for the core class + maths 341 | // 342 | // Construct with same rules as the core ( uint8_t busType, uint8_t inputArg ) 343 | // 344 | //****************************************************************************// 345 | LSM6DS3::LSM6DS3( uint8_t busType, uint8_t inputArg ) : LSM6DS3Core( busType, inputArg ) 346 | { 347 | //Construct with these default settings 348 | 349 | settings.gyroEnabled = 1; //Can be 0 or 1 350 | settings.gyroRange = 2000; //Max deg/s. Can be: 125, 245, 500, 1000, 2000 351 | settings.gyroSampleRate = 416; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666 352 | settings.gyroBandWidth = 400; //Hz. Can be: 50, 100, 200, 400; 353 | settings.gyroFifoEnabled = 1; //Set to include gyro in FIFO 354 | settings.gyroFifoDecimation = 1; //set 1 for on /1 355 | 356 | settings.accelEnabled = 1; 357 | settings.accelODROff = 1; 358 | settings.accelRange = 16; //Max G force readable. Can be: 2, 4, 8, 16 359 | settings.accelSampleRate = 416; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666, 3332, 6664, 13330 360 | settings.accelBandWidth = 100; //Hz. Can be: 50, 100, 200, 400; 361 | settings.accelFifoEnabled = 1; //Set to include accelerometer in the FIFO 362 | settings.accelFifoDecimation = 1; //set 1 for on /1 363 | 364 | settings.tempEnabled = 1; 365 | 366 | //Select interface mode 367 | settings.commMode = 1; //Can be modes 1, 2 or 3 368 | 369 | //FIFO control data 370 | settings.fifoThreshold = 3000; //Can be 0 to 4096 (16 bit bytes) 371 | settings.fifoSampleRate = 10; //default 10Hz 372 | settings.fifoModeWord = 0; //Default off 373 | 374 | allOnesCounter = 0; 375 | nonSuccessCounter = 0; 376 | 377 | } 378 | 379 | //****************************************************************************// 380 | // 381 | // Configuration section 382 | // 383 | // This uses the stored SensorSettings to start the IMU 384 | // Use statements such as "myIMU.settings.commInterface = SPI_MODE;" or 385 | // "myIMU.settings.accelEnabled = 1;" to configure before calling .begin(); 386 | // 387 | //****************************************************************************// 388 | status_t LSM6DS3::begin() 389 | { 390 | //Check the settings structure values to determine how to setup the device 391 | uint8_t dataToWrite = 0; //Temporary variable 392 | 393 | //Begin the inherited core. This gets the physical wires connected 394 | status_t returnError = beginCore(); 395 | 396 | //Setup the accelerometer****************************** 397 | dataToWrite = 0; //Start Fresh! 398 | if ( settings.accelEnabled == 1) { 399 | //Build config reg 400 | //First patch in filter bandwidth 401 | switch (settings.accelBandWidth) { 402 | case 50: 403 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_50Hz; 404 | break; 405 | case 100: 406 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_100Hz; 407 | break; 408 | case 200: 409 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_200Hz; 410 | break; 411 | default: //set default case to max passthrough 412 | case 400: 413 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_400Hz; 414 | break; 415 | } 416 | //Next, patch in full scale 417 | switch (settings.accelRange) { 418 | case 2: 419 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_2g; 420 | break; 421 | case 4: 422 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_4g; 423 | break; 424 | case 8: 425 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_8g; 426 | break; 427 | default: //set default case to 16(max) 428 | case 16: 429 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_16g; 430 | break; 431 | } 432 | //Lastly, patch in accelerometer ODR 433 | switch (settings.accelSampleRate) { 434 | case 13: 435 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_13Hz; 436 | break; 437 | case 26: 438 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_26Hz; 439 | break; 440 | case 52: 441 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_52Hz; 442 | break; 443 | default: //Set default to 104 444 | case 104: 445 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_104Hz; 446 | break; 447 | case 208: 448 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_208Hz; 449 | break; 450 | case 416: 451 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_416Hz; 452 | break; 453 | case 833: 454 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_833Hz; 455 | break; 456 | case 1660: 457 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_1660Hz; 458 | break; 459 | case 3330: 460 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_3330Hz; 461 | break; 462 | case 6660: 463 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_6660Hz; 464 | break; 465 | case 13330: 466 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_13330Hz; 467 | break; 468 | } 469 | } 470 | else 471 | { 472 | //dataToWrite already = 0 (powerdown); 473 | } 474 | 475 | //Now, write the patched together data 476 | writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, dataToWrite); 477 | 478 | //Set the ODR bit 479 | readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C); 480 | dataToWrite &= ~((uint8_t)LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED); 481 | if ( settings.accelODROff == 1) { 482 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED; 483 | } 484 | writeRegister(LSM6DS3_ACC_GYRO_CTRL4_C, dataToWrite); 485 | 486 | //Setup the gyroscope********************************************** 487 | dataToWrite = 0; //Start Fresh! 488 | if ( settings.gyroEnabled == 1) { 489 | //Build config reg 490 | //First, patch in full scale 491 | switch (settings.gyroRange) { 492 | case 125: 493 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_125_ENABLED; 494 | break; 495 | case 245: 496 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_245dps; 497 | break; 498 | case 500: 499 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_500dps; 500 | break; 501 | case 1000: 502 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_1000dps; 503 | break; 504 | default: //Default to full 2000DPS range 505 | case 2000: 506 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_2000dps; 507 | break; 508 | } 509 | //Lastly, patch in gyro ODR 510 | switch (settings.gyroSampleRate) { 511 | case 13: 512 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_13Hz; 513 | break; 514 | case 26: 515 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_26Hz; 516 | break; 517 | case 52: 518 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_52Hz; 519 | break; 520 | default: //Set default to 104 521 | case 104: 522 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_104Hz; 523 | break; 524 | case 208: 525 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_208Hz; 526 | break; 527 | case 416: 528 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_416Hz; 529 | break; 530 | case 833: 531 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_833Hz; 532 | break; 533 | case 1660: 534 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_1660Hz; 535 | break; 536 | } 537 | } 538 | else 539 | { 540 | //dataToWrite already = 0 (powerdown); 541 | } 542 | //Write the byte 543 | writeRegister(LSM6DS3_ACC_GYRO_CTRL2_G, dataToWrite); 544 | 545 | //Setup the internal temperature sensor 546 | if ( settings.tempEnabled == 1) { 547 | } 548 | 549 | //Return WHO AM I reg //Not no mo! 550 | uint8_t result; 551 | readRegister(&result, LSM6DS3_ACC_GYRO_WHO_AM_I_REG); 552 | 553 | return returnError; 554 | } 555 | 556 | //****************************************************************************// 557 | // 558 | // Accelerometer section 559 | // 560 | //****************************************************************************// 561 | int16_t LSM6DS3::readRawAccelX( void ) 562 | { 563 | int16_t output; 564 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTX_L_XL ); 565 | if( errorLevel != IMU_SUCCESS ) 566 | { 567 | if( errorLevel == IMU_ALL_ONES_WARNING ) 568 | { 569 | allOnesCounter++; 570 | } 571 | else 572 | { 573 | nonSuccessCounter++; 574 | } 575 | } 576 | return output; 577 | } 578 | float LSM6DS3::readFloatAccelX( void ) 579 | { 580 | float output = calcAccel(readRawAccelX()); 581 | return output; 582 | } 583 | 584 | int16_t LSM6DS3::readRawAccelY( void ) 585 | { 586 | int16_t output; 587 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTY_L_XL ); 588 | if( errorLevel != IMU_SUCCESS ) 589 | { 590 | if( errorLevel == IMU_ALL_ONES_WARNING ) 591 | { 592 | allOnesCounter++; 593 | } 594 | else 595 | { 596 | nonSuccessCounter++; 597 | } 598 | } 599 | return output; 600 | } 601 | float LSM6DS3::readFloatAccelY( void ) 602 | { 603 | float output = calcAccel(readRawAccelY()); 604 | return output; 605 | } 606 | 607 | int16_t LSM6DS3::readRawAccelZ( void ) 608 | { 609 | int16_t output; 610 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTZ_L_XL ); 611 | if( errorLevel != IMU_SUCCESS ) 612 | { 613 | if( errorLevel == IMU_ALL_ONES_WARNING ) 614 | { 615 | allOnesCounter++; 616 | } 617 | else 618 | { 619 | nonSuccessCounter++; 620 | } 621 | } 622 | return output; 623 | } 624 | float LSM6DS3::readFloatAccelZ( void ) 625 | { 626 | float output = calcAccel(readRawAccelZ()); 627 | return output; 628 | } 629 | 630 | float LSM6DS3::calcAccel( int16_t input ) 631 | { 632 | float output = (float)input * 0.061 * (settings.accelRange >> 1) / 1000; 633 | return output; 634 | } 635 | 636 | //****************************************************************************// 637 | // 638 | // Gyroscope section 639 | // 640 | //****************************************************************************// 641 | int16_t LSM6DS3::readRawGyroX( void ) 642 | { 643 | int16_t output; 644 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTX_L_G ); 645 | if( errorLevel != IMU_SUCCESS ) 646 | { 647 | if( errorLevel == IMU_ALL_ONES_WARNING ) 648 | { 649 | allOnesCounter++; 650 | } 651 | else 652 | { 653 | nonSuccessCounter++; 654 | } 655 | } 656 | return output; 657 | } 658 | float LSM6DS3::readFloatGyroX( void ) 659 | { 660 | float output = calcGyro(readRawGyroX()); 661 | return output; 662 | } 663 | 664 | int16_t LSM6DS3::readRawGyroY( void ) 665 | { 666 | int16_t output; 667 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTY_L_G ); 668 | if( errorLevel != IMU_SUCCESS ) 669 | { 670 | if( errorLevel == IMU_ALL_ONES_WARNING ) 671 | { 672 | allOnesCounter++; 673 | } 674 | else 675 | { 676 | nonSuccessCounter++; 677 | } 678 | } 679 | return output; 680 | } 681 | float LSM6DS3::readFloatGyroY( void ) 682 | { 683 | float output = calcGyro(readRawGyroY()); 684 | return output; 685 | } 686 | 687 | int16_t LSM6DS3::readRawGyroZ( void ) 688 | { 689 | int16_t output; 690 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTZ_L_G ); 691 | if( errorLevel != IMU_SUCCESS ) 692 | { 693 | if( errorLevel == IMU_ALL_ONES_WARNING ) 694 | { 695 | allOnesCounter++; 696 | } 697 | else 698 | { 699 | nonSuccessCounter++; 700 | } 701 | } 702 | return output; 703 | } 704 | float LSM6DS3::readFloatGyroZ( void ) 705 | { 706 | float output = calcGyro(readRawGyroZ()); 707 | return output; 708 | } 709 | 710 | float LSM6DS3::calcGyro( int16_t input ) 711 | { 712 | uint8_t gyroRangeDivisor = settings.gyroRange / 125; 713 | if ( settings.gyroRange == 245 ) { 714 | gyroRangeDivisor = 2; 715 | } 716 | 717 | float output = (float)input * 4.375 * (gyroRangeDivisor) / 1000; 718 | return output; 719 | } 720 | 721 | //****************************************************************************// 722 | // 723 | // Temperature section 724 | // 725 | //****************************************************************************// 726 | int16_t LSM6DS3::readRawTemp( void ) 727 | { 728 | int16_t output; 729 | readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUT_TEMP_L ); 730 | return output; 731 | } 732 | 733 | float LSM6DS3::readTempC( void ) 734 | { 735 | float output = (float)readRawTemp() / 16; //divide by 16 to scale 736 | output += 25; //Add 25 degrees to remove offset 737 | 738 | return output; 739 | 740 | } 741 | 742 | float LSM6DS3::readTempF( void ) 743 | { 744 | float output = (float)readRawTemp() / 16; //divide by 16 to scale 745 | output += 25; //Add 25 degrees to remove offset 746 | output = (output * 9) / 5 + 32; 747 | 748 | return output; 749 | 750 | } 751 | 752 | //****************************************************************************// 753 | // 754 | // FIFO section 755 | // 756 | //****************************************************************************// 757 | void LSM6DS3::fifoBegin( void ) { 758 | //CONFIGURE THE VARIOUS FIFO SETTINGS 759 | // 760 | // 761 | //This section first builds a bunch of config words, then goes through 762 | //and writes them all. 763 | 764 | //Split and mask the threshold 765 | uint8_t thresholdLByte = settings.fifoThreshold & 0x00FF; 766 | uint8_t thresholdHByte = (settings.fifoThreshold & 0x0F00) >> 8; 767 | //Pedo bits not configured (ctl2) 768 | 769 | //CONFIGURE FIFO_CTRL3 770 | uint8_t tempFIFO_CTRL3 = 0; 771 | if (settings.gyroFifoEnabled == 1) 772 | { 773 | //Set up gyro stuff 774 | //Build on FIFO_CTRL3 775 | //Set decimation 776 | tempFIFO_CTRL3 |= (settings.gyroFifoDecimation & 0x07) << 3; 777 | 778 | } 779 | if (settings.accelFifoEnabled == 1) 780 | { 781 | //Set up accelerometer stuff 782 | //Build on FIFO_CTRL3 783 | //Set decimation 784 | tempFIFO_CTRL3 |= (settings.accelFifoDecimation & 0x07); 785 | } 786 | 787 | //CONFIGURE FIFO_CTRL4 (nothing for now-- sets data sets 3 and 4 788 | uint8_t tempFIFO_CTRL4 = 0; 789 | 790 | 791 | //CONFIGURE FIFO_CTRL5 792 | uint8_t tempFIFO_CTRL5 = 0; 793 | switch (settings.fifoSampleRate) { 794 | default: //set default case to 10Hz(slowest) 795 | case 10: 796 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_10Hz; 797 | break; 798 | case 25: 799 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_25Hz; 800 | break; 801 | case 50: 802 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_50Hz; 803 | break; 804 | case 100: 805 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_100Hz; 806 | break; 807 | case 200: 808 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_200Hz; 809 | break; 810 | case 400: 811 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_400Hz; 812 | break; 813 | case 800: 814 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_800Hz; 815 | break; 816 | case 1600: 817 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_1600Hz; 818 | break; 819 | case 3300: 820 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_3300Hz; 821 | break; 822 | case 6600: 823 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_6600Hz; 824 | break; 825 | } 826 | //Hard code the fifo mode here: 827 | tempFIFO_CTRL5 |= settings.fifoModeWord = 6; //set mode: 828 | 829 | //Write the data 830 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL1, thresholdLByte); 831 | //Serial.println(thresholdLByte, HEX); 832 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL2, thresholdHByte); 833 | //Serial.println(thresholdHByte, HEX); 834 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL3, tempFIFO_CTRL3); 835 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL4, tempFIFO_CTRL4); 836 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL5, tempFIFO_CTRL5); 837 | 838 | } 839 | void LSM6DS3::fifoClear( void ) { 840 | //Drain the fifo data and dump it 841 | while( (fifoGetStatus() & 0x1000 ) == 0 ) { 842 | fifoRead(); 843 | } 844 | 845 | } 846 | int16_t LSM6DS3::fifoRead( void ) { 847 | //Pull the last data from the fifo 848 | uint8_t tempReadByte = 0; 849 | uint16_t tempAccumulator = 0; 850 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_L); 851 | tempAccumulator = tempReadByte; 852 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_H); 853 | tempAccumulator |= ((uint16_t)tempReadByte << 8); 854 | 855 | return tempAccumulator; 856 | } 857 | 858 | uint16_t LSM6DS3::fifoGetStatus( void ) { 859 | //Return some data on the state of the fifo 860 | uint8_t tempReadByte = 0; 861 | uint16_t tempAccumulator = 0; 862 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_STATUS1); 863 | tempAccumulator = tempReadByte; 864 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_STATUS2); 865 | tempAccumulator |= (tempReadByte << 8); 866 | 867 | return tempAccumulator; 868 | 869 | } 870 | void LSM6DS3::fifoEnd( void ) { 871 | // turn off the fifo 872 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_STATUS1, 0x00); //Disable 873 | } 874 | 875 | -------------------------------------------------------------------------------- /Libraries/Arduino/src/SparkFunLSM6DS3.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | SparkFunLSM6DS3.h 3 | LSM6DS3 Arduino and Teensy Driver 4 | 5 | Marshall Taylor @ SparkFun Electronics 6 | May 20, 2015 7 | https://github.com/sparkfun/LSM6DS3_Breakout 8 | https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library 9 | 10 | Resources: 11 | Uses Wire.h for i2c operation 12 | Uses SPI.h for SPI operation 13 | Either can be omitted if not used 14 | 15 | Development environment specifics: 16 | Arduino IDE 1.6.4 17 | Teensy loader 1.23 18 | 19 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 20 | 21 | Please review the LICENSE.md file included with this example. If you have any questions 22 | or concerns with licensing, please contact techsupport@sparkfun.com. 23 | 24 | Distributed as-is; no warranty is given. 25 | ******************************************************************************/ 26 | 27 | #ifndef __LSM6DS3IMU_H__ 28 | #define __LSM6DS3IMU_H__ 29 | 30 | #include "stdint.h" 31 | 32 | #define I2C_MODE 0 33 | #define SPI_MODE 1 34 | 35 | // Return values 36 | typedef enum 37 | { 38 | IMU_SUCCESS, 39 | IMU_HW_ERROR, 40 | IMU_NOT_SUPPORTED, 41 | IMU_GENERIC_ERROR, 42 | IMU_OUT_OF_BOUNDS, 43 | IMU_ALL_ONES_WARNING, 44 | //... 45 | } status_t; 46 | 47 | //This is the core operational class of the driver. 48 | // LSM6DS3Core contains only read and write operations towards the IMU. 49 | // To use the higher level functions, use the class LSM6DS3 which inherits 50 | // this class. 51 | 52 | class LSM6DS3Core 53 | { 54 | public: 55 | LSM6DS3Core( uint8_t ); 56 | LSM6DS3Core( uint8_t, uint8_t ); 57 | ~LSM6DS3Core() = default; 58 | 59 | status_t beginCore( void ); 60 | 61 | //The following utilities read and write to the IMU 62 | 63 | //ReadRegisterRegion takes a uint8 array address as input and reads 64 | // a chunk of memory into that array. 65 | status_t readRegisterRegion(uint8_t*, uint8_t, uint8_t ); 66 | 67 | //readRegister reads one 8-bit register 68 | status_t readRegister(uint8_t*, uint8_t); 69 | 70 | //Reads two 8-bit regs, LSByte then MSByte order, and concatenates them. 71 | // Acts as a 16-bit read operation 72 | status_t readRegisterInt16(int16_t*, uint8_t offset ); 73 | 74 | //Writes an 8-bit byte; 75 | status_t writeRegister(uint8_t, uint8_t); 76 | 77 | //Change to embedded page 78 | status_t embeddedPage( void ); 79 | 80 | //Change to base page 81 | status_t basePage( void ); 82 | 83 | private: 84 | 85 | //Communication stuff 86 | uint8_t commInterface; 87 | uint8_t I2CAddress; 88 | uint8_t chipSelectPin; 89 | 90 | }; 91 | 92 | //This struct holds the settings the driver uses to do calculations 93 | struct SensorSettings { 94 | public: 95 | //Gyro settings 96 | uint8_t gyroEnabled; 97 | uint16_t gyroRange; 98 | uint16_t gyroSampleRate; 99 | uint16_t gyroBandWidth; 100 | 101 | uint8_t gyroFifoEnabled; 102 | uint8_t gyroFifoDecimation; 103 | 104 | //Accelerometer settings 105 | uint8_t accelEnabled; 106 | uint8_t accelODROff; 107 | uint16_t accelRange; 108 | uint16_t accelSampleRate; 109 | uint16_t accelBandWidth; 110 | 111 | uint8_t accelFifoEnabled; 112 | uint8_t accelFifoDecimation; 113 | 114 | //Temperature settings 115 | uint8_t tempEnabled; 116 | 117 | //Non-basic mode settings 118 | uint8_t commMode; 119 | 120 | //FIFO control data 121 | uint16_t fifoThreshold; 122 | int16_t fifoSampleRate; 123 | uint8_t fifoModeWord; 124 | 125 | }; 126 | 127 | 128 | //This is the highest level class of the driver. 129 | // 130 | // class LSM6DS3 inherits the core and makes use of the beginCore() 131 | //method through it's own begin() method. It also contains the 132 | //settings struct to hold user settings. 133 | 134 | class LSM6DS3 : public LSM6DS3Core 135 | { 136 | public: 137 | //IMU settings 138 | SensorSettings settings; 139 | 140 | //Error checking 141 | uint16_t allOnesCounter; 142 | uint16_t nonSuccessCounter; 143 | 144 | //Constructor generates default SensorSettings. 145 | //(over-ride after construction if desired) 146 | LSM6DS3( uint8_t busType = I2C_MODE, uint8_t inputArg = 0x6B ); 147 | ~LSM6DS3() = default; 148 | 149 | //Call to apply SensorSettings 150 | status_t begin(void); 151 | 152 | //Returns the raw bits from the sensor cast as 16-bit signed integers 153 | int16_t readRawAccelX( void ); 154 | int16_t readRawAccelY( void ); 155 | int16_t readRawAccelZ( void ); 156 | int16_t readRawGyroX( void ); 157 | int16_t readRawGyroY( void ); 158 | int16_t readRawGyroZ( void ); 159 | 160 | //Returns the values as floats. Inside, this calls readRaw___(); 161 | float readFloatAccelX( void ); 162 | float readFloatAccelY( void ); 163 | float readFloatAccelZ( void ); 164 | float readFloatGyroX( void ); 165 | float readFloatGyroY( void ); 166 | float readFloatGyroZ( void ); 167 | 168 | //Temperature related methods 169 | int16_t readRawTemp( void ); 170 | float readTempC( void ); 171 | float readTempF( void ); 172 | 173 | //FIFO stuff 174 | void fifoBegin( void ); 175 | void fifoClear( void ); 176 | int16_t fifoRead( void ); 177 | uint16_t fifoGetStatus( void ); 178 | void fifoEnd( void ); 179 | 180 | float calcGyro( int16_t ); 181 | float calcAccel( int16_t ); 182 | 183 | private: 184 | 185 | }; 186 | 187 | 188 | 189 | 190 | 191 | 192 | /************** Device Register *******************/ 193 | #define LSM6DS3_ACC_GYRO_TEST_PAGE 0X00 194 | #define LSM6DS3_ACC_GYRO_RAM_ACCESS 0X01 195 | #define LSM6DS3_ACC_GYRO_SENSOR_SYNC_TIME 0X04 196 | #define LSM6DS3_ACC_GYRO_SENSOR_SYNC_EN 0X05 197 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL1 0X06 198 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL2 0X07 199 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL3 0X08 200 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL4 0X09 201 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL5 0X0A 202 | #define LSM6DS3_ACC_GYRO_ORIENT_CFG_G 0X0B 203 | #define LSM6DS3_ACC_GYRO_REFERENCE_G 0X0C 204 | #define LSM6DS3_ACC_GYRO_INT1_CTRL 0X0D 205 | #define LSM6DS3_ACC_GYRO_INT2_CTRL 0X0E 206 | #define LSM6DS3_ACC_GYRO_WHO_AM_I_REG 0X0F 207 | #define LSM6DS3_ACC_GYRO_CTRL1_XL 0X10 208 | #define LSM6DS3_ACC_GYRO_CTRL2_G 0X11 209 | #define LSM6DS3_ACC_GYRO_CTRL3_C 0X12 210 | #define LSM6DS3_ACC_GYRO_CTRL4_C 0X13 211 | #define LSM6DS3_ACC_GYRO_CTRL5_C 0X14 212 | #define LSM6DS3_ACC_GYRO_CTRL6_G 0X15 213 | #define LSM6DS3_ACC_GYRO_CTRL7_G 0X16 214 | #define LSM6DS3_ACC_GYRO_CTRL8_XL 0X17 215 | #define LSM6DS3_ACC_GYRO_CTRL9_XL 0X18 216 | #define LSM6DS3_ACC_GYRO_CTRL10_C 0X19 217 | #define LSM6DS3_ACC_GYRO_MASTER_CONFIG 0X1A 218 | #define LSM6DS3_ACC_GYRO_WAKE_UP_SRC 0X1B 219 | #define LSM6DS3_ACC_GYRO_TAP_SRC 0X1C 220 | #define LSM6DS3_ACC_GYRO_D6D_SRC 0X1D 221 | #define LSM6DS3_ACC_GYRO_STATUS_REG 0X1E 222 | #define LSM6DS3_ACC_GYRO_OUT_TEMP_L 0X20 223 | #define LSM6DS3_ACC_GYRO_OUT_TEMP_H 0X21 224 | #define LSM6DS3_ACC_GYRO_OUTX_L_G 0X22 225 | #define LSM6DS3_ACC_GYRO_OUTX_H_G 0X23 226 | #define LSM6DS3_ACC_GYRO_OUTY_L_G 0X24 227 | #define LSM6DS3_ACC_GYRO_OUTY_H_G 0X25 228 | #define LSM6DS3_ACC_GYRO_OUTZ_L_G 0X26 229 | #define LSM6DS3_ACC_GYRO_OUTZ_H_G 0X27 230 | #define LSM6DS3_ACC_GYRO_OUTX_L_XL 0X28 231 | #define LSM6DS3_ACC_GYRO_OUTX_H_XL 0X29 232 | #define LSM6DS3_ACC_GYRO_OUTY_L_XL 0X2A 233 | #define LSM6DS3_ACC_GYRO_OUTY_H_XL 0X2B 234 | #define LSM6DS3_ACC_GYRO_OUTZ_L_XL 0X2C 235 | #define LSM6DS3_ACC_GYRO_OUTZ_H_XL 0X2D 236 | #define LSM6DS3_ACC_GYRO_SENSORHUB1_REG 0X2E 237 | #define LSM6DS3_ACC_GYRO_SENSORHUB2_REG 0X2F 238 | #define LSM6DS3_ACC_GYRO_SENSORHUB3_REG 0X30 239 | #define LSM6DS3_ACC_GYRO_SENSORHUB4_REG 0X31 240 | #define LSM6DS3_ACC_GYRO_SENSORHUB5_REG 0X32 241 | #define LSM6DS3_ACC_GYRO_SENSORHUB6_REG 0X33 242 | #define LSM6DS3_ACC_GYRO_SENSORHUB7_REG 0X34 243 | #define LSM6DS3_ACC_GYRO_SENSORHUB8_REG 0X35 244 | #define LSM6DS3_ACC_GYRO_SENSORHUB9_REG 0X36 245 | #define LSM6DS3_ACC_GYRO_SENSORHUB10_REG 0X37 246 | #define LSM6DS3_ACC_GYRO_SENSORHUB11_REG 0X38 247 | #define LSM6DS3_ACC_GYRO_SENSORHUB12_REG 0X39 248 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS1 0X3A 249 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS2 0X3B 250 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS3 0X3C 251 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS4 0X3D 252 | #define LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_L 0X3E 253 | #define LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_H 0X3F 254 | #define LSM6DS3_ACC_GYRO_TIMESTAMP0_REG 0X40 255 | #define LSM6DS3_ACC_GYRO_TIMESTAMP1_REG 0X41 256 | #define LSM6DS3_ACC_GYRO_TIMESTAMP2_REG 0X42 257 | #define LSM6DS3_ACC_GYRO_STEP_COUNTER_L 0X4B 258 | #define LSM6DS3_ACC_GYRO_STEP_COUNTER_H 0X4C 259 | #define LSM6DS3_ACC_GYRO_FUNC_SRC 0X53 260 | #define LSM6DS3_ACC_GYRO_TAP_CFG1 0X58 261 | #define LSM6DS3_ACC_GYRO_TAP_THS_6D 0X59 262 | #define LSM6DS3_ACC_GYRO_INT_DUR2 0X5A 263 | #define LSM6DS3_ACC_GYRO_WAKE_UP_THS 0X5B 264 | #define LSM6DS3_ACC_GYRO_WAKE_UP_DUR 0X5C 265 | #define LSM6DS3_ACC_GYRO_FREE_FALL 0X5D 266 | #define LSM6DS3_ACC_GYRO_MD1_CFG 0X5E 267 | #define LSM6DS3_ACC_GYRO_MD2_CFG 0X5F 268 | 269 | /************** Access Device RAM *******************/ 270 | #define LSM6DS3_ACC_GYRO_ADDR0_TO_RW_RAM 0x62 271 | #define LSM6DS3_ACC_GYRO_ADDR1_TO_RW_RAM 0x63 272 | #define LSM6DS3_ACC_GYRO_DATA_TO_WR_RAM 0x64 273 | #define LSM6DS3_ACC_GYRO_DATA_RD_FROM_RAM 0x65 274 | 275 | #define LSM6DS3_ACC_GYRO_RAM_SIZE 4096 276 | 277 | /************** Embedded functions register mapping *******************/ 278 | #define LSM6DS3_ACC_GYRO_SLV0_ADD 0x02 279 | #define LSM6DS3_ACC_GYRO_SLV0_SUBADD 0x03 280 | #define LSM6DS3_ACC_GYRO_SLAVE0_CONFIG 0x04 281 | #define LSM6DS3_ACC_GYRO_SLV1_ADD 0x05 282 | #define LSM6DS3_ACC_GYRO_SLV1_SUBADD 0x06 283 | #define LSM6DS3_ACC_GYRO_SLAVE1_CONFIG 0x07 284 | #define LSM6DS3_ACC_GYRO_SLV2_ADD 0x08 285 | #define LSM6DS3_ACC_GYRO_SLV2_SUBADD 0x09 286 | #define LSM6DS3_ACC_GYRO_SLAVE2_CONFIG 0x0A 287 | #define LSM6DS3_ACC_GYRO_SLV3_ADD 0x0B 288 | #define LSM6DS3_ACC_GYRO_SLV3_SUBADD 0x0C 289 | #define LSM6DS3_ACC_GYRO_SLAVE3_CONFIG 0x0D 290 | #define LSM6DS3_ACC_GYRO_DATAWRITE_SRC_MODE_SUB_SLV0 0x0E 291 | #define LSM6DS3_ACC_GYRO_CONFIG_PEDO_THS_MIN 0x0F 292 | #define LSM6DS3_ACC_GYRO_CONFIG_TILT_IIR 0x10 293 | #define LSM6DS3_ACC_GYRO_CONFIG_TILT_ACOS 0x11 294 | #define LSM6DS3_ACC_GYRO_CONFIG_TILT_WTIME 0x12 295 | #define LSM6DS3_ACC_GYRO_SM_STEP_THS 0x13 296 | #define LSM6DS3_ACC_GYRO_MAG_SI_XX 0x24 297 | #define LSM6DS3_ACC_GYRO_MAG_SI_XY 0x25 298 | #define LSM6DS3_ACC_GYRO_MAG_SI_XZ 0x26 299 | #define LSM6DS3_ACC_GYRO_MAG_SI_YX 0x27 300 | #define LSM6DS3_ACC_GYRO_MAG_SI_YY 0x28 301 | #define LSM6DS3_ACC_GYRO_MAG_SI_YZ 0x29 302 | #define LSM6DS3_ACC_GYRO_MAG_SI_ZX 0x2A 303 | #define LSM6DS3_ACC_GYRO_MAG_SI_ZY 0x2B 304 | #define LSM6DS3_ACC_GYRO_MAG_SI_ZZ 0x2C 305 | #define LSM6DS3_ACC_GYRO_MAG_OFFX_L 0x2D 306 | #define LSM6DS3_ACC_GYRO_MAG_OFFX_H 0x2E 307 | #define LSM6DS3_ACC_GYRO_MAG_OFFY_L 0x2F 308 | #define LSM6DS3_ACC_GYRO_MAG_OFFY_H 0x30 309 | #define LSM6DS3_ACC_GYRO_MAG_OFFZ_L 0x31 310 | #define LSM6DS3_ACC_GYRO_MAG_OFFZ_H 0x32 311 | 312 | /******************************************************************************* 313 | * Register : TEST_PAGE 314 | * Address : 0X00 315 | * Bit Group Name: FLASH_PAGE 316 | * Permission : RW 317 | *******************************************************************************/ 318 | #define FLASH_PAGE 0x40 319 | 320 | /******************************************************************************* 321 | * Register : RAM_ACCESS 322 | * Address : 0X01 323 | * Bit Group Name: PROG_RAM1 324 | * Permission : RW 325 | *******************************************************************************/ 326 | typedef enum { 327 | LSM6DS3_ACC_GYRO_PROG_RAM1_DISABLED = 0x00, 328 | LSM6DS3_ACC_GYRO_PROG_RAM1_ENABLED = 0x01, 329 | } LSM6DS3_ACC_GYRO_PROG_RAM1_t; 330 | 331 | /******************************************************************************* 332 | * Register : RAM_ACCESS 333 | * Address : 0X01 334 | * Bit Group Name: CUSTOMROM1 335 | * Permission : RW 336 | *******************************************************************************/ 337 | typedef enum { 338 | LSM6DS3_ACC_GYRO_CUSTOMROM1_DISABLED = 0x00, 339 | LSM6DS3_ACC_GYRO_CUSTOMROM1_ENABLED = 0x04, 340 | } LSM6DS3_ACC_GYRO_CUSTOMROM1_t; 341 | 342 | /******************************************************************************* 343 | * Register : RAM_ACCESS 344 | * Address : 0X01 345 | * Bit Group Name: RAM_PAGE 346 | * Permission : RW 347 | *******************************************************************************/ 348 | typedef enum { 349 | LSM6DS3_ACC_GYRO_RAM_PAGE_DISABLED = 0x00, 350 | LSM6DS3_ACC_GYRO_RAM_PAGE_ENABLED = 0x80, 351 | } LSM6DS3_ACC_GYRO_RAM_PAGE_t; 352 | 353 | /******************************************************************************* 354 | * Register : SENSOR_SYNC_TIME 355 | * Address : 0X04 356 | * Bit Group Name: TPH 357 | * Permission : RW 358 | *******************************************************************************/ 359 | #define LSM6DS3_ACC_GYRO_TPH_MASK 0xFF 360 | #define LSM6DS3_ACC_GYRO_TPH_POSITION 0 361 | 362 | /******************************************************************************* 363 | * Register : SENSOR_SYNC_EN 364 | * Address : 0X05 365 | * Bit Group Name: SYNC_EN 366 | * Permission : RW 367 | *******************************************************************************/ 368 | typedef enum { 369 | LSM6DS3_ACC_GYRO_SYNC_EN_DISABLED = 0x00, 370 | LSM6DS3_ACC_GYRO_SYNC_EN_ENABLED = 0x01, 371 | } LSM6DS3_ACC_GYRO_SYNC_EN_t; 372 | 373 | /******************************************************************************* 374 | * Register : SENSOR_SYNC_EN 375 | * Address : 0X05 376 | * Bit Group Name: HP_RST 377 | * Permission : RW 378 | *******************************************************************************/ 379 | typedef enum { 380 | LSM6DS3_ACC_GYRO_HP_RST_RST_OFF = 0x00, 381 | LSM6DS3_ACC_GYRO_HP_RST_RST_ON = 0x02, 382 | } LSM6DS3_ACC_GYRO_HP_RST_t; 383 | 384 | /******************************************************************************* 385 | * Register : FIFO_CTRL1 386 | * Address : 0X06 387 | * Bit Group Name: WTM_FIFO 388 | * Permission : RW 389 | *******************************************************************************/ 390 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL1_MASK 0xFF 391 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL1_POSITION 0 392 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL2_MASK 0x0F 393 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL2_POSITION 0 394 | 395 | /******************************************************************************* 396 | * Register : FIFO_CTRL2 397 | * Address : 0X07 398 | * Bit Group Name: TIM_PEDO_FIFO_DRDY 399 | * Permission : RW 400 | *******************************************************************************/ 401 | typedef enum { 402 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_DRDY_DISABLED = 0x00, 403 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_DRDY_ENABLED = 0x40, 404 | } LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_DRDY_t; 405 | 406 | /******************************************************************************* 407 | * Register : FIFO_CTRL2 408 | * Address : 0X07 409 | * Bit Group Name: TIM_PEDO_FIFO_EN 410 | * Permission : RW 411 | *******************************************************************************/ 412 | typedef enum { 413 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_EN_DISABLED = 0x00, 414 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_EN_ENABLED = 0x80, 415 | } LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_EN_t; 416 | 417 | /******************************************************************************* 418 | * Register : FIFO_CTRL3 419 | * Address : 0X08 420 | * Bit Group Name: DEC_FIFO_XL 421 | * Permission : RW 422 | *******************************************************************************/ 423 | typedef enum { 424 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DATA_NOT_IN_FIFO = 0x00, 425 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_NO_DECIMATION = 0x01, 426 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_2 = 0x02, 427 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_3 = 0x03, 428 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_4 = 0x04, 429 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_8 = 0x05, 430 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_16 = 0x06, 431 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_32 = 0x07, 432 | } LSM6DS3_ACC_GYRO_DEC_FIFO_XL_t; 433 | 434 | /******************************************************************************* 435 | * Register : FIFO_CTRL3 436 | * Address : 0X08 437 | * Bit Group Name: DEC_FIFO_G 438 | * Permission : RW 439 | *******************************************************************************/ 440 | typedef enum { 441 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DATA_NOT_IN_FIFO = 0x00, 442 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_NO_DECIMATION = 0x08, 443 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_2 = 0x10, 444 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_3 = 0x18, 445 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_4 = 0x20, 446 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_8 = 0x28, 447 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_16 = 0x30, 448 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_32 = 0x38, 449 | } LSM6DS3_ACC_GYRO_DEC_FIFO_G_t; 450 | 451 | /******************************************************************************* 452 | * Register : FIFO_CTRL4 453 | * Address : 0X09 454 | * Bit Group Name: DEC_FIFO_SLV0 455 | * Permission : RW 456 | *******************************************************************************/ 457 | typedef enum { 458 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DATA_NOT_IN_FIFO = 0x00, 459 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_NO_DECIMATION = 0x01, 460 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_2 = 0x02, 461 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_3 = 0x03, 462 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_4 = 0x04, 463 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_8 = 0x05, 464 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_16 = 0x06, 465 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_32 = 0x07, 466 | } LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_t; 467 | 468 | /******************************************************************************* 469 | * Register : FIFO_CTRL4 470 | * Address : 0X09 471 | * Bit Group Name: DEC_FIFO_SLV1 472 | * Permission : RW 473 | *******************************************************************************/ 474 | typedef enum { 475 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DATA_NOT_IN_FIFO = 0x00, 476 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_NO_DECIMATION = 0x08, 477 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_2 = 0x10, 478 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_3 = 0x18, 479 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_4 = 0x20, 480 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_8 = 0x28, 481 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_16 = 0x30, 482 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_32 = 0x38, 483 | } LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_t; 484 | 485 | /******************************************************************************* 486 | * Register : FIFO_CTRL4 487 | * Address : 0X09 488 | * Bit Group Name: HI_DATA_ONLY 489 | * Permission : RW 490 | *******************************************************************************/ 491 | typedef enum { 492 | LSM6DS3_ACC_GYRO_HI_DATA_ONLY_DISABLED = 0x00, 493 | LSM6DS3_ACC_GYRO_HI_DATA_ONLY_ENABLED = 0x40, 494 | } LSM6DS3_ACC_GYRO_HI_DATA_ONLY_t; 495 | 496 | /******************************************************************************* 497 | * Register : FIFO_CTRL5 498 | * Address : 0X0A 499 | * Bit Group Name: FIFO_MODE 500 | * Permission : RW 501 | *******************************************************************************/ 502 | typedef enum { 503 | LSM6DS3_ACC_GYRO_FIFO_MODE_BYPASS = 0x00, 504 | LSM6DS3_ACC_GYRO_FIFO_MODE_FIFO = 0x01, 505 | LSM6DS3_ACC_GYRO_FIFO_MODE_STREAM = 0x02, 506 | LSM6DS3_ACC_GYRO_FIFO_MODE_STF = 0x03, 507 | LSM6DS3_ACC_GYRO_FIFO_MODE_BTS = 0x04, 508 | LSM6DS3_ACC_GYRO_FIFO_MODE_DYN_STREAM = 0x05, 509 | LSM6DS3_ACC_GYRO_FIFO_MODE_DYN_STREAM_2 = 0x06, 510 | LSM6DS3_ACC_GYRO_FIFO_MODE_BTF = 0x07, 511 | } LSM6DS3_ACC_GYRO_FIFO_MODE_t; 512 | 513 | /******************************************************************************* 514 | * Register : FIFO_CTRL5 515 | * Address : 0X0A 516 | * Bit Group Name: ODR_FIFO 517 | * Permission : RW 518 | *******************************************************************************/ 519 | typedef enum { 520 | LSM6DS3_ACC_GYRO_ODR_FIFO_10Hz = 0x08, 521 | LSM6DS3_ACC_GYRO_ODR_FIFO_25Hz = 0x10, 522 | LSM6DS3_ACC_GYRO_ODR_FIFO_50Hz = 0x18, 523 | LSM6DS3_ACC_GYRO_ODR_FIFO_100Hz = 0x20, 524 | LSM6DS3_ACC_GYRO_ODR_FIFO_200Hz = 0x28, 525 | LSM6DS3_ACC_GYRO_ODR_FIFO_400Hz = 0x30, 526 | LSM6DS3_ACC_GYRO_ODR_FIFO_800Hz = 0x38, 527 | LSM6DS3_ACC_GYRO_ODR_FIFO_1600Hz = 0x40, 528 | LSM6DS3_ACC_GYRO_ODR_FIFO_3300Hz = 0x48, 529 | LSM6DS3_ACC_GYRO_ODR_FIFO_6600Hz = 0x50, 530 | LSM6DS3_ACC_GYRO_ODR_FIFO_13300Hz = 0x58, 531 | } LSM6DS3_ACC_GYRO_ODR_FIFO_t; 532 | 533 | /******************************************************************************* 534 | * Register : ORIENT_CFG_G 535 | * Address : 0X0B 536 | * Bit Group Name: ORIENT 537 | * Permission : RW 538 | *******************************************************************************/ 539 | typedef enum { 540 | LSM6DS3_ACC_GYRO_ORIENT_XYZ = 0x00, 541 | LSM6DS3_ACC_GYRO_ORIENT_XZY = 0x01, 542 | LSM6DS3_ACC_GYRO_ORIENT_YXZ = 0x02, 543 | LSM6DS3_ACC_GYRO_ORIENT_YZX = 0x03, 544 | LSM6DS3_ACC_GYRO_ORIENT_ZXY = 0x04, 545 | LSM6DS3_ACC_GYRO_ORIENT_ZYX = 0x05, 546 | } LSM6DS3_ACC_GYRO_ORIENT_t; 547 | 548 | /******************************************************************************* 549 | * Register : ORIENT_CFG_G 550 | * Address : 0X0B 551 | * Bit Group Name: SIGN_Z_G 552 | * Permission : RW 553 | *******************************************************************************/ 554 | typedef enum { 555 | LSM6DS3_ACC_GYRO_SIGN_Z_G_POSITIVE = 0x00, 556 | LSM6DS3_ACC_GYRO_SIGN_Z_G_NEGATIVE = 0x08, 557 | } LSM6DS3_ACC_GYRO_SIGN_Z_G_t; 558 | 559 | /******************************************************************************* 560 | * Register : ORIENT_CFG_G 561 | * Address : 0X0B 562 | * Bit Group Name: SIGN_Y_G 563 | * Permission : RW 564 | *******************************************************************************/ 565 | typedef enum { 566 | LSM6DS3_ACC_GYRO_SIGN_Y_G_POSITIVE = 0x00, 567 | LSM6DS3_ACC_GYRO_SIGN_Y_G_NEGATIVE = 0x10, 568 | } LSM6DS3_ACC_GYRO_SIGN_Y_G_t; 569 | 570 | /******************************************************************************* 571 | * Register : ORIENT_CFG_G 572 | * Address : 0X0B 573 | * Bit Group Name: SIGN_X_G 574 | * Permission : RW 575 | *******************************************************************************/ 576 | typedef enum { 577 | LSM6DS3_ACC_GYRO_SIGN_X_G_POSITIVE = 0x00, 578 | LSM6DS3_ACC_GYRO_SIGN_X_G_NEGATIVE = 0x20, 579 | } LSM6DS3_ACC_GYRO_SIGN_X_G_t; 580 | 581 | /******************************************************************************* 582 | * Register : REFERENCE_G 583 | * Address : 0X0C 584 | * Bit Group Name: REF_G 585 | * Permission : RW 586 | *******************************************************************************/ 587 | #define LSM6DS3_ACC_GYRO_REF_G_MASK 0xFF 588 | #define LSM6DS3_ACC_GYRO_REF_G_POSITION 0 589 | 590 | /******************************************************************************* 591 | * Register : INT1_CTRL 592 | * Address : 0X0D 593 | * Bit Group Name: INT1_DRDY_XL 594 | * Permission : RW 595 | *******************************************************************************/ 596 | typedef enum { 597 | LSM6DS3_ACC_GYRO_INT1_DRDY_XL_DISABLED = 0x00, 598 | LSM6DS3_ACC_GYRO_INT1_DRDY_XL_ENABLED = 0x01, 599 | } LSM6DS3_ACC_GYRO_INT1_DRDY_XL_t; 600 | 601 | /******************************************************************************* 602 | * Register : INT1_CTRL 603 | * Address : 0X0D 604 | * Bit Group Name: INT1_DRDY_G 605 | * Permission : RW 606 | *******************************************************************************/ 607 | typedef enum { 608 | LSM6DS3_ACC_GYRO_INT1_DRDY_G_DISABLED = 0x00, 609 | LSM6DS3_ACC_GYRO_INT1_DRDY_G_ENABLED = 0x02, 610 | } LSM6DS3_ACC_GYRO_INT1_DRDY_G_t; 611 | 612 | /******************************************************************************* 613 | * Register : INT1_CTRL 614 | * Address : 0X0D 615 | * Bit Group Name: INT1_BOOT 616 | * Permission : RW 617 | *******************************************************************************/ 618 | typedef enum { 619 | LSM6DS3_ACC_GYRO_INT1_BOOT_DISABLED = 0x00, 620 | LSM6DS3_ACC_GYRO_INT1_BOOT_ENABLED = 0x04, 621 | } LSM6DS3_ACC_GYRO_INT1_BOOT_t; 622 | 623 | /******************************************************************************* 624 | * Register : INT1_CTRL 625 | * Address : 0X0D 626 | * Bit Group Name: INT1_FTH 627 | * Permission : RW 628 | *******************************************************************************/ 629 | typedef enum { 630 | LSM6DS3_ACC_GYRO_INT1_FTH_DISABLED = 0x00, 631 | LSM6DS3_ACC_GYRO_INT1_FTH_ENABLED = 0x08, 632 | } LSM6DS3_ACC_GYRO_INT1_FTH_t; 633 | 634 | /******************************************************************************* 635 | * Register : INT1_CTRL 636 | * Address : 0X0D 637 | * Bit Group Name: INT1_OVR 638 | * Permission : RW 639 | *******************************************************************************/ 640 | typedef enum { 641 | LSM6DS3_ACC_GYRO_INT1_OVR_DISABLED = 0x00, 642 | LSM6DS3_ACC_GYRO_INT1_OVR_ENABLED = 0x10, 643 | } LSM6DS3_ACC_GYRO_INT1_OVR_t; 644 | 645 | /******************************************************************************* 646 | * Register : INT1_CTRL 647 | * Address : 0X0D 648 | * Bit Group Name: INT1_FSS5 649 | * Permission : RW 650 | *******************************************************************************/ 651 | typedef enum { 652 | LSM6DS3_ACC_GYRO_INT1_FSS5_DISABLED = 0x00, 653 | LSM6DS3_ACC_GYRO_INT1_FSS5_ENABLED = 0x20, 654 | } LSM6DS3_ACC_GYRO_INT1_FSS5_t; 655 | 656 | /******************************************************************************* 657 | * Register : INT1_CTRL 658 | * Address : 0X0D 659 | * Bit Group Name: INT1_SIGN_MOT 660 | * Permission : RW 661 | *******************************************************************************/ 662 | typedef enum { 663 | LSM6DS3_ACC_GYRO_INT1_SIGN_MOT_DISABLED = 0x00, 664 | LSM6DS3_ACC_GYRO_INT1_SIGN_MOT_ENABLED = 0x40, 665 | } LSM6DS3_ACC_GYRO_INT1_SIGN_MOT_t; 666 | 667 | /******************************************************************************* 668 | * Register : INT1_CTRL 669 | * Address : 0X0D 670 | * Bit Group Name: INT1_PEDO 671 | * Permission : RW 672 | *******************************************************************************/ 673 | typedef enum { 674 | LSM6DS3_ACC_GYRO_INT1_PEDO_DISABLED = 0x00, 675 | LSM6DS3_ACC_GYRO_INT1_PEDO_ENABLED = 0x80, 676 | } LSM6DS3_ACC_GYRO_INT1_PEDO_t; 677 | 678 | /******************************************************************************* 679 | * Register : INT2_CTRL 680 | * Address : 0X0E 681 | * Bit Group Name: INT2_DRDY_XL 682 | * Permission : RW 683 | *******************************************************************************/ 684 | typedef enum { 685 | LSM6DS3_ACC_GYRO_INT2_DRDY_XL_DISABLED = 0x00, 686 | LSM6DS3_ACC_GYRO_INT2_DRDY_XL_ENABLED = 0x01, 687 | } LSM6DS3_ACC_GYRO_INT2_DRDY_XL_t; 688 | 689 | /******************************************************************************* 690 | * Register : INT2_CTRL 691 | * Address : 0X0E 692 | * Bit Group Name: INT2_DRDY_G 693 | * Permission : RW 694 | *******************************************************************************/ 695 | typedef enum { 696 | LSM6DS3_ACC_GYRO_INT2_DRDY_G_DISABLED = 0x00, 697 | LSM6DS3_ACC_GYRO_INT2_DRDY_G_ENABLED = 0x02, 698 | } LSM6DS3_ACC_GYRO_INT2_DRDY_G_t; 699 | 700 | /******************************************************************************* 701 | * Register : INT2_CTRL 702 | * Address : 0X0E 703 | * Bit Group Name: INT2_FTH 704 | * Permission : RW 705 | *******************************************************************************/ 706 | typedef enum { 707 | LSM6DS3_ACC_GYRO_INT2_FTH_DISABLED = 0x00, 708 | LSM6DS3_ACC_GYRO_INT2_FTH_ENABLED = 0x08, 709 | } LSM6DS3_ACC_GYRO_INT2_FTH_t; 710 | 711 | /******************************************************************************* 712 | * Register : INT2_CTRL 713 | * Address : 0X0E 714 | * Bit Group Name: INT2_OVR 715 | * Permission : RW 716 | *******************************************************************************/ 717 | typedef enum { 718 | LSM6DS3_ACC_GYRO_INT2_OVR_DISABLED = 0x00, 719 | LSM6DS3_ACC_GYRO_INT2_OVR_ENABLED = 0x10, 720 | } LSM6DS3_ACC_GYRO_INT2_OVR_t; 721 | 722 | /******************************************************************************* 723 | * Register : INT2_CTRL 724 | * Address : 0X0E 725 | * Bit Group Name: INT2_FSS5 726 | * Permission : RW 727 | *******************************************************************************/ 728 | typedef enum { 729 | LSM6DS3_ACC_GYRO_INT2_FSS5_DISABLED = 0x00, 730 | LSM6DS3_ACC_GYRO_INT2_FSS5_ENABLED = 0x20, 731 | } LSM6DS3_ACC_GYRO_INT2_FSS5_t; 732 | 733 | /******************************************************************************* 734 | * Register : INT2_CTRL 735 | * Address : 0X0E 736 | * Bit Group Name: INT2_SIGN_MOT 737 | * Permission : RW 738 | *******************************************************************************/ 739 | typedef enum { 740 | LSM6DS3_ACC_GYRO_INT2_SIGN_MOT_DISABLED = 0x00, 741 | LSM6DS3_ACC_GYRO_INT2_SIGN_MOT_ENABLED = 0x40, 742 | } LSM6DS3_ACC_GYRO_INT2_SIGN_MOT_t; 743 | 744 | /******************************************************************************* 745 | * Register : INT2_CTRL 746 | * Address : 0X0E 747 | * Bit Group Name: INT2_PEDO 748 | * Permission : RW 749 | *******************************************************************************/ 750 | typedef enum { 751 | LSM6DS3_ACC_GYRO_INT2_PEDO_DISABLED = 0x00, 752 | LSM6DS3_ACC_GYRO_INT2_PEDO_ENABLED = 0x80, 753 | } LSM6DS3_ACC_GYRO_INT2_PEDO_t; 754 | 755 | /******************************************************************************* 756 | * Register : WHO_AM_I 757 | * Address : 0X0F 758 | * Bit Group Name: WHO_AM_I_BIT 759 | * Permission : RO 760 | *******************************************************************************/ 761 | #define LSM6DS3_ACC_GYRO_WHO_AM_I_BIT_MASK 0xFF 762 | #define LSM6DS3_ACC_GYRO_WHO_AM_I_BIT_POSITION 0 763 | 764 | /******************************************************************************* 765 | * Register : CTRL1_XL 766 | * Address : 0X10 767 | * Bit Group Name: BW_XL 768 | * Permission : RW 769 | *******************************************************************************/ 770 | typedef enum { 771 | LSM6DS3_ACC_GYRO_BW_XL_400Hz = 0x00, 772 | LSM6DS3_ACC_GYRO_BW_XL_200Hz = 0x01, 773 | LSM6DS3_ACC_GYRO_BW_XL_100Hz = 0x02, 774 | LSM6DS3_ACC_GYRO_BW_XL_50Hz = 0x03, 775 | } LSM6DS3_ACC_GYRO_BW_XL_t; 776 | 777 | /******************************************************************************* 778 | * Register : CTRL1_XL 779 | * Address : 0X10 780 | * Bit Group Name: FS_XL 781 | * Permission : RW 782 | *******************************************************************************/ 783 | typedef enum { 784 | LSM6DS3_ACC_GYRO_FS_XL_2g = 0x00, 785 | LSM6DS3_ACC_GYRO_FS_XL_16g = 0x04, 786 | LSM6DS3_ACC_GYRO_FS_XL_4g = 0x08, 787 | LSM6DS3_ACC_GYRO_FS_XL_8g = 0x0C, 788 | } LSM6DS3_ACC_GYRO_FS_XL_t; 789 | 790 | /******************************************************************************* 791 | * Register : CTRL1_XL 792 | * Address : 0X10 793 | * Bit Group Name: ODR_XL 794 | * Permission : RW 795 | *******************************************************************************/ 796 | typedef enum { 797 | LSM6DS3_ACC_GYRO_ODR_XL_POWER_DOWN = 0x00, 798 | LSM6DS3_ACC_GYRO_ODR_XL_13Hz = 0x10, 799 | LSM6DS3_ACC_GYRO_ODR_XL_26Hz = 0x20, 800 | LSM6DS3_ACC_GYRO_ODR_XL_52Hz = 0x30, 801 | LSM6DS3_ACC_GYRO_ODR_XL_104Hz = 0x40, 802 | LSM6DS3_ACC_GYRO_ODR_XL_208Hz = 0x50, 803 | LSM6DS3_ACC_GYRO_ODR_XL_416Hz = 0x60, 804 | LSM6DS3_ACC_GYRO_ODR_XL_833Hz = 0x70, 805 | LSM6DS3_ACC_GYRO_ODR_XL_1660Hz = 0x80, 806 | LSM6DS3_ACC_GYRO_ODR_XL_3330Hz = 0x90, 807 | LSM6DS3_ACC_GYRO_ODR_XL_6660Hz = 0xA0, 808 | LSM6DS3_ACC_GYRO_ODR_XL_13330Hz = 0xB0, 809 | } LSM6DS3_ACC_GYRO_ODR_XL_t; 810 | 811 | /******************************************************************************* 812 | * Register : CTRL2_G 813 | * Address : 0X11 814 | * Bit Group Name: FS_125 815 | * Permission : RW 816 | *******************************************************************************/ 817 | typedef enum { 818 | LSM6DS3_ACC_GYRO_FS_125_DISABLED = 0x00, 819 | LSM6DS3_ACC_GYRO_FS_125_ENABLED = 0x02, 820 | } LSM6DS3_ACC_GYRO_FS_125_t; 821 | 822 | /******************************************************************************* 823 | * Register : CTRL2_G 824 | * Address : 0X11 825 | * Bit Group Name: FS_G 826 | * Permission : RW 827 | *******************************************************************************/ 828 | typedef enum { 829 | LSM6DS3_ACC_GYRO_FS_G_245dps = 0x00, 830 | LSM6DS3_ACC_GYRO_FS_G_500dps = 0x04, 831 | LSM6DS3_ACC_GYRO_FS_G_1000dps = 0x08, 832 | LSM6DS3_ACC_GYRO_FS_G_2000dps = 0x0C, 833 | } LSM6DS3_ACC_GYRO_FS_G_t; 834 | 835 | /******************************************************************************* 836 | * Register : CTRL2_G 837 | * Address : 0X11 838 | * Bit Group Name: ODR_G 839 | * Permission : RW 840 | *******************************************************************************/ 841 | typedef enum { 842 | LSM6DS3_ACC_GYRO_ODR_G_POWER_DOWN = 0x00, 843 | LSM6DS3_ACC_GYRO_ODR_G_13Hz = 0x10, 844 | LSM6DS3_ACC_GYRO_ODR_G_26Hz = 0x20, 845 | LSM6DS3_ACC_GYRO_ODR_G_52Hz = 0x30, 846 | LSM6DS3_ACC_GYRO_ODR_G_104Hz = 0x40, 847 | LSM6DS3_ACC_GYRO_ODR_G_208Hz = 0x50, 848 | LSM6DS3_ACC_GYRO_ODR_G_416Hz = 0x60, 849 | LSM6DS3_ACC_GYRO_ODR_G_833Hz = 0x70, 850 | LSM6DS3_ACC_GYRO_ODR_G_1660Hz = 0x80, 851 | } LSM6DS3_ACC_GYRO_ODR_G_t; 852 | 853 | /******************************************************************************* 854 | * Register : CTRL3_C 855 | * Address : 0X12 856 | * Bit Group Name: SW_RESET 857 | * Permission : RW 858 | *******************************************************************************/ 859 | typedef enum { 860 | LSM6DS3_ACC_GYRO_SW_RESET_NORMAL_MODE = 0x00, 861 | LSM6DS3_ACC_GYRO_SW_RESET_RESET_DEVICE = 0x01, 862 | } LSM6DS3_ACC_GYRO_SW_RESET_t; 863 | 864 | /******************************************************************************* 865 | * Register : CTRL3_C 866 | * Address : 0X12 867 | * Bit Group Name: BLE 868 | * Permission : RW 869 | *******************************************************************************/ 870 | typedef enum { 871 | LSM6DS3_ACC_GYRO_BLE_LSB = 0x00, 872 | LSM6DS3_ACC_GYRO_BLE_MSB = 0x02, 873 | } LSM6DS3_ACC_GYRO_BLE_t; 874 | 875 | /******************************************************************************* 876 | * Register : CTRL3_C 877 | * Address : 0X12 878 | * Bit Group Name: IF_INC 879 | * Permission : RW 880 | *******************************************************************************/ 881 | typedef enum { 882 | LSM6DS3_ACC_GYRO_IF_INC_DISABLED = 0x00, 883 | LSM6DS3_ACC_GYRO_IF_INC_ENABLED = 0x04, 884 | } LSM6DS3_ACC_GYRO_IF_INC_t; 885 | 886 | /******************************************************************************* 887 | * Register : CTRL3_C 888 | * Address : 0X12 889 | * Bit Group Name: SIM 890 | * Permission : RW 891 | *******************************************************************************/ 892 | typedef enum { 893 | LSM6DS3_ACC_GYRO_SIM_4_WIRE = 0x00, 894 | LSM6DS3_ACC_GYRO_SIM_3_WIRE = 0x08, 895 | } LSM6DS3_ACC_GYRO_SIM_t; 896 | 897 | /******************************************************************************* 898 | * Register : CTRL3_C 899 | * Address : 0X12 900 | * Bit Group Name: PP_OD 901 | * Permission : RW 902 | *******************************************************************************/ 903 | typedef enum { 904 | LSM6DS3_ACC_GYRO_PP_OD_PUSH_PULL = 0x00, 905 | LSM6DS3_ACC_GYRO_PP_OD_OPEN_DRAIN = 0x10, 906 | } LSM6DS3_ACC_GYRO_PP_OD_t; 907 | 908 | /******************************************************************************* 909 | * Register : CTRL3_C 910 | * Address : 0X12 911 | * Bit Group Name: INT_ACT_LEVEL 912 | * Permission : RW 913 | *******************************************************************************/ 914 | typedef enum { 915 | LSM6DS3_ACC_GYRO_INT_ACT_LEVEL_ACTIVE_HI = 0x00, 916 | LSM6DS3_ACC_GYRO_INT_ACT_LEVEL_ACTIVE_LO = 0x20, 917 | } LSM6DS3_ACC_GYRO_INT_ACT_LEVEL_t; 918 | 919 | /******************************************************************************* 920 | * Register : CTRL3_C 921 | * Address : 0X12 922 | * Bit Group Name: BDU 923 | * Permission : RW 924 | *******************************************************************************/ 925 | typedef enum { 926 | LSM6DS3_ACC_GYRO_BDU_CONTINUOS = 0x00, 927 | LSM6DS3_ACC_GYRO_BDU_BLOCK_UPDATE = 0x40, 928 | } LSM6DS3_ACC_GYRO_BDU_t; 929 | 930 | /******************************************************************************* 931 | * Register : CTRL3_C 932 | * Address : 0X12 933 | * Bit Group Name: BOOT 934 | * Permission : RW 935 | *******************************************************************************/ 936 | typedef enum { 937 | LSM6DS3_ACC_GYRO_BOOT_NORMAL_MODE = 0x00, 938 | LSM6DS3_ACC_GYRO_BOOT_REBOOT_MODE = 0x80, 939 | } LSM6DS3_ACC_GYRO_BOOT_t; 940 | 941 | /******************************************************************************* 942 | * Register : CTRL4_C 943 | * Address : 0X13 944 | * Bit Group Name: STOP_ON_FTH 945 | * Permission : RW 946 | *******************************************************************************/ 947 | typedef enum { 948 | LSM6DS3_ACC_GYRO_STOP_ON_FTH_DISABLED = 0x00, 949 | LSM6DS3_ACC_GYRO_STOP_ON_FTH_ENABLED = 0x01, 950 | } LSM6DS3_ACC_GYRO_STOP_ON_FTH_t; 951 | 952 | /******************************************************************************* 953 | * Register : CTRL4_C 954 | * Address : 0X13 955 | * Bit Group Name: MODE3_EN 956 | * Permission : RW 957 | *******************************************************************************/ 958 | typedef enum { 959 | LSM6DS3_ACC_GYRO_MODE3_EN_DISABLED = 0x00, 960 | LSM6DS3_ACC_GYRO_MODE3_EN_ENABLED = 0x02, 961 | } LSM6DS3_ACC_GYRO_MODE3_EN_t; 962 | 963 | /******************************************************************************* 964 | * Register : CTRL4_C 965 | * Address : 0X13 966 | * Bit Group Name: I2C_DISABLE 967 | * Permission : RW 968 | *******************************************************************************/ 969 | typedef enum { 970 | LSM6DS3_ACC_GYRO_I2C_DISABLE_I2C_AND_SPI = 0x00, 971 | LSM6DS3_ACC_GYRO_I2C_DISABLE_SPI_ONLY = 0x04, 972 | } LSM6DS3_ACC_GYRO_I2C_DISABLE_t; 973 | 974 | /******************************************************************************* 975 | * Register : CTRL4_C 976 | * Address : 0X13 977 | * Bit Group Name: DRDY_MSK 978 | * Permission : RW 979 | *******************************************************************************/ 980 | typedef enum { 981 | LSM6DS3_ACC_GYRO_DRDY_MSK_DISABLED = 0x00, 982 | LSM6DS3_ACC_GYRO_DRDY_MSK_ENABLED = 0x08, 983 | } LSM6DS3_ACC_GYRO_DRDY_MSK_t; 984 | 985 | /******************************************************************************* 986 | * Register : CTRL4_C 987 | * Address : 0X13 988 | * Bit Group Name: FIFO_TEMP_EN 989 | * Permission : RW 990 | *******************************************************************************/ 991 | typedef enum { 992 | LSM6DS3_ACC_GYRO_FIFO_TEMP_EN_DISABLED = 0x00, 993 | LSM6DS3_ACC_GYRO_FIFO_TEMP_EN_ENABLED = 0x10, 994 | } LSM6DS3_ACC_GYRO_FIFO_TEMP_EN_t; 995 | 996 | /******************************************************************************* 997 | * Register : CTRL4_C 998 | * Address : 0X13 999 | * Bit Group Name: INT2_ON_INT1 1000 | * Permission : RW 1001 | *******************************************************************************/ 1002 | typedef enum { 1003 | LSM6DS3_ACC_GYRO_INT2_ON_INT1_DISABLED = 0x00, 1004 | LSM6DS3_ACC_GYRO_INT2_ON_INT1_ENABLED = 0x20, 1005 | } LSM6DS3_ACC_GYRO_INT2_ON_INT1_t; 1006 | 1007 | /******************************************************************************* 1008 | * Register : CTRL4_C 1009 | * Address : 0X13 1010 | * Bit Group Name: SLEEP_G 1011 | * Permission : RW 1012 | *******************************************************************************/ 1013 | typedef enum { 1014 | LSM6DS3_ACC_GYRO_SLEEP_G_DISABLED = 0x00, 1015 | LSM6DS3_ACC_GYRO_SLEEP_G_ENABLED = 0x40, 1016 | } LSM6DS3_ACC_GYRO_SLEEP_G_t; 1017 | 1018 | /******************************************************************************* 1019 | * Register : CTRL4_C 1020 | * Address : 0X13 1021 | * Bit Group Name: BW_SCAL_ODR 1022 | * Permission : RW 1023 | *******************************************************************************/ 1024 | typedef enum { 1025 | LSM6DS3_ACC_GYRO_BW_SCAL_ODR_DISABLED = 0x00, 1026 | LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED = 0x80, 1027 | } LSM6DS3_ACC_GYRO_BW_SCAL_ODR_t; 1028 | 1029 | /******************************************************************************* 1030 | * Register : CTRL5_C 1031 | * Address : 0X14 1032 | * Bit Group Name: ST_XL 1033 | * Permission : RW 1034 | *******************************************************************************/ 1035 | typedef enum { 1036 | LSM6DS3_ACC_GYRO_ST_XL_NORMAL_MODE = 0x00, 1037 | LSM6DS3_ACC_GYRO_ST_XL_POS_SIGN_TEST = 0x01, 1038 | LSM6DS3_ACC_GYRO_ST_XL_NEG_SIGN_TEST = 0x02, 1039 | LSM6DS3_ACC_GYRO_ST_XL_NA = 0x03, 1040 | } LSM6DS3_ACC_GYRO_ST_XL_t; 1041 | 1042 | /******************************************************************************* 1043 | * Register : CTRL5_C 1044 | * Address : 0X14 1045 | * Bit Group Name: ST_G 1046 | * Permission : RW 1047 | *******************************************************************************/ 1048 | typedef enum { 1049 | LSM6DS3_ACC_GYRO_ST_G_NORMAL_MODE = 0x00, 1050 | LSM6DS3_ACC_GYRO_ST_G_POS_SIGN_TEST = 0x04, 1051 | LSM6DS3_ACC_GYRO_ST_G_NA = 0x08, 1052 | LSM6DS3_ACC_GYRO_ST_G_NEG_SIGN_TEST = 0x0C, 1053 | } LSM6DS3_ACC_GYRO_ST_G_t; 1054 | 1055 | /******************************************************************************* 1056 | * Register : CTRL6_G 1057 | * Address : 0X15 1058 | * Bit Group Name: LP_XL 1059 | * Permission : RW 1060 | *******************************************************************************/ 1061 | typedef enum { 1062 | LSM6DS3_ACC_GYRO_LP_XL_DISABLED = 0x00, 1063 | LSM6DS3_ACC_GYRO_LP_XL_ENABLED = 0x10, 1064 | } LSM6DS3_ACC_GYRO_LP_XL_t; 1065 | 1066 | /******************************************************************************* 1067 | * Register : CTRL6_G 1068 | * Address : 0X15 1069 | * Bit Group Name: DEN_LVL2_EN 1070 | * Permission : RW 1071 | *******************************************************************************/ 1072 | typedef enum { 1073 | LSM6DS3_ACC_GYRO_DEN_LVL2_EN_DISABLED = 0x00, 1074 | LSM6DS3_ACC_GYRO_DEN_LVL2_EN_ENABLED = 0x20, 1075 | } LSM6DS3_ACC_GYRO_DEN_LVL2_EN_t; 1076 | 1077 | /******************************************************************************* 1078 | * Register : CTRL6_G 1079 | * Address : 0X15 1080 | * Bit Group Name: DEN_LVL_EN 1081 | * Permission : RW 1082 | *******************************************************************************/ 1083 | typedef enum { 1084 | LSM6DS3_ACC_GYRO_DEN_LVL_EN_DISABLED = 0x00, 1085 | LSM6DS3_ACC_GYRO_DEN_LVL_EN_ENABLED = 0x40, 1086 | } LSM6DS3_ACC_GYRO_DEN_LVL_EN_t; 1087 | 1088 | /******************************************************************************* 1089 | * Register : CTRL6_G 1090 | * Address : 0X15 1091 | * Bit Group Name: DEN_EDGE_EN 1092 | * Permission : RW 1093 | *******************************************************************************/ 1094 | typedef enum { 1095 | LSM6DS3_ACC_GYRO_DEN_EDGE_EN_DISABLED = 0x00, 1096 | LSM6DS3_ACC_GYRO_DEN_EDGE_EN_ENABLED = 0x80, 1097 | } LSM6DS3_ACC_GYRO_DEN_EDGE_EN_t; 1098 | 1099 | /******************************************************************************* 1100 | * Register : CTRL7_G 1101 | * Address : 0X16 1102 | * Bit Group Name: HPM_G 1103 | * Permission : RW 1104 | *******************************************************************************/ 1105 | typedef enum { 1106 | LSM6DS3_ACC_GYRO_HPM_G_NORMAL_MODE = 0x00, 1107 | LSM6DS3_ACC_GYRO_HPM_G_REF_SIGNAL = 0x10, 1108 | LSM6DS3_ACC_GYRO_HPM_G_NORMAL_MODE_2 = 0x20, 1109 | LSM6DS3_ACC_GYRO_HPM_G_AUTO_RESET_ON_INT = 0x30, 1110 | } LSM6DS3_ACC_GYRO_HPM_G_t; 1111 | 1112 | /******************************************************************************* 1113 | * Register : CTRL7_G 1114 | * Address : 0X16 1115 | * Bit Group Name: HP_EN 1116 | * Permission : RW 1117 | *******************************************************************************/ 1118 | typedef enum { 1119 | LSM6DS3_ACC_GYRO_HP_EN_DISABLED = 0x00, 1120 | LSM6DS3_ACC_GYRO_HP_EN_ENABLED = 0x40, 1121 | } LSM6DS3_ACC_GYRO_HP_EN_t; 1122 | 1123 | /******************************************************************************* 1124 | * Register : CTRL7_G 1125 | * Address : 0X16 1126 | * Bit Group Name: LP_EN 1127 | * Permission : RW 1128 | *******************************************************************************/ 1129 | typedef enum { 1130 | LSM6DS3_ACC_GYRO_LP_EN_DISABLED = 0x00, 1131 | LSM6DS3_ACC_GYRO_LP_EN_ENABLED = 0x80, 1132 | } LSM6DS3_ACC_GYRO_LP_EN_t; 1133 | 1134 | /******************************************************************************* 1135 | * Register : CTRL8_XL 1136 | * Address : 0X17 1137 | * Bit Group Name: FDS 1138 | * Permission : RW 1139 | *******************************************************************************/ 1140 | typedef enum { 1141 | LSM6DS3_ACC_GYRO_FDS_FILTER_OFF = 0x00, 1142 | LSM6DS3_ACC_GYRO_FDS_FILTER_ON = 0x04, 1143 | } LSM6DS3_ACC_GYRO_FDS_t; 1144 | 1145 | /******************************************************************************* 1146 | * Register : CTRL9_XL 1147 | * Address : 0X18 1148 | * Bit Group Name: XEN_XL 1149 | * Permission : RW 1150 | *******************************************************************************/ 1151 | typedef enum { 1152 | LSM6DS3_ACC_GYRO_XEN_XL_DISABLED = 0x00, 1153 | LSM6DS3_ACC_GYRO_XEN_XL_ENABLED = 0x08, 1154 | } LSM6DS3_ACC_GYRO_XEN_XL_t; 1155 | 1156 | /******************************************************************************* 1157 | * Register : CTRL9_XL 1158 | * Address : 0X18 1159 | * Bit Group Name: YEN_XL 1160 | * Permission : RW 1161 | *******************************************************************************/ 1162 | typedef enum { 1163 | LSM6DS3_ACC_GYRO_YEN_XL_DISABLED = 0x00, 1164 | LSM6DS3_ACC_GYRO_YEN_XL_ENABLED = 0x10, 1165 | } LSM6DS3_ACC_GYRO_YEN_XL_t; 1166 | 1167 | /******************************************************************************* 1168 | * Register : CTRL9_XL 1169 | * Address : 0X18 1170 | * Bit Group Name: ZEN_XL 1171 | * Permission : RW 1172 | *******************************************************************************/ 1173 | typedef enum { 1174 | LSM6DS3_ACC_GYRO_ZEN_XL_DISABLED = 0x00, 1175 | LSM6DS3_ACC_GYRO_ZEN_XL_ENABLED = 0x20, 1176 | } LSM6DS3_ACC_GYRO_ZEN_XL_t; 1177 | 1178 | /******************************************************************************* 1179 | * Register : CTRL10_C 1180 | * Address : 0X19 1181 | * Bit Group Name: SIGN_MOTION_EN 1182 | * Permission : RW 1183 | *******************************************************************************/ 1184 | typedef enum { 1185 | LSM6DS3_ACC_GYRO_SIGN_MOTION_EN_DISABLED = 0x00, 1186 | LSM6DS3_ACC_GYRO_SIGN_MOTION_EN_ENABLED = 0x01, 1187 | } LSM6DS3_ACC_GYRO_SIGN_MOTION_EN_t; 1188 | 1189 | /******************************************************************************* 1190 | * Register : CTRL10_C 1191 | * Address : 0X19 1192 | * Bit Group Name: PEDO_RST_STEP 1193 | * Permission : RW 1194 | *******************************************************************************/ 1195 | typedef enum { 1196 | LSM6DS3_ACC_GYRO_PEDO_RST_STEP_DISABLED = 0x00, 1197 | LSM6DS3_ACC_GYRO_PEDO_RST_STEP_ENABLED = 0x02, 1198 | } LSM6DS3_ACC_GYRO_PEDO_RST_STEP_t; 1199 | 1200 | /******************************************************************************* 1201 | * Register : CTRL10_C 1202 | * Address : 0X19 1203 | * Bit Group Name: XEN_G 1204 | * Permission : RW 1205 | *******************************************************************************/ 1206 | typedef enum { 1207 | LSM6DS3_ACC_GYRO_XEN_G_DISABLED = 0x00, 1208 | LSM6DS3_ACC_GYRO_XEN_G_ENABLED = 0x08, 1209 | } LSM6DS3_ACC_GYRO_XEN_G_t; 1210 | 1211 | /******************************************************************************* 1212 | * Register : CTRL10_C 1213 | * Address : 0X19 1214 | * Bit Group Name: YEN_G 1215 | * Permission : RW 1216 | *******************************************************************************/ 1217 | typedef enum { 1218 | LSM6DS3_ACC_GYRO_YEN_G_DISABLED = 0x00, 1219 | LSM6DS3_ACC_GYRO_YEN_G_ENABLED = 0x10, 1220 | } LSM6DS3_ACC_GYRO_YEN_G_t; 1221 | 1222 | /******************************************************************************* 1223 | * Register : CTRL10_C 1224 | * Address : 0X19 1225 | * Bit Group Name: ZEN_G 1226 | * Permission : RW 1227 | *******************************************************************************/ 1228 | typedef enum { 1229 | LSM6DS3_ACC_GYRO_ZEN_G_DISABLED = 0x00, 1230 | LSM6DS3_ACC_GYRO_ZEN_G_ENABLED = 0x20, 1231 | } LSM6DS3_ACC_GYRO_ZEN_G_t; 1232 | 1233 | /******************************************************************************* 1234 | * Register : CTRL10_C 1235 | * Address : 0X19 1236 | * Bit Group Name: FUNC_EN 1237 | * Permission : RW 1238 | *******************************************************************************/ 1239 | typedef enum { 1240 | LSM6DS3_ACC_GYRO_FUNC_EN_DISABLED = 0x00, 1241 | LSM6DS3_ACC_GYRO_FUNC_EN_ENABLED = 0x04, 1242 | } LSM6DS3_ACC_GYRO_FUNC_EN_t; 1243 | 1244 | /******************************************************************************* 1245 | * Register : MASTER_CONFIG 1246 | * Address : 0X1A 1247 | * Bit Group Name: MASTER_ON 1248 | * Permission : RW 1249 | *******************************************************************************/ 1250 | typedef enum { 1251 | LSM6DS3_ACC_GYRO_MASTER_ON_DISABLED = 0x00, 1252 | LSM6DS3_ACC_GYRO_MASTER_ON_ENABLED = 0x01, 1253 | } LSM6DS3_ACC_GYRO_MASTER_ON_t; 1254 | 1255 | /******************************************************************************* 1256 | * Register : MASTER_CONFIG 1257 | * Address : 0X1A 1258 | * Bit Group Name: IRON_EN 1259 | * Permission : RW 1260 | *******************************************************************************/ 1261 | typedef enum { 1262 | LSM6DS3_ACC_GYRO_IRON_EN_DISABLED = 0x00, 1263 | LSM6DS3_ACC_GYRO_IRON_EN_ENABLED = 0x02, 1264 | } LSM6DS3_ACC_GYRO_IRON_EN_t; 1265 | 1266 | /******************************************************************************* 1267 | * Register : MASTER_CONFIG 1268 | * Address : 0X1A 1269 | * Bit Group Name: PASS_THRU_MODE 1270 | * Permission : RW 1271 | *******************************************************************************/ 1272 | typedef enum { 1273 | LSM6DS3_ACC_GYRO_PASS_THRU_MODE_DISABLED = 0x00, 1274 | LSM6DS3_ACC_GYRO_PASS_THRU_MODE_ENABLED = 0x04, 1275 | } LSM6DS3_ACC_GYRO_PASS_THRU_MODE_t; 1276 | 1277 | /******************************************************************************* 1278 | * Register : MASTER_CONFIG 1279 | * Address : 0X1A 1280 | * Bit Group Name: PULL_UP_EN 1281 | * Permission : RW 1282 | *******************************************************************************/ 1283 | typedef enum { 1284 | LSM6DS3_ACC_GYRO_PULL_UP_EN_DISABLED = 0x00, 1285 | LSM6DS3_ACC_GYRO_PULL_UP_EN_ENABLED = 0x08, 1286 | } LSM6DS3_ACC_GYRO_PULL_UP_EN_t; 1287 | 1288 | /******************************************************************************* 1289 | * Register : MASTER_CONFIG 1290 | * Address : 0X1A 1291 | * Bit Group Name: START_CONFIG 1292 | * Permission : RW 1293 | *******************************************************************************/ 1294 | typedef enum { 1295 | LSM6DS3_ACC_GYRO_START_CONFIG_XL_G_DRDY = 0x00, 1296 | LSM6DS3_ACC_GYRO_START_CONFIG_EXT_INT2 = 0x10, 1297 | } LSM6DS3_ACC_GYRO_START_CONFIG_t; 1298 | 1299 | /******************************************************************************* 1300 | * Register : MASTER_CONFIG 1301 | * Address : 0X1A 1302 | * Bit Group Name: DATA_VAL_SEL_FIFO 1303 | * Permission : RW 1304 | *******************************************************************************/ 1305 | typedef enum { 1306 | LSM6DS3_ACC_GYRO_DATA_VAL_SEL_FIFO_XL_G_DRDY = 0x00, 1307 | LSM6DS3_ACC_GYRO_DATA_VAL_SEL_FIFO_SHUB_DRDY = 0x40, 1308 | } LSM6DS3_ACC_GYRO_DATA_VAL_SEL_FIFO_t; 1309 | 1310 | /******************************************************************************* 1311 | * Register : MASTER_CONFIG 1312 | * Address : 0X1A 1313 | * Bit Group Name: DRDY_ON_INT1 1314 | * Permission : RW 1315 | *******************************************************************************/ 1316 | typedef enum { 1317 | LSM6DS3_ACC_GYRO_DRDY_ON_INT1_DISABLED = 0x00, 1318 | LSM6DS3_ACC_GYRO_DRDY_ON_INT1_ENABLED = 0x80, 1319 | } LSM6DS3_ACC_GYRO_DRDY_ON_INT1_t; 1320 | 1321 | /******************************************************************************* 1322 | * Register : WAKE_UP_SRC 1323 | * Address : 0X1B 1324 | * Bit Group Name: Z_WU 1325 | * Permission : RO 1326 | *******************************************************************************/ 1327 | typedef enum { 1328 | LSM6DS3_ACC_GYRO_Z_WU_NOT_DETECTED = 0x00, 1329 | LSM6DS3_ACC_GYRO_Z_WU_DETECTED = 0x01, 1330 | } LSM6DS3_ACC_GYRO_Z_WU_t; 1331 | 1332 | /******************************************************************************* 1333 | * Register : WAKE_UP_SRC 1334 | * Address : 0X1B 1335 | * Bit Group Name: Y_WU 1336 | * Permission : RO 1337 | *******************************************************************************/ 1338 | typedef enum { 1339 | LSM6DS3_ACC_GYRO_Y_WU_NOT_DETECTED = 0x00, 1340 | LSM6DS3_ACC_GYRO_Y_WU_DETECTED = 0x02, 1341 | } LSM6DS3_ACC_GYRO_Y_WU_t; 1342 | 1343 | /******************************************************************************* 1344 | * Register : WAKE_UP_SRC 1345 | * Address : 0X1B 1346 | * Bit Group Name: X_WU 1347 | * Permission : RO 1348 | *******************************************************************************/ 1349 | typedef enum { 1350 | LSM6DS3_ACC_GYRO_X_WU_NOT_DETECTED = 0x00, 1351 | LSM6DS3_ACC_GYRO_X_WU_DETECTED = 0x04, 1352 | } LSM6DS3_ACC_GYRO_X_WU_t; 1353 | 1354 | /******************************************************************************* 1355 | * Register : WAKE_UP_SRC 1356 | * Address : 0X1B 1357 | * Bit Group Name: WU_EV_STATUS 1358 | * Permission : RO 1359 | *******************************************************************************/ 1360 | typedef enum { 1361 | LSM6DS3_ACC_GYRO_WU_EV_STATUS_NOT_DETECTED = 0x00, 1362 | LSM6DS3_ACC_GYRO_WU_EV_STATUS_DETECTED = 0x08, 1363 | } LSM6DS3_ACC_GYRO_WU_EV_STATUS_t; 1364 | 1365 | /******************************************************************************* 1366 | * Register : WAKE_UP_SRC 1367 | * Address : 0X1B 1368 | * Bit Group Name: SLEEP_EV_STATUS 1369 | * Permission : RO 1370 | *******************************************************************************/ 1371 | typedef enum { 1372 | LSM6DS3_ACC_GYRO_SLEEP_EV_STATUS_NOT_DETECTED = 0x00, 1373 | LSM6DS3_ACC_GYRO_SLEEP_EV_STATUS_DETECTED = 0x10, 1374 | } LSM6DS3_ACC_GYRO_SLEEP_EV_STATUS_t; 1375 | 1376 | /******************************************************************************* 1377 | * Register : WAKE_UP_SRC 1378 | * Address : 0X1B 1379 | * Bit Group Name: FF_EV_STATUS 1380 | * Permission : RO 1381 | *******************************************************************************/ 1382 | typedef enum { 1383 | LSM6DS3_ACC_GYRO_FF_EV_STATUS_NOT_DETECTED = 0x00, 1384 | LSM6DS3_ACC_GYRO_FF_EV_STATUS_DETECTED = 0x20, 1385 | } LSM6DS3_ACC_GYRO_FF_EV_STATUS_t; 1386 | 1387 | /******************************************************************************* 1388 | * Register : TAP_SRC 1389 | * Address : 0X1C 1390 | * Bit Group Name: Z_TAP 1391 | * Permission : RO 1392 | *******************************************************************************/ 1393 | typedef enum { 1394 | LSM6DS3_ACC_GYRO_Z_TAP_NOT_DETECTED = 0x00, 1395 | LSM6DS3_ACC_GYRO_Z_TAP_DETECTED = 0x01, 1396 | } LSM6DS3_ACC_GYRO_Z_TAP_t; 1397 | 1398 | /******************************************************************************* 1399 | * Register : TAP_SRC 1400 | * Address : 0X1C 1401 | * Bit Group Name: Y_TAP 1402 | * Permission : RO 1403 | *******************************************************************************/ 1404 | typedef enum { 1405 | LSM6DS3_ACC_GYRO_Y_TAP_NOT_DETECTED = 0x00, 1406 | LSM6DS3_ACC_GYRO_Y_TAP_DETECTED = 0x02, 1407 | } LSM6DS3_ACC_GYRO_Y_TAP_t; 1408 | 1409 | /******************************************************************************* 1410 | * Register : TAP_SRC 1411 | * Address : 0X1C 1412 | * Bit Group Name: X_TAP 1413 | * Permission : RO 1414 | *******************************************************************************/ 1415 | typedef enum { 1416 | LSM6DS3_ACC_GYRO_X_TAP_NOT_DETECTED = 0x00, 1417 | LSM6DS3_ACC_GYRO_X_TAP_DETECTED = 0x04, 1418 | } LSM6DS3_ACC_GYRO_X_TAP_t; 1419 | 1420 | /******************************************************************************* 1421 | * Register : TAP_SRC 1422 | * Address : 0X1C 1423 | * Bit Group Name: TAP_SIGN 1424 | * Permission : RO 1425 | *******************************************************************************/ 1426 | typedef enum { 1427 | LSM6DS3_ACC_GYRO_TAP_SIGN_POS_SIGN = 0x00, 1428 | LSM6DS3_ACC_GYRO_TAP_SIGN_NEG_SIGN = 0x08, 1429 | } LSM6DS3_ACC_GYRO_TAP_SIGN_t; 1430 | 1431 | /******************************************************************************* 1432 | * Register : TAP_SRC 1433 | * Address : 0X1C 1434 | * Bit Group Name: DOUBLE_TAP_EV_STATUS 1435 | * Permission : RO 1436 | *******************************************************************************/ 1437 | typedef enum { 1438 | LSM6DS3_ACC_GYRO_DOUBLE_TAP_EV_STATUS_NOT_DETECTED = 0x00, 1439 | LSM6DS3_ACC_GYRO_DOUBLE_TAP_EV_STATUS_DETECTED = 0x10, 1440 | } LSM6DS3_ACC_GYRO_DOUBLE_TAP_EV_STATUS_t; 1441 | 1442 | /******************************************************************************* 1443 | * Register : TAP_SRC 1444 | * Address : 0X1C 1445 | * Bit Group Name: SINGLE_TAP_EV_STATUS 1446 | * Permission : RO 1447 | *******************************************************************************/ 1448 | typedef enum { 1449 | LSM6DS3_ACC_GYRO_SINGLE_TAP_EV_STATUS_NOT_DETECTED = 0x00, 1450 | LSM6DS3_ACC_GYRO_SINGLE_TAP_EV_STATUS_DETECTED = 0x20, 1451 | } LSM6DS3_ACC_GYRO_SINGLE_TAP_EV_STATUS_t; 1452 | 1453 | /******************************************************************************* 1454 | * Register : TAP_SRC 1455 | * Address : 0X1C 1456 | * Bit Group Name: TAP_EV_STATUS 1457 | * Permission : RO 1458 | *******************************************************************************/ 1459 | typedef enum { 1460 | LSM6DS3_ACC_GYRO_TAP_EV_STATUS_NOT_DETECTED = 0x00, 1461 | LSM6DS3_ACC_GYRO_TAP_EV_STATUS_DETECTED = 0x40, 1462 | } LSM6DS3_ACC_GYRO_TAP_EV_STATUS_t; 1463 | 1464 | /******************************************************************************* 1465 | * Register : D6D_SRC 1466 | * Address : 0X1D 1467 | * Bit Group Name: DSD_XL 1468 | * Permission : RO 1469 | *******************************************************************************/ 1470 | typedef enum { 1471 | LSM6DS3_ACC_GYRO_DSD_XL_NOT_DETECTED = 0x00, 1472 | LSM6DS3_ACC_GYRO_DSD_XL_DETECTED = 0x01, 1473 | } LSM6DS3_ACC_GYRO_DSD_XL_t; 1474 | 1475 | /******************************************************************************* 1476 | * Register : D6D_SRC 1477 | * Address : 0X1D 1478 | * Bit Group Name: DSD_XH 1479 | * Permission : RO 1480 | *******************************************************************************/ 1481 | typedef enum { 1482 | LSM6DS3_ACC_GYRO_DSD_XH_NOT_DETECTED = 0x00, 1483 | LSM6DS3_ACC_GYRO_DSD_XH_DETECTED = 0x02, 1484 | } LSM6DS3_ACC_GYRO_DSD_XH_t; 1485 | 1486 | /******************************************************************************* 1487 | * Register : D6D_SRC 1488 | * Address : 0X1D 1489 | * Bit Group Name: DSD_YL 1490 | * Permission : RO 1491 | *******************************************************************************/ 1492 | typedef enum { 1493 | LSM6DS3_ACC_GYRO_DSD_YL_NOT_DETECTED = 0x00, 1494 | LSM6DS3_ACC_GYRO_DSD_YL_DETECTED = 0x04, 1495 | } LSM6DS3_ACC_GYRO_DSD_YL_t; 1496 | 1497 | /******************************************************************************* 1498 | * Register : D6D_SRC 1499 | * Address : 0X1D 1500 | * Bit Group Name: DSD_YH 1501 | * Permission : RO 1502 | *******************************************************************************/ 1503 | typedef enum { 1504 | LSM6DS3_ACC_GYRO_DSD_YH_NOT_DETECTED = 0x00, 1505 | LSM6DS3_ACC_GYRO_DSD_YH_DETECTED = 0x08, 1506 | } LSM6DS3_ACC_GYRO_DSD_YH_t; 1507 | 1508 | /******************************************************************************* 1509 | * Register : D6D_SRC 1510 | * Address : 0X1D 1511 | * Bit Group Name: DSD_ZL 1512 | * Permission : RO 1513 | *******************************************************************************/ 1514 | typedef enum { 1515 | LSM6DS3_ACC_GYRO_DSD_ZL_NOT_DETECTED = 0x00, 1516 | LSM6DS3_ACC_GYRO_DSD_ZL_DETECTED = 0x10, 1517 | } LSM6DS3_ACC_GYRO_DSD_ZL_t; 1518 | 1519 | /******************************************************************************* 1520 | * Register : D6D_SRC 1521 | * Address : 0X1D 1522 | * Bit Group Name: DSD_ZH 1523 | * Permission : RO 1524 | *******************************************************************************/ 1525 | typedef enum { 1526 | LSM6DS3_ACC_GYRO_DSD_ZH_NOT_DETECTED = 0x00, 1527 | LSM6DS3_ACC_GYRO_DSD_ZH_DETECTED = 0x20, 1528 | } LSM6DS3_ACC_GYRO_DSD_ZH_t; 1529 | 1530 | /******************************************************************************* 1531 | * Register : D6D_SRC 1532 | * Address : 0X1D 1533 | * Bit Group Name: D6D_EV_STATUS 1534 | * Permission : RO 1535 | *******************************************************************************/ 1536 | typedef enum { 1537 | LSM6DS3_ACC_GYRO_D6D_EV_STATUS_NOT_DETECTED = 0x00, 1538 | LSM6DS3_ACC_GYRO_D6D_EV_STATUS_DETECTED = 0x40, 1539 | } LSM6DS3_ACC_GYRO_D6D_EV_STATUS_t; 1540 | 1541 | /******************************************************************************* 1542 | * Register : STATUS_REG 1543 | * Address : 0X1E 1544 | * Bit Group Name: XLDA 1545 | * Permission : RO 1546 | *******************************************************************************/ 1547 | typedef enum { 1548 | LSM6DS3_ACC_GYRO_XLDA_NO_DATA_AVAIL = 0x00, 1549 | LSM6DS3_ACC_GYRO_XLDA_DATA_AVAIL = 0x01, 1550 | } LSM6DS3_ACC_GYRO_XLDA_t; 1551 | 1552 | /******************************************************************************* 1553 | * Register : STATUS_REG 1554 | * Address : 0X1E 1555 | * Bit Group Name: GDA 1556 | * Permission : RO 1557 | *******************************************************************************/ 1558 | typedef enum { 1559 | LSM6DS3_ACC_GYRO_GDA_NO_DATA_AVAIL = 0x00, 1560 | LSM6DS3_ACC_GYRO_GDA_DATA_AVAIL = 0x02, 1561 | } LSM6DS3_ACC_GYRO_GDA_t; 1562 | 1563 | /******************************************************************************* 1564 | * Register : STATUS_REG 1565 | * Address : 0X1E 1566 | * Bit Group Name: EV_BOOT 1567 | * Permission : RO 1568 | *******************************************************************************/ 1569 | typedef enum { 1570 | LSM6DS3_ACC_GYRO_EV_BOOT_NO_BOOT_RUNNING = 0x00, 1571 | LSM6DS3_ACC_GYRO_EV_BOOT_BOOT_IS_RUNNING = 0x08, 1572 | } LSM6DS3_ACC_GYRO_EV_BOOT_t; 1573 | 1574 | /******************************************************************************* 1575 | * Register : FIFO_STATUS1 1576 | * Address : 0X3A 1577 | * Bit Group Name: DIFF_FIFO 1578 | * Permission : RO 1579 | *******************************************************************************/ 1580 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS1_MASK 0xFF 1581 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS1_POSITION 0 1582 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS2_MASK 0xF 1583 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS2_POSITION 0 1584 | 1585 | /******************************************************************************* 1586 | * Register : FIFO_STATUS2 1587 | * Address : 0X3B 1588 | * Bit Group Name: FIFO_EMPTY 1589 | * Permission : RO 1590 | *******************************************************************************/ 1591 | typedef enum { 1592 | LSM6DS3_ACC_GYRO_FIFO_EMPTY_FIFO_NOT_EMPTY = 0x00, 1593 | LSM6DS3_ACC_GYRO_FIFO_EMPTY_FIFO_EMPTY = 0x10, 1594 | } LSM6DS3_ACC_GYRO_FIFO_EMPTY_t; 1595 | 1596 | /******************************************************************************* 1597 | * Register : FIFO_STATUS2 1598 | * Address : 0X3B 1599 | * Bit Group Name: FIFO_FULL 1600 | * Permission : RO 1601 | *******************************************************************************/ 1602 | typedef enum { 1603 | LSM6DS3_ACC_GYRO_FIFO_FULL_FIFO_NOT_FULL = 0x00, 1604 | LSM6DS3_ACC_GYRO_FIFO_FULL_FIFO_FULL = 0x20, 1605 | } LSM6DS3_ACC_GYRO_FIFO_FULL_t; 1606 | 1607 | /******************************************************************************* 1608 | * Register : FIFO_STATUS2 1609 | * Address : 0X3B 1610 | * Bit Group Name: OVERRUN 1611 | * Permission : RO 1612 | *******************************************************************************/ 1613 | typedef enum { 1614 | LSM6DS3_ACC_GYRO_OVERRUN_NO_OVERRUN = 0x00, 1615 | LSM6DS3_ACC_GYRO_OVERRUN_OVERRUN = 0x40, 1616 | } LSM6DS3_ACC_GYRO_OVERRUN_t; 1617 | 1618 | /******************************************************************************* 1619 | * Register : FIFO_STATUS2 1620 | * Address : 0X3B 1621 | * Bit Group Name: WTM 1622 | * Permission : RO 1623 | *******************************************************************************/ 1624 | typedef enum { 1625 | LSM6DS3_ACC_GYRO_WTM_BELOW_WTM = 0x00, 1626 | LSM6DS3_ACC_GYRO_WTM_ABOVE_OR_EQUAL_WTM = 0x80, 1627 | } LSM6DS3_ACC_GYRO_WTM_t; 1628 | 1629 | /******************************************************************************* 1630 | * Register : FIFO_STATUS3 1631 | * Address : 0X3C 1632 | * Bit Group Name: FIFO_PATTERN 1633 | * Permission : RO 1634 | *******************************************************************************/ 1635 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS3_PATTERN_MASK 0xFF 1636 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS3_PATTERN_POSITION 0 1637 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS4_PATTERN_MASK 0x03 1638 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS4_PATTERN_POSITION 0 1639 | 1640 | /******************************************************************************* 1641 | * Register : FUNC_SRC 1642 | * Address : 0X53 1643 | * Bit Group Name: SENS_HUB_END 1644 | * Permission : RO 1645 | *******************************************************************************/ 1646 | typedef enum { 1647 | LSM6DS3_ACC_GYRO_SENS_HUB_END_STILL_ONGOING = 0x00, 1648 | LSM6DS3_ACC_GYRO_SENS_HUB_END_OP_COMPLETED = 0x01, 1649 | } LSM6DS3_ACC_GYRO_SENS_HUB_END_t; 1650 | 1651 | /******************************************************************************* 1652 | * Register : FUNC_SRC 1653 | * Address : 0X53 1654 | * Bit Group Name: SOFT_IRON_END 1655 | * Permission : RO 1656 | *******************************************************************************/ 1657 | typedef enum { 1658 | LSM6DS3_ACC_GYRO_SOFT_IRON_END_NOT_COMPLETED = 0x00, 1659 | LSM6DS3_ACC_GYRO_SOFT_IRON_END_COMPLETED = 0x02, 1660 | } LSM6DS3_ACC_GYRO_SOFT_IRON_END_t; 1661 | 1662 | /******************************************************************************* 1663 | * Register : FUNC_SRC 1664 | * Address : 0X53 1665 | * Bit Group Name: PEDO_EV_STATUS 1666 | * Permission : RO 1667 | *******************************************************************************/ 1668 | typedef enum { 1669 | LSM6DS3_ACC_GYRO_PEDO_EV_STATUS_NOT_DETECTED = 0x00, 1670 | LSM6DS3_ACC_GYRO_PEDO_EV_STATUS_DETECTED = 0x10, 1671 | } LSM6DS3_ACC_GYRO_PEDO_EV_STATUS_t; 1672 | 1673 | /******************************************************************************* 1674 | * Register : FUNC_SRC 1675 | * Address : 0X53 1676 | * Bit Group Name: TILT_EV_STATUS 1677 | * Permission : RO 1678 | *******************************************************************************/ 1679 | typedef enum { 1680 | LSM6DS3_ACC_GYRO_TILT_EV_STATUS_NOT_DETECTED = 0x00, 1681 | LSM6DS3_ACC_GYRO_TILT_EV_STATUS_DETECTED = 0x20, 1682 | } LSM6DS3_ACC_GYRO_TILT_EV_STATUS_t; 1683 | 1684 | /******************************************************************************* 1685 | * Register : FUNC_SRC 1686 | * Address : 0X53 1687 | * Bit Group Name: SIGN_MOT_EV_STATUS 1688 | * Permission : RO 1689 | *******************************************************************************/ 1690 | typedef enum { 1691 | LSM6DS3_ACC_GYRO_SIGN_MOT_EV_STATUS_NOT_DETECTED = 0x00, 1692 | LSM6DS3_ACC_GYRO_SIGN_MOT_EV_STATUS_DETECTED = 0x40, 1693 | } LSM6DS3_ACC_GYRO_SIGN_MOT_EV_STATUS_t; 1694 | 1695 | /******************************************************************************* 1696 | * Register : TAP_CFG1 1697 | * Address : 0X58 1698 | * Bit Group Name: LIR 1699 | * Permission : RW 1700 | *******************************************************************************/ 1701 | typedef enum { 1702 | LSM6DS3_ACC_GYRO_LIR_DISABLED = 0x00, 1703 | LSM6DS3_ACC_GYRO_LIR_ENABLED = 0x01, 1704 | } LSM6DS3_ACC_GYRO_LIR_t; 1705 | 1706 | /******************************************************************************* 1707 | * Register : TAP_CFG1 1708 | * Address : 0X58 1709 | * Bit Group Name: TAP_Z_EN 1710 | * Permission : RW 1711 | *******************************************************************************/ 1712 | typedef enum { 1713 | LSM6DS3_ACC_GYRO_TAP_Z_EN_DISABLED = 0x00, 1714 | LSM6DS3_ACC_GYRO_TAP_Z_EN_ENABLED = 0x02, 1715 | } LSM6DS3_ACC_GYRO_TAP_Z_EN_t; 1716 | 1717 | /******************************************************************************* 1718 | * Register : TAP_CFG1 1719 | * Address : 0X58 1720 | * Bit Group Name: TAP_Y_EN 1721 | * Permission : RW 1722 | *******************************************************************************/ 1723 | typedef enum { 1724 | LSM6DS3_ACC_GYRO_TAP_Y_EN_DISABLED = 0x00, 1725 | LSM6DS3_ACC_GYRO_TAP_Y_EN_ENABLED = 0x04, 1726 | } LSM6DS3_ACC_GYRO_TAP_Y_EN_t; 1727 | 1728 | /******************************************************************************* 1729 | * Register : TAP_CFG1 1730 | * Address : 0X58 1731 | * Bit Group Name: TAP_X_EN 1732 | * Permission : RW 1733 | *******************************************************************************/ 1734 | typedef enum { 1735 | LSM6DS3_ACC_GYRO_TAP_X_EN_DISABLED = 0x00, 1736 | LSM6DS3_ACC_GYRO_TAP_X_EN_ENABLED = 0x08, 1737 | } LSM6DS3_ACC_GYRO_TAP_X_EN_t; 1738 | 1739 | /******************************************************************************* 1740 | * Register : TAP_CFG1 1741 | * Address : 0X58 1742 | * Bit Group Name: TILT_EN 1743 | * Permission : RW 1744 | *******************************************************************************/ 1745 | typedef enum { 1746 | LSM6DS3_ACC_GYRO_TILT_EN_DISABLED = 0x00, 1747 | LSM6DS3_ACC_GYRO_TILT_EN_ENABLED = 0x20, 1748 | } LSM6DS3_ACC_GYRO_TILT_EN_t; 1749 | 1750 | /******************************************************************************* 1751 | * Register : TAP_CFG1 1752 | * Address : 0X58 1753 | * Bit Group Name: PEDO_EN 1754 | * Permission : RW 1755 | *******************************************************************************/ 1756 | typedef enum { 1757 | LSM6DS3_ACC_GYRO_PEDO_EN_DISABLED = 0x00, 1758 | LSM6DS3_ACC_GYRO_PEDO_EN_ENABLED = 0x40, 1759 | } LSM6DS3_ACC_GYRO_PEDO_EN_t; 1760 | 1761 | /******************************************************************************* 1762 | * Register : TAP_CFG1 1763 | * Address : 0X58 1764 | * Bit Group Name: TIMER_EN 1765 | * Permission : RW 1766 | *******************************************************************************/ 1767 | typedef enum { 1768 | LSM6DS3_ACC_GYRO_TIMER_EN_DISABLED = 0x00, 1769 | LSM6DS3_ACC_GYRO_TIMER_EN_ENABLED = 0x80, 1770 | } LSM6DS3_ACC_GYRO_TIMER_EN_t; 1771 | 1772 | /******************************************************************************* 1773 | * Register : TAP_THS_6D 1774 | * Address : 0X59 1775 | * Bit Group Name: TAP_THS 1776 | * Permission : RW 1777 | *******************************************************************************/ 1778 | #define LSM6DS3_ACC_GYRO_TAP_THS_MASK 0x1F 1779 | #define LSM6DS3_ACC_GYRO_TAP_THS_POSITION 0 1780 | 1781 | /******************************************************************************* 1782 | * Register : TAP_THS_6D 1783 | * Address : 0X59 1784 | * Bit Group Name: SIXD_THS 1785 | * Permission : RW 1786 | *******************************************************************************/ 1787 | typedef enum { 1788 | LSM6DS3_ACC_GYRO_SIXD_THS_80_degree = 0x00, 1789 | LSM6DS3_ACC_GYRO_SIXD_THS_70_degree = 0x20, 1790 | LSM6DS3_ACC_GYRO_SIXD_THS_60_degree = 0x40, 1791 | LSM6DS3_ACC_GYRO_SIXD_THS_50_degree = 0x60, 1792 | } LSM6DS3_ACC_GYRO_SIXD_THS_t; 1793 | 1794 | /******************************************************************************* 1795 | * Register : INT_DUR2 1796 | * Address : 0X5A 1797 | * Bit Group Name: SHOCK 1798 | * Permission : RW 1799 | *******************************************************************************/ 1800 | #define LSM6DS3_ACC_GYRO_SHOCK_MASK 0x03 1801 | #define LSM6DS3_ACC_GYRO_SHOCK_POSITION 0 1802 | 1803 | /******************************************************************************* 1804 | * Register : INT_DUR2 1805 | * Address : 0X5A 1806 | * Bit Group Name: QUIET 1807 | * Permission : RW 1808 | *******************************************************************************/ 1809 | #define LSM6DS3_ACC_GYRO_QUIET_MASK 0x0C 1810 | #define LSM6DS3_ACC_GYRO_QUIET_POSITION 2 1811 | 1812 | /******************************************************************************* 1813 | * Register : INT_DUR2 1814 | * Address : 0X5A 1815 | * Bit Group Name: DUR 1816 | * Permission : RW 1817 | *******************************************************************************/ 1818 | #define LSM6DS3_ACC_GYRO_DUR_MASK 0xF0 1819 | #define LSM6DS3_ACC_GYRO_DUR_POSITION 4 1820 | 1821 | /******************************************************************************* 1822 | * Register : WAKE_UP_THS 1823 | * Address : 0X5B 1824 | * Bit Group Name: WK_THS 1825 | * Permission : RW 1826 | *******************************************************************************/ 1827 | #define LSM6DS3_ACC_GYRO_WK_THS_MASK 0x3F 1828 | #define LSM6DS3_ACC_GYRO_WK_THS_POSITION 0 1829 | 1830 | /******************************************************************************* 1831 | * Register : WAKE_UP_THS 1832 | * Address : 0X5B 1833 | * Bit Group Name: INACTIVITY_ON 1834 | * Permission : RW 1835 | *******************************************************************************/ 1836 | typedef enum { 1837 | LSM6DS3_ACC_GYRO_INACTIVITY_ON_DISABLED = 0x00, 1838 | LSM6DS3_ACC_GYRO_INACTIVITY_ON_ENABLED = 0x40, 1839 | } LSM6DS3_ACC_GYRO_INACTIVITY_ON_t; 1840 | 1841 | /******************************************************************************* 1842 | * Register : WAKE_UP_THS 1843 | * Address : 0X5B 1844 | * Bit Group Name: SINGLE_DOUBLE_TAP 1845 | * Permission : RW 1846 | *******************************************************************************/ 1847 | typedef enum { 1848 | LSM6DS3_ACC_GYRO_SINGLE_DOUBLE_TAP_DOUBLE_TAP = 0x00, 1849 | LSM6DS3_ACC_GYRO_SINGLE_DOUBLE_TAP_SINGLE_TAP = 0x80, 1850 | } LSM6DS3_ACC_GYRO_SINGLE_DOUBLE_TAP_t; 1851 | 1852 | /******************************************************************************* 1853 | * Register : WAKE_UP_DUR 1854 | * Address : 0X5C 1855 | * Bit Group Name: SLEEP_DUR 1856 | * Permission : RW 1857 | *******************************************************************************/ 1858 | #define LSM6DS3_ACC_GYRO_SLEEP_DUR_MASK 0x0F 1859 | #define LSM6DS3_ACC_GYRO_SLEEP_DUR_POSITION 0 1860 | 1861 | /******************************************************************************* 1862 | * Register : WAKE_UP_DUR 1863 | * Address : 0X5C 1864 | * Bit Group Name: TIMER_HR 1865 | * Permission : RW 1866 | *******************************************************************************/ 1867 | typedef enum { 1868 | LSM6DS3_ACC_GYRO_TIMER_HR_6_4ms = 0x00, 1869 | LSM6DS3_ACC_GYRO_TIMER_HR_25us = 0x10, 1870 | } LSM6DS3_ACC_GYRO_TIMER_HR_t; 1871 | 1872 | /******************************************************************************* 1873 | * Register : WAKE_UP_DUR 1874 | * Address : 0X5C 1875 | * Bit Group Name: WAKE_DUR 1876 | * Permission : RW 1877 | *******************************************************************************/ 1878 | #define LSM6DS3_ACC_GYRO_WAKE_DUR_MASK 0x60 1879 | #define LSM6DS3_ACC_GYRO_WAKE_DUR_POSITION 5 1880 | 1881 | /******************************************************************************* 1882 | * Register : FREE_FALL 1883 | * Address : 0X5D 1884 | * Bit Group Name: FF_DUR 1885 | * Permission : RW 1886 | *******************************************************************************/ 1887 | #define LSM6DS3_ACC_GYRO_FF_FREE_FALL_DUR_MASK 0xF8 1888 | #define LSM6DS3_ACC_GYRO_FF_FREE_FALL_DUR_POSITION 3 1889 | #define LSM6DS3_ACC_GYRO_FF_WAKE_UP_DUR_MASK 0x80 1890 | #define LSM6DS3_ACC_GYRO_FF_WAKE_UP_DUR_POSITION 7 1891 | 1892 | 1893 | /******************************************************************************* 1894 | * Register : FREE_FALL 1895 | * Address : 0X5D 1896 | * Bit Group Name: FF_THS 1897 | * Permission : RW 1898 | *******************************************************************************/ 1899 | typedef enum { 1900 | LSM6DS3_ACC_GYRO_FF_THS_5 = 0x00, 1901 | LSM6DS3_ACC_GYRO_FF_THS_7 = 0x01, 1902 | LSM6DS3_ACC_GYRO_FF_THS_8 = 0x02, 1903 | LSM6DS3_ACC_GYRO_FF_THS_10 = 0x03, 1904 | LSM6DS3_ACC_GYRO_FF_THS_11 = 0x04, 1905 | LSM6DS3_ACC_GYRO_FF_THS_13 = 0x05, 1906 | LSM6DS3_ACC_GYRO_FF_THS_15 = 0x06, 1907 | LSM6DS3_ACC_GYRO_FF_THS_16 = 0x07, 1908 | } LSM6DS3_ACC_GYRO_FF_THS_t; 1909 | 1910 | /******************************************************************************* 1911 | * Register : MD1_CFG 1912 | * Address : 0X5E 1913 | * Bit Group Name: INT1_TIMER 1914 | * Permission : RW 1915 | *******************************************************************************/ 1916 | typedef enum { 1917 | LSM6DS3_ACC_GYRO_INT1_TIMER_DISABLED = 0x00, 1918 | LSM6DS3_ACC_GYRO_INT1_TIMER_ENABLED = 0x01, 1919 | } LSM6DS3_ACC_GYRO_INT1_TIMER_t; 1920 | 1921 | /******************************************************************************* 1922 | * Register : MD1_CFG 1923 | * Address : 0X5E 1924 | * Bit Group Name: INT1_TILT 1925 | * Permission : RW 1926 | *******************************************************************************/ 1927 | typedef enum { 1928 | LSM6DS3_ACC_GYRO_INT1_TILT_DISABLED = 0x00, 1929 | LSM6DS3_ACC_GYRO_INT1_TILT_ENABLED = 0x02, 1930 | } LSM6DS3_ACC_GYRO_INT1_TILT_t; 1931 | 1932 | /******************************************************************************* 1933 | * Register : MD1_CFG 1934 | * Address : 0X5E 1935 | * Bit Group Name: INT1_6D 1936 | * Permission : RW 1937 | *******************************************************************************/ 1938 | typedef enum { 1939 | LSM6DS3_ACC_GYRO_INT1_6D_DISABLED = 0x00, 1940 | LSM6DS3_ACC_GYRO_INT1_6D_ENABLED = 0x04, 1941 | } LSM6DS3_ACC_GYRO_INT1_6D_t; 1942 | 1943 | /******************************************************************************* 1944 | * Register : MD1_CFG 1945 | * Address : 0X5E 1946 | * Bit Group Name: INT1_TAP 1947 | * Permission : RW 1948 | *******************************************************************************/ 1949 | typedef enum { 1950 | LSM6DS3_ACC_GYRO_INT1_TAP_DISABLED = 0x00, 1951 | LSM6DS3_ACC_GYRO_INT1_TAP_ENABLED = 0x08, 1952 | } LSM6DS3_ACC_GYRO_INT1_TAP_t; 1953 | 1954 | /******************************************************************************* 1955 | * Register : MD1_CFG 1956 | * Address : 0X5E 1957 | * Bit Group Name: INT1_FF 1958 | * Permission : RW 1959 | *******************************************************************************/ 1960 | typedef enum { 1961 | LSM6DS3_ACC_GYRO_INT1_FF_DISABLED = 0x00, 1962 | LSM6DS3_ACC_GYRO_INT1_FF_ENABLED = 0x10, 1963 | } LSM6DS3_ACC_GYRO_INT1_FF_t; 1964 | 1965 | /******************************************************************************* 1966 | * Register : MD1_CFG 1967 | * Address : 0X5E 1968 | * Bit Group Name: INT1_WU 1969 | * Permission : RW 1970 | *******************************************************************************/ 1971 | typedef enum { 1972 | LSM6DS3_ACC_GYRO_INT1_WU_DISABLED = 0x00, 1973 | LSM6DS3_ACC_GYRO_INT1_WU_ENABLED = 0x20, 1974 | } LSM6DS3_ACC_GYRO_INT1_WU_t; 1975 | 1976 | /******************************************************************************* 1977 | * Register : MD1_CFG 1978 | * Address : 0X5E 1979 | * Bit Group Name: INT1_SINGLE_TAP 1980 | * Permission : RW 1981 | *******************************************************************************/ 1982 | typedef enum { 1983 | LSM6DS3_ACC_GYRO_INT1_SINGLE_TAP_DISABLED = 0x00, 1984 | LSM6DS3_ACC_GYRO_INT1_SINGLE_TAP_ENABLED = 0x40, 1985 | } LSM6DS3_ACC_GYRO_INT1_SINGLE_TAP_t; 1986 | 1987 | /******************************************************************************* 1988 | * Register : MD1_CFG 1989 | * Address : 0X5E 1990 | * Bit Group Name: INT1_SLEEP 1991 | * Permission : RW 1992 | *******************************************************************************/ 1993 | typedef enum { 1994 | LSM6DS3_ACC_GYRO_INT1_SLEEP_DISABLED = 0x00, 1995 | LSM6DS3_ACC_GYRO_INT1_SLEEP_ENABLED = 0x80, 1996 | } LSM6DS3_ACC_GYRO_INT1_SLEEP_t; 1997 | 1998 | /******************************************************************************* 1999 | * Register : MD2_CFG 2000 | * Address : 0X5F 2001 | * Bit Group Name: INT2_TIMER 2002 | * Permission : RW 2003 | *******************************************************************************/ 2004 | typedef enum { 2005 | LSM6DS3_ACC_GYRO_INT2_TIMER_DISABLED = 0x00, 2006 | LSM6DS3_ACC_GYRO_INT2_TIMER_ENABLED = 0x01, 2007 | } LSM6DS3_ACC_GYRO_INT2_TIMER_t; 2008 | 2009 | /******************************************************************************* 2010 | * Register : MD2_CFG 2011 | * Address : 0X5F 2012 | * Bit Group Name: INT2_TILT 2013 | * Permission : RW 2014 | *******************************************************************************/ 2015 | typedef enum { 2016 | LSM6DS3_ACC_GYRO_INT2_TILT_DISABLED = 0x00, 2017 | LSM6DS3_ACC_GYRO_INT2_TILT_ENABLED = 0x02, 2018 | } LSM6DS3_ACC_GYRO_INT2_TILT_t; 2019 | 2020 | /******************************************************************************* 2021 | * Register : MD2_CFG 2022 | * Address : 0X5F 2023 | * Bit Group Name: INT2_6D 2024 | * Permission : RW 2025 | *******************************************************************************/ 2026 | typedef enum { 2027 | LSM6DS3_ACC_GYRO_INT2_6D_DISABLED = 0x00, 2028 | LSM6DS3_ACC_GYRO_INT2_6D_ENABLED = 0x04, 2029 | } LSM6DS3_ACC_GYRO_INT2_6D_t; 2030 | 2031 | /******************************************************************************* 2032 | * Register : MD2_CFG 2033 | * Address : 0X5F 2034 | * Bit Group Name: INT2_TAP 2035 | * Permission : RW 2036 | *******************************************************************************/ 2037 | typedef enum { 2038 | LSM6DS3_ACC_GYRO_INT2_TAP_DISABLED = 0x00, 2039 | LSM6DS3_ACC_GYRO_INT2_TAP_ENABLED = 0x08, 2040 | } LSM6DS3_ACC_GYRO_INT2_TAP_t; 2041 | 2042 | /******************************************************************************* 2043 | * Register : MD2_CFG 2044 | * Address : 0X5F 2045 | * Bit Group Name: INT2_FF 2046 | * Permission : RW 2047 | *******************************************************************************/ 2048 | typedef enum { 2049 | LSM6DS3_ACC_GYRO_INT2_FF_DISABLED = 0x00, 2050 | LSM6DS3_ACC_GYRO_INT2_FF_ENABLED = 0x10, 2051 | } LSM6DS3_ACC_GYRO_INT2_FF_t; 2052 | 2053 | /******************************************************************************* 2054 | * Register : MD2_CFG 2055 | * Address : 0X5F 2056 | * Bit Group Name: INT2_WU 2057 | * Permission : RW 2058 | *******************************************************************************/ 2059 | typedef enum { 2060 | LSM6DS3_ACC_GYRO_INT2_WU_DISABLED = 0x00, 2061 | LSM6DS3_ACC_GYRO_INT2_WU_ENABLED = 0x20, 2062 | } LSM6DS3_ACC_GYRO_INT2_WU_t; 2063 | 2064 | /******************************************************************************* 2065 | * Register : MD2_CFG 2066 | * Address : 0X5F 2067 | * Bit Group Name: INT2_SINGLE_TAP 2068 | * Permission : RW 2069 | *******************************************************************************/ 2070 | typedef enum { 2071 | LSM6DS3_ACC_GYRO_INT2_SINGLE_TAP_DISABLED = 0x00, 2072 | LSM6DS3_ACC_GYRO_INT2_SINGLE_TAP_ENABLED = 0x40, 2073 | } LSM6DS3_ACC_GYRO_INT2_SINGLE_TAP_t; 2074 | 2075 | /******************************************************************************* 2076 | * Register : MD2_CFG 2077 | * Address : 0X5F 2078 | * Bit Group Name: INT2_SLEEP 2079 | * Permission : RW 2080 | *******************************************************************************/ 2081 | typedef enum { 2082 | LSM6DS3_ACC_GYRO_INT2_SLEEP_DISABLED = 0x00, 2083 | LSM6DS3_ACC_GYRO_INT2_SLEEP_ENABLED = 0x80, 2084 | } LSM6DS3_ACC_GYRO_INT2_SLEEP_t; 2085 | 2086 | #endif // End of __LSM6DS3IMU_H__ definition check 2087 | --------------------------------------------------------------------------------