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
84a094d0
Commit
84a094d0
authored
9 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
drivers/lsm303dlhc: added SAUL integration
parent
5274c4e8
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
drivers/include/lsm303dlhc.h
+35
-20
35 additions, 20 deletions
drivers/include/lsm303dlhc.h
drivers/lsm303dlhc/lsm303dlhc_saul.c
+59
-0
59 additions, 0 deletions
drivers/lsm303dlhc/lsm303dlhc_saul.c
with
94 additions
and
20 deletions
drivers/include/lsm303dlhc.h
+
35
−
20
View file @
84a094d0
...
...
@@ -35,26 +35,6 @@ extern "C" {
#define LSM303DLHC_ACC_DEFAULT_ADDRESS (0x19)
#define LSM303DLHC_MAG_DEFAULT_ADDRESS (0x1e)
/**
* @brief 3d data container
*/
typedef
struct
{
int16_t
x_axis
;
int16_t
y_axis
;
int16_t
z_axis
;
}
lsm303dlhc_3d_data_t
;
/**
* @brief Device descriptor for LSM303DLHC sensors
*/
typedef
struct
{
i2c_t
i2c
;
/**< I2C device */
uint8_t
acc_address
;
/**< accelerometer's I2C address */
uint8_t
mag_address
;
/**< magnetometer's I2C address */
gpio_t
acc_pin
;
/**< accelerometer's data ready pin */
gpio_t
mag_pin
;
/**< magnetometer's data ready pin */
}
lsm303dlhc_t
;
/**
* @brief Possible accelerometer sample rates
*/
...
...
@@ -108,6 +88,41 @@ typedef enum {
LSM303DLHC_MAG_GAIN_230_205_GAUSS
=
0xe0
,
/**< 230Gauss XYZ 205Gauss Z */
}
lsm303dlhc_mag_gain_t
;
/**
* @brief 3d data container
*/
typedef
struct
{
int16_t
x_axis
;
int16_t
y_axis
;
int16_t
z_axis
;
}
lsm303dlhc_3d_data_t
;
/**
* @brief Device descriptor for LSM303DLHC sensors
*/
typedef
struct
{
i2c_t
i2c
;
/**< I2C device */
uint8_t
acc_address
;
/**< accelerometer's I2C address */
uint8_t
mag_address
;
/**< magnetometer's I2C address */
gpio_t
acc_pin
;
/**< accelerometer's data ready pin */
gpio_t
mag_pin
;
/**< magnetometer's data ready pin */
}
lsm303dlhc_t
;
/**
* @brief Data structure holding all the information needed for initialization
*/
typedef
struct
{
i2c_t
i2c
;
/**< I2C bus used */
uint8_t
acc_addr
;
/**< accelerometer I2C address */
gpio_t
acc_pin
;
/**< accelerometer EXTI pin */
lsm303dlhc_acc_sample_rate_t
acc_rate
;
/**< accelerometer sample rate */
lsm303dlhc_acc_scale_t
acc_scale
;
/**< accelerometer scale factor */
uint8_t
mag_addr
;
/**< magnetometer I2C address */
gpio_t
mag_pin
;
/**< magnetometer EXTI pin */
lsm303dlhc_mag_sample_rate_t
mag_rate
;
/**< magnetometer sample rate */
lsm303dlhc_mag_gain_t
mag_gain
;
/**< magnetometer gain */
}
lsm303dlhc_params_t
;
/**
* @brief Initialize a new LSM303DLHC device
*
...
...
This diff is collapsed.
Click to expand it.
drivers/lsm303dlhc/lsm303dlhc_saul.c
0 → 100644
+
59
−
0
View file @
84a094d0
/*
* Copyright (C) 2015 Freie Universität Berlin
*
* 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
* directory for more details.
*/
/**
* @ingroup driver_lsm303dlhc
* @{
*
* @file
* @brief LSM303DLHC adaption to the RIOT actuator/sensor interface
*
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*
* @}
*/
#include
<string.h>
#include
"saul.h"
#include
"lsm303dlhc.h"
static
int
read_acc
(
void
*
dev
,
phydat_t
*
res
)
{
lsm303dlhc_t
*
d
=
(
lsm303dlhc_t
*
)
dev
;
lsm303dlhc_read_acc
(
d
,
(
lsm303dlhc_3d_data_t
*
)
res
);
res
->
unit
=
UNIT_G
;
res
->
scale
=
0
;
return
3
;
}
static
int
read_mag
(
void
*
dev
,
phydat_t
*
res
)
{
lsm303dlhc_t
*
d
=
(
lsm303dlhc_t
*
)
dev
;
lsm303dlhc_read_mag
(
d
,
(
lsm303dlhc_3d_data_t
*
)
res
);
res
->
unit
=
UNIT_GS
;
res
->
scale
=
0
;
return
3
;
}
static
int
write
(
void
*
dev
,
phydat_t
*
state
)
{
return
-
ENOTSUP
;
}
const
saul_driver_t
lsm303dlhc_saul_acc_driver
=
{
.
read
=
read_acc
,
.
write
=
write
,
.
type
=
SAUL_SENSE_ACCEL
,
};
const
saul_driver_t
lsm303dlhc_saul_mag_driver
=
{
.
read
=
read_mag
,
.
write
=
write
,
.
type
=
SAUL_SENSE_MAG
,
};
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