libpruio  0.0
AM33xx-PRU driver for digital input / output and analog input
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
1.c
Go to the documentation of this file.
1 /*! \file 1.c
2 \brief Example: minimal code for ADC input.
3 
4 This file contains an short and simple example for text output of the
5 analog input lines. It's designed for the description pages and shows
6 the basic usage of libpruio with a minimum of source code, translatable
7 between FreeBASIC and C.
8 
9 Licence: GPLv3
10 
11 Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
12 
13 
14 Compile by:
15 
16 gcc -Wall -o 1 1.c /usr/local/lib/freebasic/fbrt0.o -lpruio -L"/usr/local/lib/freebasic/" -lfb -lpthread -lprussdrv -ltermcap -lsupc++
17 
18 */
19 
20 
21 #include "stdio.h"
22 #include "../c_wrapper/pruio_c_wrapper.h" // include header
23 
24 int main(int argc, char **argv)
25 {
26  int i, n;
27  PruIo *io = pruio_new(0, 0x98, 0 ,1); // create new driver UDT
28  pruio_config(io, 0, 0x1FE, 0, 4, 0); // upload (default) settings, start IO mode
29 
30 /* now current ADC samples are available for AIN0 to AIN7 in array Value[] */
31 
32  for(n = 1; n <= 13; n++) { /* print some lines */
33  for(i = 1; i < 9; i++) /* all steps */
34  printf(" %4X", io->Value[i]); /* output one channel as hexadecimal */
35  printf("\n"); /* next line */
36  }
37 
38 /* we're done */
39 
40  pruio_destroy(io); // destroy driver structure
41  return 0;
42 } // end of main