Repository navigation
BMI160: apply target IMU alignment to the accelerometer - #12182
sensei-hacker wants to merge 1 commit into
Conversation
bmi160GyroDetect() takes the gyro alignment from the bus device param (the target's IMU_BMI160_ALIGN), but bmi160AccDetect() never set acc->accAlign, so the accelerometer stayed at ALIGN_DEFAULT. On targets with a rotated BMI160 (SYNERDUINO* use CW270_DEG) the gyro and accelerometer ended up 90 degrees apart in yaw, which board alignment cannot correct because it rotates both sensors together. Set accAlign from the bus device param, as every other IMU driver does. The BMI160 accelerometer and gyro share one axis system (datasheet section 5.2), so no per-sensor remap is needed. Add a unit test that runs the real detect functions with a CW270 bus device and checks both sensors get the same alignment.
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoApply target BMI160 alignment to the accelerometer
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can enable the Remediation agent and Qodo fixes findings in a dedicated fix PR |
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #12182 251 targets built. Find your board's
|
|
yes , did we kept the BMI 160 as is or did we added the fix ? |
Summary
bmi160GyroDetect()takes the gyro alignment from the target'sIMU_BMI160_ALIGN(the bus device param).bmi160AccDetect()never setacc->accAlign, so the accelerometer stayed atALIGN_DEFAULT.On targets with a rotated BMI160, the gyro and accelerometer end up 90° apart in yaw. All four SYNERDUINO* targets use
CW270_DEG. Board alignment can't correct this, because it rotates both sensors together. The board maker reported it: setting the accelerometer orientation right makes the gyro wrong, and the reverse.This PR sets
acc->accAlign = acc->busDev->param;, the same as every other IMU driver (BMI088, BMI270, ICM*, LSM6DXX, MPU*).The BMI160 accelerometer and gyro share one axis system (datasheet BST-BMI160-DS000, §5.2, Fig. 42), so no per-sensor remap is needed in the driver.
Affected targets
CW270_DEG). After this PR the accelerometer is rotated to match the gyro.CW0_DEG).release/9.1has no rotated BMI160 target, which is why this targetsmaintenance-10.x.Testing
accgyro_bmi160_unittest. It runs the real detect functions with a CW270 bus device and checks that the gyro and accelerometer both get the target alignment.maintenance-10.xeven without this change. TheHSE_MHZ 25setting fails the H7HSE_VALUE % 1600000static assert, and the target isSKIP_RELEASES. That's a separate issue.bmi160AccReadScratchpad()should drop that workaround with this fix. Otherwise the accelerometer is rotated twice.