forked from mattvenn/machinekit-bipod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·99 lines (83 loc) · 2.88 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
# Copyright 2013
# Charles Steinkuehler <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
export PATH=$PATH:/usr/local/bin/
dtbo_err () {
echo "Error loading device tree overlay file: $DTBO" >&2
exit 1
}
pin_err () {
echo "Error exporting pin:$PIN" >&2
exit 1
}
dir_err () {
echo "Error setting direction:$DIR on pin:$PIN" >&2
exit 1
}
SLOTS=/sys/devices/bone_capemgr.*/slots
# Make sure required device tree overlay(s) are loaded
for DTBO in cape-universal ; do
if grep -q $DTBO $SLOTS ; then
echo $DTBO overlay found
else
echo Loading $DTBO overlay to $SLOTS
sudo -A su -c "echo $DTBO > $SLOTS" || dtbo_err
sleep 1
fi
done;
#if [ ! -r /sys/devices/ocp.*/helper.*/AIN0 ] ; then
# echo Analog input files not found in /sys/devices/ocp.*/helper.* >&2
# exit 1;
#fi
# Export GPIO pins:
# One pin needs to be exported to enable the low-level clocks for the GPIO
# modules (there is probably a better way to do this)
#
# Any GPIO pins driven by the PRU need to have their direction set properly
# here. The PRU does not do any setup of the GPIO, it just yanks on the
# pins and assumes you have the output enables configured already
#
# Direct PRU inputs and outputs do not need to be configured here, the pin
# mux setup (which is handled by the device tree overlay) should be all
# the setup needed.
#
# Any GPIO pins driven by the hal_bb_gpio driver do not need to be
# configured here. The hal_bb_gpio module handles setting the output
# enable bits properly. These pins _can_ however be set here without
# causing problems. You may wish to do this for documentation or to make
# sure the pin starts with a known value as soon as possible.
sudo $(which config-pin) -f - <<- EOF
P9.11 in # e stop
P9.12 in # reset/user
P9.13 out # gondola charge
P9.24 uart # serial
P9.26 uart # serial
P9.15 out # ystep
P9.16 out # y dir
P9.17 out # x step
P9.18 out # x dir
P9.14 out # enable
P9.21 in # home x
P9.22 in # home y
P9.42 pwm # 7 segment
EOF
# interrupt on p9.12 button press
sudo -A su -c "echo rising > /sys/class/gpio/gpio60/edge"
if [ ! -r /sys/class/uio/uio0 ] ; then
echo PRU control files not found in /sys/class/uio/uio0 >&2
exit 1;
fi