libpruio  0.0
AM33xx-PRU driver for digital input / output and analog input
 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.
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 sos.bas
15 
16 '/
17 
18 '* include libpruio
19 #INCLUDE ONCE "../pruio/pruio.bi"
20 
21 #DEFINE PIN 24 '' CPU ball # of user led 3
22 #DEFINE OUT_K .gpio_out(PIN, 1) : SLEEP 250 : .gpio_out(PIN, 0) : SLEEP 150
23 #DEFINE OUT_L .gpio_out(PIN, 1) : SLEEP 750 : .gpio_out(PIN, 0) : SLEEP 150
24 #DEFINE OUT_S OUT_K : OUT_K : OUT_K : SLEEP 250
25 #DEFINE OUT_O OUT_L : OUT_L : OUT_L : SLEEP 250
26 
27 ' ***** main *****
28 
29 VAR io = NEW PruIo '*< create a PruIo structure, wakeup devices
30 WITH *io
31  DO
32  IF .Errr THEN ?"initialisation failed (" & *.Errr & ")" : EXIT DO
33  IF .gpio_set(PIN, PRUIO_OUT0, PRUIO_UNLOCK_NEW) THEN _
34  ?"pin configuration failed (" & *.Errr & ")" : EXIT DO
35  IF .config() THEN _
36  ?"config failed (" & *.Errr & ")" : EXIT DO
37  ?"watch SOS code on user LED 3 (near ethernet connector)"
38  ?
39  ?"execute the following command to get rid of mmc1 triggers"
40  ?" sudo su && echo none > /sys/class/leds/beaglebone:green:usr3/trigger && exit"
41  ?
42  ?"press any key to quit"
43  DO ' print current state (until keystroke)
44  OUT_S
45  OUT_O
46  OUT_S
47  SLEEP 1500
48  LOOP UNTIL LEN(INKEY())
49  LOOP UNTIL 1
50  .gpio_out(PIN, 0) ' shut off LED
51  IF .gpio_set(PIN, , PRUIO_LOCK_ORIG) THEN _ ' re-configure CPU ball
52  ?"pin re-configuration failed (" & *.Errr & ")"
53 
54  IF .Errr THEN ?"press any key to quit" : SLEEP
55 END WITH
56 
57 DELETE io ' reset ADC, PinMux and GPIOs, clear memory
58