demo: Update GPIO based kernel crash trigger logic
[glsdk/util-scripts.git] / debug / ovcam.sh
1 #!/bin/bash
2 #set -x
4 usage()
5 {
6         echo -e "\t\t ovcam v1.0"
7         echo -e "\tUtility for reading/writing to OVcamera"
8         echo -e "\tOV camera uses SCCB (Serial Camera Control Bus)"
9         echo -e "\tfor read/write of registers which are 16bit addressed"
10         echo -e "\tThis uses SMbus protocol to emulate the master_xfer"
11         echo -e "\tUsage:-"
12         echo -e "\t    ovcam read | write <16bit address> [<value>]"
13         echo -e "\t        e.g. ovcam read  0x3003"
14         echo -e "\t        e.g. ovcam write 0x3005 0x20"
15         echo
16         exit
17 }
19 #ovcam [r|w] <addr> <val>
20 BUS=1
21 CHIP=0x30
22 if [ $# -le 1 -o $# -ge 4 ]; then
23         usage
24 fi
25 ADDR=$2
26 VAL=$3
28         addrlow=`printf "0x%02x" $(($ADDR & 0xff))`
29         addrhigh=`printf "0x%02x" $(($ADDR >> 8))`
30         i2cset -f -y $BUS $CHIP $addrhigh $addrlow $VAL i
31         if [ $1 = "read" ]; then
32                 i2cget -f -y $BUS $CHIP
33         fi