⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 l2_flens.c

📁 dz3000_51.0.0.4.rar
💻 C
📖 第 1 页 / 共 3 页
字号:
#include "general.h"
//patch3.02@richie@0410
// EV board definition
// patch4.4@andrew@M91H2_1    //update YGLiu code
#ifdef         M91H2        
 #define        IN1_CTL	  0x20    // GPIO 21, XBYTE[0x2032] bit 5
 #define        IN2_CTL	  0x80    // GPIO 23, XBYTE[0x2032] bit 7
 #define        ENA_CTL	  0x00    

 #define        FMA_CTL	  0x20    // GPIO 21, XBYTE[0x2032] bit 5
 #define        FMB_CTL	  0x80    // GPIO 23, XBYTE[0x2032] bit 7
 #define        FMCNT_CTL  0x40    // GPIO 22, XBYTE[0x2032] bit 6

 #define        PIC_CTL    0x04    // GPIO 34, XBYTE[0x2034] bit 2
 #define        SVC_CTL    0x00    // GPIO 35, XBYTE[0x2034] bit 3
 #define        PI_SENSE   0x08    // GPIO 35, XBYTE[0x2044] bit 3
 #define        UPPER_STEP 26      // Upper step of the lense
 #define        LOWER_STEP 0       // Lower step of the lense
#endif


#ifdef         RICOH4T16        
 #define        IN1_CTL	  0x01    // XBYTE[0x2B07] bit 0
 #define        IN2_CTL	  0x04    // GPIO 34, XBYTE[0x2034] bit 3
 #define        ENA_CTL	  0x10    // GPIO 36, XBYTE[0x2034] bit 4
#endif

#ifdef         VQAF        
 #define        IN1_CTL	  0x20    // GPIO 21, XBYTE[0x2032] bit 5
 #define        IN2_CTL	  0x80    // GPIO 23, XBYTE[0x2032] bit 7
#endif


