libpruio  0.2
Input/Output driver for digital/analog lines on Beagleboard hardware
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
1.c
Go to the documentation of this file.
1 
19 #include "stdio.h"
20 #include "../c_wrapper/pruio.h" // include header
21 
23 int main(int argc, char **argv)
24 {
25  int i, n;
26  pruIo *io = pruio_new(PRUIO_DEF_ACTIVE, 0x98, 0, 1);
27  if (pruio_config(io, 1, 0x1FE, 0, 4)){ // upload (default) settings, start IO mode
28  printf("config failed (%s)\n", io->Errr);}
29  else {
30 
31 /* now current ADC samples are available for AIN-0 to AIN-7 in array io->Adc->Value[] */
32  for(n = 1; n <= 13; n++) { // print some lines
33  for(i = 1; i < 9; i++) // all steps
34  printf(" %4X", io->Adc->Value[i]); // output one channel in hex
35  printf("\n"); // next line
36  }
37  }
38 /* we're done */
39 
40  pruio_destroy(io); /* destroy driver structure */
41  return 0;
42 }
VAR i
The samples index.
Definition: triggers.bas:129
VAR io
create new driver UDT
Definition: 1.bas:21
adcUdt * Adc
pointer to ADC device structure
Definition: pruio.h:404
Wrapper structure for PruIo.
Definition: pruio.h:403
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
char * Errr
pointer for error messages
Definition: pruio.h:411
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo.
VAR n
The active channel number.
Definition: pwm_adc.bas:107
activate all devices
Definition: pruio.h:385
uint16 * Value
fetched ADC samples
Definition: pruio.h:133
int main(int argc, char **argv)
The main function.
Definition: 1.c:23
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().