Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
9a3c983d
Commit
9a3c983d
authored
7 years ago
by
Sebastian Meiling
Browse files
Options
Downloads
Patches
Plain Diff
drivers, lsm6dsl: update test, and add README
parent
6d252099
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/driver_lsm6dsl/README.md
+10
-0
10 additions, 0 deletions
tests/driver_lsm6dsl/README.md
tests/driver_lsm6dsl/main.c
+23
-17
23 additions, 17 deletions
tests/driver_lsm6dsl/main.c
with
33 additions
and
17 deletions
tests/driver_lsm6dsl/README.md
0 → 100644
+
10
−
0
View file @
9a3c983d
# About
This is a manual test application for the ST LSM6DSL sensor driver.
# Usage
After successful initialization, the sensor reads the accelerometer, gyroscope,
and temperature values every 500ms and prints them to the STDOUT. If device
initialization fails the tests exits with 1, otherwise it runs forever.
Note: reading sensor values may fail even on successful initialization.
This diff is collapsed.
Click to expand it.
tests/driver_lsm6dsl/main.c
+
23
−
17
View file @
9a3c983d
/*
/*
* Copyright (C) 2017 OTA keys S.A.
* Copyright (C) 2017 OTA keys S.A.
* 2017 HAW Hamburg
*
*
* This file is subject to the terms and conditions of the GNU Lesser
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* General Public License v2.1. See the file LICENSE in the top level
...
@@ -7,11 +8,16 @@
...
@@ -7,11 +8,16 @@
*/
*/
/**
/**
* @ingroup tests
* @{
*
* @file
* @file
* @brief Test application for the LSM6DSL accelerometer/gyroscope driver.
* @brief Test application for the LSM6DSL accelerometer/gyroscope driver.
*
*
* @author Vincent Dupont <vincent@otakeys.com>
* @author Vincent Dupont <vincent@otakeys.com>
* @author Sebastian Meiling <s@mlng.net>
*
*
* @}
*/
*/
#include
<stdio.h>
#include
<stdio.h>
...
@@ -20,7 +26,7 @@
...
@@ -20,7 +26,7 @@
#include
"lsm6dsl.h"
#include
"lsm6dsl.h"
#include
"lsm6dsl_params.h"
#include
"lsm6dsl_params.h"
#define SLEEP (
1
00 *
1000U
)
#define SLEEP (
5
00
UL
*
US_PER_MS
)
int
main
(
void
)
int
main
(
void
)
{
{
...
@@ -29,42 +35,42 @@ int main(void)
...
@@ -29,42 +35,42 @@ int main(void)
lsm6dsl_3d_data_t
mag_value
;
lsm6dsl_3d_data_t
mag_value
;
lsm6dsl_3d_data_t
acc_value
;
lsm6dsl_3d_data_t
acc_value
;
puts
(
"LSM6DSL test application
\n
"
);
puts
(
"LSM6DSL test application"
);
printf
(
"Initializing LSM6DSL sensor at I2C_%i... "
,
lsm6dsl_params
->
i2c
);
printf
(
"Initializing LSM6DSL sensor at I2C_%i... "
,
lsm6dsl_params
->
i2c
);
if
(
lsm6dsl_init
(
&
dev
,
lsm6dsl_params
)
==
0
)
{
if
(
lsm6dsl_init
(
&
dev
,
lsm6dsl_params
)
!=
LSM6DSL_OK
)
{
puts
(
"[OK]
\n
"
);
puts
(
"[ERROR]"
);
}
else
{
puts
(
"[Failed]"
);
return
1
;
return
1
;
}
}
puts
(
"[SUCCESS]
\n
"
);
while
(
1
)
{
while
(
1
)
{
if
(
lsm6dsl_read_acc
(
&
dev
,
&
acc_value
)
==
0
)
{
if
(
lsm6dsl_read_acc
(
&
dev
,
&
acc_value
)
==
LSM6DSL_OK
)
{
printf
(
"Accelerometer x: %i y: %i z: %i
\n
"
,
acc_value
.
x
,
printf
(
"Accelerometer x: %i y: %i z: %i
\n
"
,
acc_value
.
x
,
acc_value
.
y
,
acc_value
.
y
,
acc_value
.
z
);
acc_value
.
z
);
}
}
else
{
else
{
puts
(
"
\n
Failed reading accelerometer values
\n
"
);
puts
(
"[ERROR] reading accelerometer!
\n
"
);
}
if
(
lsm6dsl_read_temp
(
&
dev
,
&
temp_value
)
==
0
)
{
printf
(
"Temperature value: %i degrees
\n
"
,
temp_value
);
}
else
{
puts
(
"
\n
Failed reading value
\n
"
);
}
}
if
(
lsm6dsl_read_gyro
(
&
dev
,
&
mag_value
)
==
0
)
{
if
(
lsm6dsl_read_gyro
(
&
dev
,
&
mag_value
)
==
LSM6DSL_OK
)
{
printf
(
"Gyroscope x: %i y: %i z: %i
\n
"
,
mag_value
.
x
,
printf
(
"Gyroscope x: %i y: %i z: %i
\n
"
,
mag_value
.
x
,
mag_value
.
y
,
mag_value
.
y
,
mag_value
.
z
);
mag_value
.
z
);
}
}
else
{
else
{
puts
(
"
\n
Failed reading Gyroscope values
\n
"
);
puts
(
"[ERROR] reading gyroscope!
\n
"
);
}
if
(
lsm6dsl_read_temp
(
&
dev
,
&
temp_value
)
==
LSM6DSL_OK
)
{
printf
(
"Temperature [in °C x 100]: %i
\n
"
,
temp_value
);
}
else
{
puts
(
"[ERROR] reading temperature!
\n
"
);
}
}
puts
(
""
);
xtimer_usleep
(
SLEEP
);
xtimer_usleep
(
SLEEP
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment