ST意法半导体
直播中

寇昕

8年用户 248经验值
私信 关注
[问答]

连接LIS3DH的命令或算法是什么

亲爱的先生,
我想从LIS3DH读取X,Y,Z数据。我已经浏览了同样的数据表,但仍然不明白访问它的命令是什么。如果你告诉我读取数据的命令或算法,那将是你的一种。
问候,
Manoj Hiwarkar

以上来自于谷歌翻译


以下为原文




Dear sir,
I want to read X,Y,Z data from LIS3DH. I have gone through the datasheet of the same but still didn't understand what are the commands to access it. So it will be kind of you if you tell me the commands or algorithm to read the data.
Regards,
Manoj Hiwarkar

回帖(4)

符伯峪

2019-4-8 07:48:06
您与用于读取器件内部寄存器的总线上的器件进行交互,数据表应列出寄存器位置和内容。如何连接到您的微控制器将影响您访问它的方式。
如果您不熟悉微控制器和接口,可能会有关于此类事情的书籍或课程。
HAL / CUBE版本中有各种STM32平台的示例驱动程序:
STM32Cube_FW_F4_V1.18.0  DRIVERS  BSP 组件 lis3dsh  lis3dsh.c
STM32Cube_FW_F4_V1.18.0  DRIVERS  BSP 组件 l3gd20  l3gd20.c
我认为网络搜索会产生更多的例子

以上来自于谷歌翻译


以下为原文




You interact with the part on the bus you're using to read the internal registers in the device, the data sheet should enumerate the register locations and content. How it is wired to your micro-controller will impact how you access it.
If you are unfamiliar with micro-controllers and interfacing there are likely books or courses on such things.
There are example drivers for various STM32 platforms in the HAL/CUBE releases:
STM32Cube_FW_F4_V1.18.0DriversBSPComponentslis3dshlis3dsh.c
STM32Cube_FW_F4_V1.18.0DriversBSPComponentsl3gd20l3gd20.c
I'd imagine a web search would yield many more examples
举报

寇昕

2019-4-8 07:55:15
我使用的是nrf 52832.我们有这个驱动程序吗?

以上来自于谷歌翻译


以下为原文




I am using nrf 52832. do we have any driver for this ?
举报

符伯峪

2019-4-8 08:13:42
我个人,没有。
你有没有通过SPI或I2C连接?该平台上那些接口的标准驱动程序应该能够访问设备中的寄存器。以上STM32上的示例代码在SPI / I2C之上的级别进行抽象。这可能是可移植的,或者您可能会使用LIS3DH找到您更喜欢飞行控制器或INS实现的代码
/ **
 
 * @brief阅读LIS3DSH设备ID。
 * @param无
 * @retval设备ID(两个字节)。
 * /
uint8_t LIS3DSH_ReadID(void)
{
 uint8_t tmp = 0; / *配置低级接口* /
 
 ACCELERO_IO_Init(); / *阅读WHO_AM_I注册* /
 
 ACCELERO_IO_Read(& tmp,LIS3DSH_WHO_AM_I_ADDR,1); / *返回ID * /
 
 return(uint16_t)tmp;
}

以上来自于谷歌翻译


以下为原文




Me personally, no.
Do you have it connected via SPI or I2C? Standard drivers for those interfaces on that platform should be able to access the registers within the device. The example code on the STM32 above is abstracted at the level above the SPI/I2C. This might be portable, or you might find code you like better for a Flight Controller or INS implementation, using the the LIS3DH
/**

  * @brief  Read LIS3DSH device ID.
  * @param  None
  * @retval The Device ID (two bytes).
  */
uint8_t LIS3DSH_ReadID(void)
{
  uint8_t tmp = 0;  /* Configure the low level interface */

  ACCELERO_IO_Init();  /* Read WHO_AM_I register */

  ACCELERO_IO_Read(&tmp, LIS3DSH_WHO_AM_I_ADDR, 1);  /* Return the ID */

  return (uint16_t)tmp;
}
举报

寇昕

2019-4-8 08:21:56
是的,我们通过i2c连接了它
在2018年5月12日星期六,下午4:41 Clive One,< st-microelectronics@jiveon.com>

以上来自于谷歌翻译


以下为原文




Yes we have connected it via i2c
On Sat 12 May, 2018, 4:41 PM Clive One,
举报

更多回帖

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