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

emul: icm42688: Implement backend sensor emul API #61051

Merged

Conversation

tristan-google
Copy link
Collaborator

Implement the backend emul API for the ICM42688 motion sensor so it can be automatically tested by the generic sensor test (see #60394). Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the programmable full-scale accel and gyro ranges.

Also fixes an arithmetic bug in the driver that was causing a minor error in the returned readings.

Implement the backend emul API for the ICM42688 motion sensor so it can
be automatically tested by the generic sensor test (see zephyrproject-rtos#60394).
Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the
programmable full-scale accel and gyro ranges.

Also fixes an arithmetic bug in the driver that was causing a minor
error in the returned readings.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
@fabiobaltieri fabiobaltieri merged commit 128b466 into zephyrproject-rtos:main Aug 9, 2023
18 checks passed

/* Epsilon is equal to 1.5 bit-counts worth of error. */
*epsilon = (3 * SENSOR_PI * Q31_SCALE * 10LL / 1000000LL / 180LL / sensitivity / 2LL) >>
*shift;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@tristan-google In case shift==-1 (BIT_GYRO_UI_FS_15_625 case in icm42688_emul_get_gyro_settings), the right shift operation has an undefined behavior

The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type
or if E1 has a signed type and a nonnegative value, the value of the result is the integral
part of the quotient of E1 divided by the quantity, 2 raised to the power E2. If E1 has a
signed type and a negative value, the resulting value is implementation-defined

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

Successfully merging this pull request may close these issues.

None yet

7 participants