libpruio  0.2
Input/Output driver for digital/analog lines on Beagleboard hardware
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
analyse.bas
Go to the documentation of this file.
1 /'* \file analyse.bas
2 \brief Example: analyse the subsystems configurations.
3 
4 This file contains an example on how to use libpruio to read the
5 configurations of the subsystems (initial and corrent). It creates a
6 PruIo structure containing the data and then prints out in a
7 human-readable form. You may 'borrow' some code for debugging purposes
8 in your code.
9 
10 Licence: GPLv3
11 
12 Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
13 
14 
15 Compile by: `fbc -w all analyse.bas`
16 
17 '/
18 
19 ' include libpruio
20 #INCLUDE ONCE "../pruio/pruio.bi"
21 '~ #INCLUDE ONCE "../pruio/pruio.bas"
22 ' include the convenience macros for header pins
23 #INCLUDE ONCE "../pruio/pruio_pins.bi"
24 ' include macros to print out register context
25 #INCLUDE ONCE "../pruio/pruio_out.bi"
26 
27  '* The type of the output (either Inint or Conf).
28 #define OUT_TYPE Init ' alternative: Conf
29 
30 ' ***** main *****
31 
32 VAR io = NEW PruIo '*< Create a PruIo structure, wakeup subsystems.
33 
34 WITH *io
35  IF .Errr THEN
36  ?"initialisation failed (" & *.Errr & ")"
37  ELSE
38 #IF __ALL_PINS__
39  BALL_OUT(OUT_TYPE)
40 #ELSE
41  ?"Header Pins:"
42  FOR i AS LONG = 0 TO UBOUND(P8_Pins)
43  ?" " & *.Pin(P8_Pins(i))
44  NEXT
45  FOR i AS LONG = 0 TO UBOUND(P9_Pins)
46  ?" " & *.Pin(P9_Pins(i))
47  NEXT
48 #ENDIF
49 
50  GPIO_OUT(OUT_TYPE)
51  ADC_OUT(OUT_TYPE)
52  PWMSS_OUT(OUT_TYPE)
53  END IF
54 END WITH
55 
56 DELETE io ' reset ADC, PinMux and GPIOs, clear memory
57 
58 '' help Doxygen to dokument the main code
59 '&/** The main function. */
60 '&int main() {PruIo::PruIo(); PruIo::~PruIo();}
61