libpruio
0.2
Input/Output driver for digital/analog lines on Beagleboard hardware
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
sos.bas
Go to the documentation of this file.
1
/'* \file sos.bas
2
\brief Example: blink user LED 3.
3
4
This file contains an example on how to use libpruio to control the
5
user LED 3 (near ethernet connector) on the beaglebone board. It shows
6
how to unlock a CPU ball that is used by the system. And it shows how
7
to control the unlocked ball.
8
9
Licence: GPLv3
10
11
Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
12
13
14
Compile by: `fbc -w all sos.bas`
15
16
'/
17
18
19
' include libpruio
20
#INCLUDE ONCE
"../pruio/pruio.bi"
21
22
'* The CPU ball to control (user LED 3).
23
#DEFINE
PIN
24
24
'* Output a short blink.
25
#DEFINE
OUT_K .Gpio->setValue(
PIN
,
pinmode
+ 128) :
SLEEP 150
_
26
: .Gpio->setValue(
PIN
,
pinmode
) :
SLEEP 100
27
'* Output a long blink.
28
#DEFINE
OUT_L .Gpio->setValue(
PIN
,
pinmode
+ 128) :
SLEEP 350
_
29
: .Gpio->setValue(
PIN
,
pinmode
) :
SLEEP 100
30
'* Output a 'S' (short - short - short).
31
#DEFINE
OUT_S OUT_K : OUT_K : OUT_K :
SLEEP 150
32
'* Output an 'O' (long - long - long).
33
#DEFINE
OUT_O OUT_L : OUT_L : OUT_L :
SLEEP 150
34
35
' ***** main *****
36
37
VAR
io
=
NEW
PruIo
'*< Create a PruIo structure, wakeup subsystems.
38
39
WITH
*
io
40
DO
41
IF
.Errr
THEN ?
"initialisation failed ("
& *.Errr &
")"
:
EXIT DO
42
43
VAR
pinmode
= .BallConf[
PIN
]
'*< The current pinmode.
44
45
IF
.config()
THEN ?
"config failed ("
& *.Errr &
")"
:
EXIT DO
46
47
?
"watch SOS code on user LED 3 (near ethernet connector)"
48
?
49
?
"execute the following command to get rid of mmc1 triggers"
50
?
" sudo su && echo none > /sys/class/leds/beaglebone:green:usr3/trigger && exit"
51
?
52
?
"press any key to quit"
53
DO
' print current state (until keystroke)
54
?
!
"S"
; : OUT_S :
IF
.Errr
THEN ?
"blink failed ("
& *.Errr &
")"
:
EXIT DO
55
?
!
"O"
; : OUT_O
56
?
!
"S"
; : OUT_S
57
?
!
"\r \r"
; :
SLEEP 1500
58
LOOP UNTIL LEN
(
INKEY
()) :
?
59
.Gpio->setValue(
PIN
,
pinmode
)
' reset LED (cosmetic)
60
LOOP UNTIL 1
61
62
IF
.Errr
THEN ?
"press any key to quit"
:
SLEEP
63
END WITH
64
65
DELETE
io
' reset ADC, PinMux and GPIOs, clear memory
66
67
'' help Doxygen to dokument the main code
68
'&/** The main function. */
69
'&int main() {PruIo::PruIo(); PruIo::config(); GpioUdt::setValue(); PruIo::~PruIo();}
70
src
examples
sos.bas
Generated on Sun Oct 26 2014 16:53:02 for libpruio by
1.8.6