Skip to content

sensor: axis-align: Add helper API to align for fetch-get - #18

Open
ubieda wants to merge 1 commit into
main-with-patchesfrom
extend-axis-align-to-fetch-get
Open

sensor: axis-align: Add helper API to align for fetch-get#18
ubieda wants to merge 1 commit into
main-with-patchesfrom
extend-axis-align-to-fetch-get

Conversation

@ubieda

@ubieda ubieda commented Dec 19, 2025

Copy link
Copy Markdown
Member

For backwards compatibility support. Assuming double[3].

Tested by adding the following code in imu zros-driver:

		...
		sensor_sample_fetch(ctx->accel_dev);
		sensor_channel_get(ctx->accel_dev, SENSOR_CHAN_ACCEL_XYZ, accel_value);
		for (int j = 0; j < 3; j++) {
			ctx->accel_raw[j] = sensor_value_to_double(&accel_value[j]);
		}
		if (axis_ref) {
			sensor_three_axis_ref_align_fp(axis_ref, ctx->accel_raw);
		}
		...

@PetervdPerk-NXP PetervdPerk-NXP left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you do the axis alignment on the raw struct sensor_value instead of doubles, this generates either a vmul.f64 or vneg.f64 cpu instruction which is quite costly.

Also we I would consider unrolling the loop to help the CPU pipeline.

@ubieda

ubieda commented Jan 6, 2026

Copy link
Copy Markdown
Member Author

@PetervdPerk-NXP I can make the change - Although I'm concerned that most if not all floating-point operations in Cerebri are done with doubles. Wouldn't that be a much higher problem?

For backwards compatibility support. Operates on struct sensor_value[3]
directly to avoid costly floating-point operations (vmul.f64/vneg.f64).
Loop is unrolled to help CPU pipelining.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
@ubieda
ubieda force-pushed the extend-axis-align-to-fetch-get branch from 031c066 to 98e52c3 Compare January 16, 2026 22:25
@ubieda

ubieda commented Jan 16, 2026

Copy link
Copy Markdown
Member Author

Could you do the axis alignment on the raw struct sensor_value instead of doubles, this generates either a vmul.f64 or vneg.f64 cpu instruction which is quite costly.

Also we I would consider unrolling the loop to help the CPU pipeline.

@PetervdPerk-NXP PTAL with these new updates. Should meet your previous change-requests.

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