├── .gitattributes ├── .gitignore ├── LICENSE.md ├── README.md ├── examples ├── DoubleCheckSettings │ └── DoubleCheckSettings.ino ├── FifoExample │ └── FifoExample.ino ├── InterruptFreeFallConfig │ └── InterruptFreeFallConfig.ino ├── InterruptHWTapConfig │ └── InterruptHWTapConfig.ino ├── LowLevelExample │ └── LowLevelExample.ino ├── MemoryPagingExample │ └── MemoryPagingExample.ino ├── MinimalistExample │ ├── MinimalistExample.ino │ └── README.md ├── MultiI2C │ └── MultiI2C.ino ├── MultiSPI │ └── MultiSPI.ino ├── Pedometer │ └── Pedometer.ino └── README.md ├── extras └── class diagrams.pdf ├── keywords.txt ├── library.properties └── src ├── README.md ├── SparkFunLSM6DS3.cpp └── SparkFunLSM6DS3.h /.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 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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, ESP32, ESP8266, 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 | * [V 1.0.1](https://github.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library/releases/tag/V_1.0.1) -- Adds SPI compatibility to the ESP32 and ESP8266 boards for this product. 51 | 52 | License Information 53 | ------------------- 54 | 55 | This product is _**open source**_! 56 | 57 | Please review the LICENSE.md file for license information. 58 | 59 | If you have any questions or concerns on licensing, please contact techsupport@sparkfun.com. 60 | 61 | Distributed as-is; no warranty is given. 62 | 63 | - Your friends at SparkFun. 64 | 65 | -------------------------------------------------------------------------------- /examples/DoubleCheckSettings/DoubleCheckSettings.ino: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | MinimalistExample.ino 3 | 4 | Owen Lyke @ SparkFun Electronics 5 | March 13, 2019 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 - except now you can see if your settings got changed 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 | // Let's choose an unsupported setting... 50 | myIMU.settings.accelSampleRate = 404; // Typo, 'meant' to type '104' 51 | 52 | // Make a SensorSettings object to remember what you wanted to set everyhting to 53 | SensorSettings settingsIWanted; 54 | 55 | //Call .begin() to configure the IMU - supplying pointer to the SensorSettings structure 56 | myIMU.begin(&settingsIWanted); 57 | 58 | // Compare the sensor settings structure to know if anything was changed 59 | compareSettings(settingsIWanted); 60 | 61 | } 62 | 63 | 64 | void loop() 65 | { 66 | //Get all parameters 67 | Serial.print("\nAccelerometer:\n"); 68 | Serial.print(" X = "); 69 | Serial.println(myIMU.readFloatAccelX(), 4); 70 | Serial.print(" Y = "); 71 | Serial.println(myIMU.readFloatAccelY(), 4); 72 | Serial.print(" Z = "); 73 | Serial.println(myIMU.readFloatAccelZ(), 4); 74 | 75 | Serial.print("\nGyroscope:\n"); 76 | Serial.print(" X = "); 77 | Serial.println(myIMU.readFloatGyroX(), 4); 78 | Serial.print(" Y = "); 79 | Serial.println(myIMU.readFloatGyroY(), 4); 80 | Serial.print(" Z = "); 81 | Serial.println(myIMU.readFloatGyroZ(), 4); 82 | 83 | Serial.print("\nThermometer:\n"); 84 | Serial.print(" Degrees C = "); 85 | Serial.println(myIMU.readTempC(), 4); 86 | Serial.print(" Degrees F = "); 87 | Serial.println(myIMU.readTempF(), 4); 88 | 89 | delay(1000); 90 | } 91 | 92 | void compareSettings(SensorSettings desiredSettings){ 93 | if(myIMU.settings.accelBandWidth != desiredSettings.accelBandWidth ) { Serial.println("'accelBandWidth' was changed!"); } 94 | if(myIMU.settings.accelRange != desiredSettings.accelRange ) { Serial.println("'accelRange' was changed!"); } 95 | if(myIMU.settings.accelSampleRate != desiredSettings.accelSampleRate ) { Serial.println("'accelSampleRate' was changed!"); } 96 | if(myIMU.settings.gyroRange != desiredSettings.gyroRange ) { Serial.println("'gyroRange' was changed!"); } 97 | if(myIMU.settings.gyroSampleRate != desiredSettings.gyroSampleRate ) { Serial.println("'gyroSampleRate' was changed!"); } 98 | // That's all the settings that might get changed in 'begin()' 99 | } 100 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | errorAccumulator += myIMU.readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C); 78 | 79 | // Write 00h into WAKE_UP_DUR 80 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_WAKE_UP_DUR, 0x00 ); 81 | 82 | // Set FF threshold (FF_THS[2:0] = 011b) 83 | // Set six samples event duration (FF_DUR[5:0] = 000110b) 84 | // Write 33h into FREE_FALL 85 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_FREE_FALL, 0x33); 86 | 87 | // FF interrupt driven to INT1 pin 88 | // Write 10h into MD1_CFG 89 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_MD1_CFG, 0x10 ); 90 | // Also route to INT2 pin 91 | // Write 10h into MD1_CFG 92 | errorAccumulator += myIMU.writeRegister( LSM6DS3_ACC_GYRO_MD2_CFG, 0x10 ); 93 | 94 | // Latch interrupt 95 | // Write 01h into TAP_CFG 96 | errorAccumulator += myIMU.writeRegister(LSM6DS3_ACC_GYRO_TAP_CFG1, 0x01); 97 | 98 | if( errorAccumulator ) 99 | { 100 | Serial.println("Problem configuring the device."); 101 | } 102 | else 103 | { 104 | Serial.println("Device O.K."); 105 | } 106 | } 107 | 108 | void loop() 109 | { 110 | uint8_t readDataByte = 0; 111 | //Read the wake-up source register 112 | myIMU.readRegister(&readDataByte, LSM6DS3_ACC_GYRO_WAKE_UP_SRC); 113 | //Mask off the FF_IA bit for free-fall detection 114 | readDataByte &= 0x20; 115 | //Check for free-fall 116 | if( readDataByte ) 117 | { 118 | //debounce 119 | delay(10); 120 | Serial.println("Interrupt caught. Free fall detected."); 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /examples/MinimalistExample/README.md: -------------------------------------------------------------------------------- 1 | Minimalist Example 2 | ======= 3 | 4 | Basic read function -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /extras/class diagrams.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparkfun/SparkFun_LSM6DS3_Arduino_Library/fa686db5006826a84e5d930bb83838406905b571/extras/class diagrams.pdf -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /library.properties: -------------------------------------------------------------------------------- 1 | name=SparkFun LSM6DS3 Breakout 2 | version=1.0.3 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=* 10 | -------------------------------------------------------------------------------- /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. -------------------------------------------------------------------------------- /src/SparkFunLSM6DS3.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | SparkFunLSM6DS3.cpp 3 | LSM6DS3 Arduino, Teensy Driver, SparkFun ESP32 and ESP8266 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 | ESPTool 2.6 for ESP32 19 | 20 | This code is released under the [MIT License](http://opensource.org/licenses/MIT). 21 | 22 | Please review the LICENSE.md file included with this example. If you have any questions 23 | or concerns with licensing, please contact techsupport@sparkfun.com. 24 | 25 | Distributed as-is; no warranty is given. 26 | ******************************************************************************/ 27 | 28 | //See SparkFunLSM6DS3.h for additional topology notes. 29 | 30 | #include "SparkFunLSM6DS3.h" 31 | 32 | //****************************************************************************// 33 | // 34 | // LSM6DS3Core functions. 35 | // 36 | // Construction arguments: 37 | // ( uint8_t busType, uint8_t inputArg ), 38 | // 39 | // where inputArg is address for I2C_MODE and chip select pin 40 | // number for SPI_MODE 41 | // 42 | // For SPI, construct LSM6DS3Core myIMU(SPI_MODE, 10); 43 | // For I2C, construct LSM6DS3Core myIMU(I2C_MODE, 0x6B); 44 | // 45 | // Default construction is I2C mode, address 0x6B. 46 | // 47 | //****************************************************************************// 48 | LSM6DS3Core::LSM6DS3Core( uint8_t busType, uint8_t inputArg) : commInterface(I2C_MODE), I2CAddress(0x6B), chipSelectPin(10) 49 | { 50 | commInterface = busType; 51 | if( commInterface == I2C_MODE ) 52 | { 53 | I2CAddress = inputArg; 54 | } 55 | if( commInterface == SPI_MODE ) 56 | { 57 | chipSelectPin = inputArg; 58 | } 59 | 60 | } 61 | 62 | status_t LSM6DS3Core::beginCore(void) 63 | { 64 | status_t returnError = IMU_SUCCESS; 65 | uint32_t spiPortSpeed = 5000000; 66 | 67 | switch (commInterface) { 68 | 69 | case I2C_MODE: 70 | Wire.begin(); 71 | break; 72 | 73 | case SPI_MODE: 74 | // start the SPI library: 75 | SPI.begin(); 76 | 77 | #ifdef __AVR__ 78 | mySpiSettings = SPISettings(spiPortSpeed, MSB_FIRST, SPI_MODE1); 79 | #endif 80 | #if defined(ESP32) || defined(ESP8266) 81 | mySpiSettings = SPISettings(spiPortSpeed, MSBFIRST, SPI_MODE1); 82 | #endif 83 | #ifdef __MK20DX256__ 84 | mySpiSettings = SPISettings(spiPortSpeed, MSB_FIRST, SPI_MODE0); 85 | #endif 86 | #ifdef ARDUINO_NANO33BLE 87 | mySpiSettings = SPISettings(spiPortSpeed, MSB_FIRST, SPI_MODE0); 88 | #endif 89 | 90 | pinMode(chipSelectPin, OUTPUT); 91 | digitalWrite(chipSelectPin, HIGH); 92 | break; 93 | default: 94 | break; 95 | } 96 | 97 | //Spin for a few ms 98 | volatile uint8_t temp = 0; 99 | for( uint16_t i = 0; i < 10000; i++ ) 100 | { 101 | temp++; 102 | } 103 | 104 | //Check the ID register to determine if the operation was a success. 105 | uint8_t readCheck; 106 | readRegister(&readCheck, LSM6DS3_ACC_GYRO_WHO_AM_I_REG); 107 | if( readCheck != 0x69 ) 108 | { 109 | returnError = IMU_HW_ERROR; 110 | } 111 | 112 | return returnError; 113 | 114 | } 115 | 116 | //****************************************************************************// 117 | // 118 | // ReadRegisterRegion 119 | // 120 | // Parameters: 121 | // *outputPointer -- Pass &variable (base address of) to save read data to 122 | // offset -- register to read 123 | // length -- number of bytes to read 124 | // 125 | // Note: Does not know if the target memory space is an array or not, or 126 | // if there is the array is big enough. if the variable passed is only 127 | // two bytes long and 3 bytes are requested, this will over-write some 128 | // other memory! 129 | // 130 | //****************************************************************************// 131 | status_t LSM6DS3Core::readRegisterRegion(uint8_t *outputPointer , uint8_t offset, uint8_t length) 132 | { 133 | status_t returnError = IMU_SUCCESS; 134 | 135 | //define pointer that will point to the external space 136 | uint8_t i = 0; 137 | uint8_t c = 0; 138 | uint8_t tempFFCounter = 0; 139 | 140 | switch (commInterface) { 141 | 142 | case I2C_MODE: 143 | Wire.beginTransmission(I2CAddress); 144 | Wire.write(offset); 145 | if( Wire.endTransmission() != 0 ) 146 | { 147 | returnError = IMU_HW_ERROR; 148 | } 149 | else //OK, all worked, keep going 150 | { 151 | // request 6 bytes from slave device 152 | Wire.requestFrom(I2CAddress, length); 153 | while ( (Wire.available()) && (i < length)) // slave may send less than requested 154 | { 155 | c = Wire.read(); // receive a byte as character 156 | *outputPointer = c; 157 | outputPointer++; 158 | i++; 159 | } 160 | } 161 | break; 162 | 163 | case SPI_MODE: 164 | // take the chip select low to select the device: 165 | digitalWrite(chipSelectPin, LOW); 166 | // send the device the register you want to read: 167 | SPI.transfer(offset | 0x80); //Ored with "read request" bit 168 | while ( i < length ) // slave may send less than requested 169 | { 170 | c = SPI.transfer(0x00); // receive a byte as character 171 | if( c == 0xFF ) 172 | { 173 | //May have problem 174 | tempFFCounter++; 175 | } 176 | *outputPointer = c; 177 | outputPointer++; 178 | i++; 179 | } 180 | if( tempFFCounter == i ) 181 | { 182 | //Ok, we've recieved all ones, report 183 | returnError = IMU_ALL_ONES_WARNING; 184 | } 185 | // take the chip select high to de-select: 186 | digitalWrite(chipSelectPin, HIGH); 187 | break; 188 | 189 | default: 190 | break; 191 | } 192 | 193 | return returnError; 194 | } 195 | 196 | //****************************************************************************// 197 | // 198 | // ReadRegister 199 | // 200 | // Parameters: 201 | // *outputPointer -- Pass &variable (address of) to save read data to 202 | // offset -- register to read 203 | // 204 | //****************************************************************************// 205 | status_t LSM6DS3Core::readRegister(uint8_t* outputPointer, uint8_t offset) { 206 | //Return value 207 | uint8_t result = 0; 208 | uint8_t numBytes = 1; 209 | status_t returnError = IMU_SUCCESS; 210 | 211 | switch (commInterface) { 212 | 213 | case I2C_MODE: 214 | Wire.beginTransmission(I2CAddress); 215 | Wire.write(offset); 216 | if( Wire.endTransmission() != 0 ) 217 | { 218 | returnError = IMU_HW_ERROR; 219 | } 220 | Wire.requestFrom(I2CAddress, numBytes); 221 | while ( Wire.available() ) // slave may send less than requested 222 | { 223 | result = Wire.read(); // receive a byte as a proper uint8_t 224 | } 225 | break; 226 | 227 | case SPI_MODE: 228 | // take the chip select low to select the device: 229 | digitalWrite(chipSelectPin, LOW); 230 | // send the device the register you want to read: 231 | SPI.transfer(offset | 0x80); //Ored with "read request" bit 232 | // send a value of 0 to read the first byte returned: 233 | result = SPI.transfer(0x00); 234 | // take the chip select high to de-select: 235 | digitalWrite(chipSelectPin, HIGH); 236 | 237 | if( result == 0xFF ) 238 | { 239 | //we've recieved all ones, report 240 | returnError = IMU_ALL_ONES_WARNING; 241 | } 242 | break; 243 | 244 | default: 245 | break; 246 | } 247 | 248 | *outputPointer = result; 249 | return returnError; 250 | } 251 | 252 | //****************************************************************************// 253 | // 254 | // readRegisterInt16 255 | // 256 | // Parameters: 257 | // *outputPointer -- Pass &variable (base address of) to save read data to 258 | // offset -- register to read 259 | // 260 | //****************************************************************************// 261 | status_t LSM6DS3Core::readRegisterInt16( int16_t* outputPointer, uint8_t offset ) 262 | { 263 | uint8_t myBuffer[2]; 264 | status_t returnError = readRegisterRegion(myBuffer, offset, 2); //Does memory transfer 265 | int16_t output = (int16_t)myBuffer[0] | int16_t(myBuffer[1] << 8); 266 | 267 | *outputPointer = output; 268 | return returnError; 269 | } 270 | 271 | //****************************************************************************// 272 | // 273 | // writeRegister 274 | // 275 | // Parameters: 276 | // offset -- register to write 277 | // dataToWrite -- 8 bit data to write to register 278 | // 279 | //****************************************************************************// 280 | status_t LSM6DS3Core::writeRegister(uint8_t offset, uint8_t dataToWrite) { 281 | status_t returnError = IMU_SUCCESS; 282 | switch (commInterface) { 283 | case I2C_MODE: 284 | //Write the byte 285 | Wire.beginTransmission(I2CAddress); 286 | Wire.write(offset); 287 | Wire.write(dataToWrite); 288 | if( Wire.endTransmission() != 0 ) 289 | { 290 | returnError = IMU_HW_ERROR; 291 | } 292 | break; 293 | 294 | case SPI_MODE: 295 | // take the chip select low to select the device: 296 | SPI.beginTransaction(mySpiSettings); 297 | digitalWrite(chipSelectPin, LOW); 298 | // send the device the register you want to read: 299 | SPI.transfer(offset); 300 | // send a value of 0 to read the first byte returned: 301 | SPI.transfer(dataToWrite); 302 | // decrement the number of bytes left to read: 303 | // take the chip select high to de-select: 304 | digitalWrite(chipSelectPin, HIGH); 305 | break; 306 | 307 | //No way to check error on this write (Except to read back but that's not reliable) 308 | 309 | default: 310 | break; 311 | } 312 | 313 | return returnError; 314 | } 315 | 316 | status_t LSM6DS3Core::embeddedPage( void ) 317 | { 318 | status_t returnError = writeRegister( LSM6DS3_ACC_GYRO_RAM_ACCESS, 0x80 ); 319 | 320 | return returnError; 321 | } 322 | 323 | status_t LSM6DS3Core::basePage( void ) 324 | { 325 | status_t returnError = writeRegister( LSM6DS3_ACC_GYRO_RAM_ACCESS, 0x00 ); 326 | 327 | return returnError; 328 | } 329 | 330 | 331 | //****************************************************************************// 332 | // 333 | // Main user class -- wrapper for the core class + maths 334 | // 335 | // Construct with same rules as the core ( uint8_t busType, uint8_t inputArg ) 336 | // 337 | //****************************************************************************// 338 | LSM6DS3::LSM6DS3( uint8_t busType, uint8_t inputArg ) : LSM6DS3Core( busType, inputArg ) 339 | { 340 | //Construct with these default settings 341 | 342 | settings.gyroEnabled = 1; //Can be 0 or 1 343 | settings.gyroRange = 2000; //Max deg/s. Can be: 125, 245, 500, 1000, 2000 344 | settings.gyroSampleRate = 416; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666 345 | settings.gyroBandWidth = 400; //Hz. Can be: 50, 100, 200, 400; 346 | settings.gyroFifoEnabled = 1; //Set to include gyro in FIFO 347 | settings.gyroFifoDecimation = 1; //set 1 for on /1 348 | 349 | settings.accelEnabled = 1; 350 | settings.accelODROff = 1; 351 | settings.accelRange = 16; //Max G force readable. Can be: 2, 4, 8, 16 352 | settings.accelSampleRate = 416; //Hz. Can be: 13, 26, 52, 104, 208, 416, 833, 1666, 3332, 6664, 13330 353 | settings.accelBandWidth = 100; //Hz. Can be: 50, 100, 200, 400; 354 | settings.accelFifoEnabled = 1; //Set to include accelerometer in the FIFO 355 | settings.accelFifoDecimation = 1; //set 1 for on /1 356 | 357 | settings.tempEnabled = 1; 358 | 359 | //Select interface mode 360 | settings.commMode = 1; //Can be modes 1, 2 or 3 361 | 362 | //FIFO control data 363 | settings.fifoThreshold = 3000; //Can be 0 to 4095 (16 bit bytes) 364 | settings.fifoSampleRate = 10; //default 10Hz 365 | settings.fifoModeWord = 0; //Default off 366 | 367 | allOnesCounter = 0; 368 | nonSuccessCounter = 0; 369 | 370 | } 371 | 372 | //****************************************************************************// 373 | // 374 | // Configuration section 375 | // 376 | // This uses the stored SensorSettings to start the IMU 377 | // Use statements such as "myIMU.settings.commInterface = SPI_MODE;" or 378 | // "myIMU.settings.accelEnabled = 1;" to configure before calling .begin(); 379 | // 380 | //****************************************************************************// 381 | status_t LSM6DS3::begin(SensorSettings* pSettingsYouWanted) 382 | { 383 | //Check the settings structure values to determine how to setup the device 384 | uint8_t dataToWrite = 0; //Temporary variable 385 | 386 | //Begin the inherited core. This gets the physical wires connected 387 | status_t returnError = beginCore(); 388 | 389 | // Copy the values from the user's settings into the output 'pSettingsYouWanted' 390 | // compare settings with 'pSettingsYouWanted' after 'begin' to see if anything changed 391 | if(pSettingsYouWanted != NULL){ 392 | pSettingsYouWanted->gyroEnabled = settings.gyroEnabled; 393 | pSettingsYouWanted->gyroRange = settings.gyroRange; 394 | pSettingsYouWanted->gyroSampleRate = settings.gyroSampleRate; 395 | pSettingsYouWanted->gyroBandWidth = settings.gyroBandWidth; 396 | pSettingsYouWanted->gyroFifoEnabled = settings.gyroFifoEnabled; 397 | pSettingsYouWanted->gyroFifoDecimation = settings.gyroFifoDecimation; 398 | pSettingsYouWanted->accelEnabled = settings.accelEnabled; 399 | pSettingsYouWanted->accelODROff = settings.accelODROff; 400 | pSettingsYouWanted->accelRange = settings.accelRange; 401 | pSettingsYouWanted->accelSampleRate = settings.accelSampleRate; 402 | pSettingsYouWanted->accelBandWidth = settings.accelBandWidth; 403 | pSettingsYouWanted->accelFifoEnabled = settings.accelFifoEnabled; 404 | pSettingsYouWanted->accelFifoDecimation = settings.accelFifoDecimation; 405 | pSettingsYouWanted->tempEnabled = settings.tempEnabled; 406 | pSettingsYouWanted->commMode = settings.commMode; 407 | pSettingsYouWanted->fifoThreshold = settings.fifoThreshold; 408 | pSettingsYouWanted->fifoSampleRate = settings.fifoSampleRate; 409 | pSettingsYouWanted->fifoModeWord = settings.fifoModeWord; 410 | } 411 | 412 | //Setup the accelerometer****************************** 413 | dataToWrite = 0; //Start Fresh! 414 | if ( settings.accelEnabled == 1) { 415 | //Build config reg 416 | //First patch in filter bandwidth 417 | switch (settings.accelBandWidth) { 418 | case 50: 419 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_50Hz; 420 | break; 421 | case 100: 422 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_100Hz; 423 | break; 424 | case 200: 425 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_200Hz; 426 | break; 427 | default: //set default case to max passthrough 428 | settings.accelBandWidth = 400; 429 | case 400: 430 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_XL_400Hz; 431 | break; 432 | } 433 | //Next, patch in full scale 434 | switch (settings.accelRange) { 435 | case 2: 436 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_2g; 437 | break; 438 | case 4: 439 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_4g; 440 | break; 441 | case 8: 442 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_8g; 443 | break; 444 | default: //set default case to 16(max) 445 | settings.accelRange = 16; 446 | case 16: 447 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_XL_16g; 448 | break; 449 | } 450 | //Lastly, patch in accelerometer ODR 451 | switch (settings.accelSampleRate) { 452 | case 13: 453 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_13Hz; 454 | break; 455 | case 26: 456 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_26Hz; 457 | break; 458 | case 52: 459 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_52Hz; 460 | break; 461 | default: //Set default to 104 462 | settings.accelSampleRate = 104; 463 | case 104: 464 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_104Hz; 465 | break; 466 | case 208: 467 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_208Hz; 468 | break; 469 | case 416: 470 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_416Hz; 471 | break; 472 | case 833: 473 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_833Hz; 474 | break; 475 | case 1660: 476 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_1660Hz; 477 | break; 478 | case 3330: 479 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_3330Hz; 480 | break; 481 | case 6660: 482 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_6660Hz; 483 | break; 484 | case 13330: 485 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_XL_13330Hz; 486 | break; 487 | } 488 | } 489 | else 490 | { 491 | //dataToWrite already = 0 (powerdown); 492 | } 493 | 494 | //Now, write the patched together data 495 | writeRegister(LSM6DS3_ACC_GYRO_CTRL1_XL, dataToWrite); 496 | 497 | //Set the ODR bit 498 | readRegister(&dataToWrite, LSM6DS3_ACC_GYRO_CTRL4_C); 499 | dataToWrite &= ~((uint8_t)LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED); 500 | if ( settings.accelODROff == 1) { 501 | dataToWrite |= LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED; 502 | } 503 | writeRegister(LSM6DS3_ACC_GYRO_CTRL4_C, dataToWrite); 504 | 505 | //Setup the gyroscope********************************************** 506 | dataToWrite = 0; //Start Fresh! 507 | if ( settings.gyroEnabled == 1) { 508 | //Build config reg 509 | //First, patch in full scale 510 | switch (settings.gyroRange) { 511 | case 125: 512 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_125_ENABLED; 513 | break; 514 | case 245: 515 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_245dps; 516 | break; 517 | case 500: 518 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_500dps; 519 | break; 520 | case 1000: 521 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_1000dps; 522 | break; 523 | default: //Default to full 2000DPS range 524 | settings.gyroRange = 2000; 525 | case 2000: 526 | dataToWrite |= LSM6DS3_ACC_GYRO_FS_G_2000dps; 527 | break; 528 | } 529 | //Lastly, patch in gyro ODR 530 | switch (settings.gyroSampleRate) { 531 | case 13: 532 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_13Hz; 533 | break; 534 | case 26: 535 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_26Hz; 536 | break; 537 | case 52: 538 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_52Hz; 539 | break; 540 | default: //Set default to 104 541 | settings.gyroSampleRate = 104; 542 | case 104: 543 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_104Hz; 544 | break; 545 | case 208: 546 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_208Hz; 547 | break; 548 | case 416: 549 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_416Hz; 550 | break; 551 | case 833: 552 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_833Hz; 553 | break; 554 | case 1660: 555 | dataToWrite |= LSM6DS3_ACC_GYRO_ODR_G_1660Hz; 556 | break; 557 | } 558 | } 559 | else 560 | { 561 | //dataToWrite already = 0 (powerdown); 562 | } 563 | //Write the byte 564 | writeRegister(LSM6DS3_ACC_GYRO_CTRL2_G, dataToWrite); 565 | 566 | //Setup the internal temperature sensor 567 | if ( settings.tempEnabled == 1) { 568 | } 569 | 570 | //Return WHO AM I reg //Not no mo! 571 | uint8_t result; 572 | readRegister(&result, LSM6DS3_ACC_GYRO_WHO_AM_I_REG); 573 | 574 | return returnError; 575 | } 576 | 577 | //****************************************************************************// 578 | // 579 | // Accelerometer section 580 | // 581 | //****************************************************************************// 582 | int16_t LSM6DS3::readRawAccelX( void ) 583 | { 584 | int16_t output; 585 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTX_L_XL ); 586 | if( errorLevel != IMU_SUCCESS ) 587 | { 588 | if( errorLevel == IMU_ALL_ONES_WARNING ) 589 | { 590 | allOnesCounter++; 591 | } 592 | else 593 | { 594 | nonSuccessCounter++; 595 | } 596 | } 597 | return output; 598 | } 599 | float LSM6DS3::readFloatAccelX( void ) 600 | { 601 | float output = calcAccel(readRawAccelX()); 602 | return output; 603 | } 604 | 605 | int16_t LSM6DS3::readRawAccelY( void ) 606 | { 607 | int16_t output; 608 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTY_L_XL ); 609 | if( errorLevel != IMU_SUCCESS ) 610 | { 611 | if( errorLevel == IMU_ALL_ONES_WARNING ) 612 | { 613 | allOnesCounter++; 614 | } 615 | else 616 | { 617 | nonSuccessCounter++; 618 | } 619 | } 620 | return output; 621 | } 622 | float LSM6DS3::readFloatAccelY( void ) 623 | { 624 | float output = calcAccel(readRawAccelY()); 625 | return output; 626 | } 627 | 628 | int16_t LSM6DS3::readRawAccelZ( void ) 629 | { 630 | int16_t output; 631 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTZ_L_XL ); 632 | if( errorLevel != IMU_SUCCESS ) 633 | { 634 | if( errorLevel == IMU_ALL_ONES_WARNING ) 635 | { 636 | allOnesCounter++; 637 | } 638 | else 639 | { 640 | nonSuccessCounter++; 641 | } 642 | } 643 | return output; 644 | } 645 | float LSM6DS3::readFloatAccelZ( void ) 646 | { 647 | float output = calcAccel(readRawAccelZ()); 648 | return output; 649 | } 650 | 651 | float LSM6DS3::calcAccel( int16_t input ) 652 | { 653 | float output = (float)input * 0.061 * (settings.accelRange >> 1) / 1000; 654 | return output; 655 | } 656 | 657 | //****************************************************************************// 658 | // 659 | // Gyroscope section 660 | // 661 | //****************************************************************************// 662 | int16_t LSM6DS3::readRawGyroX( void ) 663 | { 664 | int16_t output; 665 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTX_L_G ); 666 | if( errorLevel != IMU_SUCCESS ) 667 | { 668 | if( errorLevel == IMU_ALL_ONES_WARNING ) 669 | { 670 | allOnesCounter++; 671 | } 672 | else 673 | { 674 | nonSuccessCounter++; 675 | } 676 | } 677 | return output; 678 | } 679 | float LSM6DS3::readFloatGyroX( void ) 680 | { 681 | float output = calcGyro(readRawGyroX()); 682 | return output; 683 | } 684 | 685 | int16_t LSM6DS3::readRawGyroY( void ) 686 | { 687 | int16_t output; 688 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTY_L_G ); 689 | if( errorLevel != IMU_SUCCESS ) 690 | { 691 | if( errorLevel == IMU_ALL_ONES_WARNING ) 692 | { 693 | allOnesCounter++; 694 | } 695 | else 696 | { 697 | nonSuccessCounter++; 698 | } 699 | } 700 | return output; 701 | } 702 | float LSM6DS3::readFloatGyroY( void ) 703 | { 704 | float output = calcGyro(readRawGyroY()); 705 | return output; 706 | } 707 | 708 | int16_t LSM6DS3::readRawGyroZ( void ) 709 | { 710 | int16_t output; 711 | status_t errorLevel = readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUTZ_L_G ); 712 | if( errorLevel != IMU_SUCCESS ) 713 | { 714 | if( errorLevel == IMU_ALL_ONES_WARNING ) 715 | { 716 | allOnesCounter++; 717 | } 718 | else 719 | { 720 | nonSuccessCounter++; 721 | } 722 | } 723 | return output; 724 | } 725 | float LSM6DS3::readFloatGyroZ( void ) 726 | { 727 | float output = calcGyro(readRawGyroZ()); 728 | return output; 729 | } 730 | 731 | float LSM6DS3::calcGyro( int16_t input ) 732 | { 733 | uint8_t gyroRangeDivisor = settings.gyroRange / 125; 734 | if ( settings.gyroRange == 245 ) { 735 | gyroRangeDivisor = 2; 736 | } 737 | 738 | float output = (float)input * 4.375 * (gyroRangeDivisor) / 1000; 739 | return output; 740 | } 741 | 742 | //****************************************************************************// 743 | // 744 | // Temperature section 745 | // 746 | //****************************************************************************// 747 | int16_t LSM6DS3::readRawTemp( void ) 748 | { 749 | int16_t output; 750 | readRegisterInt16( &output, LSM6DS3_ACC_GYRO_OUT_TEMP_L ); 751 | return output; 752 | } 753 | 754 | float LSM6DS3::readTempC( void ) 755 | { 756 | float output = (float)readRawTemp() / 16; //divide by 16 to scale 757 | output += 25; //Add 25 degrees to remove offset 758 | 759 | return output; 760 | 761 | } 762 | 763 | float LSM6DS3::readTempF( void ) 764 | { 765 | float output = (float)readRawTemp() / 16; //divide by 16 to scale 766 | output += 25; //Add 25 degrees to remove offset 767 | output = (output * 9) / 5 + 32; 768 | 769 | return output; 770 | 771 | } 772 | 773 | //****************************************************************************// 774 | // 775 | // FIFO section 776 | // 777 | //****************************************************************************// 778 | void LSM6DS3::fifoBegin( void ) { 779 | //CONFIGURE THE VARIOUS FIFO SETTINGS 780 | // 781 | // 782 | //This section first builds a bunch of config words, then goes through 783 | //and writes them all. 784 | 785 | //Split and mask the threshold 786 | uint8_t thresholdLByte = settings.fifoThreshold & 0x00FF; 787 | uint8_t thresholdHByte = (settings.fifoThreshold & 0x0F00) >> 8; 788 | //Pedo bits not configured (ctl2) 789 | 790 | //CONFIGURE FIFO_CTRL3 791 | uint8_t tempFIFO_CTRL3 = 0; 792 | if (settings.gyroFifoEnabled == 1) 793 | { 794 | //Set up gyro stuff 795 | //Build on FIFO_CTRL3 796 | //Set decimation 797 | tempFIFO_CTRL3 |= (settings.gyroFifoDecimation & 0x07) << 3; 798 | 799 | } 800 | if (settings.accelFifoEnabled == 1) 801 | { 802 | //Set up accelerometer stuff 803 | //Build on FIFO_CTRL3 804 | //Set decimation 805 | tempFIFO_CTRL3 |= (settings.accelFifoDecimation & 0x07); 806 | } 807 | 808 | //CONFIGURE FIFO_CTRL4 (nothing for now-- sets data sets 3 and 4 809 | uint8_t tempFIFO_CTRL4 = 0; 810 | 811 | 812 | //CONFIGURE FIFO_CTRL5 813 | uint8_t tempFIFO_CTRL5 = 0; 814 | switch (settings.fifoSampleRate) { 815 | default: //set default case to 10Hz(slowest) 816 | case 10: 817 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_10Hz; 818 | break; 819 | case 25: 820 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_25Hz; 821 | break; 822 | case 50: 823 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_50Hz; 824 | break; 825 | case 100: 826 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_100Hz; 827 | break; 828 | case 200: 829 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_200Hz; 830 | break; 831 | case 400: 832 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_400Hz; 833 | break; 834 | case 800: 835 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_800Hz; 836 | break; 837 | case 1600: 838 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_1600Hz; 839 | break; 840 | case 3300: 841 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_3300Hz; 842 | break; 843 | case 6600: 844 | tempFIFO_CTRL5 |= LSM6DS3_ACC_GYRO_ODR_FIFO_6600Hz; 845 | break; 846 | } 847 | //Hard code the fifo mode here: 848 | tempFIFO_CTRL5 |= settings.fifoModeWord = 6; //set mode: 849 | 850 | //Write the data 851 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL1, thresholdLByte); 852 | //Serial.println(thresholdLByte, HEX); 853 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL2, thresholdHByte); 854 | //Serial.println(thresholdHByte, HEX); 855 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL3, tempFIFO_CTRL3); 856 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL4, tempFIFO_CTRL4); 857 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL5, tempFIFO_CTRL5); 858 | 859 | } 860 | void LSM6DS3::fifoClear( void ) { 861 | //Drain the fifo data and dump it 862 | while( (fifoGetStatus() & 0x1000 ) == 0 ) { 863 | fifoRead(); 864 | } 865 | 866 | } 867 | int16_t LSM6DS3::fifoRead( void ) { 868 | //Pull the last data from the fifo 869 | uint8_t tempReadByte = 0; 870 | uint16_t tempAccumulator = 0; 871 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_L); 872 | tempAccumulator = tempReadByte; 873 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_H); 874 | tempAccumulator |= ((uint16_t)tempReadByte << 8); 875 | 876 | return tempAccumulator; 877 | } 878 | 879 | uint16_t LSM6DS3::fifoGetStatus( void ) { 880 | //Return some data on the state of the fifo 881 | uint8_t tempReadByte = 0; 882 | uint16_t tempAccumulator = 0; 883 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_STATUS1); 884 | tempAccumulator = tempReadByte; 885 | readRegister(&tempReadByte, LSM6DS3_ACC_GYRO_FIFO_STATUS2); 886 | tempAccumulator |= (tempReadByte << 8); 887 | 888 | return tempAccumulator; 889 | 890 | } 891 | void LSM6DS3::fifoEnd( void ) { 892 | // turn off the fifo 893 | writeRegister(LSM6DS3_ACC_GYRO_FIFO_CTRL5, 0x00); //Disable 894 | } 895 | 896 | -------------------------------------------------------------------------------- /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 "Arduino.h" 31 | #include "Wire.h" 32 | #include "SPI.h" 33 | 34 | #define I2C_MODE 0 35 | #define SPI_MODE 1 36 | 37 | // Return values 38 | typedef enum 39 | { 40 | IMU_SUCCESS, 41 | IMU_HW_ERROR, 42 | IMU_NOT_SUPPORTED, 43 | IMU_GENERIC_ERROR, 44 | IMU_OUT_OF_BOUNDS, 45 | IMU_ALL_ONES_WARNING, 46 | //... 47 | } status_t; 48 | 49 | //This is the core operational class of the driver. 50 | // LSM6DS3Core contains only read and write operations towards the IMU. 51 | // To use the higher level functions, use the class LSM6DS3 which inherits 52 | // this class. 53 | 54 | class LSM6DS3Core 55 | { 56 | public: 57 | LSM6DS3Core( uint8_t ); 58 | LSM6DS3Core( uint8_t, uint8_t ); 59 | ~LSM6DS3Core() = default; 60 | 61 | status_t beginCore( void ); 62 | 63 | //The following utilities read and write to the IMU 64 | 65 | //ReadRegisterRegion takes a uint8 array address as input and reads 66 | // a chunk of memory into that array. 67 | status_t readRegisterRegion(uint8_t*, uint8_t, uint8_t ); 68 | 69 | //readRegister reads one 8-bit register 70 | status_t readRegister(uint8_t*, uint8_t); 71 | 72 | //Reads two 8-bit regs, LSByte then MSByte order, and concatenates them. 73 | // Acts as a 16-bit read operation 74 | status_t readRegisterInt16(int16_t*, uint8_t offset ); 75 | 76 | //Writes an 8-bit byte; 77 | status_t writeRegister(uint8_t, uint8_t); 78 | 79 | //Change to embedded page 80 | status_t embeddedPage( void ); 81 | 82 | //Change to base page 83 | status_t basePage( void ); 84 | SPISettings mySpiSettings; 85 | 86 | private: 87 | 88 | //Communication stuff 89 | uint8_t commInterface; 90 | uint8_t I2CAddress; 91 | uint8_t chipSelectPin; 92 | 93 | }; 94 | 95 | //This struct holds the settings the driver uses to do calculations 96 | struct SensorSettings { 97 | public: 98 | //Gyro settings 99 | uint8_t gyroEnabled; 100 | uint16_t gyroRange; 101 | uint16_t gyroSampleRate; 102 | uint16_t gyroBandWidth; 103 | 104 | uint8_t gyroFifoEnabled; 105 | uint8_t gyroFifoDecimation; 106 | 107 | //Accelerometer settings 108 | uint8_t accelEnabled; 109 | uint8_t accelODROff; 110 | uint16_t accelRange; 111 | uint16_t accelSampleRate; 112 | uint16_t accelBandWidth; 113 | 114 | uint8_t accelFifoEnabled; 115 | uint8_t accelFifoDecimation; 116 | 117 | //Temperature settings 118 | uint8_t tempEnabled; 119 | 120 | //Non-basic mode settings 121 | uint8_t commMode; 122 | 123 | //FIFO control data 124 | uint16_t fifoThreshold; 125 | int16_t fifoSampleRate; 126 | uint8_t fifoModeWord; 127 | 128 | }; 129 | 130 | 131 | //This is the highest level class of the driver. 132 | // 133 | // class LSM6DS3 inherits the core and makes use of the beginCore() 134 | //method through it's own begin() method. It also contains the 135 | //settings struct to hold user settings. 136 | 137 | class LSM6DS3 : public LSM6DS3Core 138 | { 139 | public: 140 | //IMU settings 141 | SensorSettings settings; 142 | 143 | //Error checking 144 | uint16_t allOnesCounter; 145 | uint16_t nonSuccessCounter; 146 | 147 | //Constructor generates default SensorSettings. 148 | //(over-ride after construction if desired) 149 | LSM6DS3( uint8_t busType = I2C_MODE, uint8_t inputArg = 0x6B ); 150 | ~LSM6DS3() = default; 151 | 152 | //Call to apply SensorSettings 153 | status_t begin(SensorSettings* pSettingsYouWanted = NULL); 154 | 155 | //Returns the raw bits from the sensor cast as 16-bit signed integers 156 | int16_t readRawAccelX( void ); 157 | int16_t readRawAccelY( void ); 158 | int16_t readRawAccelZ( void ); 159 | int16_t readRawGyroX( void ); 160 | int16_t readRawGyroY( void ); 161 | int16_t readRawGyroZ( void ); 162 | 163 | //Returns the values as floats. Inside, this calls readRaw___(); 164 | float readFloatAccelX( void ); 165 | float readFloatAccelY( void ); 166 | float readFloatAccelZ( void ); 167 | float readFloatGyroX( void ); 168 | float readFloatGyroY( void ); 169 | float readFloatGyroZ( void ); 170 | 171 | //Temperature related methods 172 | int16_t readRawTemp( void ); 173 | float readTempC( void ); 174 | float readTempF( void ); 175 | 176 | //FIFO stuff 177 | void fifoBegin( void ); 178 | void fifoClear( void ); 179 | int16_t fifoRead( void ); 180 | uint16_t fifoGetStatus( void ); 181 | void fifoEnd( void ); 182 | 183 | float calcGyro( int16_t ); 184 | float calcAccel( int16_t ); 185 | 186 | 187 | private: 188 | 189 | }; 190 | 191 | 192 | 193 | 194 | 195 | 196 | /************** Device Register *******************/ 197 | #define LSM6DS3_ACC_GYRO_TEST_PAGE 0X00 198 | #define LSM6DS3_ACC_GYRO_RAM_ACCESS 0X01 199 | #define LSM6DS3_ACC_GYRO_SENSOR_SYNC_TIME 0X04 200 | #define LSM6DS3_ACC_GYRO_SENSOR_SYNC_EN 0X05 201 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL1 0X06 202 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL2 0X07 203 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL3 0X08 204 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL4 0X09 205 | #define LSM6DS3_ACC_GYRO_FIFO_CTRL5 0X0A 206 | #define LSM6DS3_ACC_GYRO_ORIENT_CFG_G 0X0B 207 | #define LSM6DS3_ACC_GYRO_REFERENCE_G 0X0C 208 | #define LSM6DS3_ACC_GYRO_INT1_CTRL 0X0D 209 | #define LSM6DS3_ACC_GYRO_INT2_CTRL 0X0E 210 | #define LSM6DS3_ACC_GYRO_WHO_AM_I_REG 0X0F 211 | #define LSM6DS3_ACC_GYRO_CTRL1_XL 0X10 212 | #define LSM6DS3_ACC_GYRO_CTRL2_G 0X11 213 | #define LSM6DS3_ACC_GYRO_CTRL3_C 0X12 214 | #define LSM6DS3_ACC_GYRO_CTRL4_C 0X13 215 | #define LSM6DS3_ACC_GYRO_CTRL5_C 0X14 216 | #define LSM6DS3_ACC_GYRO_CTRL6_G 0X15 217 | #define LSM6DS3_ACC_GYRO_CTRL7_G 0X16 218 | #define LSM6DS3_ACC_GYRO_CTRL8_XL 0X17 219 | #define LSM6DS3_ACC_GYRO_CTRL9_XL 0X18 220 | #define LSM6DS3_ACC_GYRO_CTRL10_C 0X19 221 | #define LSM6DS3_ACC_GYRO_MASTER_CONFIG 0X1A 222 | #define LSM6DS3_ACC_GYRO_WAKE_UP_SRC 0X1B 223 | #define LSM6DS3_ACC_GYRO_TAP_SRC 0X1C 224 | #define LSM6DS3_ACC_GYRO_D6D_SRC 0X1D 225 | #define LSM6DS3_ACC_GYRO_STATUS_REG 0X1E 226 | #define LSM6DS3_ACC_GYRO_OUT_TEMP_L 0X20 227 | #define LSM6DS3_ACC_GYRO_OUT_TEMP_H 0X21 228 | #define LSM6DS3_ACC_GYRO_OUTX_L_G 0X22 229 | #define LSM6DS3_ACC_GYRO_OUTX_H_G 0X23 230 | #define LSM6DS3_ACC_GYRO_OUTY_L_G 0X24 231 | #define LSM6DS3_ACC_GYRO_OUTY_H_G 0X25 232 | #define LSM6DS3_ACC_GYRO_OUTZ_L_G 0X26 233 | #define LSM6DS3_ACC_GYRO_OUTZ_H_G 0X27 234 | #define LSM6DS3_ACC_GYRO_OUTX_L_XL 0X28 235 | #define LSM6DS3_ACC_GYRO_OUTX_H_XL 0X29 236 | #define LSM6DS3_ACC_GYRO_OUTY_L_XL 0X2A 237 | #define LSM6DS3_ACC_GYRO_OUTY_H_XL 0X2B 238 | #define LSM6DS3_ACC_GYRO_OUTZ_L_XL 0X2C 239 | #define LSM6DS3_ACC_GYRO_OUTZ_H_XL 0X2D 240 | #define LSM6DS3_ACC_GYRO_SENSORHUB1_REG 0X2E 241 | #define LSM6DS3_ACC_GYRO_SENSORHUB2_REG 0X2F 242 | #define LSM6DS3_ACC_GYRO_SENSORHUB3_REG 0X30 243 | #define LSM6DS3_ACC_GYRO_SENSORHUB4_REG 0X31 244 | #define LSM6DS3_ACC_GYRO_SENSORHUB5_REG 0X32 245 | #define LSM6DS3_ACC_GYRO_SENSORHUB6_REG 0X33 246 | #define LSM6DS3_ACC_GYRO_SENSORHUB7_REG 0X34 247 | #define LSM6DS3_ACC_GYRO_SENSORHUB8_REG 0X35 248 | #define LSM6DS3_ACC_GYRO_SENSORHUB9_REG 0X36 249 | #define LSM6DS3_ACC_GYRO_SENSORHUB10_REG 0X37 250 | #define LSM6DS3_ACC_GYRO_SENSORHUB11_REG 0X38 251 | #define LSM6DS3_ACC_GYRO_SENSORHUB12_REG 0X39 252 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS1 0X3A 253 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS2 0X3B 254 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS3 0X3C 255 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS4 0X3D 256 | #define LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_L 0X3E 257 | #define LSM6DS3_ACC_GYRO_FIFO_DATA_OUT_H 0X3F 258 | #define LSM6DS3_ACC_GYRO_TIMESTAMP0_REG 0X40 259 | #define LSM6DS3_ACC_GYRO_TIMESTAMP1_REG 0X41 260 | #define LSM6DS3_ACC_GYRO_TIMESTAMP2_REG 0X42 261 | #define LSM6DS3_ACC_GYRO_STEP_COUNTER_L 0X4B 262 | #define LSM6DS3_ACC_GYRO_STEP_COUNTER_H 0X4C 263 | #define LSM6DS3_ACC_GYRO_FUNC_SRC 0X53 264 | #define LSM6DS3_ACC_GYRO_TAP_CFG1 0X58 265 | #define LSM6DS3_ACC_GYRO_TAP_THS_6D 0X59 266 | #define LSM6DS3_ACC_GYRO_INT_DUR2 0X5A 267 | #define LSM6DS3_ACC_GYRO_WAKE_UP_THS 0X5B 268 | #define LSM6DS3_ACC_GYRO_WAKE_UP_DUR 0X5C 269 | #define LSM6DS3_ACC_GYRO_FREE_FALL 0X5D 270 | #define LSM6DS3_ACC_GYRO_MD1_CFG 0X5E 271 | #define LSM6DS3_ACC_GYRO_MD2_CFG 0X5F 272 | 273 | /************** Access Device RAM *******************/ 274 | #define LSM6DS3_ACC_GYRO_ADDR0_TO_RW_RAM 0x62 275 | #define LSM6DS3_ACC_GYRO_ADDR1_TO_RW_RAM 0x63 276 | #define LSM6DS3_ACC_GYRO_DATA_TO_WR_RAM 0x64 277 | #define LSM6DS3_ACC_GYRO_DATA_RD_FROM_RAM 0x65 278 | 279 | #define LSM6DS3_ACC_GYRO_RAM_SIZE 4096 280 | 281 | /************** Embedded functions register mapping *******************/ 282 | #define LSM6DS3_ACC_GYRO_SLV0_ADD 0x02 283 | #define LSM6DS3_ACC_GYRO_SLV0_SUBADD 0x03 284 | #define LSM6DS3_ACC_GYRO_SLAVE0_CONFIG 0x04 285 | #define LSM6DS3_ACC_GYRO_SLV1_ADD 0x05 286 | #define LSM6DS3_ACC_GYRO_SLV1_SUBADD 0x06 287 | #define LSM6DS3_ACC_GYRO_SLAVE1_CONFIG 0x07 288 | #define LSM6DS3_ACC_GYRO_SLV2_ADD 0x08 289 | #define LSM6DS3_ACC_GYRO_SLV2_SUBADD 0x09 290 | #define LSM6DS3_ACC_GYRO_SLAVE2_CONFIG 0x0A 291 | #define LSM6DS3_ACC_GYRO_SLV3_ADD 0x0B 292 | #define LSM6DS3_ACC_GYRO_SLV3_SUBADD 0x0C 293 | #define LSM6DS3_ACC_GYRO_SLAVE3_CONFIG 0x0D 294 | #define LSM6DS3_ACC_GYRO_DATAWRITE_SRC_MODE_SUB_SLV0 0x0E 295 | #define LSM6DS3_ACC_GYRO_CONFIG_PEDO_THS_MIN 0x0F 296 | #define LSM6DS3_ACC_GYRO_CONFIG_TILT_IIR 0x10 297 | #define LSM6DS3_ACC_GYRO_CONFIG_TILT_ACOS 0x11 298 | #define LSM6DS3_ACC_GYRO_CONFIG_TILT_WTIME 0x12 299 | #define LSM6DS3_ACC_GYRO_SM_STEP_THS 0x13 300 | #define LSM6DS3_ACC_GYRO_MAG_SI_XX 0x24 301 | #define LSM6DS3_ACC_GYRO_MAG_SI_XY 0x25 302 | #define LSM6DS3_ACC_GYRO_MAG_SI_XZ 0x26 303 | #define LSM6DS3_ACC_GYRO_MAG_SI_YX 0x27 304 | #define LSM6DS3_ACC_GYRO_MAG_SI_YY 0x28 305 | #define LSM6DS3_ACC_GYRO_MAG_SI_YZ 0x29 306 | #define LSM6DS3_ACC_GYRO_MAG_SI_ZX 0x2A 307 | #define LSM6DS3_ACC_GYRO_MAG_SI_ZY 0x2B 308 | #define LSM6DS3_ACC_GYRO_MAG_SI_ZZ 0x2C 309 | #define LSM6DS3_ACC_GYRO_MAG_OFFX_L 0x2D 310 | #define LSM6DS3_ACC_GYRO_MAG_OFFX_H 0x2E 311 | #define LSM6DS3_ACC_GYRO_MAG_OFFY_L 0x2F 312 | #define LSM6DS3_ACC_GYRO_MAG_OFFY_H 0x30 313 | #define LSM6DS3_ACC_GYRO_MAG_OFFZ_L 0x31 314 | #define LSM6DS3_ACC_GYRO_MAG_OFFZ_H 0x32 315 | 316 | /******************************************************************************* 317 | * Register : TEST_PAGE 318 | * Address : 0X00 319 | * Bit Group Name: FLASH_PAGE 320 | * Permission : RW 321 | *******************************************************************************/ 322 | #define FLASH_PAGE 0x40 323 | 324 | /******************************************************************************* 325 | * Register : RAM_ACCESS 326 | * Address : 0X01 327 | * Bit Group Name: PROG_RAM1 328 | * Permission : RW 329 | *******************************************************************************/ 330 | typedef enum { 331 | LSM6DS3_ACC_GYRO_PROG_RAM1_DISABLED = 0x00, 332 | LSM6DS3_ACC_GYRO_PROG_RAM1_ENABLED = 0x01, 333 | } LSM6DS3_ACC_GYRO_PROG_RAM1_t; 334 | 335 | /******************************************************************************* 336 | * Register : RAM_ACCESS 337 | * Address : 0X01 338 | * Bit Group Name: CUSTOMROM1 339 | * Permission : RW 340 | *******************************************************************************/ 341 | typedef enum { 342 | LSM6DS3_ACC_GYRO_CUSTOMROM1_DISABLED = 0x00, 343 | LSM6DS3_ACC_GYRO_CUSTOMROM1_ENABLED = 0x04, 344 | } LSM6DS3_ACC_GYRO_CUSTOMROM1_t; 345 | 346 | /******************************************************************************* 347 | * Register : RAM_ACCESS 348 | * Address : 0X01 349 | * Bit Group Name: RAM_PAGE 350 | * Permission : RW 351 | *******************************************************************************/ 352 | typedef enum { 353 | LSM6DS3_ACC_GYRO_RAM_PAGE_DISABLED = 0x00, 354 | LSM6DS3_ACC_GYRO_RAM_PAGE_ENABLED = 0x80, 355 | } LSM6DS3_ACC_GYRO_RAM_PAGE_t; 356 | 357 | /******************************************************************************* 358 | * Register : SENSOR_SYNC_TIME 359 | * Address : 0X04 360 | * Bit Group Name: TPH 361 | * Permission : RW 362 | *******************************************************************************/ 363 | #define LSM6DS3_ACC_GYRO_TPH_MASK 0xFF 364 | #define LSM6DS3_ACC_GYRO_TPH_POSITION 0 365 | 366 | /******************************************************************************* 367 | * Register : SENSOR_SYNC_EN 368 | * Address : 0X05 369 | * Bit Group Name: SYNC_EN 370 | * Permission : RW 371 | *******************************************************************************/ 372 | typedef enum { 373 | LSM6DS3_ACC_GYRO_SYNC_EN_DISABLED = 0x00, 374 | LSM6DS3_ACC_GYRO_SYNC_EN_ENABLED = 0x01, 375 | } LSM6DS3_ACC_GYRO_SYNC_EN_t; 376 | 377 | /******************************************************************************* 378 | * Register : SENSOR_SYNC_EN 379 | * Address : 0X05 380 | * Bit Group Name: HP_RST 381 | * Permission : RW 382 | *******************************************************************************/ 383 | typedef enum { 384 | LSM6DS3_ACC_GYRO_HP_RST_RST_OFF = 0x00, 385 | LSM6DS3_ACC_GYRO_HP_RST_RST_ON = 0x02, 386 | } LSM6DS3_ACC_GYRO_HP_RST_t; 387 | 388 | /******************************************************************************* 389 | * Register : FIFO_CTRL1 390 | * Address : 0X06 391 | * Bit Group Name: WTM_FIFO 392 | * Permission : RW 393 | *******************************************************************************/ 394 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL1_MASK 0xFF 395 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL1_POSITION 0 396 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL2_MASK 0x0F 397 | #define LSM6DS3_ACC_GYRO_WTM_FIFO_CTRL2_POSITION 0 398 | 399 | /******************************************************************************* 400 | * Register : FIFO_CTRL2 401 | * Address : 0X07 402 | * Bit Group Name: TIM_PEDO_FIFO_DRDY 403 | * Permission : RW 404 | *******************************************************************************/ 405 | typedef enum { 406 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_DRDY_DISABLED = 0x00, 407 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_DRDY_ENABLED = 0x40, 408 | } LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_DRDY_t; 409 | 410 | /******************************************************************************* 411 | * Register : FIFO_CTRL2 412 | * Address : 0X07 413 | * Bit Group Name: TIM_PEDO_FIFO_EN 414 | * Permission : RW 415 | *******************************************************************************/ 416 | typedef enum { 417 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_EN_DISABLED = 0x00, 418 | LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_EN_ENABLED = 0x80, 419 | } LSM6DS3_ACC_GYRO_TIM_PEDO_FIFO_EN_t; 420 | 421 | /******************************************************************************* 422 | * Register : FIFO_CTRL3 423 | * Address : 0X08 424 | * Bit Group Name: DEC_FIFO_XL 425 | * Permission : RW 426 | *******************************************************************************/ 427 | typedef enum { 428 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DATA_NOT_IN_FIFO = 0x00, 429 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_NO_DECIMATION = 0x01, 430 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_2 = 0x02, 431 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_3 = 0x03, 432 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_4 = 0x04, 433 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_8 = 0x05, 434 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_16 = 0x06, 435 | LSM6DS3_ACC_GYRO_DEC_FIFO_XL_DECIMATION_BY_32 = 0x07, 436 | } LSM6DS3_ACC_GYRO_DEC_FIFO_XL_t; 437 | 438 | /******************************************************************************* 439 | * Register : FIFO_CTRL3 440 | * Address : 0X08 441 | * Bit Group Name: DEC_FIFO_G 442 | * Permission : RW 443 | *******************************************************************************/ 444 | typedef enum { 445 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DATA_NOT_IN_FIFO = 0x00, 446 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_NO_DECIMATION = 0x08, 447 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_2 = 0x10, 448 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_3 = 0x18, 449 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_4 = 0x20, 450 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_8 = 0x28, 451 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_16 = 0x30, 452 | LSM6DS3_ACC_GYRO_DEC_FIFO_G_DECIMATION_BY_32 = 0x38, 453 | } LSM6DS3_ACC_GYRO_DEC_FIFO_G_t; 454 | 455 | /******************************************************************************* 456 | * Register : FIFO_CTRL4 457 | * Address : 0X09 458 | * Bit Group Name: DEC_FIFO_SLV0 459 | * Permission : RW 460 | *******************************************************************************/ 461 | typedef enum { 462 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DATA_NOT_IN_FIFO = 0x00, 463 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_NO_DECIMATION = 0x01, 464 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_2 = 0x02, 465 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_3 = 0x03, 466 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_4 = 0x04, 467 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_8 = 0x05, 468 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_16 = 0x06, 469 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_DECIMATION_BY_32 = 0x07, 470 | } LSM6DS3_ACC_GYRO_DEC_FIFO_SLV0_t; 471 | 472 | /******************************************************************************* 473 | * Register : FIFO_CTRL4 474 | * Address : 0X09 475 | * Bit Group Name: DEC_FIFO_SLV1 476 | * Permission : RW 477 | *******************************************************************************/ 478 | typedef enum { 479 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DATA_NOT_IN_FIFO = 0x00, 480 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_NO_DECIMATION = 0x08, 481 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_2 = 0x10, 482 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_3 = 0x18, 483 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_4 = 0x20, 484 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_8 = 0x28, 485 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_16 = 0x30, 486 | LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_DECIMATION_BY_32 = 0x38, 487 | } LSM6DS3_ACC_GYRO_DEC_FIFO_SLV1_t; 488 | 489 | /******************************************************************************* 490 | * Register : FIFO_CTRL4 491 | * Address : 0X09 492 | * Bit Group Name: HI_DATA_ONLY 493 | * Permission : RW 494 | *******************************************************************************/ 495 | typedef enum { 496 | LSM6DS3_ACC_GYRO_HI_DATA_ONLY_DISABLED = 0x00, 497 | LSM6DS3_ACC_GYRO_HI_DATA_ONLY_ENABLED = 0x40, 498 | } LSM6DS3_ACC_GYRO_HI_DATA_ONLY_t; 499 | 500 | /******************************************************************************* 501 | * Register : FIFO_CTRL5 502 | * Address : 0X0A 503 | * Bit Group Name: FIFO_MODE 504 | * Permission : RW 505 | *******************************************************************************/ 506 | typedef enum { 507 | LSM6DS3_ACC_GYRO_FIFO_MODE_BYPASS = 0x00, 508 | LSM6DS3_ACC_GYRO_FIFO_MODE_FIFO = 0x01, 509 | LSM6DS3_ACC_GYRO_FIFO_MODE_STREAM = 0x02, 510 | LSM6DS3_ACC_GYRO_FIFO_MODE_STF = 0x03, 511 | LSM6DS3_ACC_GYRO_FIFO_MODE_BTS = 0x04, 512 | LSM6DS3_ACC_GYRO_FIFO_MODE_DYN_STREAM = 0x05, 513 | LSM6DS3_ACC_GYRO_FIFO_MODE_DYN_STREAM_2 = 0x06, 514 | LSM6DS3_ACC_GYRO_FIFO_MODE_BTF = 0x07, 515 | } LSM6DS3_ACC_GYRO_FIFO_MODE_t; 516 | 517 | /******************************************************************************* 518 | * Register : FIFO_CTRL5 519 | * Address : 0X0A 520 | * Bit Group Name: ODR_FIFO 521 | * Permission : RW 522 | *******************************************************************************/ 523 | typedef enum { 524 | LSM6DS3_ACC_GYRO_ODR_FIFO_10Hz = 0x08, 525 | LSM6DS3_ACC_GYRO_ODR_FIFO_25Hz = 0x10, 526 | LSM6DS3_ACC_GYRO_ODR_FIFO_50Hz = 0x18, 527 | LSM6DS3_ACC_GYRO_ODR_FIFO_100Hz = 0x20, 528 | LSM6DS3_ACC_GYRO_ODR_FIFO_200Hz = 0x28, 529 | LSM6DS3_ACC_GYRO_ODR_FIFO_400Hz = 0x30, 530 | LSM6DS3_ACC_GYRO_ODR_FIFO_800Hz = 0x38, 531 | LSM6DS3_ACC_GYRO_ODR_FIFO_1600Hz = 0x40, 532 | LSM6DS3_ACC_GYRO_ODR_FIFO_3300Hz = 0x48, 533 | LSM6DS3_ACC_GYRO_ODR_FIFO_6600Hz = 0x50, 534 | LSM6DS3_ACC_GYRO_ODR_FIFO_13300Hz = 0x58, 535 | } LSM6DS3_ACC_GYRO_ODR_FIFO_t; 536 | 537 | /******************************************************************************* 538 | * Register : ORIENT_CFG_G 539 | * Address : 0X0B 540 | * Bit Group Name: ORIENT 541 | * Permission : RW 542 | *******************************************************************************/ 543 | typedef enum { 544 | LSM6DS3_ACC_GYRO_ORIENT_XYZ = 0x00, 545 | LSM6DS3_ACC_GYRO_ORIENT_XZY = 0x01, 546 | LSM6DS3_ACC_GYRO_ORIENT_YXZ = 0x02, 547 | LSM6DS3_ACC_GYRO_ORIENT_YZX = 0x03, 548 | LSM6DS3_ACC_GYRO_ORIENT_ZXY = 0x04, 549 | LSM6DS3_ACC_GYRO_ORIENT_ZYX = 0x05, 550 | } LSM6DS3_ACC_GYRO_ORIENT_t; 551 | 552 | /******************************************************************************* 553 | * Register : ORIENT_CFG_G 554 | * Address : 0X0B 555 | * Bit Group Name: SIGN_Z_G 556 | * Permission : RW 557 | *******************************************************************************/ 558 | typedef enum { 559 | LSM6DS3_ACC_GYRO_SIGN_Z_G_POSITIVE = 0x00, 560 | LSM6DS3_ACC_GYRO_SIGN_Z_G_NEGATIVE = 0x08, 561 | } LSM6DS3_ACC_GYRO_SIGN_Z_G_t; 562 | 563 | /******************************************************************************* 564 | * Register : ORIENT_CFG_G 565 | * Address : 0X0B 566 | * Bit Group Name: SIGN_Y_G 567 | * Permission : RW 568 | *******************************************************************************/ 569 | typedef enum { 570 | LSM6DS3_ACC_GYRO_SIGN_Y_G_POSITIVE = 0x00, 571 | LSM6DS3_ACC_GYRO_SIGN_Y_G_NEGATIVE = 0x10, 572 | } LSM6DS3_ACC_GYRO_SIGN_Y_G_t; 573 | 574 | /******************************************************************************* 575 | * Register : ORIENT_CFG_G 576 | * Address : 0X0B 577 | * Bit Group Name: SIGN_X_G 578 | * Permission : RW 579 | *******************************************************************************/ 580 | typedef enum { 581 | LSM6DS3_ACC_GYRO_SIGN_X_G_POSITIVE = 0x00, 582 | LSM6DS3_ACC_GYRO_SIGN_X_G_NEGATIVE = 0x20, 583 | } LSM6DS3_ACC_GYRO_SIGN_X_G_t; 584 | 585 | /******************************************************************************* 586 | * Register : REFERENCE_G 587 | * Address : 0X0C 588 | * Bit Group Name: REF_G 589 | * Permission : RW 590 | *******************************************************************************/ 591 | #define LSM6DS3_ACC_GYRO_REF_G_MASK 0xFF 592 | #define LSM6DS3_ACC_GYRO_REF_G_POSITION 0 593 | 594 | /******************************************************************************* 595 | * Register : INT1_CTRL 596 | * Address : 0X0D 597 | * Bit Group Name: INT1_DRDY_XL 598 | * Permission : RW 599 | *******************************************************************************/ 600 | typedef enum { 601 | LSM6DS3_ACC_GYRO_INT1_DRDY_XL_DISABLED = 0x00, 602 | LSM6DS3_ACC_GYRO_INT1_DRDY_XL_ENABLED = 0x01, 603 | } LSM6DS3_ACC_GYRO_INT1_DRDY_XL_t; 604 | 605 | /******************************************************************************* 606 | * Register : INT1_CTRL 607 | * Address : 0X0D 608 | * Bit Group Name: INT1_DRDY_G 609 | * Permission : RW 610 | *******************************************************************************/ 611 | typedef enum { 612 | LSM6DS3_ACC_GYRO_INT1_DRDY_G_DISABLED = 0x00, 613 | LSM6DS3_ACC_GYRO_INT1_DRDY_G_ENABLED = 0x02, 614 | } LSM6DS3_ACC_GYRO_INT1_DRDY_G_t; 615 | 616 | /******************************************************************************* 617 | * Register : INT1_CTRL 618 | * Address : 0X0D 619 | * Bit Group Name: INT1_BOOT 620 | * Permission : RW 621 | *******************************************************************************/ 622 | typedef enum { 623 | LSM6DS3_ACC_GYRO_INT1_BOOT_DISABLED = 0x00, 624 | LSM6DS3_ACC_GYRO_INT1_BOOT_ENABLED = 0x04, 625 | } LSM6DS3_ACC_GYRO_INT1_BOOT_t; 626 | 627 | /******************************************************************************* 628 | * Register : INT1_CTRL 629 | * Address : 0X0D 630 | * Bit Group Name: INT1_FTH 631 | * Permission : RW 632 | *******************************************************************************/ 633 | typedef enum { 634 | LSM6DS3_ACC_GYRO_INT1_FTH_DISABLED = 0x00, 635 | LSM6DS3_ACC_GYRO_INT1_FTH_ENABLED = 0x08, 636 | } LSM6DS3_ACC_GYRO_INT1_FTH_t; 637 | 638 | /******************************************************************************* 639 | * Register : INT1_CTRL 640 | * Address : 0X0D 641 | * Bit Group Name: INT1_OVR 642 | * Permission : RW 643 | *******************************************************************************/ 644 | typedef enum { 645 | LSM6DS3_ACC_GYRO_INT1_OVR_DISABLED = 0x00, 646 | LSM6DS3_ACC_GYRO_INT1_OVR_ENABLED = 0x10, 647 | } LSM6DS3_ACC_GYRO_INT1_OVR_t; 648 | 649 | /******************************************************************************* 650 | * Register : INT1_CTRL 651 | * Address : 0X0D 652 | * Bit Group Name: INT1_FSS5 653 | * Permission : RW 654 | *******************************************************************************/ 655 | typedef enum { 656 | LSM6DS3_ACC_GYRO_INT1_FSS5_DISABLED = 0x00, 657 | LSM6DS3_ACC_GYRO_INT1_FSS5_ENABLED = 0x20, 658 | } LSM6DS3_ACC_GYRO_INT1_FSS5_t; 659 | 660 | /******************************************************************************* 661 | * Register : INT1_CTRL 662 | * Address : 0X0D 663 | * Bit Group Name: INT1_SIGN_MOT 664 | * Permission : RW 665 | *******************************************************************************/ 666 | typedef enum { 667 | LSM6DS3_ACC_GYRO_INT1_SIGN_MOT_DISABLED = 0x00, 668 | LSM6DS3_ACC_GYRO_INT1_SIGN_MOT_ENABLED = 0x40, 669 | } LSM6DS3_ACC_GYRO_INT1_SIGN_MOT_t; 670 | 671 | /******************************************************************************* 672 | * Register : INT1_CTRL 673 | * Address : 0X0D 674 | * Bit Group Name: INT1_PEDO 675 | * Permission : RW 676 | *******************************************************************************/ 677 | typedef enum { 678 | LSM6DS3_ACC_GYRO_INT1_PEDO_DISABLED = 0x00, 679 | LSM6DS3_ACC_GYRO_INT1_PEDO_ENABLED = 0x80, 680 | } LSM6DS3_ACC_GYRO_INT1_PEDO_t; 681 | 682 | /******************************************************************************* 683 | * Register : INT2_CTRL 684 | * Address : 0X0E 685 | * Bit Group Name: INT2_DRDY_XL 686 | * Permission : RW 687 | *******************************************************************************/ 688 | typedef enum { 689 | LSM6DS3_ACC_GYRO_INT2_DRDY_XL_DISABLED = 0x00, 690 | LSM6DS3_ACC_GYRO_INT2_DRDY_XL_ENABLED = 0x01, 691 | } LSM6DS3_ACC_GYRO_INT2_DRDY_XL_t; 692 | 693 | /******************************************************************************* 694 | * Register : INT2_CTRL 695 | * Address : 0X0E 696 | * Bit Group Name: INT2_DRDY_G 697 | * Permission : RW 698 | *******************************************************************************/ 699 | typedef enum { 700 | LSM6DS3_ACC_GYRO_INT2_DRDY_G_DISABLED = 0x00, 701 | LSM6DS3_ACC_GYRO_INT2_DRDY_G_ENABLED = 0x02, 702 | } LSM6DS3_ACC_GYRO_INT2_DRDY_G_t; 703 | 704 | /******************************************************************************* 705 | * Register : INT2_CTRL 706 | * Address : 0X0E 707 | * Bit Group Name: INT2_FTH 708 | * Permission : RW 709 | *******************************************************************************/ 710 | typedef enum { 711 | LSM6DS3_ACC_GYRO_INT2_FTH_DISABLED = 0x00, 712 | LSM6DS3_ACC_GYRO_INT2_FTH_ENABLED = 0x08, 713 | } LSM6DS3_ACC_GYRO_INT2_FTH_t; 714 | 715 | /******************************************************************************* 716 | * Register : INT2_CTRL 717 | * Address : 0X0E 718 | * Bit Group Name: INT2_OVR 719 | * Permission : RW 720 | *******************************************************************************/ 721 | typedef enum { 722 | LSM6DS3_ACC_GYRO_INT2_OVR_DISABLED = 0x00, 723 | LSM6DS3_ACC_GYRO_INT2_OVR_ENABLED = 0x10, 724 | } LSM6DS3_ACC_GYRO_INT2_OVR_t; 725 | 726 | /******************************************************************************* 727 | * Register : INT2_CTRL 728 | * Address : 0X0E 729 | * Bit Group Name: INT2_FSS5 730 | * Permission : RW 731 | *******************************************************************************/ 732 | typedef enum { 733 | LSM6DS3_ACC_GYRO_INT2_FSS5_DISABLED = 0x00, 734 | LSM6DS3_ACC_GYRO_INT2_FSS5_ENABLED = 0x20, 735 | } LSM6DS3_ACC_GYRO_INT2_FSS5_t; 736 | 737 | /******************************************************************************* 738 | * Register : INT2_CTRL 739 | * Address : 0X0E 740 | * Bit Group Name: INT2_SIGN_MOT 741 | * Permission : RW 742 | *******************************************************************************/ 743 | typedef enum { 744 | LSM6DS3_ACC_GYRO_INT2_SIGN_MOT_DISABLED = 0x00, 745 | LSM6DS3_ACC_GYRO_INT2_SIGN_MOT_ENABLED = 0x40, 746 | } LSM6DS3_ACC_GYRO_INT2_SIGN_MOT_t; 747 | 748 | /******************************************************************************* 749 | * Register : INT2_CTRL 750 | * Address : 0X0E 751 | * Bit Group Name: INT2_PEDO 752 | * Permission : RW 753 | *******************************************************************************/ 754 | typedef enum { 755 | LSM6DS3_ACC_GYRO_INT2_PEDO_DISABLED = 0x00, 756 | LSM6DS3_ACC_GYRO_INT2_PEDO_ENABLED = 0x80, 757 | } LSM6DS3_ACC_GYRO_INT2_PEDO_t; 758 | 759 | /******************************************************************************* 760 | * Register : WHO_AM_I 761 | * Address : 0X0F 762 | * Bit Group Name: WHO_AM_I_BIT 763 | * Permission : RO 764 | *******************************************************************************/ 765 | #define LSM6DS3_ACC_GYRO_WHO_AM_I_BIT_MASK 0xFF 766 | #define LSM6DS3_ACC_GYRO_WHO_AM_I_BIT_POSITION 0 767 | 768 | /******************************************************************************* 769 | * Register : CTRL1_XL 770 | * Address : 0X10 771 | * Bit Group Name: BW_XL 772 | * Permission : RW 773 | *******************************************************************************/ 774 | typedef enum { 775 | LSM6DS3_ACC_GYRO_BW_XL_400Hz = 0x00, 776 | LSM6DS3_ACC_GYRO_BW_XL_200Hz = 0x01, 777 | LSM6DS3_ACC_GYRO_BW_XL_100Hz = 0x02, 778 | LSM6DS3_ACC_GYRO_BW_XL_50Hz = 0x03, 779 | } LSM6DS3_ACC_GYRO_BW_XL_t; 780 | 781 | /******************************************************************************* 782 | * Register : CTRL1_XL 783 | * Address : 0X10 784 | * Bit Group Name: FS_XL 785 | * Permission : RW 786 | *******************************************************************************/ 787 | typedef enum { 788 | LSM6DS3_ACC_GYRO_FS_XL_2g = 0x00, 789 | LSM6DS3_ACC_GYRO_FS_XL_16g = 0x04, 790 | LSM6DS3_ACC_GYRO_FS_XL_4g = 0x08, 791 | LSM6DS3_ACC_GYRO_FS_XL_8g = 0x0C, 792 | } LSM6DS3_ACC_GYRO_FS_XL_t; 793 | 794 | /******************************************************************************* 795 | * Register : CTRL1_XL 796 | * Address : 0X10 797 | * Bit Group Name: ODR_XL 798 | * Permission : RW 799 | *******************************************************************************/ 800 | typedef enum { 801 | LSM6DS3_ACC_GYRO_ODR_XL_POWER_DOWN = 0x00, 802 | LSM6DS3_ACC_GYRO_ODR_XL_13Hz = 0x10, 803 | LSM6DS3_ACC_GYRO_ODR_XL_26Hz = 0x20, 804 | LSM6DS3_ACC_GYRO_ODR_XL_52Hz = 0x30, 805 | LSM6DS3_ACC_GYRO_ODR_XL_104Hz = 0x40, 806 | LSM6DS3_ACC_GYRO_ODR_XL_208Hz = 0x50, 807 | LSM6DS3_ACC_GYRO_ODR_XL_416Hz = 0x60, 808 | LSM6DS3_ACC_GYRO_ODR_XL_833Hz = 0x70, 809 | LSM6DS3_ACC_GYRO_ODR_XL_1660Hz = 0x80, 810 | LSM6DS3_ACC_GYRO_ODR_XL_3330Hz = 0x90, 811 | LSM6DS3_ACC_GYRO_ODR_XL_6660Hz = 0xA0, 812 | LSM6DS3_ACC_GYRO_ODR_XL_13330Hz = 0xB0, 813 | } LSM6DS3_ACC_GYRO_ODR_XL_t; 814 | 815 | /******************************************************************************* 816 | * Register : CTRL2_G 817 | * Address : 0X11 818 | * Bit Group Name: FS_125 819 | * Permission : RW 820 | *******************************************************************************/ 821 | typedef enum { 822 | LSM6DS3_ACC_GYRO_FS_125_DISABLED = 0x00, 823 | LSM6DS3_ACC_GYRO_FS_125_ENABLED = 0x02, 824 | } LSM6DS3_ACC_GYRO_FS_125_t; 825 | 826 | /******************************************************************************* 827 | * Register : CTRL2_G 828 | * Address : 0X11 829 | * Bit Group Name: FS_G 830 | * Permission : RW 831 | *******************************************************************************/ 832 | typedef enum { 833 | LSM6DS3_ACC_GYRO_FS_G_245dps = 0x00, 834 | LSM6DS3_ACC_GYRO_FS_G_500dps = 0x04, 835 | LSM6DS3_ACC_GYRO_FS_G_1000dps = 0x08, 836 | LSM6DS3_ACC_GYRO_FS_G_2000dps = 0x0C, 837 | } LSM6DS3_ACC_GYRO_FS_G_t; 838 | 839 | /******************************************************************************* 840 | * Register : CTRL2_G 841 | * Address : 0X11 842 | * Bit Group Name: ODR_G 843 | * Permission : RW 844 | *******************************************************************************/ 845 | typedef enum { 846 | LSM6DS3_ACC_GYRO_ODR_G_POWER_DOWN = 0x00, 847 | LSM6DS3_ACC_GYRO_ODR_G_13Hz = 0x10, 848 | LSM6DS3_ACC_GYRO_ODR_G_26Hz = 0x20, 849 | LSM6DS3_ACC_GYRO_ODR_G_52Hz = 0x30, 850 | LSM6DS3_ACC_GYRO_ODR_G_104Hz = 0x40, 851 | LSM6DS3_ACC_GYRO_ODR_G_208Hz = 0x50, 852 | LSM6DS3_ACC_GYRO_ODR_G_416Hz = 0x60, 853 | LSM6DS3_ACC_GYRO_ODR_G_833Hz = 0x70, 854 | LSM6DS3_ACC_GYRO_ODR_G_1660Hz = 0x80, 855 | } LSM6DS3_ACC_GYRO_ODR_G_t; 856 | 857 | /******************************************************************************* 858 | * Register : CTRL3_C 859 | * Address : 0X12 860 | * Bit Group Name: SW_RESET 861 | * Permission : RW 862 | *******************************************************************************/ 863 | typedef enum { 864 | LSM6DS3_ACC_GYRO_SW_RESET_NORMAL_MODE = 0x00, 865 | LSM6DS3_ACC_GYRO_SW_RESET_RESET_DEVICE = 0x01, 866 | } LSM6DS3_ACC_GYRO_SW_RESET_t; 867 | 868 | /******************************************************************************* 869 | * Register : CTRL3_C 870 | * Address : 0X12 871 | * Bit Group Name: BLE 872 | * Permission : RW 873 | *******************************************************************************/ 874 | typedef enum { 875 | LSM6DS3_ACC_GYRO_BLE_LSB = 0x00, 876 | LSM6DS3_ACC_GYRO_BLE_MSB = 0x02, 877 | } LSM6DS3_ACC_GYRO_BLE_t; 878 | 879 | /******************************************************************************* 880 | * Register : CTRL3_C 881 | * Address : 0X12 882 | * Bit Group Name: IF_INC 883 | * Permission : RW 884 | *******************************************************************************/ 885 | typedef enum { 886 | LSM6DS3_ACC_GYRO_IF_INC_DISABLED = 0x00, 887 | LSM6DS3_ACC_GYRO_IF_INC_ENABLED = 0x04, 888 | } LSM6DS3_ACC_GYRO_IF_INC_t; 889 | 890 | /******************************************************************************* 891 | * Register : CTRL3_C 892 | * Address : 0X12 893 | * Bit Group Name: SIM 894 | * Permission : RW 895 | *******************************************************************************/ 896 | typedef enum { 897 | LSM6DS3_ACC_GYRO_SIM_4_WIRE = 0x00, 898 | LSM6DS3_ACC_GYRO_SIM_3_WIRE = 0x08, 899 | } LSM6DS3_ACC_GYRO_SIM_t; 900 | 901 | /******************************************************************************* 902 | * Register : CTRL3_C 903 | * Address : 0X12 904 | * Bit Group Name: PP_OD 905 | * Permission : RW 906 | *******************************************************************************/ 907 | typedef enum { 908 | LSM6DS3_ACC_GYRO_PP_OD_PUSH_PULL = 0x00, 909 | LSM6DS3_ACC_GYRO_PP_OD_OPEN_DRAIN = 0x10, 910 | } LSM6DS3_ACC_GYRO_PP_OD_t; 911 | 912 | /******************************************************************************* 913 | * Register : CTRL3_C 914 | * Address : 0X12 915 | * Bit Group Name: INT_ACT_LEVEL 916 | * Permission : RW 917 | *******************************************************************************/ 918 | typedef enum { 919 | LSM6DS3_ACC_GYRO_INT_ACT_LEVEL_ACTIVE_HI = 0x00, 920 | LSM6DS3_ACC_GYRO_INT_ACT_LEVEL_ACTIVE_LO = 0x20, 921 | } LSM6DS3_ACC_GYRO_INT_ACT_LEVEL_t; 922 | 923 | /******************************************************************************* 924 | * Register : CTRL3_C 925 | * Address : 0X12 926 | * Bit Group Name: BDU 927 | * Permission : RW 928 | *******************************************************************************/ 929 | typedef enum { 930 | LSM6DS3_ACC_GYRO_BDU_CONTINUOS = 0x00, 931 | LSM6DS3_ACC_GYRO_BDU_BLOCK_UPDATE = 0x40, 932 | } LSM6DS3_ACC_GYRO_BDU_t; 933 | 934 | /******************************************************************************* 935 | * Register : CTRL3_C 936 | * Address : 0X12 937 | * Bit Group Name: BOOT 938 | * Permission : RW 939 | *******************************************************************************/ 940 | typedef enum { 941 | LSM6DS3_ACC_GYRO_BOOT_NORMAL_MODE = 0x00, 942 | LSM6DS3_ACC_GYRO_BOOT_REBOOT_MODE = 0x80, 943 | } LSM6DS3_ACC_GYRO_BOOT_t; 944 | 945 | /******************************************************************************* 946 | * Register : CTRL4_C 947 | * Address : 0X13 948 | * Bit Group Name: STOP_ON_FTH 949 | * Permission : RW 950 | *******************************************************************************/ 951 | typedef enum { 952 | LSM6DS3_ACC_GYRO_STOP_ON_FTH_DISABLED = 0x00, 953 | LSM6DS3_ACC_GYRO_STOP_ON_FTH_ENABLED = 0x01, 954 | } LSM6DS3_ACC_GYRO_STOP_ON_FTH_t; 955 | 956 | /******************************************************************************* 957 | * Register : CTRL4_C 958 | * Address : 0X13 959 | * Bit Group Name: MODE3_EN 960 | * Permission : RW 961 | *******************************************************************************/ 962 | typedef enum { 963 | LSM6DS3_ACC_GYRO_MODE3_EN_DISABLED = 0x00, 964 | LSM6DS3_ACC_GYRO_MODE3_EN_ENABLED = 0x02, 965 | } LSM6DS3_ACC_GYRO_MODE3_EN_t; 966 | 967 | /******************************************************************************* 968 | * Register : CTRL4_C 969 | * Address : 0X13 970 | * Bit Group Name: I2C_DISABLE 971 | * Permission : RW 972 | *******************************************************************************/ 973 | typedef enum { 974 | LSM6DS3_ACC_GYRO_I2C_DISABLE_I2C_AND_SPI = 0x00, 975 | LSM6DS3_ACC_GYRO_I2C_DISABLE_SPI_ONLY = 0x04, 976 | } LSM6DS3_ACC_GYRO_I2C_DISABLE_t; 977 | 978 | /******************************************************************************* 979 | * Register : CTRL4_C 980 | * Address : 0X13 981 | * Bit Group Name: DRDY_MSK 982 | * Permission : RW 983 | *******************************************************************************/ 984 | typedef enum { 985 | LSM6DS3_ACC_GYRO_DRDY_MSK_DISABLED = 0x00, 986 | LSM6DS3_ACC_GYRO_DRDY_MSK_ENABLED = 0x08, 987 | } LSM6DS3_ACC_GYRO_DRDY_MSK_t; 988 | 989 | /******************************************************************************* 990 | * Register : CTRL4_C 991 | * Address : 0X13 992 | * Bit Group Name: FIFO_TEMP_EN 993 | * Permission : RW 994 | *******************************************************************************/ 995 | typedef enum { 996 | LSM6DS3_ACC_GYRO_FIFO_TEMP_EN_DISABLED = 0x00, 997 | LSM6DS3_ACC_GYRO_FIFO_TEMP_EN_ENABLED = 0x10, 998 | } LSM6DS3_ACC_GYRO_FIFO_TEMP_EN_t; 999 | 1000 | /******************************************************************************* 1001 | * Register : CTRL4_C 1002 | * Address : 0X13 1003 | * Bit Group Name: INT2_ON_INT1 1004 | * Permission : RW 1005 | *******************************************************************************/ 1006 | typedef enum { 1007 | LSM6DS3_ACC_GYRO_INT2_ON_INT1_DISABLED = 0x00, 1008 | LSM6DS3_ACC_GYRO_INT2_ON_INT1_ENABLED = 0x20, 1009 | } LSM6DS3_ACC_GYRO_INT2_ON_INT1_t; 1010 | 1011 | /******************************************************************************* 1012 | * Register : CTRL4_C 1013 | * Address : 0X13 1014 | * Bit Group Name: SLEEP_G 1015 | * Permission : RW 1016 | *******************************************************************************/ 1017 | typedef enum { 1018 | LSM6DS3_ACC_GYRO_SLEEP_G_DISABLED = 0x00, 1019 | LSM6DS3_ACC_GYRO_SLEEP_G_ENABLED = 0x40, 1020 | } LSM6DS3_ACC_GYRO_SLEEP_G_t; 1021 | 1022 | /******************************************************************************* 1023 | * Register : CTRL4_C 1024 | * Address : 0X13 1025 | * Bit Group Name: BW_SCAL_ODR 1026 | * Permission : RW 1027 | *******************************************************************************/ 1028 | typedef enum { 1029 | LSM6DS3_ACC_GYRO_BW_SCAL_ODR_DISABLED = 0x00, 1030 | LSM6DS3_ACC_GYRO_BW_SCAL_ODR_ENABLED = 0x80, 1031 | } LSM6DS3_ACC_GYRO_BW_SCAL_ODR_t; 1032 | 1033 | /******************************************************************************* 1034 | * Register : CTRL5_C 1035 | * Address : 0X14 1036 | * Bit Group Name: ST_XL 1037 | * Permission : RW 1038 | *******************************************************************************/ 1039 | typedef enum { 1040 | LSM6DS3_ACC_GYRO_ST_XL_NORMAL_MODE = 0x00, 1041 | LSM6DS3_ACC_GYRO_ST_XL_POS_SIGN_TEST = 0x01, 1042 | LSM6DS3_ACC_GYRO_ST_XL_NEG_SIGN_TEST = 0x02, 1043 | LSM6DS3_ACC_GYRO_ST_XL_NA = 0x03, 1044 | } LSM6DS3_ACC_GYRO_ST_XL_t; 1045 | 1046 | /******************************************************************************* 1047 | * Register : CTRL5_C 1048 | * Address : 0X14 1049 | * Bit Group Name: ST_G 1050 | * Permission : RW 1051 | *******************************************************************************/ 1052 | typedef enum { 1053 | LSM6DS3_ACC_GYRO_ST_G_NORMAL_MODE = 0x00, 1054 | LSM6DS3_ACC_GYRO_ST_G_POS_SIGN_TEST = 0x04, 1055 | LSM6DS3_ACC_GYRO_ST_G_NA = 0x08, 1056 | LSM6DS3_ACC_GYRO_ST_G_NEG_SIGN_TEST = 0x0C, 1057 | } LSM6DS3_ACC_GYRO_ST_G_t; 1058 | 1059 | /******************************************************************************* 1060 | * Register : CTRL6_G 1061 | * Address : 0X15 1062 | * Bit Group Name: LP_XL 1063 | * Permission : RW 1064 | *******************************************************************************/ 1065 | typedef enum { 1066 | LSM6DS3_ACC_GYRO_LP_XL_DISABLED = 0x00, 1067 | LSM6DS3_ACC_GYRO_LP_XL_ENABLED = 0x10, 1068 | } LSM6DS3_ACC_GYRO_LP_XL_t; 1069 | 1070 | /******************************************************************************* 1071 | * Register : CTRL6_G 1072 | * Address : 0X15 1073 | * Bit Group Name: DEN_LVL2_EN 1074 | * Permission : RW 1075 | *******************************************************************************/ 1076 | typedef enum { 1077 | LSM6DS3_ACC_GYRO_DEN_LVL2_EN_DISABLED = 0x00, 1078 | LSM6DS3_ACC_GYRO_DEN_LVL2_EN_ENABLED = 0x20, 1079 | } LSM6DS3_ACC_GYRO_DEN_LVL2_EN_t; 1080 | 1081 | /******************************************************************************* 1082 | * Register : CTRL6_G 1083 | * Address : 0X15 1084 | * Bit Group Name: DEN_LVL_EN 1085 | * Permission : RW 1086 | *******************************************************************************/ 1087 | typedef enum { 1088 | LSM6DS3_ACC_GYRO_DEN_LVL_EN_DISABLED = 0x00, 1089 | LSM6DS3_ACC_GYRO_DEN_LVL_EN_ENABLED = 0x40, 1090 | } LSM6DS3_ACC_GYRO_DEN_LVL_EN_t; 1091 | 1092 | /******************************************************************************* 1093 | * Register : CTRL6_G 1094 | * Address : 0X15 1095 | * Bit Group Name: DEN_EDGE_EN 1096 | * Permission : RW 1097 | *******************************************************************************/ 1098 | typedef enum { 1099 | LSM6DS3_ACC_GYRO_DEN_EDGE_EN_DISABLED = 0x00, 1100 | LSM6DS3_ACC_GYRO_DEN_EDGE_EN_ENABLED = 0x80, 1101 | } LSM6DS3_ACC_GYRO_DEN_EDGE_EN_t; 1102 | 1103 | /******************************************************************************* 1104 | * Register : CTRL7_G 1105 | * Address : 0X16 1106 | * Bit Group Name: HPM_G 1107 | * Permission : RW 1108 | *******************************************************************************/ 1109 | typedef enum { 1110 | LSM6DS3_ACC_GYRO_HPM_G_NORMAL_MODE = 0x00, 1111 | LSM6DS3_ACC_GYRO_HPM_G_REF_SIGNAL = 0x10, 1112 | LSM6DS3_ACC_GYRO_HPM_G_NORMAL_MODE_2 = 0x20, 1113 | LSM6DS3_ACC_GYRO_HPM_G_AUTO_RESET_ON_INT = 0x30, 1114 | } LSM6DS3_ACC_GYRO_HPM_G_t; 1115 | 1116 | /******************************************************************************* 1117 | * Register : CTRL7_G 1118 | * Address : 0X16 1119 | * Bit Group Name: HP_EN 1120 | * Permission : RW 1121 | *******************************************************************************/ 1122 | typedef enum { 1123 | LSM6DS3_ACC_GYRO_HP_EN_DISABLED = 0x00, 1124 | LSM6DS3_ACC_GYRO_HP_EN_ENABLED = 0x40, 1125 | } LSM6DS3_ACC_GYRO_HP_EN_t; 1126 | 1127 | /******************************************************************************* 1128 | * Register : CTRL7_G 1129 | * Address : 0X16 1130 | * Bit Group Name: LP_EN 1131 | * Permission : RW 1132 | *******************************************************************************/ 1133 | typedef enum { 1134 | LSM6DS3_ACC_GYRO_LP_EN_DISABLED = 0x00, 1135 | LSM6DS3_ACC_GYRO_LP_EN_ENABLED = 0x80, 1136 | } LSM6DS3_ACC_GYRO_LP_EN_t; 1137 | 1138 | /******************************************************************************* 1139 | * Register : CTRL8_XL 1140 | * Address : 0X17 1141 | * Bit Group Name: FDS 1142 | * Permission : RW 1143 | *******************************************************************************/ 1144 | typedef enum { 1145 | LSM6DS3_ACC_GYRO_FDS_FILTER_OFF = 0x00, 1146 | LSM6DS3_ACC_GYRO_FDS_FILTER_ON = 0x04, 1147 | } LSM6DS3_ACC_GYRO_FDS_t; 1148 | 1149 | /******************************************************************************* 1150 | * Register : CTRL9_XL 1151 | * Address : 0X18 1152 | * Bit Group Name: XEN_XL 1153 | * Permission : RW 1154 | *******************************************************************************/ 1155 | typedef enum { 1156 | LSM6DS3_ACC_GYRO_XEN_XL_DISABLED = 0x00, 1157 | LSM6DS3_ACC_GYRO_XEN_XL_ENABLED = 0x08, 1158 | } LSM6DS3_ACC_GYRO_XEN_XL_t; 1159 | 1160 | /******************************************************************************* 1161 | * Register : CTRL9_XL 1162 | * Address : 0X18 1163 | * Bit Group Name: YEN_XL 1164 | * Permission : RW 1165 | *******************************************************************************/ 1166 | typedef enum { 1167 | LSM6DS3_ACC_GYRO_YEN_XL_DISABLED = 0x00, 1168 | LSM6DS3_ACC_GYRO_YEN_XL_ENABLED = 0x10, 1169 | } LSM6DS3_ACC_GYRO_YEN_XL_t; 1170 | 1171 | /******************************************************************************* 1172 | * Register : CTRL9_XL 1173 | * Address : 0X18 1174 | * Bit Group Name: ZEN_XL 1175 | * Permission : RW 1176 | *******************************************************************************/ 1177 | typedef enum { 1178 | LSM6DS3_ACC_GYRO_ZEN_XL_DISABLED = 0x00, 1179 | LSM6DS3_ACC_GYRO_ZEN_XL_ENABLED = 0x20, 1180 | } LSM6DS3_ACC_GYRO_ZEN_XL_t; 1181 | 1182 | /******************************************************************************* 1183 | * Register : CTRL10_C 1184 | * Address : 0X19 1185 | * Bit Group Name: SIGN_MOTION_EN 1186 | * Permission : RW 1187 | *******************************************************************************/ 1188 | typedef enum { 1189 | LSM6DS3_ACC_GYRO_SIGN_MOTION_EN_DISABLED = 0x00, 1190 | LSM6DS3_ACC_GYRO_SIGN_MOTION_EN_ENABLED = 0x01, 1191 | } LSM6DS3_ACC_GYRO_SIGN_MOTION_EN_t; 1192 | 1193 | /******************************************************************************* 1194 | * Register : CTRL10_C 1195 | * Address : 0X19 1196 | * Bit Group Name: PEDO_RST_STEP 1197 | * Permission : RW 1198 | *******************************************************************************/ 1199 | typedef enum { 1200 | LSM6DS3_ACC_GYRO_PEDO_RST_STEP_DISABLED = 0x00, 1201 | LSM6DS3_ACC_GYRO_PEDO_RST_STEP_ENABLED = 0x02, 1202 | } LSM6DS3_ACC_GYRO_PEDO_RST_STEP_t; 1203 | 1204 | /******************************************************************************* 1205 | * Register : CTRL10_C 1206 | * Address : 0X19 1207 | * Bit Group Name: XEN_G 1208 | * Permission : RW 1209 | *******************************************************************************/ 1210 | typedef enum { 1211 | LSM6DS3_ACC_GYRO_XEN_G_DISABLED = 0x00, 1212 | LSM6DS3_ACC_GYRO_XEN_G_ENABLED = 0x08, 1213 | } LSM6DS3_ACC_GYRO_XEN_G_t; 1214 | 1215 | /******************************************************************************* 1216 | * Register : CTRL10_C 1217 | * Address : 0X19 1218 | * Bit Group Name: YEN_G 1219 | * Permission : RW 1220 | *******************************************************************************/ 1221 | typedef enum { 1222 | LSM6DS3_ACC_GYRO_YEN_G_DISABLED = 0x00, 1223 | LSM6DS3_ACC_GYRO_YEN_G_ENABLED = 0x10, 1224 | } LSM6DS3_ACC_GYRO_YEN_G_t; 1225 | 1226 | /******************************************************************************* 1227 | * Register : CTRL10_C 1228 | * Address : 0X19 1229 | * Bit Group Name: ZEN_G 1230 | * Permission : RW 1231 | *******************************************************************************/ 1232 | typedef enum { 1233 | LSM6DS3_ACC_GYRO_ZEN_G_DISABLED = 0x00, 1234 | LSM6DS3_ACC_GYRO_ZEN_G_ENABLED = 0x20, 1235 | } LSM6DS3_ACC_GYRO_ZEN_G_t; 1236 | 1237 | /******************************************************************************* 1238 | * Register : CTRL10_C 1239 | * Address : 0X19 1240 | * Bit Group Name: FUNC_EN 1241 | * Permission : RW 1242 | *******************************************************************************/ 1243 | typedef enum { 1244 | LSM6DS3_ACC_GYRO_FUNC_EN_DISABLED = 0x00, 1245 | LSM6DS3_ACC_GYRO_FUNC_EN_ENABLED = 0x04, 1246 | } LSM6DS3_ACC_GYRO_FUNC_EN_t; 1247 | 1248 | /******************************************************************************* 1249 | * Register : MASTER_CONFIG 1250 | * Address : 0X1A 1251 | * Bit Group Name: MASTER_ON 1252 | * Permission : RW 1253 | *******************************************************************************/ 1254 | typedef enum { 1255 | LSM6DS3_ACC_GYRO_MASTER_ON_DISABLED = 0x00, 1256 | LSM6DS3_ACC_GYRO_MASTER_ON_ENABLED = 0x01, 1257 | } LSM6DS3_ACC_GYRO_MASTER_ON_t; 1258 | 1259 | /******************************************************************************* 1260 | * Register : MASTER_CONFIG 1261 | * Address : 0X1A 1262 | * Bit Group Name: IRON_EN 1263 | * Permission : RW 1264 | *******************************************************************************/ 1265 | typedef enum { 1266 | LSM6DS3_ACC_GYRO_IRON_EN_DISABLED = 0x00, 1267 | LSM6DS3_ACC_GYRO_IRON_EN_ENABLED = 0x02, 1268 | } LSM6DS3_ACC_GYRO_IRON_EN_t; 1269 | 1270 | /******************************************************************************* 1271 | * Register : MASTER_CONFIG 1272 | * Address : 0X1A 1273 | * Bit Group Name: PASS_THRU_MODE 1274 | * Permission : RW 1275 | *******************************************************************************/ 1276 | typedef enum { 1277 | LSM6DS3_ACC_GYRO_PASS_THRU_MODE_DISABLED = 0x00, 1278 | LSM6DS3_ACC_GYRO_PASS_THRU_MODE_ENABLED = 0x04, 1279 | } LSM6DS3_ACC_GYRO_PASS_THRU_MODE_t; 1280 | 1281 | /******************************************************************************* 1282 | * Register : MASTER_CONFIG 1283 | * Address : 0X1A 1284 | * Bit Group Name: PULL_UP_EN 1285 | * Permission : RW 1286 | *******************************************************************************/ 1287 | typedef enum { 1288 | LSM6DS3_ACC_GYRO_PULL_UP_EN_DISABLED = 0x00, 1289 | LSM6DS3_ACC_GYRO_PULL_UP_EN_ENABLED = 0x08, 1290 | } LSM6DS3_ACC_GYRO_PULL_UP_EN_t; 1291 | 1292 | /******************************************************************************* 1293 | * Register : MASTER_CONFIG 1294 | * Address : 0X1A 1295 | * Bit Group Name: START_CONFIG 1296 | * Permission : RW 1297 | *******************************************************************************/ 1298 | typedef enum { 1299 | LSM6DS3_ACC_GYRO_START_CONFIG_XL_G_DRDY = 0x00, 1300 | LSM6DS3_ACC_GYRO_START_CONFIG_EXT_INT2 = 0x10, 1301 | } LSM6DS3_ACC_GYRO_START_CONFIG_t; 1302 | 1303 | /******************************************************************************* 1304 | * Register : MASTER_CONFIG 1305 | * Address : 0X1A 1306 | * Bit Group Name: DATA_VAL_SEL_FIFO 1307 | * Permission : RW 1308 | *******************************************************************************/ 1309 | typedef enum { 1310 | LSM6DS3_ACC_GYRO_DATA_VAL_SEL_FIFO_XL_G_DRDY = 0x00, 1311 | LSM6DS3_ACC_GYRO_DATA_VAL_SEL_FIFO_SHUB_DRDY = 0x40, 1312 | } LSM6DS3_ACC_GYRO_DATA_VAL_SEL_FIFO_t; 1313 | 1314 | /******************************************************************************* 1315 | * Register : MASTER_CONFIG 1316 | * Address : 0X1A 1317 | * Bit Group Name: DRDY_ON_INT1 1318 | * Permission : RW 1319 | *******************************************************************************/ 1320 | typedef enum { 1321 | LSM6DS3_ACC_GYRO_DRDY_ON_INT1_DISABLED = 0x00, 1322 | LSM6DS3_ACC_GYRO_DRDY_ON_INT1_ENABLED = 0x80, 1323 | } LSM6DS3_ACC_GYRO_DRDY_ON_INT1_t; 1324 | 1325 | /******************************************************************************* 1326 | * Register : WAKE_UP_SRC 1327 | * Address : 0X1B 1328 | * Bit Group Name: Z_WU 1329 | * Permission : RO 1330 | *******************************************************************************/ 1331 | typedef enum { 1332 | LSM6DS3_ACC_GYRO_Z_WU_NOT_DETECTED = 0x00, 1333 | LSM6DS3_ACC_GYRO_Z_WU_DETECTED = 0x01, 1334 | } LSM6DS3_ACC_GYRO_Z_WU_t; 1335 | 1336 | /******************************************************************************* 1337 | * Register : WAKE_UP_SRC 1338 | * Address : 0X1B 1339 | * Bit Group Name: Y_WU 1340 | * Permission : RO 1341 | *******************************************************************************/ 1342 | typedef enum { 1343 | LSM6DS3_ACC_GYRO_Y_WU_NOT_DETECTED = 0x00, 1344 | LSM6DS3_ACC_GYRO_Y_WU_DETECTED = 0x02, 1345 | } LSM6DS3_ACC_GYRO_Y_WU_t; 1346 | 1347 | /******************************************************************************* 1348 | * Register : WAKE_UP_SRC 1349 | * Address : 0X1B 1350 | * Bit Group Name: X_WU 1351 | * Permission : RO 1352 | *******************************************************************************/ 1353 | typedef enum { 1354 | LSM6DS3_ACC_GYRO_X_WU_NOT_DETECTED = 0x00, 1355 | LSM6DS3_ACC_GYRO_X_WU_DETECTED = 0x04, 1356 | } LSM6DS3_ACC_GYRO_X_WU_t; 1357 | 1358 | /******************************************************************************* 1359 | * Register : WAKE_UP_SRC 1360 | * Address : 0X1B 1361 | * Bit Group Name: WU_EV_STATUS 1362 | * Permission : RO 1363 | *******************************************************************************/ 1364 | typedef enum { 1365 | LSM6DS3_ACC_GYRO_WU_EV_STATUS_NOT_DETECTED = 0x00, 1366 | LSM6DS3_ACC_GYRO_WU_EV_STATUS_DETECTED = 0x08, 1367 | } LSM6DS3_ACC_GYRO_WU_EV_STATUS_t; 1368 | 1369 | /******************************************************************************* 1370 | * Register : WAKE_UP_SRC 1371 | * Address : 0X1B 1372 | * Bit Group Name: SLEEP_EV_STATUS 1373 | * Permission : RO 1374 | *******************************************************************************/ 1375 | typedef enum { 1376 | LSM6DS3_ACC_GYRO_SLEEP_EV_STATUS_NOT_DETECTED = 0x00, 1377 | LSM6DS3_ACC_GYRO_SLEEP_EV_STATUS_DETECTED = 0x10, 1378 | } LSM6DS3_ACC_GYRO_SLEEP_EV_STATUS_t; 1379 | 1380 | /******************************************************************************* 1381 | * Register : WAKE_UP_SRC 1382 | * Address : 0X1B 1383 | * Bit Group Name: FF_EV_STATUS 1384 | * Permission : RO 1385 | *******************************************************************************/ 1386 | typedef enum { 1387 | LSM6DS3_ACC_GYRO_FF_EV_STATUS_NOT_DETECTED = 0x00, 1388 | LSM6DS3_ACC_GYRO_FF_EV_STATUS_DETECTED = 0x20, 1389 | } LSM6DS3_ACC_GYRO_FF_EV_STATUS_t; 1390 | 1391 | /******************************************************************************* 1392 | * Register : TAP_SRC 1393 | * Address : 0X1C 1394 | * Bit Group Name: Z_TAP 1395 | * Permission : RO 1396 | *******************************************************************************/ 1397 | typedef enum { 1398 | LSM6DS3_ACC_GYRO_Z_TAP_NOT_DETECTED = 0x00, 1399 | LSM6DS3_ACC_GYRO_Z_TAP_DETECTED = 0x01, 1400 | } LSM6DS3_ACC_GYRO_Z_TAP_t; 1401 | 1402 | /******************************************************************************* 1403 | * Register : TAP_SRC 1404 | * Address : 0X1C 1405 | * Bit Group Name: Y_TAP 1406 | * Permission : RO 1407 | *******************************************************************************/ 1408 | typedef enum { 1409 | LSM6DS3_ACC_GYRO_Y_TAP_NOT_DETECTED = 0x00, 1410 | LSM6DS3_ACC_GYRO_Y_TAP_DETECTED = 0x02, 1411 | } LSM6DS3_ACC_GYRO_Y_TAP_t; 1412 | 1413 | /******************************************************************************* 1414 | * Register : TAP_SRC 1415 | * Address : 0X1C 1416 | * Bit Group Name: X_TAP 1417 | * Permission : RO 1418 | *******************************************************************************/ 1419 | typedef enum { 1420 | LSM6DS3_ACC_GYRO_X_TAP_NOT_DETECTED = 0x00, 1421 | LSM6DS3_ACC_GYRO_X_TAP_DETECTED = 0x04, 1422 | } LSM6DS3_ACC_GYRO_X_TAP_t; 1423 | 1424 | /******************************************************************************* 1425 | * Register : TAP_SRC 1426 | * Address : 0X1C 1427 | * Bit Group Name: TAP_SIGN 1428 | * Permission : RO 1429 | *******************************************************************************/ 1430 | typedef enum { 1431 | LSM6DS3_ACC_GYRO_TAP_SIGN_POS_SIGN = 0x00, 1432 | LSM6DS3_ACC_GYRO_TAP_SIGN_NEG_SIGN = 0x08, 1433 | } LSM6DS3_ACC_GYRO_TAP_SIGN_t; 1434 | 1435 | /******************************************************************************* 1436 | * Register : TAP_SRC 1437 | * Address : 0X1C 1438 | * Bit Group Name: DOUBLE_TAP_EV_STATUS 1439 | * Permission : RO 1440 | *******************************************************************************/ 1441 | typedef enum { 1442 | LSM6DS3_ACC_GYRO_DOUBLE_TAP_EV_STATUS_NOT_DETECTED = 0x00, 1443 | LSM6DS3_ACC_GYRO_DOUBLE_TAP_EV_STATUS_DETECTED = 0x10, 1444 | } LSM6DS3_ACC_GYRO_DOUBLE_TAP_EV_STATUS_t; 1445 | 1446 | /******************************************************************************* 1447 | * Register : TAP_SRC 1448 | * Address : 0X1C 1449 | * Bit Group Name: SINGLE_TAP_EV_STATUS 1450 | * Permission : RO 1451 | *******************************************************************************/ 1452 | typedef enum { 1453 | LSM6DS3_ACC_GYRO_SINGLE_TAP_EV_STATUS_NOT_DETECTED = 0x00, 1454 | LSM6DS3_ACC_GYRO_SINGLE_TAP_EV_STATUS_DETECTED = 0x20, 1455 | } LSM6DS3_ACC_GYRO_SINGLE_TAP_EV_STATUS_t; 1456 | 1457 | /******************************************************************************* 1458 | * Register : TAP_SRC 1459 | * Address : 0X1C 1460 | * Bit Group Name: TAP_EV_STATUS 1461 | * Permission : RO 1462 | *******************************************************************************/ 1463 | typedef enum { 1464 | LSM6DS3_ACC_GYRO_TAP_EV_STATUS_NOT_DETECTED = 0x00, 1465 | LSM6DS3_ACC_GYRO_TAP_EV_STATUS_DETECTED = 0x40, 1466 | } LSM6DS3_ACC_GYRO_TAP_EV_STATUS_t; 1467 | 1468 | /******************************************************************************* 1469 | * Register : D6D_SRC 1470 | * Address : 0X1D 1471 | * Bit Group Name: DSD_XL 1472 | * Permission : RO 1473 | *******************************************************************************/ 1474 | typedef enum { 1475 | LSM6DS3_ACC_GYRO_DSD_XL_NOT_DETECTED = 0x00, 1476 | LSM6DS3_ACC_GYRO_DSD_XL_DETECTED = 0x01, 1477 | } LSM6DS3_ACC_GYRO_DSD_XL_t; 1478 | 1479 | /******************************************************************************* 1480 | * Register : D6D_SRC 1481 | * Address : 0X1D 1482 | * Bit Group Name: DSD_XH 1483 | * Permission : RO 1484 | *******************************************************************************/ 1485 | typedef enum { 1486 | LSM6DS3_ACC_GYRO_DSD_XH_NOT_DETECTED = 0x00, 1487 | LSM6DS3_ACC_GYRO_DSD_XH_DETECTED = 0x02, 1488 | } LSM6DS3_ACC_GYRO_DSD_XH_t; 1489 | 1490 | /******************************************************************************* 1491 | * Register : D6D_SRC 1492 | * Address : 0X1D 1493 | * Bit Group Name: DSD_YL 1494 | * Permission : RO 1495 | *******************************************************************************/ 1496 | typedef enum { 1497 | LSM6DS3_ACC_GYRO_DSD_YL_NOT_DETECTED = 0x00, 1498 | LSM6DS3_ACC_GYRO_DSD_YL_DETECTED = 0x04, 1499 | } LSM6DS3_ACC_GYRO_DSD_YL_t; 1500 | 1501 | /******************************************************************************* 1502 | * Register : D6D_SRC 1503 | * Address : 0X1D 1504 | * Bit Group Name: DSD_YH 1505 | * Permission : RO 1506 | *******************************************************************************/ 1507 | typedef enum { 1508 | LSM6DS3_ACC_GYRO_DSD_YH_NOT_DETECTED = 0x00, 1509 | LSM6DS3_ACC_GYRO_DSD_YH_DETECTED = 0x08, 1510 | } LSM6DS3_ACC_GYRO_DSD_YH_t; 1511 | 1512 | /******************************************************************************* 1513 | * Register : D6D_SRC 1514 | * Address : 0X1D 1515 | * Bit Group Name: DSD_ZL 1516 | * Permission : RO 1517 | *******************************************************************************/ 1518 | typedef enum { 1519 | LSM6DS3_ACC_GYRO_DSD_ZL_NOT_DETECTED = 0x00, 1520 | LSM6DS3_ACC_GYRO_DSD_ZL_DETECTED = 0x10, 1521 | } LSM6DS3_ACC_GYRO_DSD_ZL_t; 1522 | 1523 | /******************************************************************************* 1524 | * Register : D6D_SRC 1525 | * Address : 0X1D 1526 | * Bit Group Name: DSD_ZH 1527 | * Permission : RO 1528 | *******************************************************************************/ 1529 | typedef enum { 1530 | LSM6DS3_ACC_GYRO_DSD_ZH_NOT_DETECTED = 0x00, 1531 | LSM6DS3_ACC_GYRO_DSD_ZH_DETECTED = 0x20, 1532 | } LSM6DS3_ACC_GYRO_DSD_ZH_t; 1533 | 1534 | /******************************************************************************* 1535 | * Register : D6D_SRC 1536 | * Address : 0X1D 1537 | * Bit Group Name: D6D_EV_STATUS 1538 | * Permission : RO 1539 | *******************************************************************************/ 1540 | typedef enum { 1541 | LSM6DS3_ACC_GYRO_D6D_EV_STATUS_NOT_DETECTED = 0x00, 1542 | LSM6DS3_ACC_GYRO_D6D_EV_STATUS_DETECTED = 0x40, 1543 | } LSM6DS3_ACC_GYRO_D6D_EV_STATUS_t; 1544 | 1545 | /******************************************************************************* 1546 | * Register : STATUS_REG 1547 | * Address : 0X1E 1548 | * Bit Group Name: XLDA 1549 | * Permission : RO 1550 | *******************************************************************************/ 1551 | typedef enum { 1552 | LSM6DS3_ACC_GYRO_XLDA_NO_DATA_AVAIL = 0x00, 1553 | LSM6DS3_ACC_GYRO_XLDA_DATA_AVAIL = 0x01, 1554 | } LSM6DS3_ACC_GYRO_XLDA_t; 1555 | 1556 | /******************************************************************************* 1557 | * Register : STATUS_REG 1558 | * Address : 0X1E 1559 | * Bit Group Name: GDA 1560 | * Permission : RO 1561 | *******************************************************************************/ 1562 | typedef enum { 1563 | LSM6DS3_ACC_GYRO_GDA_NO_DATA_AVAIL = 0x00, 1564 | LSM6DS3_ACC_GYRO_GDA_DATA_AVAIL = 0x02, 1565 | } LSM6DS3_ACC_GYRO_GDA_t; 1566 | 1567 | /******************************************************************************* 1568 | * Register : STATUS_REG 1569 | * Address : 0X1E 1570 | * Bit Group Name: EV_BOOT 1571 | * Permission : RO 1572 | *******************************************************************************/ 1573 | typedef enum { 1574 | LSM6DS3_ACC_GYRO_EV_BOOT_NO_BOOT_RUNNING = 0x00, 1575 | LSM6DS3_ACC_GYRO_EV_BOOT_BOOT_IS_RUNNING = 0x08, 1576 | } LSM6DS3_ACC_GYRO_EV_BOOT_t; 1577 | 1578 | /******************************************************************************* 1579 | * Register : FIFO_STATUS1 1580 | * Address : 0X3A 1581 | * Bit Group Name: DIFF_FIFO 1582 | * Permission : RO 1583 | *******************************************************************************/ 1584 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS1_MASK 0xFF 1585 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS1_POSITION 0 1586 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS2_MASK 0xF 1587 | #define LSM6DS3_ACC_GYRO_DIFF_FIFO_STATUS2_POSITION 0 1588 | 1589 | /******************************************************************************* 1590 | * Register : FIFO_STATUS2 1591 | * Address : 0X3B 1592 | * Bit Group Name: FIFO_EMPTY 1593 | * Permission : RO 1594 | *******************************************************************************/ 1595 | typedef enum { 1596 | LSM6DS3_ACC_GYRO_FIFO_EMPTY_FIFO_NOT_EMPTY = 0x00, 1597 | LSM6DS3_ACC_GYRO_FIFO_EMPTY_FIFO_EMPTY = 0x10, 1598 | } LSM6DS3_ACC_GYRO_FIFO_EMPTY_t; 1599 | 1600 | /******************************************************************************* 1601 | * Register : FIFO_STATUS2 1602 | * Address : 0X3B 1603 | * Bit Group Name: FIFO_FULL 1604 | * Permission : RO 1605 | *******************************************************************************/ 1606 | typedef enum { 1607 | LSM6DS3_ACC_GYRO_FIFO_FULL_FIFO_NOT_FULL = 0x00, 1608 | LSM6DS3_ACC_GYRO_FIFO_FULL_FIFO_FULL = 0x20, 1609 | } LSM6DS3_ACC_GYRO_FIFO_FULL_t; 1610 | 1611 | /******************************************************************************* 1612 | * Register : FIFO_STATUS2 1613 | * Address : 0X3B 1614 | * Bit Group Name: OVERRUN 1615 | * Permission : RO 1616 | *******************************************************************************/ 1617 | typedef enum { 1618 | LSM6DS3_ACC_GYRO_OVERRUN_NO_OVERRUN = 0x00, 1619 | LSM6DS3_ACC_GYRO_OVERRUN_OVERRUN = 0x40, 1620 | } LSM6DS3_ACC_GYRO_OVERRUN_t; 1621 | 1622 | /******************************************************************************* 1623 | * Register : FIFO_STATUS2 1624 | * Address : 0X3B 1625 | * Bit Group Name: WTM 1626 | * Permission : RO 1627 | *******************************************************************************/ 1628 | typedef enum { 1629 | LSM6DS3_ACC_GYRO_WTM_BELOW_WTM = 0x00, 1630 | LSM6DS3_ACC_GYRO_WTM_ABOVE_OR_EQUAL_WTM = 0x80, 1631 | } LSM6DS3_ACC_GYRO_WTM_t; 1632 | 1633 | /******************************************************************************* 1634 | * Register : FIFO_STATUS3 1635 | * Address : 0X3C 1636 | * Bit Group Name: FIFO_PATTERN 1637 | * Permission : RO 1638 | *******************************************************************************/ 1639 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS3_PATTERN_MASK 0xFF 1640 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS3_PATTERN_POSITION 0 1641 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS4_PATTERN_MASK 0x03 1642 | #define LSM6DS3_ACC_GYRO_FIFO_STATUS4_PATTERN_POSITION 0 1643 | 1644 | /******************************************************************************* 1645 | * Register : FUNC_SRC 1646 | * Address : 0X53 1647 | * Bit Group Name: SENS_HUB_END 1648 | * Permission : RO 1649 | *******************************************************************************/ 1650 | typedef enum { 1651 | LSM6DS3_ACC_GYRO_SENS_HUB_END_STILL_ONGOING = 0x00, 1652 | LSM6DS3_ACC_GYRO_SENS_HUB_END_OP_COMPLETED = 0x01, 1653 | } LSM6DS3_ACC_GYRO_SENS_HUB_END_t; 1654 | 1655 | /******************************************************************************* 1656 | * Register : FUNC_SRC 1657 | * Address : 0X53 1658 | * Bit Group Name: SOFT_IRON_END 1659 | * Permission : RO 1660 | *******************************************************************************/ 1661 | typedef enum { 1662 | LSM6DS3_ACC_GYRO_SOFT_IRON_END_NOT_COMPLETED = 0x00, 1663 | LSM6DS3_ACC_GYRO_SOFT_IRON_END_COMPLETED = 0x02, 1664 | } LSM6DS3_ACC_GYRO_SOFT_IRON_END_t; 1665 | 1666 | /******************************************************************************* 1667 | * Register : FUNC_SRC 1668 | * Address : 0X53 1669 | * Bit Group Name: PEDO_EV_STATUS 1670 | * Permission : RO 1671 | *******************************************************************************/ 1672 | typedef enum { 1673 | LSM6DS3_ACC_GYRO_PEDO_EV_STATUS_NOT_DETECTED = 0x00, 1674 | LSM6DS3_ACC_GYRO_PEDO_EV_STATUS_DETECTED = 0x10, 1675 | } LSM6DS3_ACC_GYRO_PEDO_EV_STATUS_t; 1676 | 1677 | /******************************************************************************* 1678 | * Register : FUNC_SRC 1679 | * Address : 0X53 1680 | * Bit Group Name: TILT_EV_STATUS 1681 | * Permission : RO 1682 | *******************************************************************************/ 1683 | typedef enum { 1684 | LSM6DS3_ACC_GYRO_TILT_EV_STATUS_NOT_DETECTED = 0x00, 1685 | LSM6DS3_ACC_GYRO_TILT_EV_STATUS_DETECTED = 0x20, 1686 | } LSM6DS3_ACC_GYRO_TILT_EV_STATUS_t; 1687 | 1688 | /******************************************************************************* 1689 | * Register : FUNC_SRC 1690 | * Address : 0X53 1691 | * Bit Group Name: SIGN_MOT_EV_STATUS 1692 | * Permission : RO 1693 | *******************************************************************************/ 1694 | typedef enum { 1695 | LSM6DS3_ACC_GYRO_SIGN_MOT_EV_STATUS_NOT_DETECTED = 0x00, 1696 | LSM6DS3_ACC_GYRO_SIGN_MOT_EV_STATUS_DETECTED = 0x40, 1697 | } LSM6DS3_ACC_GYRO_SIGN_MOT_EV_STATUS_t; 1698 | 1699 | /******************************************************************************* 1700 | * Register : TAP_CFG1 1701 | * Address : 0X58 1702 | * Bit Group Name: LIR 1703 | * Permission : RW 1704 | *******************************************************************************/ 1705 | typedef enum { 1706 | LSM6DS3_ACC_GYRO_LIR_DISABLED = 0x00, 1707 | LSM6DS3_ACC_GYRO_LIR_ENABLED = 0x01, 1708 | } LSM6DS3_ACC_GYRO_LIR_t; 1709 | 1710 | /******************************************************************************* 1711 | * Register : TAP_CFG1 1712 | * Address : 0X58 1713 | * Bit Group Name: TAP_Z_EN 1714 | * Permission : RW 1715 | *******************************************************************************/ 1716 | typedef enum { 1717 | LSM6DS3_ACC_GYRO_TAP_Z_EN_DISABLED = 0x00, 1718 | LSM6DS3_ACC_GYRO_TAP_Z_EN_ENABLED = 0x02, 1719 | } LSM6DS3_ACC_GYRO_TAP_Z_EN_t; 1720 | 1721 | /******************************************************************************* 1722 | * Register : TAP_CFG1 1723 | * Address : 0X58 1724 | * Bit Group Name: TAP_Y_EN 1725 | * Permission : RW 1726 | *******************************************************************************/ 1727 | typedef enum { 1728 | LSM6DS3_ACC_GYRO_TAP_Y_EN_DISABLED = 0x00, 1729 | LSM6DS3_ACC_GYRO_TAP_Y_EN_ENABLED = 0x04, 1730 | } LSM6DS3_ACC_GYRO_TAP_Y_EN_t; 1731 | 1732 | /******************************************************************************* 1733 | * Register : TAP_CFG1 1734 | * Address : 0X58 1735 | * Bit Group Name: TAP_X_EN 1736 | * Permission : RW 1737 | *******************************************************************************/ 1738 | typedef enum { 1739 | LSM6DS3_ACC_GYRO_TAP_X_EN_DISABLED = 0x00, 1740 | LSM6DS3_ACC_GYRO_TAP_X_EN_ENABLED = 0x08, 1741 | } LSM6DS3_ACC_GYRO_TAP_X_EN_t; 1742 | 1743 | /******************************************************************************* 1744 | * Register : TAP_CFG1 1745 | * Address : 0X58 1746 | * Bit Group Name: TILT_EN 1747 | * Permission : RW 1748 | *******************************************************************************/ 1749 | typedef enum { 1750 | LSM6DS3_ACC_GYRO_TILT_EN_DISABLED = 0x00, 1751 | LSM6DS3_ACC_GYRO_TILT_EN_ENABLED = 0x20, 1752 | } LSM6DS3_ACC_GYRO_TILT_EN_t; 1753 | 1754 | /******************************************************************************* 1755 | * Register : TAP_CFG1 1756 | * Address : 0X58 1757 | * Bit Group Name: PEDO_EN 1758 | * Permission : RW 1759 | *******************************************************************************/ 1760 | typedef enum { 1761 | LSM6DS3_ACC_GYRO_PEDO_EN_DISABLED = 0x00, 1762 | LSM6DS3_ACC_GYRO_PEDO_EN_ENABLED = 0x40, 1763 | } LSM6DS3_ACC_GYRO_PEDO_EN_t; 1764 | 1765 | /******************************************************************************* 1766 | * Register : TAP_CFG1 1767 | * Address : 0X58 1768 | * Bit Group Name: TIMER_EN 1769 | * Permission : RW 1770 | *******************************************************************************/ 1771 | typedef enum { 1772 | LSM6DS3_ACC_GYRO_TIMER_EN_DISABLED = 0x00, 1773 | LSM6DS3_ACC_GYRO_TIMER_EN_ENABLED = 0x80, 1774 | } LSM6DS3_ACC_GYRO_TIMER_EN_t; 1775 | 1776 | /******************************************************************************* 1777 | * Register : TAP_THS_6D 1778 | * Address : 0X59 1779 | * Bit Group Name: TAP_THS 1780 | * Permission : RW 1781 | *******************************************************************************/ 1782 | #define LSM6DS3_ACC_GYRO_TAP_THS_MASK 0x1F 1783 | #define LSM6DS3_ACC_GYRO_TAP_THS_POSITION 0 1784 | 1785 | /******************************************************************************* 1786 | * Register : TAP_THS_6D 1787 | * Address : 0X59 1788 | * Bit Group Name: SIXD_THS 1789 | * Permission : RW 1790 | *******************************************************************************/ 1791 | typedef enum { 1792 | LSM6DS3_ACC_GYRO_SIXD_THS_80_degree = 0x00, 1793 | LSM6DS3_ACC_GYRO_SIXD_THS_70_degree = 0x20, 1794 | LSM6DS3_ACC_GYRO_SIXD_THS_60_degree = 0x40, 1795 | LSM6DS3_ACC_GYRO_SIXD_THS_50_degree = 0x60, 1796 | } LSM6DS3_ACC_GYRO_SIXD_THS_t; 1797 | 1798 | /******************************************************************************* 1799 | * Register : INT_DUR2 1800 | * Address : 0X5A 1801 | * Bit Group Name: SHOCK 1802 | * Permission : RW 1803 | *******************************************************************************/ 1804 | #define LSM6DS3_ACC_GYRO_SHOCK_MASK 0x03 1805 | #define LSM6DS3_ACC_GYRO_SHOCK_POSITION 0 1806 | 1807 | /******************************************************************************* 1808 | * Register : INT_DUR2 1809 | * Address : 0X5A 1810 | * Bit Group Name: QUIET 1811 | * Permission : RW 1812 | *******************************************************************************/ 1813 | #define LSM6DS3_ACC_GYRO_QUIET_MASK 0x0C 1814 | #define LSM6DS3_ACC_GYRO_QUIET_POSITION 2 1815 | 1816 | /******************************************************************************* 1817 | * Register : INT_DUR2 1818 | * Address : 0X5A 1819 | * Bit Group Name: DUR 1820 | * Permission : RW 1821 | *******************************************************************************/ 1822 | #define LSM6DS3_ACC_GYRO_DUR_MASK 0xF0 1823 | #define LSM6DS3_ACC_GYRO_DUR_POSITION 4 1824 | 1825 | /******************************************************************************* 1826 | * Register : WAKE_UP_THS 1827 | * Address : 0X5B 1828 | * Bit Group Name: WK_THS 1829 | * Permission : RW 1830 | *******************************************************************************/ 1831 | #define LSM6DS3_ACC_GYRO_WK_THS_MASK 0x3F 1832 | #define LSM6DS3_ACC_GYRO_WK_THS_POSITION 0 1833 | 1834 | /******************************************************************************* 1835 | * Register : WAKE_UP_THS 1836 | * Address : 0X5B 1837 | * Bit Group Name: INACTIVITY_ON 1838 | * Permission : RW 1839 | *******************************************************************************/ 1840 | typedef enum { 1841 | LSM6DS3_ACC_GYRO_INACTIVITY_ON_DISABLED = 0x00, 1842 | LSM6DS3_ACC_GYRO_INACTIVITY_ON_ENABLED = 0x40, 1843 | } LSM6DS3_ACC_GYRO_INACTIVITY_ON_t; 1844 | 1845 | /******************************************************************************* 1846 | * Register : WAKE_UP_THS 1847 | * Address : 0X5B 1848 | * Bit Group Name: SINGLE_DOUBLE_TAP 1849 | * Permission : RW 1850 | *******************************************************************************/ 1851 | typedef enum { 1852 | LSM6DS3_ACC_GYRO_SINGLE_DOUBLE_TAP_DOUBLE_TAP = 0x00, 1853 | LSM6DS3_ACC_GYRO_SINGLE_DOUBLE_TAP_SINGLE_TAP = 0x80, 1854 | } LSM6DS3_ACC_GYRO_SINGLE_DOUBLE_TAP_t; 1855 | 1856 | /******************************************************************************* 1857 | * Register : WAKE_UP_DUR 1858 | * Address : 0X5C 1859 | * Bit Group Name: SLEEP_DUR 1860 | * Permission : RW 1861 | *******************************************************************************/ 1862 | #define LSM6DS3_ACC_GYRO_SLEEP_DUR_MASK 0x0F 1863 | #define LSM6DS3_ACC_GYRO_SLEEP_DUR_POSITION 0 1864 | 1865 | /******************************************************************************* 1866 | * Register : WAKE_UP_DUR 1867 | * Address : 0X5C 1868 | * Bit Group Name: TIMER_HR 1869 | * Permission : RW 1870 | *******************************************************************************/ 1871 | typedef enum { 1872 | LSM6DS3_ACC_GYRO_TIMER_HR_6_4ms = 0x00, 1873 | LSM6DS3_ACC_GYRO_TIMER_HR_25us = 0x10, 1874 | } LSM6DS3_ACC_GYRO_TIMER_HR_t; 1875 | 1876 | /******************************************************************************* 1877 | * Register : WAKE_UP_DUR 1878 | * Address : 0X5C 1879 | * Bit Group Name: WAKE_DUR 1880 | * Permission : RW 1881 | *******************************************************************************/ 1882 | #define LSM6DS3_ACC_GYRO_WAKE_DUR_MASK 0x60 1883 | #define LSM6DS3_ACC_GYRO_WAKE_DUR_POSITION 5 1884 | 1885 | /******************************************************************************* 1886 | * Register : FREE_FALL 1887 | * Address : 0X5D 1888 | * Bit Group Name: FF_DUR 1889 | * Permission : RW 1890 | *******************************************************************************/ 1891 | #define LSM6DS3_ACC_GYRO_FF_FREE_FALL_DUR_MASK 0xF8 1892 | #define LSM6DS3_ACC_GYRO_FF_FREE_FALL_DUR_POSITION 3 1893 | #define LSM6DS3_ACC_GYRO_FF_WAKE_UP_DUR_MASK 0x80 1894 | #define LSM6DS3_ACC_GYRO_FF_WAKE_UP_DUR_POSITION 7 1895 | 1896 | 1897 | /******************************************************************************* 1898 | * Register : FREE_FALL 1899 | * Address : 0X5D 1900 | * Bit Group Name: FF_THS 1901 | * Permission : RW 1902 | *******************************************************************************/ 1903 | typedef enum { 1904 | LSM6DS3_ACC_GYRO_FF_THS_5 = 0x00, 1905 | LSM6DS3_ACC_GYRO_FF_THS_7 = 0x01, 1906 | LSM6DS3_ACC_GYRO_FF_THS_8 = 0x02, 1907 | LSM6DS3_ACC_GYRO_FF_THS_10 = 0x03, 1908 | LSM6DS3_ACC_GYRO_FF_THS_11 = 0x04, 1909 | LSM6DS3_ACC_GYRO_FF_THS_13 = 0x05, 1910 | LSM6DS3_ACC_GYRO_FF_THS_15 = 0x06, 1911 | LSM6DS3_ACC_GYRO_FF_THS_16 = 0x07, 1912 | } LSM6DS3_ACC_GYRO_FF_THS_t; 1913 | 1914 | /******************************************************************************* 1915 | * Register : MD1_CFG 1916 | * Address : 0X5E 1917 | * Bit Group Name: INT1_TIMER 1918 | * Permission : RW 1919 | *******************************************************************************/ 1920 | typedef enum { 1921 | LSM6DS3_ACC_GYRO_INT1_TIMER_DISABLED = 0x00, 1922 | LSM6DS3_ACC_GYRO_INT1_TIMER_ENABLED = 0x01, 1923 | } LSM6DS3_ACC_GYRO_INT1_TIMER_t; 1924 | 1925 | /******************************************************************************* 1926 | * Register : MD1_CFG 1927 | * Address : 0X5E 1928 | * Bit Group Name: INT1_TILT 1929 | * Permission : RW 1930 | *******************************************************************************/ 1931 | typedef enum { 1932 | LSM6DS3_ACC_GYRO_INT1_TILT_DISABLED = 0x00, 1933 | LSM6DS3_ACC_GYRO_INT1_TILT_ENABLED = 0x02, 1934 | } LSM6DS3_ACC_GYRO_INT1_TILT_t; 1935 | 1936 | /******************************************************************************* 1937 | * Register : MD1_CFG 1938 | * Address : 0X5E 1939 | * Bit Group Name: INT1_6D 1940 | * Permission : RW 1941 | *******************************************************************************/ 1942 | typedef enum { 1943 | LSM6DS3_ACC_GYRO_INT1_6D_DISABLED = 0x00, 1944 | LSM6DS3_ACC_GYRO_INT1_6D_ENABLED = 0x04, 1945 | } LSM6DS3_ACC_GYRO_INT1_6D_t; 1946 | 1947 | /******************************************************************************* 1948 | * Register : MD1_CFG 1949 | * Address : 0X5E 1950 | * Bit Group Name: INT1_TAP 1951 | * Permission : RW 1952 | *******************************************************************************/ 1953 | typedef enum { 1954 | LSM6DS3_ACC_GYRO_INT1_TAP_DISABLED = 0x00, 1955 | LSM6DS3_ACC_GYRO_INT1_TAP_ENABLED = 0x08, 1956 | } LSM6DS3_ACC_GYRO_INT1_TAP_t; 1957 | 1958 | /******************************************************************************* 1959 | * Register : MD1_CFG 1960 | * Address : 0X5E 1961 | * Bit Group Name: INT1_FF 1962 | * Permission : RW 1963 | *******************************************************************************/ 1964 | typedef enum { 1965 | LSM6DS3_ACC_GYRO_INT1_FF_DISABLED = 0x00, 1966 | LSM6DS3_ACC_GYRO_INT1_FF_ENABLED = 0x10, 1967 | } LSM6DS3_ACC_GYRO_INT1_FF_t; 1968 | 1969 | /******************************************************************************* 1970 | * Register : MD1_CFG 1971 | * Address : 0X5E 1972 | * Bit Group Name: INT1_WU 1973 | * Permission : RW 1974 | *******************************************************************************/ 1975 | typedef enum { 1976 | LSM6DS3_ACC_GYRO_INT1_WU_DISABLED = 0x00, 1977 | LSM6DS3_ACC_GYRO_INT1_WU_ENABLED = 0x20, 1978 | } LSM6DS3_ACC_GYRO_INT1_WU_t; 1979 | 1980 | /******************************************************************************* 1981 | * Register : MD1_CFG 1982 | * Address : 0X5E 1983 | * Bit Group Name: INT1_SINGLE_TAP 1984 | * Permission : RW 1985 | *******************************************************************************/ 1986 | typedef enum { 1987 | LSM6DS3_ACC_GYRO_INT1_SINGLE_TAP_DISABLED = 0x00, 1988 | LSM6DS3_ACC_GYRO_INT1_SINGLE_TAP_ENABLED = 0x40, 1989 | } LSM6DS3_ACC_GYRO_INT1_SINGLE_TAP_t; 1990 | 1991 | /******************************************************************************* 1992 | * Register : MD1_CFG 1993 | * Address : 0X5E 1994 | * Bit Group Name: INT1_SLEEP 1995 | * Permission : RW 1996 | *******************************************************************************/ 1997 | typedef enum { 1998 | LSM6DS3_ACC_GYRO_INT1_SLEEP_DISABLED = 0x00, 1999 | LSM6DS3_ACC_GYRO_INT1_SLEEP_ENABLED = 0x80, 2000 | } LSM6DS3_ACC_GYRO_INT1_SLEEP_t; 2001 | 2002 | /******************************************************************************* 2003 | * Register : MD2_CFG 2004 | * Address : 0X5F 2005 | * Bit Group Name: INT2_TIMER 2006 | * Permission : RW 2007 | *******************************************************************************/ 2008 | typedef enum { 2009 | LSM6DS3_ACC_GYRO_INT2_TIMER_DISABLED = 0x00, 2010 | LSM6DS3_ACC_GYRO_INT2_TIMER_ENABLED = 0x01, 2011 | } LSM6DS3_ACC_GYRO_INT2_TIMER_t; 2012 | 2013 | /******************************************************************************* 2014 | * Register : MD2_CFG 2015 | * Address : 0X5F 2016 | * Bit Group Name: INT2_TILT 2017 | * Permission : RW 2018 | *******************************************************************************/ 2019 | typedef enum { 2020 | LSM6DS3_ACC_GYRO_INT2_TILT_DISABLED = 0x00, 2021 | LSM6DS3_ACC_GYRO_INT2_TILT_ENABLED = 0x02, 2022 | } LSM6DS3_ACC_GYRO_INT2_TILT_t; 2023 | 2024 | /******************************************************************************* 2025 | * Register : MD2_CFG 2026 | * Address : 0X5F 2027 | * Bit Group Name: INT2_6D 2028 | * Permission : RW 2029 | *******************************************************************************/ 2030 | typedef enum { 2031 | LSM6DS3_ACC_GYRO_INT2_6D_DISABLED = 0x00, 2032 | LSM6DS3_ACC_GYRO_INT2_6D_ENABLED = 0x04, 2033 | } LSM6DS3_ACC_GYRO_INT2_6D_t; 2034 | 2035 | /******************************************************************************* 2036 | * Register : MD2_CFG 2037 | * Address : 0X5F 2038 | * Bit Group Name: INT2_TAP 2039 | * Permission : RW 2040 | *******************************************************************************/ 2041 | typedef enum { 2042 | LSM6DS3_ACC_GYRO_INT2_TAP_DISABLED = 0x00, 2043 | LSM6DS3_ACC_GYRO_INT2_TAP_ENABLED = 0x08, 2044 | } LSM6DS3_ACC_GYRO_INT2_TAP_t; 2045 | 2046 | /******************************************************************************* 2047 | * Register : MD2_CFG 2048 | * Address : 0X5F 2049 | * Bit Group Name: INT2_FF 2050 | * Permission : RW 2051 | *******************************************************************************/ 2052 | typedef enum { 2053 | LSM6DS3_ACC_GYRO_INT2_FF_DISABLED = 0x00, 2054 | LSM6DS3_ACC_GYRO_INT2_FF_ENABLED = 0x10, 2055 | } LSM6DS3_ACC_GYRO_INT2_FF_t; 2056 | 2057 | /******************************************************************************* 2058 | * Register : MD2_CFG 2059 | * Address : 0X5F 2060 | * Bit Group Name: INT2_WU 2061 | * Permission : RW 2062 | *******************************************************************************/ 2063 | typedef enum { 2064 | LSM6DS3_ACC_GYRO_INT2_WU_DISABLED = 0x00, 2065 | LSM6DS3_ACC_GYRO_INT2_WU_ENABLED = 0x20, 2066 | } LSM6DS3_ACC_GYRO_INT2_WU_t; 2067 | 2068 | /******************************************************************************* 2069 | * Register : MD2_CFG 2070 | * Address : 0X5F 2071 | * Bit Group Name: INT2_SINGLE_TAP 2072 | * Permission : RW 2073 | *******************************************************************************/ 2074 | typedef enum { 2075 | LSM6DS3_ACC_GYRO_INT2_SINGLE_TAP_DISABLED = 0x00, 2076 | LSM6DS3_ACC_GYRO_INT2_SINGLE_TAP_ENABLED = 0x40, 2077 | } LSM6DS3_ACC_GYRO_INT2_SINGLE_TAP_t; 2078 | 2079 | /******************************************************************************* 2080 | * Register : MD2_CFG 2081 | * Address : 0X5F 2082 | * Bit Group Name: INT2_SLEEP 2083 | * Permission : RW 2084 | *******************************************************************************/ 2085 | typedef enum { 2086 | LSM6DS3_ACC_GYRO_INT2_SLEEP_DISABLED = 0x00, 2087 | LSM6DS3_ACC_GYRO_INT2_SLEEP_ENABLED = 0x80, 2088 | } LSM6DS3_ACC_GYRO_INT2_SLEEP_t; 2089 | 2090 | #endif // End of __LSM6DS3IMU_H__ definition check 2091 | --------------------------------------------------------------------------------