STM32F4 Discovery LIS3DSH Accelerometer via SPI #73810
-
Hi, I am currently trying to work with the LIS3DSH Accelerometer via SPI on an STM32F4 Discovery kit and am running into some issues likely with the Zephyr driver support? (this is my best guess) Essentially the issue is that when using the existing LIS2DH Zephyr drivers, we can't get past a device_is_ready check. I am relatively new and inexperienced in Zephyr (college student here), but my colleague suggested it was likely a driver compatibility issue with the sensor. I would try to debug/fix this issue myself, but I wouldn't even know where to start in terms of how to debug/alter driver code... So, I guess my question is if anyone has done SPI communication with this sensor before and could lead me in the right direction, or has any guidance on how to debug? Code is shown below. main.c
(the code to get sensor data and display admittedly may be very wrong currently - just trying to ensure the sensor is ready first) stm32f4_disco.overlay
prj.conf
(again, new to Zephyr so a lot of this is probably redundant, but I was trying different things in order to debug) My output on the serial monitor looks like this:
Also, I am just using Zephyr's given stm32f4_disco.dts for my board .dts file, in case that matters (didn't make a custom one or anything). One thing I did notice that further suggested a lack of support was that on the Bindings Index page (page) there is a st,lis2dh (on i2c bus), a st,lis2dh (on spi bus), and a st,lis3dh (on i2c bus) listed, but no "st,lis3dh (on spi bus)" like I would expect there to be... So maybe this is all a moot point, but thought someone might have better knowledge of this than my team and I. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Hi @joshegrimes, I will try to answer some of your questions
It appears that LIS3DSH is not at all supported in Zephyr (there is no compatible devicetree binding), potentially it can be used with the same driver as LIS2DH & LIS3DH , just need to add this binding in
but I am not sure (@avisconti If you could share your input, thanks!).
You should first add
If you want to use SPI in async mode, you should have To work with sensors in Zephyr, you need |
Beta Was this translation helpful? Give feedback.
-
Yes, I agree with @ajarmouni-st. |
Beta Was this translation helpful? Give feedback.
-
As LIS3DSH is not supported and obsolete, if you really require to use that device I suggest you to add the support by your own, starting from lis2dh driver. The minimum required is the driver and dts bindings. |
Beta Was this translation helpful? Give feedback.
-
@joshegrimes This can be helpful https://github.com/STMicroelectronics/lis3dsh-pid/tree/master |
Beta Was this translation helpful? Give feedback.
-
I see, thanks for all the helpful information! I may try to add support myself at some point, but right now it's not a huge priority for my team and I... more just wanted to know for sanity's sake. I will update if I ever get it to work... Thanks again! |
Beta Was this translation helpful? Give feedback.
Yes, I agree with @ajarmouni-st.
Basilically, despite the part number name which is simliar, LIS3DSH has NOTHING to do with lis2dh/lis3dh/lis3dh12. In fact the device id is 0x3F for the first one, while it is 0x33 for the other three which belong to the same family and are register compatible (in this case you can use lis2dh driver for all three devices). So, LIS3DSH is currently not supported in zephyr and it will never be, as it is declared obsolete (see https://www.st.com/content/st_com/en/search.html#q=lis3dsh-t=products-page=1)