ST意法半导体
直播中

王盼盼

7年用户 170经验值
私信 关注
[问答]

LSM330源代码都有不同的寄存器定义

目前,我现在使用LSM330,我找到的唯一参考驱动程序是官方Linux-OS驱动程序。由于没有编程指南,我在网站上搜索源代码以供参考,但却发现我找到的所有源代码都有不同的寄存器定义。


例如,在github的一个项目中,在初始化代码块中,作者编写了以下代码:


这个
- >
setAccelSensitivity

accelSensitivity
);


//查看数据表(第29页)


//正常(1.344 kHz)/低功耗模式(5.376 kHz)数据速率

//选择正常模式(默认)

//启用x,y,z轴(默认)

writeRegister

chipSelectAccel

CTRL_REG1

0
b10010111
);


//高通滤波器模式选择:正常模式(复位读取HP_RESET_FILTER)(默认)

//高通滤波器截止频率选择

//过滤数据选择:绕过内部过滤器(默认)

//为CLICK功能启用高通滤波器:绕过滤波器

//在中断2上启用AOI功能的高通滤波器:旁路滤波器

//在中断1上启用AOI功能的高通滤波器:旁路滤波器

writeRegister

chipSelectAccel

CTRL_REG2

0
B00000000
);

定义如下:

/ ******************* **
LSM330用于陀螺仪和加速度计的寄存器
************************************************** ** /
#define WHO_AM_I 0x0F
#define CTRL_REG1 0x20
#define CTRL_REG2 0x21
#define CTRL_REG3 0x22
#define CTRL_REG4 0x23
#define CTRL_REG5 0x24
#define CTRL_REG6 0x25
#define REFERENCE_A 0x26
#define REFERENCE 0x25
#define OUT_TEMP 0x26
#define STATUS_REG 0x27
#define OUT_X_L 0x28
#define OUT_X_H 0x29
#define OUT_Y_L 0x2A
#define OUT_Y_H 0x2B
#define OUT_Z_L 0x2C
#define OUT_Z_H 0x2D
#define FIFO_CTRL_REG 0x2E
#define FIFO_SRC_REG 0x2F
#define INT1_CFG 0x30
#define INT1_SRC 0x31
#define INT1_TSH_XH 0x32
#define INT1_TSH_XL 0x33
#define INT1_TSH_YH 0x34
#define INT1_TSH_YL 0x35
#define INT1_TSH_ZH 0x36
#define INT1_TSH_ZL 0x37
#define INT1_DURATION 0x38

但是,在LSM330官方数据表中,加速运动传感器没有CTRL_REG1,从内容上我们可以看到作者为ACCEL禁用了HPF,其中ACCEL-HPF ???只有陀螺仪有两个LPF和一个HPF。

有人请帮我理解这个吗?非常感谢。

以上来自于谷歌翻译


以下为原文




Currently, I am now using LSM330, the only reference driver I found is official Linux-OS driver. Since there's no programming guides, I search website for source code for reference, only to find that all source code I found have a different register definition.


For instance, in a project in github, among the initialization code block, the author wrote the code below:


   
this
->
setAccelSensitivity
(
accelSensitivity
);
   
   
// Check the datasheet (p29)


   
// Normal (1.344 kHz) / low-power mode (5.376 kHz) data rate
   
// Normal mode selected (default)
   
// x,y,z axis enabled (default)
   
writeRegister
(
chipSelectAccel
,
CTRL_REG1
,
0
b10010111
);


   
// High-pass filter mode selection : Normal mode (reset reading HP_RESET_FILTER) (default)
   
// High-pass filter cutoff frequency selection
   
// Filtered data selection : internal filter bypassed (default)
   
// High-pass filter enabled for CLICK function : filter bypassed
   
// High-pass filter enabled for AOI function on interrupt 2 : filter bypassed
   
// High-pass filter enabled for AOI function on interrupt 1 : filter bypassed
   
writeRegister
(
chipSelectAccel
,
CTRL_REG2
,
0
b00000000
);

With the definition below:



/***************************************************

LSM330 Registers for gyro and accelerometer

****************************************************/

#define WHO_AM_I 0x0F

#define CTRL_REG1 0x20

#define CTRL_REG2 0x21

#define CTRL_REG3 0x22

#define CTRL_REG4 0x23

#define CTRL_REG5 0x24

#define CTRL_REG6 0x25

#define REFERENCE_A 0x26

#define REFERENCE 0x25

#define OUT_TEMP 0x26

#define STATUS_REG 0x27

#define OUT_X_L 0x28

#define OUT_X_H 0x29

#define OUT_Y_L 0x2A

#define OUT_Y_H 0x2B

#define OUT_Z_L 0x2C

#define OUT_Z_H 0x2D

#define FIFO_CTRL_REG 0x2E

#define FIFO_SRC_REG 0x2F

#define INT1_CFG 0x30

#define INT1_SRC 0x31

#define INT1_TSH_XH 0x32

#define INT1_TSH_XL 0x33

#define INT1_TSH_YH 0x34

#define INT1_TSH_YL 0x35

#define INT1_TSH_ZH 0x36

#define INT1_TSH_ZL 0x37

#define INT1_DURATION 0x38

However, in LSM330 official datasheet, the accelerate motion sensor has no CTRL_REG1, and from the content, we can see that the author disable HPF for ACCEL, where's ACCEL-HPF??? Only gyroscope has two LPF and one HPF.

Anyone please help me understand this? Thanks very much.

回帖(1)

姚秋月

2018-10-24 11:17:52
嗨万城,
我也很难从LSM330TR读取数据。你有没有找到解决问题的方法?

以上来自于谷歌翻译


以下为原文




Hi Wancheng,
I have trouble to read data from LSM330TR too. Have you found anything to solve the problem?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分