//******************************************************************************** // Function Name : AutoGainControlSw // Retun Value : NON // Argment Value : 0 :OFF 1:ON // Explanation : Select Gyro Signal Function // History : First edition 2010.11.30 Y.Shigeoka //******************************************************************************** void AutoGainControlSw( unsigned char UcModeSw ) { if( UcModeSw == OFF ) { RegWriteA( GADJGANGXMOD, 0xE0 ); // 0x012B X exe off RegWriteA( GADJGANGYMOD, 0xE0 ); // 0x012C Y exe off RamWrite32A( GANADR , XMAXGAIN ) ; // Gain Through RamWrite32A( GANADR | 0x0100 , YMAXGAIN ) ; // Gain Through } else { RegWriteA( GADJGANGXMOD, 0xE7 ); // 0x012B X exe on RegWriteA( GADJGANGYMOD, 0xE7 ); // 0x012C Y exe on } }
//******************************************************************************** // Function Name : IniGfl // Retun Value : NON // Argment Value : NON // Explanation : Gyro Filter Initial Parameter Setting // History : First edition 2009.07.30 Y.Tashita //******************************************************************************** void IniGfl( void ) { unsigned short UsAryId ; // Gyro Filter Parameter Setting UsAryId = 0 ; while( CsGyrFil[ UsAryId ].UsRamAdd != 0xFFFF ) { RamWrite32A( CsGyrFil[ UsAryId ].UsRamAdd, CsGyrFil[ UsAryId ].UlRamDat ) ; UsAryId++ ; } }
//******************************************************************************** // Function Name : IniAdj // Retun Value : NON // Argment Value : NON // Explanation : Adjust Value Setting // History : First edition 2009.07.30 Y.Tashita //******************************************************************************** void IniAdj( void ) { RegWriteA( CMSDAC, BAIS_CUR ) ; // 0x0261 Hall Dac電流 RegWriteA( OPGSEL, AMP_GAIN ) ; // 0x0262 Hall amp Gain #ifdef USE_EXE2PROM unsigned short UsAdjCompF ; unsigned short UsAdjData ; unsigned long UlAdjData ; E2pRed( (unsigned short)ADJ_COMP_FLAG, 2, ( unsigned char * )&UsAdjCompF ) ; // Eeprom Read /* Hall Xaxis Bias,Offset */ if( (UsAdjCompF == 0x0000 ) || (UsAdjCompF & ( EXE_HXADJ - EXE_END )) ){ RamWriteA( DAHLXO, DAHLXO_INI ) ; // 0x1114 RamWriteA( DAHLXB, DAHLXB_INI ) ; // 0x1115 RamWriteA( ADHXOFF, 0x0000 ) ; // 0x1102 }else{ E2pRed( (unsigned short)HALL_OFFSET_X, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( DAHLXO, UsAdjData ) ; // 0x1114 E2pRed( (unsigned short)HALL_BIAS_X, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( DAHLXB, UsAdjData ) ; // 0x1115 E2pRed( (unsigned short)HALL_AD_OFFSET_X, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( ADHXOFF, UsAdjData ) ; // 0x1102 } /* Hall Yaxis Bias,Offset */ if( (UsAdjCompF == 0x0000 ) || (UsAdjCompF & ( EXE_HYADJ - EXE_END )) ){ RamWriteA( DAHLYO, DAHLYO_INI ) ; // 0x1116 RamWriteA( DAHLYB, DAHLYB_INI ) ; // 0x1117 RamWriteA( ADHYOFF, 0x0000 ) ; // 0x1105 }else{ E2pRed( (unsigned short)HALL_OFFSET_Y, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( DAHLYO, UsAdjData ) ; // 0x1116 E2pRed( (unsigned short)HALL_BIAS_Y, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( DAHLYB, UsAdjData ) ; // 0x1117 E2pRed( (unsigned short)HALL_AD_OFFSET_Y, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( ADHYOFF, UsAdjData ) ; // 0x1105 } /* Hall Xaxis Loop Gain */ if( (UsAdjCompF == 0x0000 ) || (UsAdjCompF & ( EXE_LXADJ - EXE_END )) ){ RamWriteA( lxgain, LXGAIN_INI ) ; // 0x132A }else{ E2pRed( (unsigned short)LOOP_GAIN_X, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( lxgain, UsAdjData ) ; // 0x132A } /* Hall Yaxis Loop Gain */ if( (UsAdjCompF == 0x0000 ) || (UsAdjCompF & ( EXE_LYADJ - EXE_END )) ){ RamWriteA( lygain, LYGAIN_INI ) ; // 0x136A }else{ E2pRed( (unsigned short)LOOP_GAIN_Y, 2, ( unsigned char * )&UsAdjData ) ; RamWriteA( lygain, UsAdjData ) ; // 0x136A } // X axis Optical Center Offset Read & Setting E2pRed( (unsigned short)OPT_CENTER_X, 2, ( unsigned char * )&UsAdjData ) ; if( ( UsAdjData != 0x0000 ) && ( UsAdjData != 0xffff )){ UsCntXof = UsAdjData ; /* Set Optical center X value */ } else { UsCntXof = OPTCEN_X ; /* Clear Optical center X value */ } RamWriteA( HXINOD, UsCntXof ) ; // 0x1127 // Y axis Optical Center Offset Read & Setting E2pRed( (unsigned short)OPT_CENTER_Y, 2, ( unsigned char * )&UsAdjData ) ; if( ( UsAdjData != 0x0000 ) && ( UsAdjData != 0xffff )){ UsCntYof = UsAdjData ; /* Set Optical center Y value */ } else { UsCntYof = OPTCEN_Y ; /* Clear Optical center Y value */ } RamWriteA( HYINOD, UsCntYof ) ; // 0x1167 /* Gyro Xaxis Offset */ E2pRed( (unsigned short)GYRO_AD_OFFSET_X, 2, ( unsigned char * )&UsAdjData ) ; if( ( UsAdjData == 0x0000 ) || ( UsAdjData == 0xffff )){ RamWriteA( ADGXOFF, 0x0000 ) ; // 0x1108 RegWriteA( IZAH, DGYRO_OFST_XH ) ; // 0x03A0 Set Offset High byte RegWriteA( IZAL, DGYRO_OFST_XL ) ; // 0x03A1 Set Offset Low byte }else{ RamWriteA( ADGXOFF, 0x0000 ) ; // 0x1108 RegWriteA( IZAH, (unsigned char)(UsAdjData >> 8) ) ; // 0x03A0 Set Offset High byte RegWriteA( IZAL, (unsigned char)(UsAdjData) ) ; // 0x03A1 Set Offset Low byte } /* Gyro Yaxis Offset */ E2pRed( (unsigned short)GYRO_AD_OFFSET_Y, 2, ( unsigned char * )&UsAdjData ) ; if( ( UsAdjData == 0x0000 ) || ( UsAdjData == 0xffff )){ RamWriteA( ADGYOFF, 0x0000 ) ; // 0x110B RegWriteA( IZBH, DGYRO_OFST_YH ) ; // 0x03A2 Set Offset High byte RegWriteA( IZBL, DGYRO_OFST_YL ) ; // 0x03A3 Set Offset Low byte }else{ RamWriteA( ADGYOFF, 0x0000 ) ; // 0x110B RegWriteA( IZBH, (unsigned char)(UsAdjData >> 8) ) ; // 0x03A2 Set Offset High byte RegWriteA( IZBL, (unsigned char)(UsAdjData) ) ; // 0x03A3 Set Offset Low byte } /* Gyro Xaxis Gain */ E2pRed( (unsigned short)GYRO_GAIN_X, 4 , ( unsigned char * )&UlAdjData ) ; if( ( UlAdjData != 0x00000000 ) && ( UlAdjData != 0xffffffff )){ RamWrite32A( gxzoom, UlAdjData ) ; // 0x1828 Gyro X axis Gain adjusted value }else{ RamWrite32A( gxzoom, GXGAIN_INI ) ; // 0x1828 Gyro X axis Gain adjusted initial value } /* Gyro Yaxis Gain */ E2pRed( (unsigned short)GYRO_GAIN_Y, 4 , ( unsigned char * )&UlAdjData ) ; if( ( UlAdjData != 0x00000000 ) && ( UlAdjData != 0xffffffff )){ RamWrite32A( gyzoom, UlAdjData ) ; // 0x1928 Gyro Y axis Gain adjusted value }else{ RamWrite32A( gyzoom, GXGAIN_INI ) ; // 0x1928 Gyro Y axis Gain adjusted initial value } /* OSC Clock value */ E2pRed( (unsigned short)OSC_CLK_VAL, 2 , ( unsigned char * )&UsAdjData ) ; if((unsigned char)UsAdjData != 0xff ){ UsCntYof = UsAdjData ; /* Optical center X value */ RegWriteA( OSCSET, (unsigned char)UsAdjData ) ; // 0x0264 }else{ RegWriteA( OSCSET, OSC_INI ) ; // 0x0264 } #else /* adjusted value */ RegWriteA( IZAH, DGYRO_OFST_XH ) ; // 0x03A0 Set Offset High byte RegWriteA( IZAL, DGYRO_OFST_XL ) ; // 0x03A1 Set Offset Low byte RegWriteA( IZBH, DGYRO_OFST_YH ) ; // 0x03A2 Set Offset High byte RegWriteA( IZBL, DGYRO_OFST_YL ) ; // 0x03A3 Set Offset Low byte RamWriteA( DAHLXO, DAHLXO_INI ) ; // 0x1114 RamWriteA( DAHLXB, DAHLXB_INI ) ; // 0x1115 RamWriteA( DAHLYO, DAHLYO_INI ) ; // 0x1116 RamWriteA( DAHLYB, DAHLYB_INI ) ; // 0x1117 RamWriteA( ADHXOFF, ADHXOFF_INI ) ; // 0x1102 RamWriteA( ADHYOFF, ADHYOFF_INI ) ; // 0x1105 RamWriteA( lxgain, LXGAIN_INI ) ; // 0x132A RamWriteA( lygain, LYGAIN_INI ) ; // 0x136A RamWriteA( ADGXOFF, 0x0000 ) ; // 0x1108 RamWriteA( ADGYOFF, 0x0000 ) ; // 0x110B UsCntXof = OPTCEN_X ; /* Clear Optical center X value */ UsCntYof = OPTCEN_Y ; /* Clear Optical center Y value */ RamWriteA( HXINOD, UsCntXof ) ; // 0x1127 RamWriteA( HYINOD, UsCntYof ) ; // 0x1167 RamWrite32A( gxzoom, GXGAIN_INI ) ; // 0x1828 Gyro X axis Gain adjusted value RamWrite32A( gyzoom, GYGAIN_INI ) ; // 0x1928 Gyro Y axis Gain adjusted value RegWriteA( OSCSET, OSC_INI ) ; // 0x0264 OSC adj #endif RamWriteA( pzgxp, PZGXP_INI ) ; // 0x133C X axis output direction initial value RamWriteA( pzgyp, PZGYP_INI ) ; // 0x137C Y axis output direction initial value RamWriteA( hxinog, 0x7fff ) ; // 0x1128 back up initial value RamWriteA( hyinog, 0x7fff ) ; // 0x1168 back up initial value SetZsp(0) ; // Zoom coefficient Initial Setting RegWriteA( PWMA , 0xC0 ); // 0x0074 PWM enable RegWriteA( STBB , 0x0F ); // 0x0260 [ - | - | - | - ][ STBOPAY | STBOPAX | STBDAC | STBADC ] RegWriteA( LXEQEN , 0x45 ); // 0x0084 RegWriteA( LYEQEN , 0x45 ); // 0x008E SetPanTiltMode( OFF ) ; /* Pan/Tilt OFF */ #ifdef H1COEF_CHANGER SetH1cMod( ACTMODE ) ; /* Lvl Change Active mode */ #endif DrvSw( ON ) ; /* 0x0070 Driver Mode setting */ }
void IniGyr( void ) { /*Initialize Gyro RAM*/ ClrGyr( 0x00 , CLR_GYR_ALL_RAM ); /*Gyro Filter Setting*/ RegWriteA( GEQSW , 0x11 ); // 0x0101 [ - | - | Sine_In | AD_In ][ - | - | - | T-Filter_Out ] RegWriteA( GSHAKEON , 0x01 ); // 0x0102 [ - | - | - | - ][ - | - | - | CmShakeOn ] RegWriteA( GSHTON , 0x00 ); // 0x0104 [ - | - | - | CmSht2PanOff ][ - | - | CmShtOpe(1:0) ] // CmShtOpe[1:0] 00: シャッターOFF, 01: シャッターON, 1x:外部制御 RegWriteA( G2NDCEFON1,0x00 ); // 0x0107 [ - | - | - | gxistp ][ gxlens | gxzoom | gxgain | gxgyro ] RegWriteA( G2NDCEFON0,0x00 ); // 0x0106 [ L4 | L3 | L2 | L1 ][ H2 | H1 | I2 | I1 ] RegWriteA( GADMEANON, 0x00 ); // 0x0113 [ - | - | - | - ][ - | - | - | CmAdMeanOn ] RegWriteA( GVREFADD , 0x14 ); // 0x0114 センター戻しを行う遅延RAMのアドレス下位6ビット (default 0x14 = GXH1Z2/GYH1Z2) RegWriteA( GSHTMOD , 0x0E ); // 0x0115 Shutter Hold mode RegWriteA( GLMT3MOD , 0x00 ); // 0x0116 [ - | - | - | - ][ - | - | - | CmLmt3Mod ] // CmLmt3Mod 0: 通常リミッター動作, 1: 円の半径リミッター動作 RegWriteA( GLMT3SEL , 0x00 ); // 0x0117 [ - | - | - | - ][ - | - | - | CmLmt3Sel ] // CmLmt3Sel 0: gxlmt3H0/gylmt3H0を使用, 1: gxlmt3H1/gylmt3H1を使用 RegWriteA( GGADON , 0x01 ); // 0x011C [ - | - | - | CmSht2PanOff ][ - | - | CmGadOn(1:0) ] // CmGadOn[1] 0: CmDwmSmpの設定でサンプリング, 1: 毎Fs周期でサンプリング // CmGadOn[0] 0: Analog Gyro使用, 1: Digital Gyro使用 RegWriteA( GGADSMP1 , 0x01 ); // 0x011E Digital GyroのAD変換確定時間を設定 RegWriteA( GGADSMP0 , 0x00 ); // 0x011D RegWriteA( GGADSMPT , 0x0E); // 0x011F X軸とY軸のみ取得する場合、0x0Eに設定 // 1Fsで4軸取得する場合、0x2Dに設定 // 2FS以上で4軸取得する場合、0x1Eに設定 /*Gyro Filter Down Sampling*/ RegWriteA( GDWNSMP1 , 0x00 ); // 0x0110 For overall filter RegWriteA( GDWNSMP2 , 0x00 ); // 0x0111 For H1 fitler RegWriteA( GDWNSMP3 , 0x00 ); // 0x0112 For T filter /*Gyro Filter Floating Point Value Limits*/ RegWriteA( GEXPLMTH , 0x81 ); // 0x019C RegWriteA( GEXPLMTL , 0x5A ); // 0x019D // Limiter RamWrite32A( gxlmt1L, 0x00000000 ) ; // 0x18B0 RamWrite32A( gxlmt1H, 0x3F800000 ) ; // 0x18B1 1.0 RamWrite32A( gylmt1L, 0x00000000 ) ; // 0x19B0 RamWrite32A( gylmt1H, 0x3F800000 ) ; // 0x19B1 1.0 RamWrite32A( gxlmt2L, 0x00000000 ) ; // 0x18B2 RamWrite32A( gxlmt2H, 0x3F800000 ) ; // 0x18B3 RamWrite32A( gylmt2L, 0x00000000 ) ; // 0x19B2 RamWrite32A( gylmt2H, 0x3F800000 ) ; // 0x19B3 RamWrite32A( gxlmt4SL, GYRO_LMT4L ) ; // 0x1808 RamWrite32A( gxlmt4SH, GYRO_LMT4H ) ; // 0x1809 RamWrite32A( gylmt4SL, GYRO_LMT4L ) ; // 0x1908 RamWrite32A( gylmt4SH, GYRO_LMT4H ) ; // 0x1909 // Limiter3 RamWrite32A( gxlmt3H0, 0x3F333333 ) ; // 0x18B4 0.7 RamWrite32A( gylmt3H0, 0x3F333333 ) ; // 0x19B4 0.7 RamWrite32A( gxlmt3H1, 0x3F333333 ) ; // 0x18B5 0.7 RamWrite32A( gylmt3H1, 0x3F333333 ) ; // 0x19B5 0.7 // Monitor Circuit RegWriteA( GDLYMON10, 0xF5 ) ; // 0x0184 RegWriteA( GDLYMON11, 0x01 ) ; // 0x0185 RegWriteA( GDLYMON20, 0xF5 ) ; // 0x0186 RegWriteA( GDLYMON21, 0x00 ) ; // 0x0187 RamWrite32A( gdm1g, 0x3F800000 ) ; // 0x18AC RamWrite32A( gdm2g, 0x3F800000 ) ; // 0x19AC RegWriteA( GDLYMON30, 0xF5 ) ; // 0x0188 RegWriteA( GDLYMON31, 0x01 ) ; // 0x0189 RegWriteA( GDLYMON40, 0xF5 ) ; // 0x018A RegWriteA( GDLYMON41, 0x00 ) ; // 0x018B RamWrite32A( gdm3g, 0x3F800000 ) ; // 0x18AD RamWrite32A( gdm4g, 0x3F800000 ) ; // 0x19AD RegWriteA( GPINMON3, 0x3C ) ; // 0x0182 RegWriteA( GPINMON4, 0x38 ) ; // 0x0183 /*Data Pass Setting*/ RegWriteA( GDPI1ADD1, 0x01 ); // 0x0171 Data Pass 1 Input RegWriteA( GDPI1ADD0, 0xC0 ); // 0x0170 RegWriteA( GDPO1ADD1, 0x01 ); // 0x0173 Data Pass 1 Output RegWriteA( GDPO1ADD0, 0xC0 ); // 0x0172 RegWriteA( GDPI2ADD1, 0x00 ); // 0x0175 Data Pass 2 Input RegWriteA( GDPI2ADD0, 0xC0 ); // 0x0174 RegWriteA( GDPO2ADD1, 0x00 ); // 0x0177 Data Pass 2 Output RegWriteA( GDPO2ADD0, 0xC0 ); // 0x0176 /*Input Sine Wave or AD value*/ RegWriteA( GSINTST , 0x00 ); // 0x018F [ - | - | - | CmSinTst_X ][ - | - | - | CmSinTst_Y ] // CmSinTst_X/Y 0: AD値を使用, 1: Sin波を使用 /* Pan/Tilt parameter */ RegWriteA( GPANADDA, 0x14 ); // 0x0130 RegWriteA( GPANADDB, 0x0E ); // 0x0131 //Threshold RamWrite32A( SttxHis, 0x00000000 ); // 0x183F RamWrite32A( SttyHis, 0x00000000 ); // 0x193F RamWrite32A( SttxaL, 0x00000000 ); // 0x18AE RamWrite32A( SttxbL, 0x00000000 ); // 0x18BE RamWrite32A( Sttx12aM, GYRA12_MID ); // 0x184F RamWrite32A( Sttx12aH, GYRA12_HGH ); // 0x185F RamWrite32A( Sttx12bM, GYRB12_MID ); // 0x186F RamWrite32A( Sttx12bH, GYRB12_HGH ); // 0x187F RamWrite32A( Sttx34aM, GYRA34_MID ); // 0x188F RamWrite32A( Sttx34aH, GYRA34_HGH ); // 0x189F RamWrite32A( Sttx34bM, GYRB34_MID ); // 0x18AF RamWrite32A( Sttx34bH, GYRB34_HGH ); // 0x18BF RamWrite32A( SttyaL, 0x00000000 ); // 0x19AE RamWrite32A( SttybL, 0x00000000 ); // 0x19BE RamWrite32A( Stty12aM, GYRA12_MID ); // 0x194F RamWrite32A( Stty12aH, GYRA12_HGH ); // 0x195F RamWrite32A( Stty12bM, GYRB12_MID ); // 0x196F RamWrite32A( Stty12bH, GYRB12_HGH ); // 0x197F RamWrite32A( Stty34aM, GYRA34_MID ); // 0x198F RamWrite32A( Stty34aH, GYRA34_HGH ); // 0x199F RamWrite32A( Stty34bM, GYRB34_MID ); // 0x19AF RamWrite32A( Stty34bH, GYRB34_HGH ); // 0x19BF // Pan level RegWriteA( GPANLEVABS, 0x00 ); // 0x0164 // Average RegWriteA( GPANSTT1DWNSMP0, 0x00 ); // 0x0134 RegWriteA( GPANSTT1DWNSMP1, 0x00 ); // 0x0135 RegWriteA( GPANSTT2DWNSMP0, 0x90 ); // 0x0136 RegWriteA( GPANSTT2DWNSMP1, 0x01 ); // 0x0137 RegWriteA( GPANSTT3DWNSMP0, 0x64 ); // 0x0138 RegWriteA( GPANSTT3DWNSMP1, 0x00 ); // 0x0139 RegWriteA( GPANSTT4DWNSMP0, 0x00 ); // 0x013A RegWriteA( GPANSTT4DWNSMP1, 0x00 ); // 0x013B RegWriteA( GMEANAUTO, 0x01 ); // 0x015E Auto // Force State RegWriteA( GPANSTTFRCE, 0x00 ); // 0x010A not use force state // Phase Transition Setting // State 2 -> 1 RegWriteA( GPANSTT21JUG0, 0x00 ); // 0x0140 RegWriteA( GPANSTT21JUG1, 0x00 ); // 0x0141 // State 3 -> 1 RegWriteA( GPANSTT31JUG0, 0x00 ); // 0x0142 RegWriteA( GPANSTT31JUG1, 0x00 ); // 0x0143 // State 4 -> 1 RegWriteA( GPANSTT41JUG0, 0x01 ); // 0x0144 RegWriteA( GPANSTT41JUG1, 0x00 ); // 0x0145 // State 1 -> 2 RegWriteA( GPANSTT12JUG0, 0x00 ); // 0x0146 RegWriteA( GPANSTT12JUG1, 0x07 ); // 0x0147 // State 1 -> 3 RegWriteA( GPANSTT13JUG0, 0x00 ); // 0x0148 RegWriteA( GPANSTT13JUG1, 0x00 ); // 0x0149 // State 2 -> 3 RegWriteA( GPANSTT23JUG0, 0x11 ); // 0x014A RegWriteA( GPANSTT23JUG1, 0x00 ); // 0x014B // State 4 -> 3 RegWriteA( GPANSTT43JUG0, 0x00 ); // 0x014C RegWriteA( GPANSTT43JUG1, 0x00 ); // 0x014D // State 3 -> 4 RegWriteA( GPANSTT34JUG0, 0x01 ); // 0x014E RegWriteA( GPANSTT34JUG1, 0x00 ); // 0x014F // State 2 -> 4 RegWriteA( GPANSTT24JUG0, 0x00 ); // 0x0150 RegWriteA( GPANSTT24JUG1, 0x00 ); // 0x0151 // State 4 -> 2 RegWriteA( GPANSTT42JUG0, 0x44 ); // 0x0152 RegWriteA( GPANSTT42JUG1, 0x04 ); // 0x0153 // State Timer RegWriteA( GPANSTT1LEVTMR, 0x00 ); // 0x0160 RegWriteA( GPANSTT2LEVTMR, 0x00 ); // 0x0161 RegWriteA( GPANSTT3LEVTMR, 0x00 ); // 0x0162 RegWriteA( GPANSTT4LEVTMR, 0x03 ); // 0x0163 // Control filter RegWriteA( GPANTRSON0, 0x01 ); // 0x0132 RegWriteA( GPANTRSON1, 0x1C ); // 0x0133 // State Setting IniPtMovMod( OFF ) ; // Pan/Tilt setting (Still) // Hold RegWriteA( GPANSTTSETILHLD, 0x00 ); // 0x0168 // HPS RegWriteA( GPANSTTSETHPS, 0xF0 ); // 0x015C RegWriteA( GHPSMOD, 0x00 ); // 0x016F RegWriteA( GPANHPSTMR0, 0x5C ); // 0x016A RegWriteA( GPANHPSTMR1, 0x00 ); // 0x016B // State2,4 Step Time Setting RegWriteA( GPANSTT2TMR0, 0x01 ); // 0x013C RegWriteA( GPANSTT2TMR1, 0x00 ); // 0x013D RegWriteA( GPANSTT4TMR0, 0x02 ); // 0x013E RegWriteA( GPANSTT4TMR1, 0x00 ); // 0x013F RegWriteA( GPANSTTXXXTH, 0x00 ); // 0x015D #ifdef GAIN_CONT RamWrite32A( gxlevmid, TRI_LEVEL ); // 0x182D Low Th RamWrite32A( gxlevhgh, TRI_HIGH ); // 0x182E Hgh Th RamWrite32A( gylevmid, TRI_LEVEL ); // 0x192D Low Th RamWrite32A( gylevhgh, TRI_HIGH ); // 0x192E Hgh Th RamWrite32A( gxadjmin, XMINGAIN ); // 0x18BA Low gain RamWrite32A( gxadjmax, XMAXGAIN ); // 0x18BB Hgh gain RamWrite32A( gxadjdn, XSTEPDN ); // 0x18BC -step RamWrite32A( gxadjup, XSTEPUP ); // 0x18BD +step RamWrite32A( gyadjmin, YMINGAIN ); // 0x19BA Low gain RamWrite32A( gyadjmax, YMAXGAIN ); // 0x19BB Hgh gain RamWrite32A( gyadjdn, YSTEPDN ); // 0x19BC -step RamWrite32A( gyadjup, YSTEPUP ); // 0x19BD +step RegWriteA( GLEVGXADD, (unsigned char)XMONADR ); // 0x0120 Input signal RegWriteA( GLEVGYADD, (unsigned char)YMONADR ); // 0x0124 Input signal RegWriteA( GLEVTMR, TIMEBSE ); // 0x0124 Base Time RegWriteA( GLEVTMRLOWGX, TIMELOW ); // 0x0121 X Low Time RegWriteA( GLEVTMRMIDGX, TIMEMID ); // 0x0122 X Mid Time RegWriteA( GLEVTMRHGHGX, TIMEHGH ); // 0x0123 X Hgh Time RegWriteA( GLEVTMRLOWGY, TIMELOW ); // 0x0125 Y Low Time RegWriteA( GLEVTMRMIDGY, TIMEMID ); // 0x0126 Y Mid Time RegWriteA( GLEVTMRHGHGY, TIMEHGH ); // 0x0127 Y Hgh Time RegWriteA( GLEVFILMOD, 0x00 ); // 0x0129 select output signal RegWriteA( GADJGANADD, (unsigned char)GANADR ); // 0x012A control address RegWriteA( GADJGANGO, 0x00 ); // 0x0108 manual off /* exe function */ AutoGainControlSw( OFF ) ; /* Auto Gain Control Mode OFF */ #endif /*Gyro Filter On*/ RegWriteA( GEQON , 0x01 ); // 0x0100 [ - | - | - | - ][ - | - | - | CmEqOn ] }
int32_t HtcActOisBinder_mappingTbl_i2c_write(int startup_mode, struct sensor_actuator_info_t * sensor_actuator_info) { int32_t rc = 0; camera_video_mode_type cur_cam_mode; uint32_t cur_line_cnt = 0; uint32_t cur_exp_time = 0; int32_t cur_zoom_level = 0; uint16_t cur_cmp_angle = 600; uint16_t cur_ois_level = 5; uint16_t ois_off = 0; if(g_ois_mode == 0) { pr_info("[OIS] %s OIS is OFF , g_ois_mode=%d\n", __func__, g_ois_mode); return rc; } if (check_if_enable_OIS_MFG_debug()) process_OIS_MFG_debug(); cur_cam_mode = sensor_actuator_info->cam_mode; cur_line_cnt = sensor_actuator_info->cur_line_cnt; cur_exp_time = sensor_actuator_info->cur_exp_time; cur_zoom_level = sensor_actuator_info->zoom_level; if (cur_cam_mode == CAM_MODE_CAMERA_PREVIEW) { cur_cmp_angle = 600; if (cur_exp_time >= (1000/24)) { cur_ois_level = 5; } else if (cur_exp_time >= (1000/48)) { cur_ois_level = 4; } else if (cur_exp_time >= (1000/83)) { cur_ois_level = 3; } else { ois_off = 1; } if (cur_zoom_level >= 45) { if (cur_exp_time >= (1000/24)) cur_ois_level = 5; else cur_ois_level = 4; ois_off = 0; } else if (cur_zoom_level >= 30) { if (cur_exp_time >= (1000/24)) cur_ois_level = 5; else cur_ois_level = 4; ois_off = 0; } else if (cur_zoom_level >= 15) { if (cur_exp_time >= (1000/24)) cur_ois_level = 5; else cur_ois_level = 4; ois_off = 0; } } else if (cur_cam_mode == CAM_MODE_VIDEO_RECORDING) { if (cur_exp_time >= (1000/24)) { cur_ois_level= 5; } else if (cur_exp_time >= (1000/48)) { cur_ois_level= 4; } else if (cur_exp_time >= (1000/83)) { cur_ois_level= 4; } else { cur_ois_level= 4; } cur_cmp_angle = 600; if (cur_zoom_level >= 45) { if (cur_exp_time >= (1000/24)) { cur_ois_level = 5; } else if (cur_exp_time >= (1000/48)) { cur_ois_level = 4; } else if (cur_exp_time >= (1000/83)) { cur_ois_level = 4; } else { cur_ois_level = 4; } } else if (cur_zoom_level >= 30) { if (cur_exp_time >= (1000/24)) { cur_ois_level = 5; } else { cur_ois_level = 4; } } else if (cur_zoom_level >= 15) { if (cur_exp_time >= (1000/24)) { cur_ois_level = 5; } else { cur_ois_level = 4; } } if (board_mfg_mode()) { pr_info("[RUMBA_S] mfg mode\n"); cur_ois_level= 5; } } else { cur_ois_level= 5; } pr_info("[OIS] ois_off=%d, cur_cam_mode=%d, cur_line_cnt=%d, cur_exp_time=%d, cur_ois_level=%d, cur_zoom_level=%d\n", ois_off, cur_cam_mode, cur_line_cnt, cur_exp_time, cur_ois_level, cur_zoom_level); if (ois_off) { cur_ois_level= 0; } if (cur_ois_level <= 6) { pr_info("[OIS] set OIS level : %d\n", cur_ois_level); SetGcf(cur_ois_level); } #if 0 if (cur_cmp_angle == 800) { pr_info("[OIS] Apply Compensation angle as 0.8deg\n"); RamWrite32A( 0x1808, 0x3FD1EB85 ) ; RamWrite32A( 0x1809, 0x3FD1EB85 ) ; RamWrite32A( 0x1908, 0x3FD1EB85 ) ; RamWrite32A( 0x1909, 0x3FD1EB85 ) ; } else if (cur_cmp_angle == 700) { pr_info("[OIS] Apply Compensation angle as 0.7deg\n"); RamWrite32A( 0x1808, 0x3FB33333 ) ; RamWrite32A( 0x1809, 0x3FB33333 ) ; RamWrite32A( 0x1908, 0x3FB33333 ) ; RamWrite32A( 0x1909, 0x3FB33333 ) ; } else if (cur_cmp_angle == 600) { pr_info("[OIS] Apply Compensation angle as 0.6deg\n"); RamWrite32A( 0x1808, 0x3F99999A ) ; RamWrite32A( 0x1809, 0x3F99999A ) ; RamWrite32A( 0x1908, 0x3F99999A ) ; RamWrite32A( 0x1909, 0x3F99999A ) ; } else { pr_info("[OIS] Apply Compensation angle : value is not allowed\n"); } #endif return rc; }
static int32_t process_OIS_MFG_debug(void) { int32_t rc = 0; uint16_t ois_level; uint16_t compensation_angle; #if 0 uint16_t ois_data_1 = 0, ois_data_2 = 0, ois_data_3 = 0, ois_data_4 = 0; #endif pr_info("[OIS] %s called\n", __func__); #if 0 RamReadA_lc898111(0x1103, &ois_data_1); RamReadA_lc898111(0x1106, &ois_data_2); pr_info("[OIS] OIS_ENABLE_DEBUG 0x1103 read : 0x%04x , 0x1106 read : 0x%04x\n", ois_data_1 , ois_data_2); RamReadA_lc898111(0x1101, &ois_data_3); RamReadA_lc898111(0x1104, &ois_data_4); pr_info("[OIS] OIS_ENABLE_DEBUG 0x1101 read : 0x%04x , 0x1104 read : 0x%04x\n", ois_data_3 , ois_data_4); #endif ois_level = get_ois_level(); if (ois_level <= 6) { pr_info("[OIS] set OIS level : %d\n", ois_level); SetGcf(ois_level); } compensation_angle = get_compensation_angle(); if(compensation_angle < ILLEGAL_CMD_INPUT_VALUE) { pr_info("[OIS] set Compensation angle : %d\n", compensation_angle); if (compensation_angle == 800) { pr_info("[OIS] Apply Compensation angle as 0.8deg\n"); RamWrite32A( 0x1808, 0x3FD1EB85 ) ; RamWrite32A( 0x1809, 0x3FD1EB85 ) ; RamWrite32A( 0x1908, 0x3FD1EB85 ) ; RamWrite32A( 0x1909, 0x3FD1EB85 ) ; } else if (compensation_angle == 700) { pr_info("[OIS] Apply Compensation angle as 0.7deg\n"); RamWrite32A( 0x1808, 0x3FB33333 ) ; RamWrite32A( 0x1809, 0x3FB33333 ) ; RamWrite32A( 0x1908, 0x3FB33333 ) ; RamWrite32A( 0x1909, 0x3FB33333 ) ; } else if (compensation_angle == 600) { pr_info("[OIS] Apply Compensation angle as 0.6deg\n"); RamWrite32A( 0x1808, 0x3F99999A ) ; RamWrite32A( 0x1809, 0x3F99999A ) ; RamWrite32A( 0x1908, 0x3F99999A ) ; RamWrite32A( 0x1909, 0x3F99999A ) ; } else { pr_info("[OIS] value is not allowed, Apply default Compensation angle as 0.8deg\n"); RamWrite32A( 0x1808, 0x3FD1EB85 ) ; RamWrite32A( 0x1809, 0x3FD1EB85 ) ; RamWrite32A( 0x1908, 0x3FD1EB85 ) ; RamWrite32A( 0x1909, 0x3FD1EB85 ) ; } } return rc; }
void HtcActOisBinder_open_init(void) { uint8_t ois_data_8; uint16_t ois_data_16; unsigned long ois_data_32; if (binder_i2c_client == NULL) return; pr_info("[OIS] %s start\n", __func__); pr_info("[OIS] %s FW_Version=0x%x\n", __func__, RdFwVr()); #if 0 RegReadA_lc898111(0x027F, &ois_data_8); pr_info("[OIS] 0x027F read : 0x%x\n", ois_data_8); #endif IniSet(); if (g_otp_size > 0) { pr_info("[OIS] %s g_otp_size=%d\n", __func__, g_otp_size); ois_data_16 = (g_otp_data[0] << 8) + g_otp_data[1]; RamWriteA_lc898111(0x1114, ois_data_16); ois_data_16 = (g_otp_data[2] << 8) + g_otp_data[3]; RamWriteA_lc898111(0x1116, ois_data_16); ois_data_16 = (g_otp_data[4] << 8) + g_otp_data[5]; RamWriteA_lc898111(0x1115, ois_data_16); ois_data_16 = (g_otp_data[6] << 8) + g_otp_data[7]; RamWriteA_lc898111(0x1117, ois_data_16); ois_data_16 = (g_otp_data[8] << 8) + g_otp_data[9]; RamWriteA_lc898111(0x1102, ois_data_16); ois_data_16 = (g_otp_data[10] << 8) + g_otp_data[11]; RamWriteA_lc898111(0x1105, ois_data_16); ois_data_16 = (g_otp_data[12] << 8) + g_otp_data[13]; RamWriteA_lc898111(0x132A, ois_data_16); ois_data_16 = (g_otp_data[14] << 8) + g_otp_data[15]; RamWriteA_lc898111(0x136A, ois_data_16); ois_data_16 = (g_otp_data[16] << 8) + g_otp_data[17]; RamWriteA_lc898111(0x1127, ois_data_16); ois_data_16 = (g_otp_data[18] << 8) + g_otp_data[19]; RamWriteA_lc898111(0x1167, ois_data_16); ois_data_8 = g_otp_data[20]; RegWriteA_lc898111(0x03A0, ois_data_8); ois_data_8 = g_otp_data[21]; RegWriteA_lc898111(0x03A1, ois_data_8); ois_data_8 = g_otp_data[22]; RegWriteA_lc898111(0x03A2, ois_data_8); ois_data_8 = g_otp_data[23]; RegWriteA_lc898111(0x03A3, ois_data_8); pr_info("[OIS] Gyro Gain X0 : 0x%x\n", g_otp_data[24]); g_otp_data[24] = g_otp_data[24] | 0x80; pr_info("[OIS] Corrected Gyro Gain X0 : 0x%x\n", g_otp_data[24]); ois_data_32 = (g_otp_data[24] << 24) + (g_otp_data[25] << 16) + (g_otp_data[26] << 8) + g_otp_data[27]; RamWrite32A(0x1828, ois_data_32); ois_data_32 = (g_otp_data[28] << 24) + (g_otp_data[29] << 16) + (g_otp_data[30] << 8) + g_otp_data[31]; RamWrite32A(0x1928, ois_data_32); ois_data_8 = g_otp_data[32]; RegWriteA_lc898111(0x0264, ois_data_8); } #if 0 RamWrite32A( 0x1808, 0x3F99999A ) ; RamWrite32A( 0x1809, 0x3F99999A ) ; RamWrite32A( 0x1908, 0x3F99999A ) ; RamWrite32A( 0x1909, 0x3F99999A ) ; #endif RtnCen(0); SetPanTiltMode(ON); pr_info("[OIS] %s g_ois_mode=%d\n", __func__, g_ois_mode); if (g_ois_mode != 0) { ClrGyr(0x06, CLR_GYR_DLY_RAM); OisEna(); SetGcf(5); } #if 0 RegReadA_lc898111(0x0084, &ois_data_8); pr_info("[OIS] 0x0084 read : 0x%x\n", ois_data_8); RamReadA_lc898111(0x1308, &ois_data_16); pr_info("[OIS] 0x1308 read : 0x%x\n", ois_data_16); RegReadA_lc898111(0x0084, &ois_data_8); pr_info("[OIS] 0x0084 read : 0x%x\n", ois_data_8); RamReadA_lc898111(0x1348, &ois_data_16); pr_info("[OIS] 0x1348 read : 0x%x\n", ois_data_16); #endif pr_info("[OIS] %s end\n", __func__); }