libpruio
0.0
AM33xx-PRU driver for digital input / output and analog input
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:
13
14
fbc -w all io_input.bas
15
16
'/
17
18
'* include libpruio
19
#INCLUDE ONCE
"../pruio/pruio.bi"
20
21
22
' ***** main *****
23
24
VAR
io
=
NEW
PruIo
'*< create a PruIo structure, wakeup devices
25
26
WITH
*
io
27
DO
' pseudo loop, just to avoid GOTOs
28
IF
.Errr
THEN ?
"initialisation failed ("
& *.Errr &
")"
:
EXIT DO
29
30
' transfer default settings to PRU and start in IO mode
31
IF
.config()
THEN ?
"config failed ("
& *.Errr &
")"
:
EXIT DO
32
33
?
" . | . | . | . |"
34
?
:
?
:
?
:
?
:
?
35
VAR
x
=
POS
() _
36
,
y
=
CSRLIN
() - 5
37
DO
' print current state (until keystroke)
38
LOCATE
y
,
x
, 0
39
?BIN
(.Gpio[0].Stat, 32)
' GPIOs 0 - 3
40
?BIN
(.Gpio[1].Stat, 32)
41
?BIN
(.Gpio[2].Stat, 32)
42
?BIN
(.Gpio[3].Stat, 32)
43
?HEX
(.Value[1], 4) &
" "
& _
' AIN 0 - 7
44
HEX
(.Value[2], 4) &
" "
& _
45
HEX
(.Value[3], 4) &
" "
& _
46
HEX
(.Value[4], 4) &
" "
& _
47
HEX
(.Value[5], 4) &
" "
& _
48
HEX
(.Value[6], 4) &
" "
& _
49
HEX
(.Value[7], 4) &
" "
& _
50
HEX
(.Value[8], 4);
51
LOOP UNTIL LEN
(
INKEY
())
52
?
53
LOOP UNTIL 1
54
END WITH
55
56
DELETE
io
' reset ADC, PinMux and GPIOs, clear memory
57
src
examples
io_input.bas
Generated on Fri May 9 2014 14:29:16 for libpruio by
1.8.4