#!/bin/sh # This script is used to test i2c bus functionality for cyclone5 board. if I2C_ADAPTERS=$(i2cdetect -l |wc -l); then echo "PASS: found $I2C_ADAPTERS i2c adapters" else echo "FAIL: no i2c adapters found" exit 1 fi if [ -z "$adapters" ]; then adapters=0 fi while [ $adapters -lt $I2C_ADAPTERS ] do i2cdetect -y -r $adapters if [ $? -ne 0 ]; then echo "FAIL: detect i2c adapter $adapters failed" else echo "PASS: detect i2c adapter $adapters success" fi ls -la /dev/ | grep i2c-$adapters if [ $? -ne 0 ]; then echo "FAIL: find i2c adapter $adapters as device failed" else echo "PASS: find i2c adapter $adapters as device success" fi i2cdump -f -y $adapters 0x03 if [ $? -ne 0 ]; then echo "FAIL: i2c dump on adapter $adapters failed" else echo "PASS: i2c dump on adapter $adapters success" fi adapters=`expr $adapters + 1` sleep 1 done