Skip to content
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

First draft for BMI088 driver #200

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

NightHawk32
Copy link
Contributor

BMI088 consists of an ACC and Gyro digital part which are tied to the same SPI bus but require separate CS lines.
This required some hacks, since the current architecture trears the IMU as one device/component. This PR tires to intorduce an andditional CS pin without braking support for the other IMUs.

  • added BMI088 driver files
  • added cli params for additional CS pin
  • set gyro ODR to 2000Hz and ACC ODR to 800Hz

Tested with custom hardware for BMI088 adn RF configurator.

Open tests:

  • test in flight
  • test of implementation with hardware that offers another sensor (checking that all other IMUs still work fine)

scale = 8;
} else if (acc.dev.acc_1G > 512 * 2) {
scale = 4;
} else if (acc.dev.acc_1G >= 512) {
scale = 2;
} else {
}else {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unncessary change

*
* If not, see <http://www.gnu.org/licenses/>.
*/

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IS this driver going to Betaflight too? If so, then this copyright is ok.
If this is for Rotorflight only, then please use Rotorflight one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intitially I planned to add the code to betaflight aswell, but I will add the RF copyright for now.

scale = 1;
}
#endif

for (int i = 0; i < 3; i++) {
#if defined(USE_ACC)
sbufWriteU16(dst, lrintf(acc.accADC[i] / scale));
sbufWriteU16(dst, lrintf((int16_t)acc.accADC[i] / scale));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this is for. Can. you explain?

Copy link
Contributor Author

@NightHawk32 NightHawk32 Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this corssesponds to the change above, for getting the ACC scaling right in the configurator. In case that is not neededl, both changes are unnecessary. So for getting the scaling of ACC right in the configurator.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I am following. acc.accADC is a float. The scale variable used to be uint8_t, but you changed it to float. Why do you need to convert accADC to integer before dividing it by the scale?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would understand if the (int16_t) was before the lrintf() function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, don't know why I introduced that cast. Doesn't make sense like that in the end.
I changed the scaling to float, since the scaling with +-12G is not an integer anymore.

Copy link
Owner

@rotorflight rotorflight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More comments about the MSP

@NightHawk32
Copy link
Contributor Author

More comments about the MSP

removed the unneressary cast, is anything else left to be done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants