libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
1.c
Go to the documentation of this file.
1 
18 #include "stdio.h"
19 #include "libpruio/pruio.h" // include header
20 
22 int main(int argc, char **argv)
23 {
24  int i, n;
25  pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0);
26  if (pruio_config(io, 1, 0x1FE, 0, 4)){ // upload (default) settings, start IO mode
27  printf("config failed (%s)\n", io->Errr);}
28  else {
29 
30 /* now current ADC samples are available for AIN-0 to AIN-7 in array io->Adc->Value[] */
31  for(n = 1; n <= 13; n++) { // print some lines
32  for(i = 1; i < 9; i++) // all steps
33  printf(" %4X", io->Adc->Value[i]); // output one channel in hex
34  printf("\n"); // next line
35  }
36  }
37 /* we're done */
38 
39  pruio_destroy(io); /* destroy driver structure */
40  return 0;
41 }
VAR io
create new driver UDT
Definition: 1.bas:18
int main(int argc, char **argv)
The main function.
Definition: 1.c:22
UInt32 n
The counter for test cycles.
Definition: performance.bas:90
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo().
@ PRUIO_DEF_ACTIVE
Activate all subsystems.
Definition: pruio.h:531
VAR i
Start index.
Definition: rb_file.bas:62
Wrapper structure for PruIo.
Definition: pruio.h:550