I don't have my Neo yet, but I'd like to know about the ADC/PWM API that you offer from the A9 end. I know I could write an arduino sketch and flash it however I want to program the M4 from python. I see that you can use files for reading/writing to GPIOs, but what about the PWM/ADC/UART/SPI? I am looking at exposing all of these in Python. Also, would it be possible to make a debugger sort of application for step execution of code on the M4? It's great to have a real debugger, but I want expose functions like digitalRead/Write, analogRead/Write in python and step-execute over them. And when I upload a program from the A9 to M4, does the binary reside on the M4 and run independent of the A9? If so, it leads me to believe I'll need an interpreter running on the M4 to do step-execution. Thanks!
Hi there psypi, for what concerns ADC there are the usual Linux tools, like Code: /sys/bus/iio/devices/iio\:device0/in_voltage0_raw Similar for PWM and other features you want to use on Linux. You need for the moment to recompile the device tree to assign this feature to A9. On Python so you can use the files contained in these standard folders.
Regarding M4 you have to go for the standard Arduino programming. Obviously if you find something tell us: sharing is the basis of each community!
Ok, so if I am building upon the M4 core, I will have to use Arduino CLI to program it!? That's certainly not the best option! I'm waiting to receive my Neo so I can explore the /arduino-x.x/hardware/arduino/avr/cores/arduino directory. Hope to find something relevant there. I think it'll be /arduino/M4/cores/arduino /usr/share/arduino/hardware/udoo/sam/variants/udooneo because it has been ported to M4! Reason I was seeking support here is because I am developing an application on a different platform(pcDuino) to be delivered by month-end, but now I want to port & ship it with the Neo instead of pcDuino.
Hi there psypi, very happy you're choosing Neo for your application! We are working to make M4 Arduino-compatible. So you'll be able to use the Arduino IDE to program M4 and to use PWM and so on.
Awesome!! As mentioned in the first post, I am hoping to make all hardware features accessible through Python! Don't know how it's going to happen, still dont have my board :/ Thinking aloud, I guess the C API (probably in the /arduino/M4/cores/arduino directory) for M4 is used by the Arduino IDE to compile & upload. If I want to port it to Python, would it be possible to just use ctypes to access all the functions? I wonder why nobody has tried this, or maybe my Googling skills are too bad
I was looking on Google too and didn't find anything of use to me. I decided to create my own library for python, which it currently just goes through the sys files and modifies the values for GPIO, Accelerometer, Magnometer, Temp sensor, Barometer Sensor and Gyroscope. I would love making it more efficient by using i2c directly, but would need some help on that. I hope this is what you are looking for... Here is the link to the Repo
Thanks for the repo link, David! This sure helps a bit, but I can already do GPIO in many ways. I am looking at ADCs and PWM API... And for those who like JS, there's also the Node.js API.
I spent a couple of hours on trying to add PWM to the library without (Some say) recompiling the kernel for PWM output for each user. Instead I tried using imx-utils, which has devregs and you can manually enter the device regs for GPIO, PWM, i2c, etc... devregs is able to change values/read them, only problem is that I don't know the GPIO and PWM regs on this. I already tried the built in keys like PWM1_.... or PWM2_..., but nothing worked when trying 30 different pins. I also want to implement my Gyro, Accelerometer and Magnometer through devregs i2c port so I can read the data faster, because there's a delay just reading the files that the kernel writes. I was wondering if anyone knows where to look? or Has anyone else been able to get PWM on the Neo without arduino IDE (Cortex)? Worst case scenario, people are going to have to use Memory Mapped files for the GPIO and manually make PWM
Yes, I noticed that PWM code Explore here for implementation of Arduino functions: Code: /usr/share/arduino/hardware/udoo/sam/variants/udooneo Cheers!
Thanks David for the Python Neo GPIO library!! Saves me a lot of work as noob in Python, Linux etc. Just to be sure: It connects to the A9 (outer) Pins , not the Arduino (inner)ones?
No Problem and No, It connects to every pin available, Event the inner pins. If you want me to I can change it where you can modify a single pin at a time. If you are planning to use arduino IDE and Neo,GPIO don't set both (Arduino and Neo) to output and high for a single pin because that will damage the board. Here is an image of the library physical mapping. If you're not planning on using some special arduino features, just upload the minimal sketch so that you are safe.
I want to use Python for programming the external bank GPIO and Arduino IDE for the internal bank. If I decide to use the outerbank GPIO I will modify the your Neo.py library myself and only use the ports I need. Your picture is not conform http://www.udoo.org/docs-neo/Hardware_&_Accessories/Gpio.html port 40-47 are outerbank ports (just for someone else not damage his board )
We're going to release a tool for configuring in a simple way (without compiling kernel dtb) the external pinout assigned to A9. Example: PWM. Regarding ADC we're going to release an easy way to use them from A9 but nevertheless you'll have to turn off M4
There is a couple of ways to use python and i2c, i2c-tools has a a module to use; https://github.com/groeck/i2c-tools/tree/master/py-smbus And https://pypi.python.org/pypi/smbus-cffi
I see you guys have something that I was thinking would work but only accepts 0 or 1 at /sys/class/leds/led0/brightness, would this be similar to what the new tool will supply for the GPIO's for PWM
The tool I was talking about is the device tree editor. You can find it under Preferences--->Device Tree editor For example you can use PWM under Cortex A9. Regarding ADC instead you need to shut down the M4 modifying /boot/uEnv.txt file