STMicroelectronics / STMems_Standard_C_drivers

Platform-independent drivers for STMicroelectronics MEMS motion and environmental sensors, based on standard C programming language.
BSD 3-Clause "New" or "Revised" License
732 stars 519 forks source link

LSM6DSO: Self test code working? Ever tried out? #145

Closed capiman closed 3 years ago

capiman commented 3 years ago

Was the code in

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dso32_STdC/examples/lsm6dso32_self_test.c

ever tried out? Shall it be working? Code (especially the following lines) seems to be at least 3 years old, so long time not working?

Just found 2 bugs:

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blame/master/lsm6dso32_STdC/examples/lsm6dso32_self_test.c#L281

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blame/master/lsm6dso32_STdC/examples/lsm6dso32_self_test.c#L308

Both time

lsm6dso32_xl_flag_data_ready_get(&dev_ctx, &drdy);

instead of

lsm6dso32_gy_flag_data_ready_get(&dev_ctx, &drdy);

Or both equivalent? Or xl correct and only not working on my side? At least on my side it was not working with xl. I was looking for hours, till I saw the error. After changing to gy at the 2 places it was working immediately...

For completeness:

STATUS_REG (0x1E) see page 64 in datasheet DS12140 - Rev 2

GDA (Bit 1) Gyroscope new data available. Default value: 0 (0: no set of data available at gyroscope output; 1: a new set of data is available at gyroscope output)

XLDA (Bit 0) Accelerometer new data available. Default value: 0 (0: no set of data available at accelerometer output; 1: a new set of data is available at accelerometer output)

avisconti commented 3 years ago

Was the code in

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dso32_STdC/examples/lsm6dso32_self_test.c

ever tried out? Shall it be working? Code (especially the following lines) seems to be at least 3 years old, so long time not working?

Just found 2 bugs:

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blame/master/lsm6dso32_STdC/examples/lsm6dso32_self_test.c#L281

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blame/master/lsm6dso32_STdC/examples/lsm6dso32_self_test.c#L308

Both time

lsm6dso32_xl_flag_data_ready_get(&dev_ctx, &drdy);

instead of

lsm6dso32_gy_flag_data_ready_get(&dev_ctx, &drdy);

Or both equivalent? Or xl correct and only not working on my side? At least on my side it was not working with xl. I was looking for hours, till I saw the error. After changing to gy at the 2 places it was working immediately...

They are not equivalent, xl is for accel and gy is for gyroscope. All of this are typos introduced with copy/paiste from the xl case to gy case. I'm sorry for this errors. I took the ownership of the STdC drivers only recently, and I guess that this example was tested for xl code only. After gy was added probably it was not retested.

I provide the patch for it.