-
Notifications
You must be signed in to change notification settings - Fork 0
/
busdrivers
executable file
·60 lines (55 loc) · 1.04 KB
/
busdrivers
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
#!/bin/bash
#
# Script to enable i2c bus drive modules. It assumes the drivers are loaded in /etc/modules and present in /proc/modules
#
# BMP280 on id 0x76
# MPL3115 on id 060
if [ $UID != 0 ]
then
echo "Must be run as root"
exit
fi
BUS="/sys/bus/i2c/devices/i2c-1"
#BMP280ID="0x76"
#MP3115ID="0x60"
BH1750ID="0x23"
clean()
{
echo "Removing i2c drivers..."
if [ -n "$BMP280ID" ]
then
echo $BMP280ID > $BUS/delete_device
fi
if [ -n "$BMP280ID" ]
then
echo $MP3115ID > $BUS/delete_device
fi
if [ -n "$BH1750ID" ]
then
echo $BH1750ID > $BUS/delete_device
fi
}
install()
{
if grep bmp280_i2c /proc/modules > /dev/null
then
echo "BMP280 device enabled at $BMP280ID"
echo "bmp280 $BMP280ID" > $BUS/new_device
fi
if grep mpl3115 /proc/modules > /dev/null
then
echo "MP3115A2 device enabled at $MP3115ID"
echo "mpl3115 $MP3115ID" > $BUS/new_device
fi
if grep bh1750 /proc/modules > /dev/null
then
echo "BH1750 enabled on $BH1750ID"
echo "bh1750 $BH1750ID" > $BUS/new_device
fi
}
if [ "$1" == "clean" ]
then
clean
else
install
fi