libpruio
0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
button2.bas
Go to the documentation of this file.
1
16
17
' include libpruio
18
#INCLUDE ONCE
"BBB/pruio.bi"
19
' include the convenience macros for header pins
20
#INCLUDE ONCE
"BBB/pruio_pins.bi"
21
22
23
#DEFINE
PIN P8_07
24
25
' ***** main *****
26
27
VAR
io
=
NEW
PruIo
28
29
WITH
*
io
30
DO
31
IF
.Errr
THEN ?
"initialisation failed ("
& *.Errr &
")"
:
EXIT DO
32
33
IF
.Gpio->config(PIN, PRUIO_GPIO_IN_0)
THEN
_
' configure pin
34
?
"GPIO configuration failed ("
& *.Errr &
")"
:
EXIT DO
35
36
IF
.config()
THEN
_
37
?
"config failed ("
& *.Errr &
")"
:
EXIT DO
38
39
DO
' print current state (until keystroke)
40
?
!
"\r"
& .Gpio->Value(PIN);
41
SLEEP 100
42
LOOP UNTIL LEN
(
INKEY
()) :
?
43
LOOP UNTIL 1
44
' The following line is optional, the DESTRUCTOR does the job by default
45
IF
.Gpio->config(PIN, PRUIO_PIN_RESET)
THEN
_
' re-configure pin
46
?
"pin re-configuration failed ("
& *.Errr &
")"
47
48
IF
.Errr
THEN ?
"press any key to quit"
:
SLEEP
49
END WITH
50
51
DELETE
io
' reset ADC, PinMux and GPIOs, clear memory
52
53
'' help Doxygen to document the main code
54
'&/** The main function. */
55
'&int main() {PruIo::PruIo(); GpioUdt::config(); PruIo::config(); GpioUdt::Value(); PruIo::~PruIo();}
56
src
examples
button2.bas
Generated on Thu May 11 2023 12:42:51 for libpruio by
1.9.1