summaryrefslogtreecommitdiffstats
path: root/recipes-test/ddt-runner/files/scripts/bsc9132qds/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-test/ddt-runner/files/scripts/bsc9132qds/i2c')
-rwxr-xr-xrecipes-test/ddt-runner/files/scripts/bsc9132qds/i2c75
1 files changed, 75 insertions, 0 deletions
diff --git a/recipes-test/ddt-runner/files/scripts/bsc9132qds/i2c b/recipes-test/ddt-runner/files/scripts/bsc9132qds/i2c
new file mode 100755
index 0000000..c4acd8e
--- /dev/null
+++ b/recipes-test/ddt-runner/files/scripts/bsc9132qds/i2c
@@ -0,0 +1,75 @@
1#!/bin/sh
2# This script is used to test i2c interface for bsc9131rdb
3
4I2C_DETECT=`which i2cdetect`
5if [ "x$I2C_DETECT" != "x" ]; then
6 echo "PASS: i2cdetect found"
7else
8 echo "FAIL: i2cdetect not found"
9 exit 1
10fi
11
12I2C_SET=`which i2cset`
13if [ "x$I2C_SET" != "x" ]; then
14 echo "PASS: i2cset found"
15else
16 echo "FAIL: i2cset not found"
17 exit 1
18fi
19
20I2C_GET=`which i2cget`
21if [ "x$I2C_GET" != "x" ]; then
22 echo "PASS: i2cget found"
23else
24 echo "FAIL: i2cget not found"
25 exit 1
26fi
27
28if I2C_ADAPTERS=`$I2C_DETECT -l |wc -l`; then
29 echo "PASS: $I2C_ADAPTERS i2c adapters found"
30else
31 echo "FAIL: no i2c adapters found"
32 exit 1
33fi
34
35adapters=0
36while [ $adapters -lt $I2C_ADAPTERS ]
37do
38 $I2C_DETECT -y $adapters
39 if [ $? -ne 0 ]; then
40 echo "FAIL: detect i2c adapter $adapters fail"
41 else
42 echo "PASS: detect i2c adapter $adapters success"
43 fi
44 adapters=`expr $adapters + 1`
45 sleep 1
46done
47
48# Area of bus:i2c-0 addr:0x52 is free to read and write
49$I2C_SET -y 0 0x52 0 0x55
50if [ $? -eq 0 ]; then
51 echo "PASS: i2c_set -y 0 0x52 0 0x55 success"
52else
53 echo "FAIL: i2c_set -y 0 0x52 0 0x55 fail"
54fi
55
56num=`$I2C_GET -y 0 0x52 0 | grep -c '0x55'`
57if [ $num -eq 1 ]; then
58 echo "PASS: i2c_get -y 0 0x52 0 success"
59else
60 echo "FAIL: i2c_get -y 0 0x52 0 fail"
61fi
62
63$I2C_SET -y 0 0x52 0 0xaa
64if [ $? -eq 0 ]; then
65 echo "PASS: i2c_set -y 0 0x52 0 0xaa success"
66else
67 echo "FAIL: i2c_set -y 0 0x52 0 0xaa fail"
68fi
69
70num=`$I2C_GET -y 0 0x52 0 | grep -c '0xaa'`
71if [ $num -eq 1 ]; then
72 echo "PASS: i2c_get -y 0 0x52 0 success"
73else
74 echo "FAIL: i2c_get -y 0 0x52 0 fail"
75fi