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.



Am Samstag, 13. Februar 2016 13:01:04 UTC+1 schrieb Davide Picchi:
>
> 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 
>  
>  int 
>  isleep(unsigned int mseconds) 
>  { 
>  fd_set set; 
>   struct timeval timeout; 
>   
>  /* Initialize the file descriptor set. */ 
>   FD_ZERO(&set); 
>   FD_SET(STDIN_FILENO, &set); 
>   
>   /* Initialize the timeout data structure. */ 
>  timeout.tv_sec = 0; 
>   timeout.tv_usec = mseconds * 1000; 
>   
>  return TEMP_FAILURE_RETRY(select(FD_SETSIZE, 
>  &set, NULL, NULL, 
>  &timeout)); 
>  } 
>   
>  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)); 
>  fflush(STDIN_FILENO); 
>  } 
>  tcsetattr(STDIN_FILENO, TCSANOW, &oldt); // reset terminal 
>   
>   printf("\n"); 
>  } 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(). 
> Parameters 
> 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??
>
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to