fpga/x359/test_scripts/reg_write.php

Go to the documentation of this file.
00001 <?php
00002 /*!***************************************************************************
00003 *! FILE NAME  : reg_read.php
00004 *! DESCRIPTION: switches between channels
00005 *! Copyright (C) 2008 Elphel, Inc
00006 *! -----------------------------------------------------------------------------**
00007 *!
00008 *!  This program is free software: you can redistribute it and/or modify
00009 *!  it under the terms of the GNU General Public License as published by
00010 *!  the Free Software Foundation, either version 3 of the License, or
00011 *!  (at your option) any later version.
00012 *!
00013 *!  This program is distributed in the hope that it will be useful,
00014 *!  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 *!  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 *!  GNU General Public License for more details.
00017 *!
00018 *!  You should have received a copy of the GNU General Public License
00019 *!  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 *! -----------------------------------------------------------------------------**
00021 *!  $Log: reg_write.php,v $
00022 *!  Revision 1.1  2008/06/23 08:11:58  dzhimiev
00023 *!  1. added more scripts for 10359 board
00024 *!
00025 *!  Revision 1.2  2008/06/16 07:43:58  dzhimiev
00026 *!  mcontr address range changed from 0x0820-0x082F to 0x0840-0x085F (for making extra channels)
00027 *!
00028 *!  Revision 1.1  2008/04/23 01:55:50  dzhimiev
00029 *!  1. added x359 files to src lists
00030 *!  2. x359 read/write DDR
00031 *!  3. x359 3 channels mux directly to out
00032 *!  4. x359 one channel through DDR and another directly frames switching at out
00033 *!
00034 */
00035 
00036 function send_i2c_4($a,$d) {
00037    $i2c  = fopen('/dev/xi2c16', 'w');
00038    fseek ($i2c, 2*$a) ;
00039    if ($w==1)    $res=fwrite($i2c, chr ($d));
00040    else          $res=fwrite($i2c, chr (floor($d/(256*256*256))).chr (($d - 256*256*256*floor($d/(256*256*256)))/(256*256)).chr (($d - 256*256*floor($d/(256*256)))/256).chr ($d - 256*floor($d/(256))) );
00041          
00042    fclose($i2c);
00043    return $res;
00044 }
00045 
00046 $adr=0x0000;
00047 $data=0x0000;
00048 
00049 printf("<pre>");
00050 
00051         foreach($_GET as $key=>$value) {
00052                 switch($key) {
00053                         case "adr"            : $adr=$value+0;        break;
00054                         case "data"           : $data=$value+0;       break;
00055                 }
00056         }
00057 
00058 send_i2c_4($adr,$data);
00059 
00060 switch($adr) {
00061                 case 0x835        : printf("\nSet channel to <font size=\"6\">$data</font>\n"); break;
00062                 default           : printf("Wrote \nAddress: 0x%04x\nData   : 0x%08x\n",$adr,$data);
00063 }
00064 
00065 printf("</pre>");
00066 
00067 ?>

Generated on Thu Aug 7 16:18:59 2008 for elphel by  doxygen 1.5.1