
#ifndef _CALIBRATION_H
#define	_CALIBRATION_H

//#define UPDATE_AFC
// #ifdef UPDATE_AFC
#define NV_AFC_SIZE      2
//#else
//#define NV_AFC_SIZE      0
//#endif 
#define AGC_SIZE     2 * 142 * 2   
#define APC_SIZE     90 * 2

#define NV_MULTI_LANG_ID  (405)

CString GetErrorDesc( UINT dwID );

BOOL FindNVOffset( WORD wId,LPBYTE lpCode,DWORD dwCodeSize,
                  DWORD& dwOffset,DWORD& dwLength);

DWORD PreserveCalibration( LPBYTE lpCode, DWORD dwCodeSize, 
                         LPBYTE lpReadBuffer, DWORD dwReadSize,
                         BOOL bOldReplaceNew, BOOL bContinue );

BOOL PreserveIMEI(LPBYTE lpCode, DWORD dwCodeSize, 
                  LPBYTE lpReadBuffer, DWORD dwReadSize );   


BOOL PreserveNVItem( WORD wID, LPBYTE lpCode, DWORD dwCodeSize, 
                    LPBYTE lpReadBuffer, DWORD dwReadSize); 

//BOOL PreserveBT( WORD wID, LPBYTE lpCode, DWORD dwCodeSize, 
//                    LPBYTE lpReadBuffer, DWORD dwReadSize, BOOL bContinue = FALSE);

BOOL PreserveNV( LPBYTE lpCode, DWORD dwCodeSize, 
                LPBYTE lpReadBuffer, DWORD dwReadSize );
/**
 *  dwNvAfcSize is only equal to  0 or 2 
 */
BOOL PreserveTDCalibration( LPBYTE lpCode, DWORD dwCodeSize,  
						   LPBYTE lpReadBuffer, DWORD dwReadSize,
						   DWORD dwOffsize, DWORD dwNvAfcSize = 0);
BOOL PreserveNVItemEx( WORD wID, LPBYTE lpCode, DWORD dwCodeSize, 
                    LPBYTE lpReadBuffer, DWORD dwReadSize,
					 BOOL bOldReplaceNew = FALSE, BOOL bContinue = FALSE ); 

DWORD PreserveTDCalibrationEx( LPBYTE lpCode, DWORD dwCodeSize, 
                         LPBYTE lpReadBuffer, DWORD dwReadSize,
                         BOOL bOldReplaceNew, BOOL bContinue );
               
#endif // _CALIBRATION_H