libpruio  0.2
Input/Output driver for digital/analog lines on Beagleboard hardware
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
io_input.bas
Go to the documentation of this file.
1 /'* \file io_input.bas
2 \brief Example: print digital and analog inputs.
3 
4 This file contains an example on how to use libpruio to print out the
5 state of the digital GPIOs and the analog input lines.
6 
7 Licence: GPLv3
8 
9 Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
10 
11 
12 Compile by: `fbc -w all io_input.bas`
13 
14 '/
15 
16 ' include libpruio
17 #INCLUDE ONCE "../pruio/pruio.bi"
18 
19 
20 ' ***** main *****
21 
22 VAR io = NEW PruIo '*< Create a PruIo structure, wakeup subsystems.
23 
24 WITH *io
25  DO ' pseudo loop, just to avoid GOTOs
26  IF .Errr THEN ?"initialisation failed (" & *.Errr & ")" : EXIT DO
27 
28 ' transfer default settings to PRU and start in IO mode
29  IF .config() THEN ?"config failed (" & *.Errr & ")" : EXIT DO
30 
31  ?" . | . | . | . |"
32  ?:?:?:?:?
33  VAR x = POS() _ '*< The cursor column for output.
34  , y = CSRLIN() - 5 '*< The cursor line for output.
35  DO ' print current state (until keystroke)
36  LOCATE y, x, 0
37  ?BIN(.Gpio->Raw(0)->Mix, 32) ' GPIOs 0 - 3
38  ?BIN(.Gpio->Raw(1)->Mix, 32)
39  ?BIN(.Gpio->Raw(2)->Mix, 32)
40  ?BIN(.Gpio->Raw(3)->Mix, 32)
41  ?HEX(.Adc->Value[1], 4) & " " & _ ' AIN 0 - 7
42  HEX(.Adc->Value[2], 4) & " " & _
43  HEX(.Adc->Value[3], 4) & " " & _
44  HEX(.Adc->Value[4], 4) & " " & _
45  HEX(.Adc->Value[5], 4) & " " & _
46  HEX(.Adc->Value[6], 4) & " " & _
47  HEX(.Adc->Value[7], 4) & " " & _
48  HEX(.Adc->Value[8], 4);
49  LOOP UNTIL LEN(INKEY())
50  ?
51  LOOP UNTIL 1
52 END WITH
53 
54 DELETE io ' reset ADC, PinMux and GPIOs, clear memory
55 
56 '' help Doxygen to dokument the main code
57 '&/** The main function. */
58 '&int main() {PruIo::PruIo(); PruIo::config(); PruIo::~PruIo();}
59