void L2_InitLens(void) USING_0
{
  
  //PRINT_FRONT ("            Enter L2_InitLens Function \n");
#ifdef LensTest
  //Initializes Pattern generator
	XBYTE[0X203A] = XBYTE[0X203A] | 0x60;  //GPIO21 Output enable   
	XBYTE[0X2B07] = 0x01;			//set Mshutter enable by manual as enable signal
	XBYTE[0X2032] = XBYTE[0X2032] | 0x40;  //GPIO22 as shutter control signal
	XBYTE[0X2032] = XBYTE[0X2032] & 0xDF;  //GPIO21 as shutter control signal
	L2_OpenMShutter();
	XBYTE[0X20C0] = XBYTE[0X20C0] & 0x3F;  //Clear interrupt
	XBYTE[0X2B08] = 0x30;
#endif

//patch3.02@richie@0402 MN39472
#ifdef MNLENS
  XBYTE[0X2B07] = 0x01;			//set Mshutter enable by manual as enable signal
  XBYTE[0X203A] = XBYTE[0X203A] | 0xA0;  //Set GPIO21,23 output enable
//patch3.02@richie@0402
  XBYTE[0X203C] = XBYTE[0X203C] | 0x18;  //Set GPIO35,36 output enable

  XBYTE[0X2032] = XBYTE[0X2032] & 0xDF;  //Set GPIO21 = 0 
  XBYTE[0X2032] = XBYTE[0X2032] & 0x7F;  //Set GPIO23 = 0
  
  XBYTE[0X2034] = XBYTE[0X2034] & 0xF7;  //Set GPIO35 = 0 
  XBYTE[0X2034] = XBYTE[0X2034] & 0xEF;  //Set GPIO36 = 0

  XBYTE[0X2B08] = 0x5A;  				//Shutter early 
  L2_OpenMShutter();
#endif


//patch3.02@richie@0410
// patch4.4@andrew@M91H2_1    //update YGLiu code
#ifdef M91H2		  		// M91H2 Lens module
 { 
    XBYTE[0x203A] |= 0xe0; // output enable for GPIO21,22,23
	XBYTE[0x203C] &= 0xF7; // Set Gpio 35 input
    XBYTE[0x2B07] = 0x10; 
    XBYTE[0X2B08] = 0x9A;  				//Shutter early 
	XBYTE[0X292E] = 0x0A;	//Use I2C address[15] to keep the Iris position   
	L2_CloseMShutter();
	L2_WaitVD(0,1);
	L2_OpenMShutter();    
//Fine AF home position    
    L3_FindAFHome();
 }	
#endif 


#ifdef VQAF		  		//  Lens module
 { 
    XBYTE[0x203A] |= 0xA0; // output enable for GPIO21,23
    XBYTE[0x2B07] = 0x10; 
 //   XBYTE[0X2B08] = 0x9A;  				//Shutter early 
    L2_CloseMShutter();
	L2_WaitVD(0,1);
	L2_OpenMShutter();
    
 }	
#endif 
	

#ifdef RICOH4T16		  		// RICOH Lens module
 { 
    //GPIO 34,36, Mshutter output enable
    XBYTE[0X2008] = XBYTE[0X2008] | 0x10; //Mshutter Output enable  */ 
    XBYTE[0x203C] |= 0x14; // output enable for GPIO 34,36
    XBYTE[0X2B07] = 0x10;  //Set mshutter set by manual
    
    //XBYTE[0X2B08] = 0x00;  				//Shutter early 
    L2_CloseMShutter();
	L2_WaitVD(0,1);
	L2_OpenMShutter();
    
 }	
#endif 	

#ifdef RICOH4T10
 {
  UCHAR i, j, yvalue[1];
  //Initializes Pattern generator
  XBYTE[0X2093] = 0x01;
  XBYTE[0X2094] = 0x01;
  XBYTE[0X2095] = 0x00;
  XBYTE[0X2096] = 0x00;
  XBYTE[0X2097] = 0x00;

  XBYTE[0X209C] = 0x01;   		//Enable PG0 
  XBYTE[0X2008] = XBYTE[0X2008] | 0x10; //Mshutter Output enable  */ 
  XBYTE[0X203A] = XBYTE[0X203A] | 0xE0; //Output enable GPIO21,22,23
  XBYTE[0X203B] = XBYTE[0X203B] | 0x01; //Output enable GPIO24
  XBYTE[0X203C] = XBYTE[0X203C] & 0xF7; //To let GPIO 35 input 
  XBYTE[0X2032] = XBYTE[0X2032] & 0xBF; //Set GPIO22 = 0
  XBYTE[0X2033] = XBYTE[0X2033] & 0xFE; //Set GPIO24 = 0
  XBYTE[0X2B08] = 0x3A;  				//Shutter early  

  //Initial ZooM 
  /*
  XBYTE[0X2033] = XBYTE[0X2033] | 0x01;
  for (i = 0; i < 255;i++);  //delay
  L3_SetMotorCW(250);
  for (i = 0; i < 255;i++);  //delay
  XBYTE[0X2033] = XBYTE[0X2033] & 0xFE;
  */
  /* CCW
             L3_SetMotorStep(0, 0, 20);
	         L3_SetMotorStep(0, 1, 20);
             L3_SetMotorStep(1, 1, 20);
             L3_SetMotorStep(1, 0, 20);    
     CW
             L3_SetMotorStep(0, 0, 20);
	         L3_SetMotorStep(1, 0, 20);
             L3_SetMotorStep(1, 1, 20);
             L3_SetMotorStep(0, 1, 20);
  */
  XBYTE[0X2B07] = 0x11;			//set Mshutter enable by manual  
  L3_SetMotorStep(0, 1, 30);	// 3ms to add for first step  
  for (i = 0; i < 8;i++)     			// for CCW 32 Pulse
    {
      L3_SetMotorStep(0, 1, 20);
      L3_SetMotorStep(1, 1, 20);
      L3_SetMotorStep(1, 0, 20);
      L3_SetMotorStep(0, 0, 20);    
    }
   
  ////////////////////////////////////////////////////////////////////////////////  
  for (i = 0; i < 2;i++)     			// for CW 10 Pulse
    {
      L3_SetMotorStep(1, 0, 20);
      L3_SetMotorStep(1, 1, 20);
      L3_SetMotorStep(0, 1, 20);
      L3_SetMotorStep(0, 0, 20); 
    }  
  L3_SetMotorStep(1, 0, 20);
  L3_SetMotorStep(1, 1, 20); 
  
  ////////////////////////////////////////////////////////////////////////////////
  L3_SetMotorStep(1, 0, 20);			// for CCW 4 Pulse
  L3_SetMotorStep(0, 0, 20);
  L3_SetMotorStep(0, 1, 20);
  L3_SetMotorStep(1, 1, 20);  
  
  //Do CCW until the shutter close//////////////////////////////////////////////
  L3_SetMotorStep(1, 0, 20);  //Step  CCW
  L3_SetMotorStep(0, 0, 20);  //Step  CCW
  L2_WaitVD(0, 2);
  L2_ReadAEWindow(13, yvalue);
  L2_WaitVD(0, 2);
//  PRINT_FRONT ("Y Value = %d \n", (USHORT)yvalue[0]);
  for (i = 0; i<5 ; i++)
    {
     if (yvalue[0] < 0x3)
	   {
	     L3_SetMotorStep(0, 1, 20);
		 XBYTE[0X292E] = 0x02;//Use I2C address[15] to keep the stand phase
	     break;
       }
	 else
	  {          
	   L3_SetMotorStep(0, 1, 20);
       L2_WaitVD(0, 2);
       L2_ReadAEWindow(13, yvalue);
//	   PRINT_FRONT ("Y Value = %d \n", (USHORT)yvalue[0]);
	   if (yvalue[0] < 3)
	    {
	     L3_SetMotorStep(1, 1, 20);
		 XBYTE[0X292E] = 0x03;//Use I2C address[15] to keep the stand phase
	     break;
        }
	   else
 		{
         L3_SetMotorStep(1, 1, 20);
         L2_WaitVD(0, 2);
         L2_ReadAEWindow(13, yvalue);
//		 PRINT_FRONT ("Y Value = %d \n", (USHORT)yvalue[0]);
		 if (yvalue[0] < 3)
	      {
	        L3_SetMotorStep(1, 0, 20);
			XBYTE[0X292E] = 0x01;//Use I2C address[15] to keep the stand phase
	        break;
          }
	     else
		  {
           L3_SetMotorStep(1, 0, 20);
           L2_WaitVD(0, 2);
           L2_ReadAEWindow(13, yvalue);
//		   PRINT_FRONT ("Y Value = %d \n", (USHORT)yvalue[0]);
		   if (yvalue[0] < 3)
	        {
	         L3_SetMotorStep(0, 0, 20);
			 XBYTE[0X292E] = 0x00;//Use I2C address[15] to keep the stand phase
	         break;
            }
	       else
			{
             L3_SetMotorStep(0, 0, 20);
             L2_WaitVD(0, 2);
             L2_ReadAEWindow(13, yvalue);
//			 PRINT_FRONT ("Y Value = %d \n", (USHORT)yvalue[0]);
		     if (yvalue[0] < 3)
	          {
	           L3_SetMotorStep(0, 1, 20);
			   XBYTE[0X292E] = 0x02;//Use I2C address[15] to keep the stand phase
	           break;
              }
			}
		  }
		}
	  }
    }


  L3_SetMotorCW(2);    //Open shutter
  L3_SetMotorCCW(1);   //To Stand By position
  
  //To find the Max Iris position//////////////////////////////////////////////
  for (i=0; i<255; i++)
   {
     if ((XBYTE[0X2044] & 0x08) == 0x00)  //Photo interrupt = Low
	   break;
	 else
	  {
        L3_SetMotorCW(5);
		L3_SetMotorCCW(5);
		for (j=0; j<255; j++);//Delay		  
	  }
   }
  L2_WaitVD(0, 2);
  L2_ReadAEWindow(13, yvalue);

  XBYTE[0X2B07] = 0x10; //Disable Step Motor 
 }
#endif
//  PRINT_FRONT ("            Exit L2_InitLens Function \n");
}


