Look at the kernel source under tools/iio for examples on how to use IIO.

Regards,
John





> On Mar 27, 2018, at 12:10 PM, pierrick.ra...@gadz.org wrote:
> 
> Hi John, 
> 
> Sorry for the late answer, I had hard time using the PRUs and I am now going 
> to use the IIO ADC driver, I am able to read the sample with the cat command 
> in /sys/bus/iio/devices/iio:device0/in_voltage3_raw 
> However I am not able to use Libiio in order to read data from a user space 
> application, I am reading (nil) instead of my data. Do you have any idea of 
> where does the problem comes from ? 
> 
> Here is the code I am using in the user space :
> 
> 
> #define _BSD_SOURCE
> #define _GNU_SOURCE
> #define _DEFAULT_SOURCE
> 
> #include <cdk/cdk.h>
> #include <locale.h>
> #include <pthread.h>
> #include <stdbool.h>
> #include <unistd.h>
> #include <stdint.h>
> #include <stdio.h>
> #include <string.h>
> 
> #ifdef __APPLE__
> #include <iio/iio.h>
> #else
> #include <iio.h>
> #endif
> 
> struct iio_context *ctx;
> struct iio_device *dev;
> struct iio_channel *ch;
> 
> int main()
> {
>   ctx = iio_create_default_context();
>   dev = iio_context_get_device(ctx, 0);
>   ch = iio_device_get_channel(dev, 3);
> 
> 
>   iio_device_attr_write_longlong(dev, "sample_rate", 100);
>   iio_channel_attr_write_double(ch, "scale", 1);
> 
>   iio_channel_enable(ch);
> 
>   char *a = iio_device_get_data(dev);
>   printf("%p\n", a);
> 
>   iio_channel_disable(ch);
> 
>   return 0;
> }
> 
> Thanks 
> 
> Pierrick 
> 
> 
> Le lundi 26 février 2018 16:46:11 UTC-5, john3909 a écrit :
> The IIO ADC driver can run at 800K samples per second. Here is the patch that 
> made that possible. 
> 
> https://patchwork.kernel.org/patch/9391487/ 
> <https://patchwork.kernel.org/patch/9391487/>
> 
> I can confirm that I have tested the driver at 800Ksps and it works fine as 
> long as you have a proper low impedance source for each ADC channel. CPU 
> utilization was about 5% if I recall and that was probably used by the iiod 
> daemon, which I used to display the waveform on a remote Linux app. 
> 
> There is example code in the original Starterware for McSPI, which should 
> work fine if you are using the PRU low level drivers. 
> 
> Regards,
> John
> 
> 
> 
> 
>> On Feb 26, 2018, at 12:56 PM, pierric...@gadz.org <> wrote:
>> 
>> Thanks John, 
>> 
>> I am now working with the starterware_PRU but i did not find examples for 
>> using the McSPI with the PRU, do you think it will be hard to adapt the 
>> initial code to the PRU ? 
>> By the way, looking to the IIO driver documentation, it seems that for the 
>> AM335x chip the max sampling rate is only 200k samples per second which may 
>> not be enough :
>> http://processors.wiki.ti.com/index.php/Linux_Core_ADC_Users_Guide 
>> <http://processors.wiki.ti.com/index.php/Linux_Core_ADC_Users_Guide> ; am I 
>> right ? 
>> 
>> 
>> Thanks 
>> 
>> Pierrick 
>> 
>> Le lundi 19 février 2018 23:15:50 UTC-5, john3909 a écrit :
>> Like I said, it was based on Starterware, so search Github for starterware 
>> and you will see a project starterware_PRU. It does use the mcspi, so it is 
>> not a bitbang implementation. 
>> 
>> Regards,
>> John
>> 
>> 
>> 
>> 
>>> On Feb 19, 2018, at 7:33 PM, pierric...@gadz.org <> wrote:
>>> 
>>> Thanks John for you answer, I was quit busy last week so I worked on this 
>>> during the Weekend. 
>>> 
>>> Unfortunately, I was not able to find a project that is using the SPI and 
>>> I2C interface with the PRU, I only found this one : 
>>> https://github.com/chanakya-vc/PRU-I2C_SPI_master/wiki/SPI-Master-Controller
>>>  
>>> <https://github.com/chanakya-vc/PRU-I2C_SPI_master/wiki/SPI-Master-Controller>
>>>  
>>> But it is using bit banging for the SPI part and not using the on-board 
>>> pull-up resistors for the I2C part.
>>> 
>>> Concerning the ADC, I'll have a loook at the UIIO drivers in the coming 
>>> days it seems that it meets my need in term of real-time acquisition. 
>>> 
>>> Regards,
>>> 
>>> Pierrick 
>>> 
>>> -- 
>>> For more options, visit http://beagleboard.org/discuss 
>>> <http://beagleboard.org/discuss>
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "BeagleBoard" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to beagleboard...@googlegroups.com <>.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/beagleboard/74949832-b67c-430f-811e-f3b2fff83852%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/beagleboard/74949832-b67c-430f-811e-f3b2fff83852%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>> For more options, visit https://groups.google.com/d/optout 
>>> <https://groups.google.com/d/optout>.
>> 
>> 
>> -- 
>> For more options, visit http://beagleboard.org/discuss 
>> <http://beagleboard.org/discuss>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BeagleBoard" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to beagleboard...@googlegroups.com <>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/beagleboard/3dc611e5-04e7-45bb-87d4-3c21a5665cec%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/beagleboard/3dc611e5-04e7-45bb-87d4-3c21a5665cec%40googlegroups.com?utm_medium=email&utm_source=footer>.
>> For more options, visit https://groups.google.com/d/optout 
>> <https://groups.google.com/d/optout>.
> 
> 
> -- 
> For more options, visit http://beagleboard.org/discuss 
> <http://beagleboard.org/discuss>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BeagleBoard" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to beagleboard+unsubscr...@googlegroups.com 
> <mailto:beagleboard+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/beagleboard/18b69929-99ca-4e7e-8539-df962a17941d%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/beagleboard/18b69929-99ca-4e7e-8539-df962a17941d%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to beagleboard+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/816B512E-0E78-4D10-8300-61836C189B0C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to