00001 <?php
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 function sendi2c16($register_address,$d0=0) {
00020 $i2c = fopen('/dev/xi2c16', 'w');
00021 fseek ($i2c, 2*$register_address) ;
00022 fwrite($i2c, chr (floor($d0/256)).chr ($d0-256*floor($d0/256)));
00023 fclose($i2c);
00024 }
00025
00026 function i2cread16 ($start,$length=256) {
00027 $i2c = fopen('/dev/xi2c16', 'r');
00028 fseek ($i2c, 2*$start) ;
00029 $data = fread($i2c, 2*$length);
00030 fclose($i2c);
00031 $regs=unpack('n*',$data);
00032
00033 echo "<table>\n";
00034 for ($i=0; $i<$length; $i+=16){
00035 printf("<tr><td>%x</td>",$i);
00036 for ($j=1; $j<17; $j++){
00037 printf("<td>%x</td>",$regs[$i+$j]);
00038 }
00039 echo "</tr>\n";
00040 }
00041 echo "</table>\n";
00042 }
00043
00044 $sensorClock=96000000;
00045 $period=$_GET['period'];
00046 $fps=$_GET['fps'];
00047 $out=$_GET['out'];
00048 if ($period && is_numeric ($period)) $period=$period+0;
00049 else $period=1;
00050
00051 if ($fps && is_numeric ($fps)) $fps=$fps+0;
00052 if ($fps>0) $period= $sensorClock/$fps;
00053
00054 if ($out && is_numeric ($out)) $out=$out+0;
00055 else $out=0xb00000;
00056 fpga_write(0x70, 0xc000000);
00057
00058
00059 fpga_write(0x7a, $out);
00060
00061
00062
00063 fpga_write(0x7b, $period);
00064
00065 ?>