Re: IRQ related query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Alex, 

Thank you so much for clarifying this. It surely explains why I couldn’t find any documentation on how to do that!!!

Seems like, taking this in account,  we are going to go the i2c route…

Thanks again



/Patrick

> On 30 Jul 2021, at 09:30, Alexandru Ardelean <ardeleanalex@xxxxxxxxx> wrote:
> 
> On Fri, Jul 30, 2021 at 11:03 AM <patrick@xxxxxxxxxxxxxx> wrote:
>> 
>> Alex,
>> 
>> Thank you so very much for your help, I browsed most of that
>> litterature already and the kernel side of it is very much covered,
>> understood and assimilated.
>> 
>> However my question is basically: How can I be alerted, for example
>> through a callback function, when an interruption occurs in the kernel
>> space and my daemon lives in userspace.
>> 
>> IRQ Occuring -------> Upper half of the interrupt(put the timestamp in
>> the buffer) ---------> Lower half of the interrupt handler (read data
>> and adds the timestamp in the buffer) -----------> ???? userspace
>> daemon (async callback of some description) that will write a log on
>> the HD.
>> 
>> I have everything up to the daemon part written and working, I seem to
>> understand that through libiio you can assign a trigger to a
>> particular channel or attribute but that is where I get stuck.
>> 
>> Litterature on the libiio (most notably its wiki) has a chapter on
>> triggers that is 4 lines long ... not very helpful to say the least.
>> 
>> iioinfo lists the devices present in the LSM6DSLTR (18 devices
>> including two triggers) and I have been unable to assign the triggers
>> to any device that they are not assigned to already (No such file or
>> directory) which I gather refer to the absence of the trigger
>> directory in the sysfs for that  particular device.
>> 
>> I also gather that the sysfs directory is, of course, slave to the
>> kernel device tree and that the creation of that part of the device
>> tree is made as the driver is loaded.
>> 
>> So there must be a way to alter that part of the sysfs filesystem by
>> asking the kernel driver to provision a device in the context to
>> implement the trigger directory so we can assign a trigger to it
>> 
>> second part will be to slave that trigger to an actual IRQ (42 in my
>> case - as listed in /proc/interrupts) and be alerted in the  userspace
>> daemon when a thresold has been reached in terms of either
>> acceleration or vibration ...
>> 
>> Well, this is the nuts and bolts of what I am trying to achieve. the
>> last part will be to write a few registers on the chip to configure
>> how and when IRQ will occur for any given integrated devices.
>> 
>> Sorry to be such a pain but I thnk my problem lies in the passage of
>> information from kernel space (very well documented) to the userspace
>> (could not find reasonable documention and/or C code examples on how
>> to achieve this)
>> 
>> Thnks again
>> 
>> /Patrick
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> Quoting Alexandru Ardelean <ardeleanalex@xxxxxxxxx>:
>> 
>>> On Thu, Jul 29, 2021 at 3:54 PM Patrick Regnouf
>>> <patrick@xxxxxxxxxxxxxx> wrote:
>>>> 
>>>> Hello,
>>>> 
>>> 
>>> [I did not hit Reply All on my first email]
>>> 
>>> Hey,
>>> 
>>> For libiio in particular, it's on Github:
>>> https://github.com/analogdevicesinc/libiio
>>> 
>>> I think you could raise some questions as issues there.
>>> 
>>> And there's also a wiki that can be browsed:
>>> https://wiki.analog.com/resources/tools-software/linux-software/libiio
>>> https://wiki.analog.com/resources/tools-software/linux-software/libiio_internals
>>> 
>>> Now, regarding IIO events support in libiio, I am not sure [at point
>>> in time] whether support is implemented.
>>> 
>>> But an example of getting events from IIO can be found here:
>>> https://github.com/torvalds/linux/blob/master/tools/iio/iio_event_monitor.c
>>> 
>>> The https://github.com/torvalds/linux/blob/master/tools/iio/  folder
>>> in the kernel should offer some basic bits about accessing IIO
>>> devices, and getting events [which can be driver IRQ events, or kernel
>>> IIO polling]
>>> 
>>> I was going to answer on the previous question that you raised, but I forgot.
>>> Apologies. It's been a busy week.
> 
> Wait, I'm confusing/mixing triggers and events [in my head].
> Apologies. I'm still processing the coffee I ingested 1-2h ago.
> 
> libiio supports triggers. But not events.
> 
> However, the driver for LSM6DSLTR (i.e. the one here
> drivers/iio/imu/st_lsm6dsx) doesn't register any IIO triggers.
> So, there's nothing for libiio [or any userspace tool] to hook into
> for triggers.
> 
> There's an IRQ handler and IRQ thread-handler, but nothing to link
> these to IIO framework triggers.
> This needs to be implemented in the driver.
> An example of how IIO kernel triggers should be implemented in the
> driver is in drivers/iio/accel/adxl372.c and drivers/iio/imu/adis***
> drivers.
> 
>>> 
>>> Alex
>>> 
>>>> Please someone tell me whether this is the right mailing list to
>>>> ask questions related to actually using libiio or actually please
>>>> point me in the right direction
>>>> 
>>>> To summarise I am looking for C source code that would capture an
>>>> IRQ emitted by an iio accelerometer (LSM6DSLTR) all of that using
>>>> libiio
>>>> 
>>>> I have successfully implemented a program that can read the x, y
>>>> and z axis but that means polling constantly. Not an option…  the
>>>> iio_device_set_trigger however returns “no such file or directory “
>>>> 
>>>> Thanks
>>>> 
>>>> /Patrick
>> 
>> 
>> 




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux