Skip to content

bmm350: Add Streaming and Read-Decode support #93048

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ubieda
Copy link
Member

@ubieda ubieda commented Jul 12, 2025

Description

This PR introduces Read-Decode and Streaming mode support to the existing BMM350 driver in-tree.
To accomplish this, there was some refactoring done to allow both v1 and v2 model to coexist without unnecessary code duplication.

Testing

Ran Sensor Shell with BMM350 enabled on an MCXN947 FRDM board and verify both v2 model (read-decode and streaming mode) as well as v1 model (fetch-get) work.

  • Build command (Streaming enabled):
west build -b frdm_mcxn947/mcxn947/cpu0 samples/subsys/shell/shell_module -- -DCONFIG_SENSOR=y -DCONFIG_SENSOR_SHELL=y -DCONFIG_SENSOR_SHELL_STREAM=y
  • Overlay frdm_mcxn947_mcxn947_cpu0.overlay
&flexcomm2_lpi2c2 {
	status = "okay";
	
	bmm350:bmm350@14 {
		compatible = "bosch,bmm350";
		reg = <0x14>;
		status = "okay";
		odr = "3.125";

		/* Arduino pin: D2 */
		drdy-gpios = <&gpio0 29 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>;
		push-pull-int;
		active-high-int;
	};
};
  • Console Output:
uart:~$ sensor get bmm350@14 
channel type=8(magn_x) index=0 shift=23 num_samples=1 value=86221911896ns (-0.277343)
channel type=9(magn_y) index=0 shift=23 num_samples=1 value=86221911896ns (-0.156250)
channel type=10(magn_z) index=0 shift=23 num_samples=1 value=86221911896ns (0.449218)
channel type=11(magn_xyz) index=0 shift=23 num_samples=1 value=86221911896ns, (-0.277343, -0.156250, 0.449218)

uart:~$ sensor stream bmm350@14 on data_ready incl 
Enabling stream...
Trigger (1 / data_ready) detected
channel type=8(magn_x) index=0 shift=23 num_samples=1 value=98747383322ns (-0.277343)
channel type=9(magn_y) index=0 shift=23 num_samples=1 value=98747383322ns (-0.156250)
channel type=10(magn_z) index=0 shift=23 num_samples=1 value=98747383322ns (0.449218)
channel type=11(magn_xyz) index=0 shift=23 num_samples=1 value=98747383322ns, (-0.277343, -0.156250, 0.449218)
Trigger (1 / data_ready) detected
channel type=8(magn_x) index=0 shift=23 num_samples=1 value=99067733376ns (-0.277343)
channel type=9(magn_y) index=0 shift=23 num_samples=1 value=99067733376ns (-0.156250)
channel type=10(magn_z) index=0 shift=23 num_samples=1 value=99067733376ns (0.449218)
channel type=11(magn_xyz) index=0 shift=23 num_samples=1 value=99067733376ns, (-0.277343, -0.156250, 0.449218)
Trigger (1 / data_ready) detected
channel type=8(magn_x) index=0 shift=23 num_samples=1 value=99388095842ns (-0.277343)
channel type=9(magn_y) index=0 shift=23 num_samples=1 value=99388095842ns (-0.156250)
channel type=10(magn_z) index=0 shift=23 num_samples=1 value=99388095842ns (0.449218)
channel type=11(magn_xyz) index=0 shift=23 num_samples=1 value=99388095842ns, (-0.277343, -0.156250, 0.449218)

ubieda added 5 commits July 10, 2025 19:04
As this isn't effectively providing any value to the driver, instead
wastes cycles on every sample-fetch. Scrubbing this simplifies the
code.

Also, remove fix_sign() and replace it for the in-tree helper
sign_extend().

Signed-off-by: Luis Ubieda <luisf@croxel.com>
To easily further extend it to other transports and be able to
implement streaming mode.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
In order to allow decoupling these two operations.
No functional changes, sensor returns same readings through shell.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
One-shot reads are now supported through the v2 model API.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
Supported for DRDY interrupts.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
@ubieda ubieda force-pushed the bmm350/read-decode-support branch from da85146 to 045ce56 Compare July 12, 2025 04:09
Copy link

@ubieda ubieda requested a review from bperseghetti July 12, 2025 16:02
@ubieda ubieda marked this pull request as ready for review July 12, 2025 16:02
@github-actions github-actions bot added the area: Sensors Sensors label Jul 12, 2025
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.

2 participants