Skip to content

Commit 8362e60

Browse files
miggazElquezdanieldegrasse
authored andcommitted
dts: bindings: add DT bindings for the lsm9ds1 magnetometer
This commit adds a description for the magnetometer part of the lsm9ds1 sensor. Signed-off-by: Miguel Gazquez <miguel.gazquez@bootlin.com>
1 parent 0285cf4 commit 8362e60

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Copyright (c) 2024 Bootlin
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
STMicroelectronics LSM9DS1 9-axis IMU (Inertial Measurement Unit) sensor
6+
accessed through I2C bus.
7+
8+
This binding describes only the magnetometer.
9+
10+
When setting the mag-range and mag-odr properties in
11+
a .dts or .dtsi file you may include lsm9ds1.h and use the macros
12+
defined here.
13+
14+
Example:
15+
#include <zephyr/dt-bindings/sensor/lsm9ds1.h>
16+
17+
lsm9ds1_mag: lsm9ds1_mag@0 {
18+
...
19+
20+
mag-range = <LSM9DS1_DT_FS_4Ga>;
21+
mag-odr = <LSM9DS1_MAG_MP_40Hz>;
22+
};
23+
24+
compatible: "st,lsm9ds1_mag"
25+
26+
include: [sensor-device.yaml, i2c-device.yaml]
27+
28+
properties:
29+
mag-range:
30+
type: int
31+
default: 0
32+
description: |
33+
Range of the magnetometer in gauss. Default is power-up configuration.
34+
35+
- 0 # LSM9DS1_DT_FS_4Ga (0.14 mgauss/LSB)
36+
- 1 # LSM9DS1_DT_FS_8Ga (0.29 mgauss/LSB)
37+
- 2 # LSM9DS1_DT_FS_12Ga (0.43 mgauss/LSB)
38+
- 3 # LSM9DS1_DT_FS_16Ga (0.58 mgauss/LSB)
39+
40+
enum: [0, 1, 2, 3]
41+
42+
mag-odr:
43+
type: int
44+
default: 0
45+
description: |
46+
Specify the default output data rate of the magnetometer (samples/second).
47+
Default is power-up configuration.
48+
- 0xC0 # LSM9DS1_MAG_POWER_DOWN
49+
- 0x00 # LS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300Hz
83+
- 0x18 # LSM9DS1_MAG_MP_560Hz
84+
- 0x08 # LSM9DS1_MAG_LP_1000Hz
85+
- 0x70 # LSM9DS1_MAG_ONE_SHOT
86+
87+
enum: [0xC0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x12, 0x13,
88+
0x14, 0x15, 0x16, 0x17, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x30, 0x31,
89+
0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x28, 0x18, 0x08, 0x70]

include/zephyr/dt-bindings/sensor/lsm9ds1.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,50 @@
4343
#define LSM9DS1_IMU_59Hz5_LP 0xA2
4444
#define LSM9DS1_IMU_119Hz_LP 0xB3
4545

46+
/* magnetometer */
47+
48+
#define LSM9DS1_DT_FS_4Ga 0
49+
#define LSM9DS1_DT_FS_8Ga 1
50+
#define LSM9DS1_DT_FS_12Ga 2
51+
#define LSM9DS1_DT_FS_16Ga 3
52+
53+
#define LSM9DS1_MAG_POWER_DOWN 0xC0
54+
#define LSM9DS1_MAG_LP_0Hz625 0x00
55+
#define LSM9DS1_MAG_LP_1Hz25 0x01
56+
#define LSM9DS1_MAG_LP_2Hz5 0x02
57+
#define LSM9DS1_MAG_LP_5Hz 0x03
58+
#define LSM9DS1_MAG_LP_10Hz 0x04
59+
#define LSM9DS1_MAG_LP_20Hz 0x05
60+
#define LSM9DS1_MAG_LP_40Hz 0x06
61+
#define LSM9DS1_MAG_LP_80Hz 0x07
62+
#define LSM9DS1_MAG_MP_0Hz625 0x10
63+
#define LSM9DS1_MAG_MP_1Hz25 0x11
64+
#define LSM9DS1_MAG_MP_2Hz5 0x12
65+
#define LSM9DS1_MAG_MP_5Hz 0x13
66+
#define LSM9DS1_MAG_MP_10Hz 0x14
67+
#define LSM9DS1_MAG_MP_20Hz 0x15
68+
#define LSM9DS1_MAG_MP_40Hz 0x16
69+
#define LSM9DS1_MAG_MP_80Hz 0x17
70+
#define LSM9DS1_MAG_HP_0Hz625 0x20
71+
#define LSM9DS1_MAG_HP_1Hz25 0x21
72+
#define LSM9DS1_MAG_HP_2Hz5 0x22
73+
#define LSM9DS1_MAG_HP_5Hz 0x23
74+
#define LSM9DS1_MAG_HP_10Hz 0x24
75+
#define LSM9DS1_MAG_HP_20Hz 0x25
76+
#define LSM9DS1_MAG_HP_40Hz 0x26
77+
#define LSM9DS1_MAG_HP_80Hz 0x27
78+
#define LSM9DS1_MAG_UHP_0Hz625 0x30
79+
#define LSM9DS1_MAG_UHP_1Hz25 0x31
80+
#define LSM9DS1_MAG_UHP_2Hz5 0x32
81+
#define LSM9DS1_MAG_UHP_5Hz 0x33
82+
#define LSM9DS1_MAG_UHP_10Hz 0x34
83+
#define LSM9DS1_MAG_UHP_20Hz 0x35
84+
#define LSM9DS1_MAG_UHP_40Hz 0x36
85+
#define LSM9DS1_MAG_UHP_80Hz 0x37
86+
#define LSM9DS1_MAG_UHP_155Hz 0x38
87+
#define LSM9DS1_MAG_HP_300Hz 0x28
88+
#define LSM9DS1_MAG_MP_560Hz 0x18
89+
#define LSM9DS1_MAG_LP_1000Hz 0x08
90+
#define LSM9DS1_MAG_ONE_SHOT 0x70
91+
4692
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ST_LSM9DS1_H_ */

0 commit comments

Comments
 (0)