00001 <?php
00002
00003
00004 function fpga_read($addr) {
00005 $fpga = fopen('/dev/fpgaio', 'r');
00006 fseek ($fpga, $addr) ;
00007 $d = fread($fpga, 4);
00008 fclose($fpga);
00009 $regs=unpack('V*',$d);
00010 return $regs[1];
00011 }
00012 function fpga_write($addr,$data) {
00013 $fpga = fopen('/dev/fpgaio', 'w');
00014 fseek ($fpga, $addr) ;
00015 fwrite($fpga, chr($data & 0xff).chr(($data>>8) & 0xff).chr(($data>>16) & 0xff).chr(($data>>24) & 0xff));
00016 fclose($fpga);
00017 }
00018
00019
00020 function senspars_read($addr) {
00021 $sensorpars = fopen('/dev/sensorpars', 'r');
00022 fseek ($sensorpars, 4*$addr) ;
00023 $d = fread($sensorpars, 4);
00024 fclose($sensorpars);
00025 $regs=unpack('V*',$d);
00026 return $regs[1];
00027 }
00028
00029 function senspars_write($addr,$data) {
00030 $sensorpars = fopen('/dev/sensorpars', 'w');
00031 fseek ($sensorpars, 4*$addr) ;
00032 fwrite($sensorpars, chr($data & 0xff).chr(($data>>8) & 0xff).chr(($data>>16) & 0xff).chr(($data>>24) & 0xff));
00033 fclose($sensorpars);
00034 }
00035
00036
00037 $sensor_phase=0x40020;
00038 $sensor_clock=96000000;
00039 if ((fpga_read(0x70) & 0xf) != 3) {
00040 echo "it is not Elphel Model 354 camera";
00041 exit (-1);
00042 }
00043
00044 $current_phase=senspars_read(0x201);
00045 printf ("Curent sensor phase is 0x%x<br/>\n",$current_phase);
00046
00047 senspars_write(0x201,$sensor_phase);
00048 exit(0);
00049 senspars_write( 14,$sensor_clock);
00050 senspars_write( 0,3);
00051 $current_phase=senspars_read(0x201);
00052 printf ("Curent sensor phase is 0x%x<br/>\n",$current_phase);
00053 $current_phase=senspars_read(0x601);
00054 printf ("601-> 0x%x<br/>\n",$current_phase);
00055
00056 sleep (5);
00057 $img = file_get_contents("http://127.0.0.1:81/admin-bin/ccam.cgi?opt=*vhcxy&ww=2592&wh=1936&bit=8&iq=10&gam=60&rscale=1&bscale=1&sens=1.0&e=1&byr=3&csb=200&csr=200");
00058 ?>