Commit 2409993f authored by Andrey Filippov's avatar Andrey Filippov
Browse files

Merge branch 'master' of git@git.elphel.com:Elphel/x393.git

parents 722e3aca 1cc2b47a
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -51,4 +51,3 @@ localparam DLY_LANE1_IDELAY = 72'h186c6c726c746a7173;
localparam          DLY_CMDA = 256'hd3d3dad2d1cccad2505050505050505050d4d1d1d2d2dbcad2cad3d4d2cacbd1;
localparam          DLY_CMDA = 256'hd3d3dad2d1cccad2505050505050505050d4d1d1d2d2dbcad2cad3d4d2cacbd1;
localparam         DLY_PHASE =   8'h34;
localparam         DLY_PHASE =   8'h34;
// localparam   DFLT_WBUF_DELAY =   4'h9;
// localparam   DFLT_WBUF_DELAY =   4'h9;
    
 No newline at end of file
+81 −37
Original line number Original line Diff line number Diff line
@@ -2046,7 +2046,7 @@ input mem mtd4 ram1
        self.x393_axi_tasks.write_control_register(base_addr + vrlg.MCNTRL_SCANLINE_MODE,          mode)
        self.x393_axi_tasks.write_control_register(base_addr + vrlg.MCNTRL_SCANLINE_MODE,          mode)




    def test_hispi_phases(self,num_sensor):
    def hispi_phases_adjust(self,num_sensor):
        """
        """
        Try to adjust phases
        Try to adjust phases
        @param num_sensor - sensor port number (0..3)
        @param num_sensor - sensor port number (0..3)
@@ -2070,7 +2070,7 @@ input mem mtd4 ram1
          value = 0
          value = 0
          count = 0
          count = 0


          for j in range(n):
          for i in range(n):


              # reset bits
              # reset bits
              thp_reset_flags(num_sensor)
              thp_reset_flags(num_sensor)
@@ -2078,7 +2078,14 @@ input mem mtd4 ram1
              barrel = (status>>14)&0xff
              barrel = (status>>14)&0xff
              barrel = (barrel>>(2*shift))&0x3
              barrel = (barrel>>(2*shift))&0x3


              print(str(barrel)+" ",end='')
              for j in range(4):
                v = (status>>14)&0xff
                v = (v>>(2*(3-j)))&0x3
                print(str(v),end='')

              print(".",end='')

              #print(str(barrel)+" ",end='')


          return barrel
          return barrel


@@ -2088,16 +2095,19 @@ input mem mtd4 ram1
            shift = shift*3
            shift = shift*3


            switched = False
            switched = False
            start = 0
            stop  = 0
            count = 0
            value = 0
            value = 0
            i1 = 0
            i2 = 0
            im = 0


            for i in range(16):
            for i in range(16):


                if (i==8):
                if (i==0):
                  phase0 += 0x4000
                  phase0 += 0x4000
                  print("| ",end='')

                if (i==8):
                  phase0 -= 0x4000
                  print("| ",end="")


                # set phase
                # set phase
                phase = phase0+((i%8)<<shift)
                phase = phase0+((i%8)<<shift)
@@ -2109,28 +2119,36 @@ input mem mtd4 ram1


                barrel = thp_read_flags(num_sensor,bitshift)
                barrel = thp_read_flags(num_sensor,bitshift)


                if i==0:
                if ((i==0)or(i==8)):
                  value = barrel
                  value = barrel

                  switched = False
                if i==8:
                else:
                  if not switched:
                  if (value!=barrel):
                    start = 0
                    if i<8:
                    count = 8

                if (i<8 and i!=0):
                  if value!=barrel:
                      if not switched:
                      if not switched:
                        switched = True
                        switched = True
                        value = barrel
                        i1 = i
                      else:
                        print("Unexpected phase shift at "+str(i))
                    else:
                    else:
                      if not switched:
                      if not switched:
                      count += 1
                        switched = True
                        value = barrel
                        i2 = i
                      else:
                        print("Unexpected phase shift at "+str(i))

            i1 = i1&0x7
            i2 = i2&0x7


                if i>=8:
            if (abs(i2-i1)<2):
                  if value==barrel:
              print("Error?")
                    count += 1


            print("")
            target_phase = phase0 + (i1<<shift)
            return [start,count]
            thp_set_phase(num_sensor,target_phase)

            return target_phase




        chn = num_sensor
        chn = num_sensor
@@ -2151,22 +2169,48 @@ input mem mtd4 ram1
        phase0 = 0x8000
        phase0 = 0x8000


        for i in range(4):
        for i in range(4):
          print("")
          print("D"+str(i))
          print("D"+str(i))
          res = thp_run(num_sensor,phase0,i,i)
          phase0 = thp_run(num_sensor,phase0,i,i)
          phase = ((res[0]+(res[1]>>1))%8)<<(3*i)
          phase0 += phase
          print("Updated phase = 0x"+"{:04x}".format(phase0))
          print("Updated phase = 0x"+"{:04x}".format(phase0))
          print("i = "+str(res[0])+"  count = "+str(res[1]))


          if (res[1]<2):
        print("Done")
            print("ERROR_D"+str(i))




        print("Done")


    def hispi_test_i2c_write(self,num_sensor):
      """
      Test i2c writes
      @param num_sensor - sensor port number (0..3)
      """

      for i in range(10000000):

        if (i%10000==0):
          print("iteration: "+str(i))

        fname = "/sys/devices/soc0/elphel393-sensor-i2c@0/i2c"+str(num_sensor)


        val = str(hex(0x8000+(i&0xfff)))


        f = open(fname,'w')
        f.write("mt9f002 0 0x31c0 "+val)
        f.close()

        #time.sleep(0.5)

        # initiate read
        f = open(fname,'w')
        f.write("mt9f002 0 0x31c0")
        f.close()

        # read
        f = open(fname,'r')
        res = int(f.read())
        f.close()

        if (res!=int(val,0)):
          print(res+" vs "+val)
          break