-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Communicating with BMI160 chip over SPI #31980
Comments
Glancing at the code I think the bmi160 driver doesn't support CS based on GPIO. If you look at other sensor drivers you see blocks of code like in the init function:
|
I looked at the other drivers, I see your point. There is no But my question is then: how do I setup SPI pins (MISO, MOSI, CLK) and CS properly? How do I synchronize CS and the communication? I would expect the driver to handle CS pin. How can this be achieved? What do I need to modify in my device tree? And are there any other modifications needed (eg. Kconfig file, etc). Thanks in advance. |
Just an update. I can get a communication with the chip, but only after taking the power of the board and re-applying it. If the power to the board is present at all times, and I just flash MCU over JTAG, device cannot be found. This is something I still need to understand. Right now, I have no idea why is it behaving like this. |
You need to add support in the driver to do the init for CS via GPIO. |
@galak , I have another problem for which I hope you can point me into the right direction. I want to configure trigger mode for BMI160. For that, my prj.conf file is set as: Dts from before did not change, except I commented in However, when I flash the code, I get the following output (as you can see, I added additonal LOGs inside of Basically, it is failing at The weired parts are: They should be set to GPIO_ACTIVE_HIGH (0) and 2, respectively. Do you see anything I am doing wrong? Do I need to set something I have not set? Thanks a lot for your help. |
@mejtejt can you remind me what SoC you are using? |
@mejtejt I'd suggest the following:
|
It is STM32L462VEI6. As for the other part, I will get back to you shortly. |
@galak , as for compiling, how do I tell it which compiler to use? Looking at the So, I waas trying to do: How do I compile bmi160.c manually? Which command I have to execute? As for the dts above, it looks fine, right? |
What did the full line in |
|
So try:
|
Step forward, but it can't find
|
Do a full build first, than re-run the command. |
Unfortunately, it did not help. I ran Do you have a possibility to try it out on STM32L462 (or similar board) by yourself? |
Are you able to push your code to your github account? I tried the following on disco_l475_iot1:
and see:
where |
@galak, I have to ask for permission rights, to see if I can pust the code to github. As you can see, the "missing" include is in the |
@galak , let me reduce the code to the minimum needed to reproduce the error, and then I will push the code to my github account. I will let you know when I do so. Thanks. |
@mejtejt are you on the zephyr slack? Might be easier to chat there. I normally use cmake directly and not west for my builds. What I'd suggest is this:
you should than be able to do the preprocessor command. |
@galak, I am not yet on zephyr slack, but I will create an account on Monday and will contact you then on slack. In a meanwhile, your last instructions helped me a lot and I was able to manually compile bmi160 driver and got the preprocessor output. The line of interest to us looks like this: It it exactly what it is supposed to be like. Which is a good and a bad thing at the same time. Good because output is as we want/expect it to be. Bad because it does not explain why the problem is happening then (i.e. how come does the I do not have the board next to me, I will try flashing the board on Monday and see if I get the same problems as before. PS. What makes using cmake directly instead of west build better? Also, is using west flash OK or |
west manages more things for you so its better for most people. I've been working on zephyr before west was around so I haven't really fully switched over my personal workflow to be fully west based. I don't believe there is any real difference between |
@galak , first of all, how do I find you on zephyr slack? I created an account, but cannot find you to DM you. In a meanwhile, let me share what I have found. I added more logs into the At the beginning of the bmi160_init function: Then just before And the last call within So, what we were trying to establish before, is actually OK. When I move the body of the What do you reckon of that? |
what's your slack username? |
@galak what's your slack username?: greyp |
Are you sure you joined the correct slack? Not seeing you on the Zephyr slack, the invite is here: |
Could this be a linker script issue? |
This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time. |
Problem description
I have bosch bmi160 IMU on my custom board and cannot get SPI communication to work.
Detailed RFC
The hardware setup is as follows:
V40 and V41 are in the meantime replaced with 1k resistors. The right hand side of the screenshot is DARTMx6, and communication from that end is working fine, so I know BMI chip if fine (properly powered, etc).
The part of MCU where it is connected to SPI is as follows:
prj.conf file has the following configuration (
gpio
is also set toy
in the part not seen here):Device tree:
From the code it is called as this:
But I get the
CS control inhibited
error:It if failing in this part of the code:
It looks like CS is not properly initialized/enabled (I guess it is not set as output). What am I missing and how do I achieve it?
Thanks for your help.
The text was updated successfully, but these errors were encountered: