Is it possible with libpruio to prepare some data to be shifted out at multiple pins simultaneously? The way I see it currently is host preparing some bytes for each pin, sending them to the PRU, and then it starts shifting the data out at a predefined rate (or shifting the data in, then informing the host CPU about new input data available).
When your GPIO pins are connected to multiple GPIO_SS, it’s not avoidable to face a latency between the settings.
But when all GPIO outputs (or inputs) are at the same GPIO_SS, they can get configured simultanuously. That’s up to 32 GPIO channels at once. That needs some expert understanding of the GPIO_SS internals.
In case of input you can check the GpioUdt::Raw(i)->Mix member variable to get all 32 input states at once.
In case of output you can either set the GpioUdt::DATAOUT member variable or better use the GpioUdt::SETDATAOUT and GpioUdt::CLEARDATAOUT member variables, and then transfer the new setting to the hardware registers, like it’s done in function GpioUdt::setGpioSs():
IF .DRam[0] > PRUIO_MSG_IO_OK THEN EXIT SUB
PruReady(1) ' wait, if PRU is busy (should never happen)
.DRam[5] = Conf(Indx)->OE
.DRam[4] = Conf(Indx)->SETDATAOUT
.DRam[3] = Conf(Indx)->CLEARDATAOUT
.DRam[2] = Conf(Indx)->DeAd + &h100
.DRam[1] = PRUIO_COM_GPIO_CONF SHL 24
In case of CLEAR/SET registers you’ll face one PRU cycle (1/200 MHz) between clearing and setting the states.
Ok, thank you.
And is it possible with libpruio to preload a bit sequence to be shifted out at a certain bit rate?
Like, shift out 11011001111100… at a certain pin.
The PRUSS have such a feature (no reason to wrap it by libpruio).
Find details in the AM335x PRU-ICSS Reference Guide in chapter
5.2.2.3.4.2 Shift Out
In shift out mode, data is shifted out of pru_r30[0] (PRU_DATAOUT) on every rising edge of pru_r30[1] (PRU_CLOCK). The shift rate is controlled by the effective divisor of two cascaded dividers applied to the 200-MHz clock.
I’m fine with my options being limited to fast PRU GPIO. But hardware support on two pins only is quite restrictive in my opinion. Does libpruio support similar software-based mode of operation for other PRU GPIO pins?
libpruio supports pinmuxing for all fast PRU-GPIO pins. Handling the pins state is the task of custom firmware (which can get loaded and started by libpruio).
There’re two PRUSS, one for libpruio (if needed) and the other for your custom firmware.
In example pruss_toggle libpruio measures the pulse train generated by custom firmware on the other PRU.
In example pruss_add libpruio is only used for loading and starting firmware (its main loop isn’t running).
So write your firmware for any PRU, loading and starting it by libpruio (CTOR configured to the other PRU). If you need libpruio features then start its main loop by calling PruIo::config() (running on the other PRU).