libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
io_input.bas
Go to the documentation of this file.
1 
14 
15 ' include libpruio
16 #INCLUDE ONCE "BBB/pruio.bi"
17 
18 
19 ' ***** main *****
20 
21 VAR io = NEW PruIo
22 
23 WITH *io
24  DO ' pseudo loop, just to avoid GOTOs
25  IF .Errr THEN ?"initialisation failed (" & *.Errr & ")" : EXIT DO
26 
27 ' transfer default settings to PRU and start in IO mode
28  IF .config() THEN ?"config failed (" & *.Errr & ")" : EXIT DO
29 
30  ?" . | . | . | . |"
31  ?:?:?:?:?
32  VAR x = POS() _
33  , y = CSRLIN() - 5
34  DO ' print current state (until keystroke)
35  LOCATE y, x, 0
36  ?BIN(.Gpio->Raw(0)->Mix, 32) ' GPIOs 0 - 3
37  ?BIN(.Gpio->Raw(1)->Mix, 32)
38  ?BIN(.Gpio->Raw(2)->Mix, 32)
39  ?BIN(.Gpio->Raw(3)->Mix, 32)
40  ?HEX(.Adc->Value[1], 4) & " " & _ ' AIN 0 - 7
41  HEX(.Adc->Value[2], 4) & " " & _
42  HEX(.Adc->Value[3], 4) & " " & _
43  HEX(.Adc->Value[4], 4) & " " & _
44  HEX(.Adc->Value[5], 4) & " " & _
45  HEX(.Adc->Value[6], 4) & " " & _
46  HEX(.Adc->Value[7], 4) & " " & _
47  HEX(.Adc->Value[8], 4);
48  LOOP UNTIL LEN(INKEY())
49  ?
50  LOOP UNTIL 1
51 END WITH
52 
53 DELETE io ' reset ADC, PinMux and GPIOs, clear memory
54 
55 '' help Doxygen to document the main code
56 '&/** The main function. */
57 '&int main() {PruIo::PruIo(); PruIo::config(); PruIo::~PruIo();}
58