📄 aes1510.c
字号:
uxTemp = 255;
}
m_sIAGC.ucOffset = (unsigned int)( uxTemp );
m_sIAGC.ucMult = (unsigned int)( (( m_sIAGC.ucMult << 7 )&0x00FF / m_sIAGC.puxGainFactor[m_sIAGC.ucGain])&0x00FF );
asm("nop");
return( 1 );
}
return( 0 );
}
unsigned int HiGv( unsigned int ucUberGain )
{
/*
* If Gain is less than 4 (0..3) then there is no HiGv (HW: 1).
*/
if( ucUberGain < 4 )
{
return ( 1 << 5 );
}
/*
* If Gain is equal to 4 then HiGv is 1 (HW: 2),
*/
if( ucUberGain == 4 )
{
return ( 2 << 5 );
}
/*
* If Gain is greater than 4 (5..13) HiGv is 2 (HW: 3).
*/
return ( 3 << 5 );
}
unsigned int UniGain( unsigned int ucUberGain )
{
if( ucUberGain < 4 )
{
return ( ucUberGain );
}
/*
* If UberGain is 4 or 5, then UniGain is 3.
*/
if( ucUberGain < 6 )
{
return ( 3 );
}
/*
* If UberGain is 6 or above the UniGain = UberGain - 2.
*/
return ( ucUberGain - 2 ) ;
}
void ERGCReset( )
{
m_sIAGC.ucMaxGain = ER_GAIN_MAX;
m_sIAGC.ucMinGain = ER_GAIN_MIN;
m_sIAGC.puxGainFactor = uxGainFactor;
m_sIAGC.ucGainOK = (unsigned int)( 0 );/* Initially Gain has not been adjusted*/
m_sIAGC.ucGain = (unsigned int)( 3 );/* Initial Gain = 3 (Measure Drive Max)*/
m_sIAGC.ucOffset = (unsigned int)( 0 );/* Initial Offset is 0. */
m_sIAGC.ucMult = (unsigned int)( 8 );/* Initial Multiplier is 1 (5.3 format)*/
}
unsigned int ProcessDACCalPacket(unsigned int psDP[])
{
m_ucIncrement = (unsigned int)( m_ucIncrement >> 1 );
if( m_ucIncrement > 0 )
{
if(psDP[0] < 128 - BAD_PIXEL_TOLERANCE)
{
m_aucOffDAC[m_ucCalGain] = (unsigned int)
( m_aucOffDAC[m_ucCalGain] + m_ucIncrement );
}
else
{
if( m_aucOffDAC[m_ucCalGain] == 0 )
{
goto CalibrationFailure;
}
m_aucOffDAC[m_ucCalGain] = (unsigned int )
( m_aucOffDAC[m_ucCalGain] - m_ucIncrement );
}
SetupDACCalibration( );
return( 0 );
}
if( psDP[0] < ( 128 - BAD_PIXEL_TOLERANCE ) )
{
m_aucOffDAC[m_ucCalGain] = (unsigned int)( m_aucOffDAC[m_ucCalGain] + 1 );
}
else
{
m_aucOffDAC[m_ucCalGain] = (unsigned int)( m_aucOffDAC[m_ucCalGain] + 0 );
}
#define FD_UBER_GAIN 9 /* Gain setting where Finger Detect is run. */
if( FD_UBER_GAIN == m_ucCalGain )
{
if( m_aucOffDAC[m_ucCalGain] > ( 0x7F - 2 ) )
{
goto CalibrationFailure;
}
}
if( m_aucOffDAC[m_ucCalGain] > 0x7F )
{
CalibrationFailure:
if( m_ucVRefDAC == 0x54 )
{
m_ucVRefDAC = 0x5A;
m_aucOffDAC[0] = m_aucOffDAC[1] = m_aucOffDAC[ 2] = m_aucOffDAC[ 3] =
m_aucOffDAC[4] = m_aucOffDAC[5] = m_aucOffDAC[ 6] = m_aucOffDAC[ 7] =
m_aucOffDAC[8] = m_aucOffDAC[9] = m_aucOffDAC[10] = m_aucOffDAC[11] =
m_aucOffDAC[12] = m_aucOffDAC[13] = m_aucMaxOffDAC
= 0; /* Start Offset DACs at zero. */
m_ucIncrement = 0x80; /* Init Incr for Binary Search. */
m_ucCalGain = ER_GAIN_MIN; /* Start Searching at Min Gain. */
SetupDACCalibration( );
return( 0 );
}
m_ucVRefDAC = 0x54;
/*
* Re-Initialize the Offset DAC Table, the Increment, and the Gain in
* preperation for calibrating again.
*/
m_aucOffDAC[0] = m_aucOffDAC[1] = m_aucOffDAC[ 2] = m_aucOffDAC[ 3] =
m_aucOffDAC[4] = m_aucOffDAC[5] = m_aucOffDAC[ 6] = m_aucOffDAC[ 7] =
m_aucOffDAC[8] = m_aucOffDAC[9] = m_aucOffDAC[10] = m_aucOffDAC[11] =
m_aucOffDAC[12] = m_aucOffDAC[13] = m_aucMaxOffDAC
= 0; /* Start Offset DACs at zero. */
m_ucIncrement = 0x80; /* Init Incr for Binary Search. */
m_ucCalGain = ER_GAIN_MIN; /* Start Searching at Min Gain. */
return(0 );
}
/*
* OK, this Gain has been calibrated.
*/
/*
* See if we have found a new Maximum. If so, we save it for use with
* HGC which is currently used in LP Navigation Mode.
*/
if( m_aucMaxOffDAC < m_aucOffDAC[m_ucCalGain] )
{
m_aucMaxOffDAC = m_aucOffDAC[m_ucCalGain];
}
if( m_ucCalGain < ER_GAIN_MAX )
{
m_ucCalGain++;
m_ucIncrement = 0x80;
SetupDACCalibration();
return( 0 );
}
return( 1 );
}
void SetupDACCalibration( void )
{
unsigned int Gain_Temp ;//Rx8E;
unsigned int Higv_Temp ; //RxA6;
unsigned int Offset_Temp;//RxAE;
unsigned int Ref_Temp ;//RxAF;
Gain_Temp = (unsigned int)( UniGainOld( m_ucCalGain ) );
Higv_Temp = (unsigned int)( HiGv( m_ucCalGain ) | 0x84 );
Offset_Temp = (unsigned int)( m_aucOffDAC[m_ucCalGain] );
Ref_Temp = m_ucVRefDAC;
/*
sWriteAES1510RegByte(0x80,0x01);
sWriteAES1510RegByte(0x80,0x12);
sWriteAES1510RegByte(0x85,0x00);
sWriteAES1510RegByte(0x8A,0x00);
sWriteAES1510RegByte(0x8B,0x0E);
sWriteAES1510RegByte(0x8C,0x90);
sWriteAES1510RegByte(0x8D,0x83);
sWriteAES1510RegByte(0x8E,Gain_Temp);
sWriteAES1510RegByte(0x8F,0x07);
sWriteAES1510RegByte(0x96,0x00);
sWriteAES1510RegByte(0x97,0x48);
sWriteAES1510RegByte(0xA2,0x50);
sWriteAES1510RegByte(0xA6,Higv_Temp);
sWriteAES1510RegByte(0xAD,0x08);
sWriteAES1510RegByte(0xAE,Offset_Temp);
sWriteAES1510RegByte(0xAF,Ref_Temp);
sWriteAES1510RegByte(0xB1,0x28);
sWriteAES1510RegByte(0xB5,0xAB);
sWriteAES1510RegByte(0xB6,0x0E);
sWriteAES1510RegByte(0x1B,0x2D);
sWriteAES1510RegByte(0x81,0x04); */
}
unsigned int UniGainOld( unsigned int ucUberGain )
{
if( ucUberGain < 4 )
{
return (unsigned int)( ( ucUberGain ) );
}
if( ucUberGain < 6 )
{
return (unsigned int)( 3 );
}
return (unsigned int)( ( ucUberGain - 2 ) );
}
void AES1510_SensorInit(void)
{
unsigned int a;
for(a =0;a<14;a++ )
{
m_aucOffDAC[a] = 0;
}
a = 0;
Init_AES1510 ();
NoFinger_Time = 0;
m_ucIncrement = 0x80;
m_ucCalGain = 0;
m_aucMaxOffDAC = 0;
m_ucVRefDAC = 0x54;
EnableFingerDetect();
while(1)
{
FingerDETECT();
asm("nop");
a =ProcessDACCalPacket( uReceiveSensorTestImageData);
asm("nop");
if(a)
{
asm("nop");
break;
}
}
asm("nop");
}
void DelayUs(int delay)
{
int i;
int j;
for(i=0;i<delay;i++)
for(j=0;j<5;j++)
asm("nop");
return;
}
unsigned int AES1510_GetTotalImage(void)
{
unsigned int i;
unsigned int Normal_Count;
unsigned int Dresult;
NoFinger_Time = 0;
m_ucIncrement = 0x80;
m_ucCalGain = 0;
m_aucMaxOffDAC = 0;
m_ucVRefDAC = 0x54;
ERGCReset( );
asm("nop");
OverTimes = 0;
AES1510_GetImageInitialization();
asm("nop");
Detect_Time = 0;
while(1)
{
EnableFingerDetect();
FingerDETECT();
if(NoFinger_Time >= 10)
{
NoFinger_Time =0;
return 1 ;
}
if(OneFrame_OK ==1)
{
NoFinger_Time =0;
Detect_Time ++;
if(Detect_Time >= 2)
{
Detect_Time = 0;
break;
}
}
}
Dresult = GetNormalImage();
return Dresult;
}
unsigned int GetNormalImage(void)
{
unsigned int i;
asm("nop");
unsigned int DDresult;
unsigned int FLAG,FLAG1;
FLAG = 0;
FLAG1 = 0;
FristSetSensor();
/************************test and view the reg**********************************
while(!(PIO_DATA1 & 0x0004));
for(i = 0;i<700;i++)
{
a[i] = uReadSPI3Byte();
}
//**********************************************************/
asm("nop");
while(1)
{
sFrameJointDataFormat(); //拼接数据转换 128*4 转换为128*8
UpdateSensorRegisters();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -