summaryrefslogtreecommitdiffstats
path: root/target/device/Atmel/atstk100x/target_skeleton/etc/init.d/S99gpio
blob: 7c07f280153345d37924b9d86ceb8a6d85e69f57 (plain)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh

echo -n "Get board type for GPIO: "
if [ ! -e "/etc/release" ]; then
	echo "missing";
	exit 1
fi

BOARD=`cat /etc/release | cut -d ' ' -f1`

if [ "${BOARD}" = "" ]; then
	echo "none";
elif [ "${BOARD}" = "NGW" ]; then
	echo "'${BOARD}'"

	echo -n "  boot LED: "
	if mkdir /config/gpio/bootled > /dev/null 2> /dev/null; then
		if ! echo 0 > /config/gpio/bootled/gpio_id; then
			echo "failed"
			exit 1
		fi

		if ! echo 0x10000 > /config/gpio/bootled/pin_mask; then
			echo "failed"
			exit 1
		fi

		if ! echo 0x10000 > /config/gpio/bootled/oe_mask; then
			echo "failed"
			exit 1
		fi

		if ! echo 1 > /config/gpio/bootled/enabled; then
			echo "failed"
			exit 1
		fi

		if ! echo 0x10000 > /dev/gpio0; then
			echo "failed"
			exit 1
		fi

		echo "done"
	else
		echo "failed"
		exit 1
	fi

	echo -n "  LED A: "
	if mkdir /config/gpio/leda > /dev/null 2> /dev/null; then
		if ! echo 0 > /config/gpio/leda/gpio_id; then
			echo "failed"
			exit 1
		fi

		if ! echo 0x80000 > /config/gpio/leda/pin_mask; then
			echo "failed"
			exit 1
		fi

		if ! echo 0x80000 > /config/gpio/leda/oe_mask; then
			echo "failed"
			exit 1
		fi

		if ! echo 1 > /config/gpio/leda/enabled; then
			echo "failed"
			exit 1
		fi

		if ! echo 0 > /dev/gpio1; then
			echo "failed"
			exit 1
		fi

		echo "done"
	else
		echo "failed"
		exit 1
	fi

	echo -n "  LED B: "
	if mkdir /config/gpio/ledb > /dev/null 2> /dev/null; then
		if ! echo 4 > /config/gpio/ledb/gpio_id; then
			echo "failed"
			exit 1
		fi

		if ! echo 0x80000 > /config/gpio/ledb/pin_mask; then
			echo "failed"
			exit 1
		fi

		if ! echo 0x80000 > /config/gpio/ledb/oe_mask; then
			echo "failed"
			exit 1
		fi

		if ! echo 1 > /config/gpio/ledb/enabled; then
			echo "failed"
			exit 1
		fi

		if ! echo 0 > /dev/gpio2; then
			echo "failed"
			exit 1
		fi

		echo "done"
	else
		echo "failed"
		exit 1
	fi
elif [ "${BOARD}" = "STK1000" ]; then # end NGW
	echo "'${BOARD}'"

	echo -n "  switches: "
	if mkdir /config/gpio/switches > /dev/null 2> /dev/null; then
		if ! echo 1 > /config/gpio/switches/gpio_id; then
			echo "failed"
			exit 1
		fi

		if ! echo 0xff > /config/gpio/switches/pin_mask; then
			echo "failed"
			exit 1
		fi

		if ! echo 1 > /config/gpio/switches/enabled; then
			echo "failed"
			exit 1
		fi

		echo "done"
	else
		echo "failed"
		exit 1
	fi
else # end STK1000
	echo "'${BOARD}'"
	echo "  WARNING: no GPIO for this board"
fi