GithubHelp home page GithubHelp logo

Configuring a hrtimer-trigger or buffered-trigger for iio-device and ODR in driver lower than actual ODR about st-mems-android-linux-drivers-iio HOT 12 CLOSED

lukasl277 avatar lukasl277 commented on September 26, 2024
Configuring a hrtimer-trigger or buffered-trigger for iio-device and ODR in driver lower than actual ODR

from st-mems-android-linux-drivers-iio.

Comments (12)

mariotesi avatar mariotesi commented on September 26, 2024 1

Hi,

the LSM6DSX driver in kernel mainline is supported by Linux community. It manage trigger events on FIFO through an hw IRQ line so you need to configure an interrupt line in your device tree. Something like that (this work for rpi 4, address 0x6b depends on SDA0):

		ism330dlc: ism330dlc@6b {
			compatible = "st,ism330dlc";
			reg = <0x6b>;
			interrupt-parent = <&gpio>;
			interrupts = <26 IRQ_TYPE_LEVEL_HIGH>;
			st,int-pin = <1>;
		};

This is the solution we suggested 2 weeks ago.

This is an off topic thread because the driver you mention is not in this repository being it maintained by Linux community. If you need more support on our products you are kindly invited to reach us on offical support

from st-mems-android-linux-drivers-iio.

rosterloh avatar rosterloh commented on September 26, 2024

@lukasl277 I'm try to do exactly the same thing. Do you ever find a solution?

from st-mems-android-linux-drivers-iio.

mariotesi avatar mariotesi commented on September 26, 2024

Hi,

the LSM6DSX driver in kernel mainline is supported by Linux community. It manage trigger events on FIFO through an hw IRQ line so you need to configure an interrupt line in your device tree. Something like that (this work for rpi 4, address 0x6b depends on SDA0):

		ism330dlc: ism330dlc@6b {
			compatible = "st,ism330dlc";
			reg = <0x6b>;
			interrupt-parent = <&gpio>;
			interrupts = <26 IRQ_TYPE_LEVEL_HIGH>;
			st,int-pin = <1>;
		};

from st-mems-android-linux-drivers-iio.

rosterloh avatar rosterloh commented on September 26, 2024

That is infact just what I have

lsm6dso@6a {
        compatible = "st,lsm6dso";
        reg = <0x6a>;
        interrupt-parent = <&gpio>;
        interrupts = <22 2>, <27 2>; // IRQ_TYPE_EDGE_FALLING
        st,drdy-int-pin = <1>;
};

When I try to read the device it is incredibly slow and and creating iio_buffers or triggers always fails to init

from st-mems-android-linux-drivers-iio.

lukasl277 avatar lukasl277 commented on September 26, 2024

I found out that you can't use the iio-trigger directory because there is none. So what you have to do is modprobe an hw trigger and an iio buffer have the right interrupt pins configured in your DT and enable your the buffer and channels later on in your iio-device directory. Then if u look in the /dev/i2c-x file there should be data coming in caused by the HW trigger.

from st-mems-android-linux-drivers-iio.

rosterloh avatar rosterloh commented on September 26, 2024

Thank @lukasl277 this what I tried but the buffer creation and assigning the trigger to the devices still fails in code

RCLCPP_INFO(get_logger(), "* Acquiring device %s", device.c_str());
iio_device *dev = iio_context_find_device(ctx, device.c_str());
if (!dev) {
  RCLCPP_ERROR(get_logger(), "Could not find %s device", device.c_str());
  continue;
}
sensor.dev_name = device.c_str();
sensor.device = dev;

RCLCPP_INFO(get_logger(), "* Initialising IIO streaming channels:");
std::ostringstream log_msg;
log_msg << "  ";
for (unsigned int i = 0; i < iio_device_get_channels_count(dev); ++i) {
  struct iio_channel *chn = iio_device_get_channel(dev, i);
  if (iio_channel_is_scan_element(chn)) {
    log_msg << iio_channel_get_id(chn) << ", ";
    sensor.channel_count++;
  }
}
RCLCPP_INFO(get_logger(), log_msg.str().c_str());
if (sensor.channel_count == 0) {
  RCLCPP_ERROR(get_logger(), "No scan elements found in device");
  continue;
}

