Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Question about DMP activation code inv_icm20948_enable_dmp_sensor #150

@dobodu

Description

@dobodu

I believe the code activating too much Data_ready an Motion Event (but the more can do the leas).

I explain :

// Now we know androidSensor is valid, reconstruct the value for DATA_OUT_CTL1 from _enabled_Android_0 and _enabled_Android_0
delta = 0; // Clear delta
for (int i = 0; i < 32; i++)
{
androidSensorAsBitMask = 1L << i;
if ((pdev->_enabled_Android_0 & androidSensorAsBitMask) > 0) // Check if the Android sensor (0-31) is enabled
{
delta |= inv_androidSensor_to_control_bits[i]; // If it is, or the required bits into delta
}
if ((pdev->_enabled_Android_1 & androidSensorAsBitMask) > 0) // Check if the Android sensor (32-) is enabled
{
delta |= inv_androidSensor_to_control_bits[i + 32]; // If it is, or the required bits into delta
}
// Also check which bits need to be set in the Data Ready Status and Motion Event Control registers
// Compare to INV_NEEDS_ACCEL_MASK, INV_NEEDS_GYRO_MASK and INV_NEEDS_COMPASS_MASK

if (((androidSensorAsBitMask & INV_NEEDS_ACCEL_MASK) > 0) || ((androidSensorAsBitMask & INV_NEEDS_ACCEL_MASK1) > 0))
{
data_rdy_status |= DMP_Data_ready_Accel;
inv_event_control |= DMP_Motion_Event_Control_Accel_Calibr;
}

for i = 0 to 32 will check all the time every bits for INV_NEEDS_ACCEL_MASK (not null) so data will always be activated.

I believe the correct test should be

if (((pdev->_enabled_Android_0 & androidSensorAsBitMask & INV_NEEDS_ACCEL_MASK) > 0) || ((pdev->_enabled_Android_1 & androidSensorAsBitMask & INV_NEEDS_ACCEL_MASK1) > 0))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions