我个人,没有。
你有没有通过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;
}
我个人,没有。
你有没有通过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;
}
举报