sensor.channels = (iio_channel **)calloc(sensor.channel_count, sizeof *sensor.channels);
if (!sensor.channels) {
  RCLCPP_ERROR(get_logger(), "Channel array allocation failed");
  continue;
}
for (unsigned int i = 0; i < sensor.channel_count; ++i) {
  struct iio_channel *chn = iio_device_get_channel(sensor.device, i);
  if (iio_channel_is_scan_element(chn))
    sensor.channels[i] = chn;
  }

  sensor.trigger_name = trigger.c_str();
  RCLCPP_INFO(
    get_logger(), "* Acquiring trigger %s for device: %s", trigger.c_str(), device.c_str());
  sensor.trigger = iio_context_find_device(ctx, sensor.trigger_name);
  if (!sensor.trigger || !iio_device_is_trigger(sensor.trigger)) {
    RCLCPP_ERROR(get_logger(), "No trigger found (try setting up the iio-trig-hrtimer module)");
    continue;
  }
     
  RCLCPP_INFO(get_logger(), "* Enabling IIO streaming channels for buffered capture");
  for (unsigned int i = 0; i < sensor.channel_count; ++i) {
    iio_channel_enable(sensor.channels[i]);
  }

  RCLCPP_INFO(get_logger(), "* Enabling IIO buffer trigger");
  if (iio_device_set_trigger(sensor.device, sensor.trigger)) {
    RCLCPP_ERROR(get_logger(), "Could not set trigger");
    continue;
  }

  RCLCPP_INFO(get_logger(), "* Creating non-cyclic IIO buffers with %d samples", BUFFER_LENGTH);
  sensor.buffer = iio_device_create_buffer(sensor.device, BUFFER_LENGTH, false);
  if (!sensor.buffer) {
    RCLCPP_ERROR(get_logger(), "Could not create buffer");
    continue;
  }
}

image

from st-mems-android-linux-drivers-iio.

lukasl277 avatar lukasl277 commented on September 26, 2024

I found that this book helped me understand the iio framework more https://www.oreilly.com/library/view/linux-device-drivers/9781785280009/42be7f96-325c-423b-96ab-ceeddeb753c9.xhtml
You just have to accept the free trial. I covers basically everything around the topic. Sadly I don't know how else to help you. The only thing that could be of possibility is that you have the wrong i2c bus and interrupt pin configured in your DTS overlay.

from st-mems-android-linux-drivers-iio.

sunny52266 avatar sunny52266 commented on September 26, 2024

@rosterloh Did you manage to find a solution to this issue? I am facing the same issue.

from st-mems-android-linux-drivers-iio.

rosterloh avatar rosterloh commented on September 26, 2024

@sunny52266 I did not I'm afraid. My solution currently is to replace the IMU with one from a different vendor

from st-mems-android-linux-drivers-iio.

sunny52266 avatar sunny52266 commented on September 26, 2024

@rosterloh I found the solution. Apparently you need to configure the interrupts for the driver to be able to configure buffers and scan elements. otherwise it shows up as we were experiencing.

from st-mems-android-linux-drivers-iio.

rosterloh avatar rosterloh commented on September 26, 2024

Thanks @sunny52266 but as you can see from my post above on 2nd of Feb I've already configured the interrupts

from st-mems-android-linux-drivers-iio.

sunny52266 avatar sunny52266 commented on September 26, 2024

You have configured st,drdy-pin as per your post. Please also ensure if pin 26 of &gpio is connected to a gpio expander, you need to enable its interrupts too and config that as interrupt controller and define its int pin. Also pl follow:

Hi,
the LSM6DSX driver in kernel mainline is supported by Linux community. It manage trigger events on FIFO through an hw IRQ line so you need to configure an interrupt line in your device tree. Something like that (this work for rpi 4, address 0x6b depends on SDA0):

		ism330dlc: ism330dlc@6b {
			compatible = "st,ism330dlc";
			reg = <0x6b>;
			interrupt-parent = <&gpio>;
			interrupts = <26 IRQ_TYPE_LEVEL_HIGH>;
			st,int-pin = <1>;
		};

This is the solution we suggested 2 weeks ago.

This is an off topic thread because the driver you mention is not in this repository being it maintained by Linux community. If you need more support on our products you are kindly invited to reach us on offical support

from st-mems-android-linux-drivers-iio.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.