Re: how to read info from ../iio/device/../iio:device0


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cheng Shi wrote:
Hi, Otavio Salvador
I have updated mxs_lradc.c in Linux-3.9.7 according to the two commits in https://community.freescale.com/thread/309351. The normal AD channels are working, and I can see their value with system command #cat in_temp9_raw etc. My question is how to read those values in my program. Are there any example code available? Thanks
BR
Cheng Shi
emtronix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The iio subsystem provides two ways to program the ADC and read the values:
- One-shot conversions performed by reading the files in /sys/bus/iio/devices/iio\:device0/
- Continuous conversions of a single channel at a time using the /dev/iio:device0 character device file
There is no other API. Nothing like an ioctl that would let you program the device and do multiple conversions and read the results with a single system call. So you need to write your own code to open the /sys/bus/iio/devices/iio\:device0/ files, read the contents, and convert them from ASCII to unsigned int for doing whatever your program needs to do with the values.
The iioutils package (http://sourceforge.net/projects/iioutils/) does all of this for you, so that's probably the best place to copy the code from.
There is some nice backgroud documentation for other processors and sensors on http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide and in Enabling input (sensor) access for ARM devices : Blueprints : Ubuntu.
There is also a libiio package (analogdevicesinc/libiio · GitHub) that adds a lot of syntactic sugar, but at the lower level doesn't do things differently than iioutils.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
are there any kernel API's for ADC??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Jonathan,
i have not much experience in Linux development and use imx6sx on sabreSd board.
I need to use ADC and followed Freescale documentation "imx6_Linux_Reference_Manual" and checked kernel configuration by menuconfig:
Device Drivers > Industrial I/O support> Analog to digital converters > Freescale vf610
This was already activated.
My problem is i can't see /sys/bus/iio directory.
This documentation speak about these directories:
/sys/devices/soc0/soc.1/2200000.aips-bus/2280000.adc/iio:device0:
/sys/devices/soc0/soc.1/2200000.aips-bus/2284000.adc/iio:device1:
These directories exist
/sys/devices/soc0/soc.0/2200000.aips-bus/2280000.adc/
/sys/devices/soc0/soc.0/2200000.aips-bus/2284000.adc/
But they don't contain iio directories.
Have you got an idea what this is due to?
Thank you for your help.
