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

Data reading from an STM32 pin with Python. #909

Open
andresbove opened this issue Sep 30, 2022 · 8 comments
Open

Data reading from an STM32 pin with Python. #909

andresbove opened this issue Sep 30, 2022 · 8 comments

Comments

@andresbove
Copy link

Hi! I'm working with an STM32MP157F-DK2, it has a microprocessor A7 that's running Linux. I need to read the voltage of one of the pins. The pin configuration for the Analogical to Digital conversion it's made with the Linux terminal in the STM32.

How do I write in the Python code the order to "extract" the digitalized data from the kernell?

@tfcollins
Copy link
Contributor

Not sure if libiio is the right place for your question. Does your ADC have an IIO driver? If you don't know you should probably reach out to ST's support.

-Travis

@andresbove
Copy link
Author

@tfcollins
Copy link
Contributor

I would start here then: https://analogdevicesinc.github.io/libiio/v0.24/python/index.html

-Travis

@andresbove
Copy link
Author

Thank you very much!

@andresbove
Copy link
Author

andresbove commented Oct 4, 2022

If I want to use the Python Bindings in libiio for accessing and using the data of the ADC, do I must do it with the "buffer"? Following the hierarchy, should I create an "context" and a "device"? Like in this code:

https://analogdevicesinc.github.io/libiio/v0.20/python/_modules/iio_readdev.html#DataReader

Now, how do I tell the application what to read? Is the "device" the STM32 ADC pin?

@tfcollins
Copy link
Contributor

IIO apps follow the hierarchy by creating a context, then find a device, and manipulate those device's channels.

Here is a basic example of an Analog Devices transceiver https://github.com/analogdevicesinc/plutosdr_scripts/blob/master/pluto.py

You should follow a similar flow.

-Travis

@andresbove
Copy link
Author

So, for the context creation can I use ctx=iio.LocalContext and link all the devices that I'm going to use to that context? Because I think that I don't need a context working with an IP address

And for the "device part" could be something like this?
ctrl = ctx.find_device("48003000.adc:adc@0")
Following the below picture:

image

@tfcollins
Copy link
Contributor

ctx = iio.Context() is the same as ctx = iio.LocalContext().

find_device looks at the name device attribute. Which would be 48003000.adc:adc@0 is your case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants