libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
sos.bas
Go to the documentation of this file.
1 
16 
17 
18 ' include libpruio
19 #INCLUDE ONCE "BBB/pruio.bi"
20 
21 
22 #DEFINE PIN 24
23 
24 #DEFINE OUT_K .Gpio->setValue(PIN, pinmode + 128) : SLEEP 150 _
25  : .Gpio->setValue(PIN, pinmode) : SLEEP 100
26 
27 #DEFINE OUT_L .Gpio->setValue(PIN, pinmode + 128) : SLEEP 350 _
28  : .Gpio->setValue(PIN, pinmode) : SLEEP 100
29 
30 #DEFINE OUT_S OUT_K : OUT_K : OUT_K : SLEEP 150
31 
32 #DEFINE OUT_O OUT_L : OUT_L : OUT_L : SLEEP 150
33 
34 ' ***** main *****
35 
36 
37 'VAR io = NEW PruIo(PRUIO_ACT_FREMUX OR PRUIO_ACT_GPIO1)
38 VAR io = NEW PruIo()
39 
40 WITH *io
41  DO
42  IF .Errr THEN ?"initialisation failed (" & *.Errr & ")" : EXIT DO
43 
44  VAR pinmode = .BallConf[PIN]
45 
46  IF .config(1, 0) THEN ?"config failed (" & *.Errr & ")" : EXIT DO
47 
48  ?"watch SOS code on user LED 3 (near ethernet connector)"
49  ?
50  ?"execute the following command to get rid of mmc1 triggers"
51  ?" sudo su && echo none > /sys/class/leds/beaglebone:green:usr3/trigger && echo 0 > /sys/class/leds/beaglebone:green:usr3/brightness && exit"
52  ?
53  ?"press any key to quit"
54  DO ' print current state (until keystroke)
55  ?!"S"; : OUT_S : IF .Errr THEN ?"blink failed (" & *.Errr & ")": EXIT DO
56  ?!"O"; : OUT_O
57  ?!"S"; : OUT_S
58  ?!"\r \r"; : SLEEP 1500
59  LOOP UNTIL LEN(INKEY()) : ?
60  if .Gpio->setValue(PIN, pinmode) then _ ' reset LED (cosmetic)
61  ?"reset failed (" & *.Errr & ") press any key to quit" : SLEEP
62  LOOP UNTIL 1
63 END WITH
64 
65 DELETE io ' reset ADC, PinMux and GPIOs, clear memory
66 
67 '' help Doxygen to document the main code
68 '&/** The main function. */
69 '&int main() {PruIo::PruIo(); PruIo::config(); GpioUdt::setValue(); PruIo::~PruIo();}
70