Reading Arduino analog & digital inputs within the same runtime

On a PYNQ-Z1, what would be the easiest method for enabling reads from both analog & digital inputs on the Arduino shield within the same program/runtime?

Normally, if only interacting with analog pins A0…5, I would use the Arduino_Analog class. However, if I wanted to read/write any GPIO (by either making use of the Arduino_IO class or a MicroblazeLibrary instance for the iop_arduino IOP), a runtime error occurs.

I understand that this is because instantiating an Arduino_Analog or Arduino_IO object will attempt to load each respective class’s associated MicroBlaze program binary (i.e., “arduino_analog.bin” and “arduino_mailbox.bin”) into the Arduino IOP, and only one program may be actively loaded at any given time for a single IOP.

So what is the easiest course of action here if I, say, need a program loop to read an analog sensor value from A0 and transmit that value to another device via UART (connected to digital pins 0 & 1)?

Is there any solution (entirely in software, preferably) other than writing a custom IOP application in C that essentially uses the same code as arduino_analog.c for interfacing w/ the XADC while also wrapping the UART API defined in uart.h? Or would even this not be feasible for the single Arduino IOP?

This is a very frequently asked question. Yes your understanding is correct. The example class we provided only supports 1 module each time; if users want to use many modules at the same time, they either have to write their own C program, or use Ipython microblaze to write C program in jupyter notebook (e.g. PYNQ/microblaze_c_libraries.ipynb at image_v2.6.0 · Xilinx/PYNQ · GitHub).