/////////////////////////////////////////////////////////////////////////////////////////////////

UCHAR L2_WCShutter() USING_0
{ 
  USHORT i; 

  for (i =0; i <65535; i++)
   {
	if ((XBYTE[0x2AA1] & 0x01) == 0x00)
	  {
	   //PRINT_FRONT ("            Close Shutter \n");
	   return 0;
	  }
   }           
  return 1;   
}

UCHAR L2_WOShutter() USING_0
{ 
  USHORT i;  
  for (i =0; i <65535; i++)
   {
	if ((XBYTE[0x2AA1] & 0x01) == 0x01)
	 {
      //PRINT_FRONT ("            Open Shutter \n");
	  return 0;
	 }
   }           
  return 1;   
}


/////////////////////////////////////////////////////////////////////////////////////////////////
void L2_CloseMShutter(void) USING_0
{ 
//PRINT_FRONT ("            Enter L2_CloseMShutter Function \n");    
#ifdef LensTest
 { 
  UCHAR i;
  XBYTE[0X2032] = XBYTE[0X2032] | 0x40;
  for (i = 0; i < 10; i++);
  XBYTE[0X2032] = XBYTE[0X2032] | 0x20;  //GPIO21 as shutter control signal
 }
#endif
//patch3.02@richie@0402 MN39472
#ifdef MNLENS
  XBYTE[0X2032] = XBYTE[0X2032] | 0x20;  //Set GPIO21 = 1 
  XBYTE[0X2032] = XBYTE[0X2032] & 0x7F;  //Set GPIO23 = 0  
  XBYTE[0X2034] = XBYTE[0X2034] | 0x08;  //Set GPIO35 = 1 
  XBYTE[0X2034] = XBYTE[0X2034] & 0xEF;  //Set GPIO36 = 0

  L2_Wait(10);
  
  XBYTE[0X2032] = XBYTE[0X2032] & 0xDF;  //Set GPIO21 = 0 
  XBYTE[0X2032] = XBYTE[0X2032] & 0x7F;  //Set GPIO23 = 0
  
  XBYTE[0X2034] = XBYTE[0X2034] & 0xF7;  //Set GPIO35 = 0 
  XBYTE[0X2034] = XBYTE[0X2034] & 0xEF;  //Set GPIO36 = 0

#endif

//patch3.02@richie@0410
#ifdef M91H2		  		// M91H2 Lens module
 {   
  XBYTE[0X292C]  = XBYTE[0X292E];  //Save now position

  switch (XBYTE[0X292E])  //Get now position
    {
      case 10:L3_SetMotorCW(10);
		 	 break;
	  case 6 :L3_SetMotorCW(6); 
		 	 break;
	  case 5 :L3_SetMotorCW(5);                  
			 break;
	  case 4 :L3_SetMotorCW(4);            
			 break;
	  default : break;                 
    }  
 }	
#endif

#ifdef RICOH4T16		  		// RICOH Lens module
 {   
  XBYTE[0x2034] |= ENA_CTL; //Enable
  L3_SetMotorStep(1, 0, 50);
  L3_SetMotorStep(0, 0, 50);
  L3_SetMotorStep(1, 0, 50);
  L3_SetMotorStep(0, 0, 50);
  L3_SetMotorStep(1, 0, 50);
  L3_SetMotorStep(0, 0, 50);
  XBYTE[0x2034] &= ~ENA_CTL; //Disable    
 }	
#endif 	 	

#ifdef RICOH4T10		  		// Ricoh Lens module    
 {  
   UCHAR i;
   XBYTE[0X2B07] = 0x11;			// Set Mshutter enable by manual
   switch (XBYTE[0X292E])
    {
      case 0:L3_SetMotorStep(0, 0, 30);
		 	 break;
	  case 1:L3_SetMotorStep(1, 0, 30);           
		 	 break;
	  case 2:L3_SetMotorStep(0, 1, 30);                   
			 break;
	  case 3:L3_SetMotorStep(1, 1, 30);            
			 break;
	  default : break;                 
    }  
   L3_SetMotorCCW(1);
   for (i = 0; i<255; i++);         //Delay
   XBYTE[0X2B07] = 0x10;			// Set Mshutter enable by manual
 }
#endif
#ifdef RICOH4T12		  		// Ricoh Lens module    
 {  
   UCHAR i;
   XBYTE[0X2B07] = 0x11;			// Set Mshutter enable by manual
   switch (XBYTE[0X292E])
    {
      case 0:L3_SetMotorStep(0, 0, 30);
		 	 break;
	  case 1:L3_SetMotorStep(1, 0, 30);           
		 	 break;
	  case 2:L3_SetMotorStep(0, 1, 30);                   
			 break;
	  case 3:L3_SetMotorStep(1, 1, 30);            
			 break;
	  default : break;                 
    }
   L3_SetMotorCCW(1);
   for (i = 0; i<255; i++);         //Delay
   XBYTE[0X2B07] = 0x10;			// Set Mshutter enable by manual  
 }
#endif 

#ifdef VQAF		  		// Lens module    
 {  
   L3_SetMotorStep(1, 0, 200);
   L3_SetMotorStep(0, 0, 10);
 }
#endif 

//PRINT_FRONT ("            Exit L2_CloseMShutter Function \n");
}
/////////////////////////////////////////////////////////////////////////////////////////////////
void L2_OpenMShutter(void) USING_0
{   
// PRINT_FRONT ("            Enter L2_OpenMShutter Function \n"); 
#ifdef LensTest
 {
  UCHAR i, j;
  XBYTE[0X2032] = XBYTE[0X2032] & 0xDF;  //GPIO21 as shutter control signal
  for (i = 0; i < 15; i++)
    for (j = 0; j < 255; j++);
  XBYTE[0X2032] = XBYTE[0X2032] & 0xBF;
 }
#endif
//richie@0402 MN39472
#ifdef MNLENS
  XBYTE[0X2032] = XBYTE[0X2032] | 0x20;  //Set GPIO21 = 1 
  XBYTE[0X2032] = XBYTE[0X2032] & 0x7F;  //Set GPIO23 = 0  
  XBYTE[0X2034] = XBYTE[0X2034] & 0xF7;  //Set GPIO35 = 0 
  XBYTE[0X2034] = XBYTE[0X2034] | 0x10;  //Set GPIO36 = 1
  
  L2_Wait(5);
  
  XBYTE[0X2032] = XBYTE[0X2032] & 0xDF;  //Set GPIO21 = 0 
  XBYTE[0X2032] = XBYTE[0X2032] & 0x7F;  //Set GPIO23 = 0 
  XBYTE[0X2034] = XBYTE[0X2034] & 0xF7;  //Set GPIO35 = 0 
  XBYTE[0X2034] = XBYTE[0X2034] & 0xEF;  //Set GPIO36 = 0

#endif

//richie@0410
#ifdef M91H2		  		// M91H2 Lens module
 {   
   switch (XBYTE[0X292C])  //Get position of close
    {
      case 10:L3_SetMotorCCW(10); 
		 	 break;
	  case 6 :L3_SetMotorCCW(6); 
		 	 break;
	  case 5 :L3_SetMotorCCW(5);             
			 break;
	  case 4 :L3_SetMotorCCW(4);      
			 break;
	  default : break;                 
    } 
 }	
#endif 

#ifdef RICOH4T16		  		// RICOH Lens module
 {   
  XBYTE[0x2034] |= ENA_CTL; //Enable

   L3_SetMotorStep(0, 0, 50);
   L3_SetMotorStep(1, 0, 200);
   
   XBYTE[0x2034] &= ~ENA_CTL; //Disable
 }	
#endif 	 	

#ifdef RICOH4T10		  		// Ricoh Lens module    
 {   
    UCHAR i, j;
    XBYTE[0X2B07] = 0x11;			// Set Mshutter enable by manual
    switch (XBYTE[0X292E])
    {
      case 0:L3_SetMotorStep(0, 0, 30);
		 	 break;
	  case 1:L3_SetMotorStep(1, 0, 30);           
		 	 break;
	  case 2:L3_SetMotorStep(0, 1, 30);                   
			 break;
	  case 3:L3_SetMotorStep(1, 1, 30);            
			 break;
	  default : break;                 
    }
   L3_SetMotorCW(2);
   L3_SetMotorCCW(1);               //To stand position
   for (i = 0; i<255; i++);         //Delay
   XBYTE[0X2B07] = 0x10;			// Set Mshutter enable by manual
 }
#endif
#ifdef RICOH4T12		  		    // Ricoh Lens module  
 {  
   UCHAR i, j;
   XBYTE[0X2B07] = 0x11;			// Set Mshutter enable by manual
   switch (XBYTE[0X292E])
    {
      case 0:L3_SetMotorStep(0, 0, 30);
		 	 break;
	  case 1:L3_SetMotorStep(1, 0, 30);           
		 	 break;
	  case 2:L3_SetMotorStep(0, 1, 30);                   
			 break;
	  case 3:L3_SetMotorStep(1, 1, 30);            
			 break;
	  default : break;                 
    }
   L3_SetMotorCW(2);
   L3_SetMotorCCW(1);     
   for (i = 0; i<255; i++);         //Delay
   XBYTE[0X2B07] = 0x10;			// Set Mshutter enable by manual
 }
#endif 

#ifdef VQAF		  		// Lens module    
 {  
   L3_SetMotorStep(0, 1, 200);
   L3_SetMotorStep(0, 0, 10);
 }
#endif
//PRINT_FRONT ("            Exit L2_OpenMShutter Function \n"); 
}
/////////////////////////////////////////////////////////////////////////////////////////////////
UCHAR L2_SetIris(UCHAR Step) USING_0
{ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -