Skip to content

Commit 2dc93fe

Browse files
Beta Release
1 parent 541c166 commit 2dc93fe

22 files changed

+279
-1190
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
SparkFun LSM6DS3 Arduino Library
22
========================================
33

4-
![LSM6DS3 Breakout](https://cdn.sparkfun.com/assets/learn_tutorials/4/1/6/perspective.jpg)
4+
->![LSM6DS3 Breakout](https://cdn.sparkfun.com/assets/learn_tutorials/4/1/6/perspective.jpg)<-
55

6-
[*LSM6DS3 Breakout (13339)*](https://www.sparkfun.com/products/13339)
6+
->[*LSM6DS3 Breakout (13339)*](https://www.sparkfun.com/products/13339)<-
77

88
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.
99

@@ -25,6 +25,7 @@ Example Briefs
2525
* InterruptFreeFall - Embedded function demonstrating free-fall detection
2626
* InterruptHWTapConfig - Embedded function demonstrating tap and double-tap detection
2727
* LowLevelExample - Demonstrates using only the core driver without math and settings overhead
28+
* MemoryPagingExample - Demonstrates switching between memory pages
2829
* MinimalistExample - The **easiest** configuration
2930
* MultiI2C - Using two LSM6DS3s over I2C
3031
* MultiSPI - Using two LSM6DS3s over SPI
@@ -45,7 +46,7 @@ Products that use this Library
4546
Version History
4647
---------------
4748

48-
* [v1.0.0](URL for tag specific to this version) - Description
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.
4950

5051
License Information
5152
-------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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 [email protected].
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/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Example Briefs
88
* InterruptFreeFall - Embedded function demonstrating free-fall detection
99
* InterruptHWTapConfig - Embedded function demonstrating tap and double-tap detection
1010
* LowLevelExample - Demonstrates using only the core driver without math and settings overhead
11+
* MemoryPagingExample - Demonstrates switching between memory pages
1112
* MinimalistExample - The **easiest** configuration
1213
* MultiI2C - Using two LSM6DS3s over I2C
1314
* MultiSPI - Using two LSM6DS3s over SPI

extras/LICENSE.md

-10
This file was deleted.

extras/README.md

-3
This file was deleted.

extras/README22.md

-51
This file was deleted.

extras/class diagrams.odg

-12.7 KB
Binary file not shown.

extras/class diagrams.odt

-7.16 KB
Binary file not shown.

extras/class diagrams.pdf

24.6 KB
Binary file not shown.

extras/examples/FifoExample/FifoExample.ino

-156
This file was deleted.

0 commit comments

Comments
 (0)