For the Arduino interface, you can use the MicroblazeLibrary class to create a wrapper object in Python that exposes the functions implemented in the PYNQ UART API (in ‘uart.c’). Here’s a very basic example of its usage:
from pynq import Overlay
from pynq.lib import MicroblazeLibraryUART_RXD = 0 ## Arduino pin 0 is RXD
UART_TXD = 1 ## Arduino pin 1 is TXDbase = Overlay(‘base.bit’)
lib = MicroblazeLibrary(base.iop_arduino, [‘uart’])
uart = lib.uart_open(UART_TXD, UART_RXD)read_command = [0xDE, 0xAD, 0xBE, 0xEF]
uart.write(read_command, len(read_command)) ## Write an iterable list of bytesresponse = [0x00] * 4
uart.read(response, 4) ## Request a 4-byte responseuart.close()
I don’t believe either of the two Pmod PYNQ Microblaze IOPs have an AXI controller for UART, so Pmod UART may not be supported.