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

drivers: sensor: adxl367: Added RTIO stream #80610

Merged

Conversation

vladislav-pejic
Copy link
Contributor

@vladislav-pejic vladislav-pejic commented Oct 30, 2024

Updated ADXL367 driver with RTIO stream functionality. RTIO stream is using both FIFO threshold and FIFO full triggers. Together with RTIO stream, RTIO async read is also implemented. Supported FIFO_CHANNEL configurations:

  • XYZ
  • X
  • Y
  • Z
  • XYZT
  • XT
  • YT
  • ZT
    Configurations with external ADC are currently not supported.

Signed-off-by: Vladislav Pejic [email protected]

if (IS_ENABLED(CONFIG_ADXL367_STREAM)) {
adxl367_stream_irq_handler(drv_data->dev);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Likely this should be in the block ifdefs below, where STREAM is an option for trigger handling.

Unclear how this would operate with both streaming and a work/thread trigger being called out. Likely problematic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are processing different IRQs (stream is expecting FIFO full or FIFO watermark and trigger is expecting Data ready or Activity threshold) so if both are enabled it should work ok. If for example, Data ready is triggered, stream code would call RTIO to read STATUS register (when callback is triggered it would determine that IRQ is not for the stream and do nothing) and adxl367_thread_cb would do the processing of that IRQ. Similar thing would happen when FIFO full would trigger (stream would do the processing and adxl367_thread_cb would do nothing). This is just my opinion. I could be wrong.

drivers/sensor/adi/adxl367/adxl367_stream.c Outdated Show resolved Hide resolved
drivers/sensor/adi/adxl367/adxl367_stream.c Outdated Show resolved Hide resolved
drivers/sensor/adi/adxl367/adxl367_stream.c Outdated Show resolved Hide resolved
drivers/sensor/adi/adxl367/adxl367_stream.c Outdated Show resolved Hide resolved
@ttmut
Copy link
Collaborator

ttmut commented Oct 30, 2024

What platform are you testing this on? I am getting a usage fault with MAX32690 somewhere in spi_max32.c when using streaming mode. Trigger mode works fine.

My build command is:

foo@bar:~$ west build -p -b max32690fthr/max32690/m4 samples/sensor/accel_polling -- -DCONFIG_ADXL367_STREAM=y -DCONFIG_SENSOR_ASYNC_API=y -DCONFIG_SPI_RTIO=y

Devicetree modification:

feather_spi: &spi0 {
	status = "okay";
	pinctrl-0 = <&spi0b_mosi_p2_28 &spi0b_miso_p2_27 &spi0b_sck_p2_29 &spi0b_ss1_p2_26>;
	pinctrl-names = "default";

	adxl367: adxl367@1 {
		compatible = "adi,adxl367";
		reg = <0x1>;
		int1-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
		spi-max-frequency = <1000000>;
		odr = <0>;
		status = "okay";
	};
};

@vladislav-pejic
Copy link
Contributor Author

What platform are you testing this on? I am getting a usage fault with MAX32690 somewhere in spi_max32.c when using streaming mode. Trigger mode works fine.

My build command is:

foo@bar:~$ west build -p -b max32690fthr/max32690/m4 samples/sensor/accel_polling -- -DCONFIG_ADXL367_STREAM=y -DCONFIG_SENSOR_ASYNC_API=y -DCONFIG_SPI_RTIO=y

Devicetree modification:

feather_spi: &spi0 {
	status = "okay";
	pinctrl-0 = <&spi0b_mosi_p2_28 &spi0b_miso_p2_27 &spi0b_sck_p2_29 &spi0b_ss1_p2_26>;
	pinctrl-names = "default";

	adxl367: adxl367@1 {
		compatible = "adi,adxl367";
		reg = <0x1>;
		int1-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
		spi-max-frequency = <1000000>;
		odr = <0>;
		status = "okay";
	};
};

I am using apard32690 (also MAX32690). Regarding build command you do not need DCONFIG_ADXL367_STREAM. It will be set automatically with Kconfig.

There are couple of bugs in the original part of a driver. One of them is causing exception when SPI driver with RTIO is used. I made another PR with bug fixes so please check #80617.

@vladislav-pejic vladislav-pejic force-pushed the adi_adxl367_rtio_stream branch 2 times, most recently from 1858798 to 4eb21c2 Compare October 31, 2024 11:50
@ttmut
Copy link
Collaborator

ttmut commented Oct 31, 2024

What platform are you testing this on? I am getting a usage fault with MAX32690 somewhere in spi_max32.c when using streaming mode. Trigger mode works fine.
My build command is:

foo@bar:~$ west build -p -b max32690fthr/max32690/m4 samples/sensor/accel_polling -- -DCONFIG_ADXL367_STREAM=y -DCONFIG_SENSOR_ASYNC_API=y -DCONFIG_SPI_RTIO=y

Devicetree modification:

feather_spi: &spi0 {
	status = "okay";
	pinctrl-0 = <&spi0b_mosi_p2_28 &spi0b_miso_p2_27 &spi0b_sck_p2_29 &spi0b_ss1_p2_26>;
	pinctrl-names = "default";

	adxl367: adxl367@1 {
		compatible = "adi,adxl367";
		reg = <0x1>;
		int1-gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
		spi-max-frequency = <1000000>;
		odr = <0>;
		status = "okay";
	};
};

I am using apard32690 (also MAX32690). Regarding build command you do not need DCONFIG_ADXL367_STREAM. It will be set automatically with Kconfig.

There are couple of bugs in the original part of a driver. One of them is causing exception when SPI driver with RTIO is used. I made another PR with bug fixes so please check #80617.

I will check that out, thanks.

@vladislav-pejic vladislav-pejic force-pushed the adi_adxl367_rtio_stream branch 8 times, most recently from 39fa785 to 51adfed Compare November 1, 2024 13:46
Updated ADXL367 driver with RTIO stream functionality.
RTIO stream is using both FIFO threshold and FIFO full triggers.
Together with RTIO stream, RTIO async read is also implemented.
Supported FIFO_CHANNEL configurations:
- XYZ
- X
- Y
- Z
- XYZT
- XT
- YT
- ZT
Configurations with external ADC are currently not supported.

Signed-off-by: Vladislav Pejic <[email protected]>
@vladislav-pejic
Copy link
Contributor Author

vladislav-pejic commented Nov 22, 2024

@teburd Can you please take a look at latest changes?

@MaureenHelm MaureenHelm added this to the v4.1.0 milestone Nov 22, 2024
write_status_addr->flags = RTIO_SQE_TRANSACTION;
rtio_sqe_prep_read(read_status_reg, data->iodev, RTIO_PRIO_NORM, &data->status, 1, NULL);
read_status_reg->flags = RTIO_SQE_CHAINED;
rtio_sqe_prep_callback(check_status_reg, adxl367_process_status_cb, (void *)dev, NULL);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would recommend using rtio_sqe_prep_callback_no_cqe for all of these to avoid creating a completion that you don't actually care about, but not a blocker if the driver is working

@kartben kartben merged commit aad4c69 into zephyrproject-rtos:main Nov 22, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Sensors Sensors platform: ADI Analog Devices, Inc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants