Bug or error in the documentation of libpruio

I was reading carefully the following example taken from here:

file: button.c

define _GNU_SOURCE 1
#include “stdio.h”
#include <termios.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
#include “…/c_wrapper/pruio.h”
#include “…/c_wrapper/pruio_pins.h”

#define PIN P8_07

isleep(unsigned int mseconds)
fd_set set;
struct timeval timeout;

/* Initialize the file descriptor set. */

/* Initialize the timeout data structure. */
timeout.tv_sec = 0;
timeout.tv_usec = mseconds * 1000;

&set, NULL, NULL,

int main(int argc, char **argv)
pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1); // <= LOOK HERE

do {
if (io->Errr) {
printf(“initialisation failed (%s)\n”, io->Errr); break;}

if (pruio_config(io, 1, 0x1FE, 0, 4)) {
printf(“config failed (%s)\n”, io->Errr); break;}

struct termios oldt, newt; // make terminal non-blocking
tcgetattr( STDIN_FILENO, &oldt );
newt = oldt;
newt.c_lflag &= ~( ICANON | ECHO );
newt.c_cc[VMIN] = 0;
newt.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &newt);

while(!isleep(1)) { // run loop until keystroke
printf("\r%1X", pruio_gpio_Value(io, PIN));
tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // reset terminal

} while (0);

pruio_destroy(io); /* destroy driver structure */
return 0;

In the following line of code you can read that the value 0x98 is the second argument passed to the function.
BUT In the documentation I found that:

pruIo* pruio_new ( uint16 Act,

uint8 Av,

uint32 OpD,

uint8 SaD


Wrapper function for the constructor PruIo::PruIo().

Act mask for active subsystems and PRU number
Av avaraging for default steps (0 to 16, defaults to 0)
OpD open delay for default steps (0 to 0x3FFFF, defaults to 0x98)
SaD sample delay for default steps (0 to 255, defaults to 0)
the second argument of that function should be the parameter Av, which ranges [0-16]. the OpD is passed lately to the function.

Is there a problem in the documentation or somewhere else??

In the following line of code you can read that the value 0x98 is the second argument passed to the function:

pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1);

I forgot to point to the function in the text.

Hi Davide!

You’re right, thanks for reporting that bug. It’ll be fixed in next release. It’s a copy / paste, you can find it in all C examples. The effect is that the ADC runs faster than expected (no delay).


One thing more:

I looked into the dtc-overlay: libpruio-00A0.dts and the overlay seems to be only for beaglebone and beaglebone-black compatible.

I think you should add beaglebone-green as well.