-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SFLP HW feature and relative example
- Loading branch information
Showing
9 changed files
with
5,924 additions
and
4,065 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/LSM6DSV16X_DataLog_Terminal/LSM6DSV16X_DataLog_Terminal.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
@file LSM6DSV16X_DataLog_Terminal.ino | ||
@author Giuseppe Roberti <[email protected]> | ||
@author STMicroelectronics | ||
@brief Example to use the LSM6DSV16X inertial measurement sensor | ||
******************************************************************************* | ||
Copyright (c) 2022, STMicroelectronics | ||
|
79 changes: 79 additions & 0 deletions
79
examples/LSM6DSV16X_Sensor_Fusion/LSM6DSV16X_Sensor_Fusion.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
@file LSM6DSV16X_Sensor_Fusion.ino | ||
@author STMicroelectronics | ||
@brief Example to use the LSM6DSV16X library with Sensor Fusion Low Power. | ||
******************************************************************************* | ||
Copyright (c) 2022, STMicroelectronics | ||
All rights reserved. | ||
This software component is licensed by ST under BSD 3-Clause license, | ||
the "License"; You may not use this file except in compliance with the | ||
License. You may obtain a copy of the License at: | ||
opensource.org/licenses/BSD-3-Clause | ||
******************************************************************************* | ||
*/ | ||
#include <LSM6DSV16XSensor.h> | ||
|
||
#define ALGO_FREQ 120U /* Algorithm frequency 120Hz */ | ||
#define ALGO_PERIOD (1000U / ALGO_FREQ) /* Algorithm period [ms] */ | ||
unsigned long startTime, elapsedTime; | ||
|
||
LSM6DSV16XSensor AccGyr(&Wire); | ||
uint8_t status = 0; | ||
uint8_t tag = 0; | ||
float quaternions[4]={0}; | ||
|
||
void setup() { | ||
|
||
Serial.begin(115200); | ||
while (!Serial) yield(); | ||
|
||
Wire.begin(); | ||
// Initialize LSM6DSV16X. | ||
AccGyr.begin(); | ||
|
||
// Enable Sensor Fusion | ||
status |= AccGyr.Enable_Rotation_Vector(); | ||
|
||
if(status != LSM6DSV16X_OK) { | ||
Serial.println("LSM6DSV16X Sensor failed to init/configure"); | ||
while(1); | ||
} | ||
Serial.println("LSM6DSV16X SFLP Demo"); | ||
} | ||
|
||
void loop() { | ||
uint16_t fifo_samples; | ||
// Get start time of loop cycle | ||
startTime = millis(); | ||
// Check the number of samples inside FIFO | ||
if(AccGyr.FIFO_Get_Num_Samples(&fifo_samples) != LSM6DSV16X_OK){ | ||
Serial.println("LSM6DSV16X Sensor failed to get number of samples inside FIFO"); | ||
while(1); | ||
} | ||
|
||
// Read the FIFO if there is one stored sample | ||
if (fifo_samples > 0) { | ||
for (int i = 0; i < fifo_samples; i++) { | ||
AccGyr.FIFO_Get_Tag(&tag); | ||
if(tag==0x13u){ | ||
AccGyr.FIFO_Get_Rotation_Vector(&quaternions[0]); | ||
|
||
// Print Quaternion data | ||
Serial.print("Quaternion: "); | ||
Serial.print(quaternions[3], 4); | ||
Serial.print(", "); | ||
Serial.print(-quaternions[1], 4); | ||
Serial.print(", "); | ||
Serial.print(quaternions[0], 4); | ||
Serial.print(", "); | ||
Serial.println(quaternions[2], 4); | ||
|
||
// Compute the elapsed time within loop cycle and wait | ||
elapsedTime = millis() - startTime; | ||
delay(ALGO_PERIOD - elapsedTime); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.