HongshiTan / RTIMULib2

9-dof, 10-dof and 11-dof IMU fusion library for Linux systems (development version)
Other
72 stars 240 forks source link

Some questions about the RTIMUHal class #12

Open brightproject opened 3 weeks ago

brightproject commented 3 weeks ago

Hello @HongshiTan I'm using code from another repo written for teensy, and I rewrote it for Arduino and compiling it for stm32f411.

https://github.com/uutzinger/RTIMULib2-Teensy/

Unfortunately for me, there is no way to discuss code and stuff in this repo. In the repository

https://github.com/HongshiTan/RTIMULib2/

there is such a possibility, but the RTIMUHal class is a little different, or rather more functional and advanced, but the meaning is the same. I'm wondering what the case-insensitive read functionality is used for?

 bool HALRead(unsigned char slaveAddr, unsigned char regAddr, unsigned char length,
 unsigned char *data, const char *errorMsg); // normal read with register select
 bool HALRead(unsigned char slaveAddr, unsigned char length,
 unsigned char *data, const char *errorMsg); // read without register select

Actually, I had a problem with compilation when the code had such a strange reading initialization: I2Cdev::readBytes(slaveAddr, regAddr, length, data, 10) which I replaced with: I2Cdev::readBytes(slaveAddr, regAddr, length, data) And also had to add a new function to the library I2Cdev.h and I2Cdev.cpp static int8_t readBytes(uint8_t devAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout, void *wireObj=0); But this is not used anywhere in the code, which is why it caused strangeness. Can someone tell me what this is used for? I mean, when is regAddr not needed? P.S. Perhaps this issue can be converted into discussions?

HongshiTan commented 2 weeks ago

Hello,

HALRead without register is a work around for some specific sensors, such as the HTU21D, etc., that do not need to specify the register address to read the measurement:

if (!m_settings->HALRead(m_humidityAddr, 3, rawData, "Failed to read HTU21D temperature"))

By the way, is the I2Cdev.cpp from RTIMULib2-Teensy? you can put the source code here

brightproject commented 2 weeks ago

Hello. Thanks for your reply. I'm used this code

https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/I2Cdev

Only it copied and started working. In general, the add-on in the form of HAL libraries

RTIMUHal.h
RTIMUHal.cpp

is quite inconvenient, and my I2C bus and microcontroller freeze after 5-10 seconds of operation. I will rewrite the work with the I2C bus as it was done in RTIMULib-Arduino

https://github.com/jordandcarter/RTIMULib-Arduino/blob/cac4454680dd6798f1f4d7fa61ab465e960dd570/libraries/RTIMULib/RTIMUGD20M303DLHC.cpp#L52