Here is the function straight from the ISG GUI for loading the
offset file on the 6MP camera. It basically creates a memory buffer
that is the size of the full image and writes the offset data file
there. Then it transfers the data to the camera in 2K blocks to a
register address (0x7CC8) that is dedicated to this purpose. If the
block transfer is not available in the host code, the data can be
written one 32bit word at a time, it will just be much slower.
#define ASYNC_BLOCK_SIZE 2048
#define MP_WFIFO_IN 0x7CC8
void CDialogFlatField::OnButtonLoadOffset()
{
char theOffsetExt[] = "Offset.raw";
char offsetfilename[200];
CString stringCopy;
LPTSTR datString;
int offsetFile;
int temp;
unsigned long *imageBuffer,*startBuffer;
unsigned long maxRange,readVal;
ULONG i,j;
maxRange = (myProjDialog->theMaxHeight *
myProjDialog->theMaxWidth)/ASYNC_BLOCK_SIZE;
m_progressOffset.SetRange( 0,(short)maxRange);
startBuffer = imageBuffer = (unsigned long
*)malloc(myProjDialog->theMaxWidth * myProjDialog->theMaxHeight
*2);
stringCopy = myProjDialog->pathBuffer;
datString = stringCopy.GetBuffer(myProjDialog->dwPathSize);
strcpy(offsetfilename,datString);
strcat(offsetfilename,theOffsetExt);
offsetFile = open(offsetfilename, O_RDONLY | O_BINARY, 0666);
if (offsetFile == -1)
{
MessageBox( offsetfilename, "Image File not found", MB_OK);
return;
}
for (i = 0; i < myProjDialog->theMaxHeight ; i++)
{
temp = read(offsetFile,imageBuffer,myProjDialog->theMaxWidth);
imageBuffer += myProjDialog->theMaxWidth/4;
}
close (offsetFile);
imageBuffer = startBuffer;
BeginWaitCursor();
theCamera.WriteQuadlet(ISG_INIT_MEM_OFFSET,1);
for (i = 0,j=0; i < (myProjDialog->theMaxHeight *
myProjDialog->theMaxWidth) ; i+=ASYNC_BLOCK_SIZE,j++)
{
theCamera.WriteQuadletBlock(MP_WFIFO_IN,imageBuffer);
imageBuffer += ASYNC_BLOCK_SIZE/4;
theCamera.ReadQuadlet(VID_RDMA_ADDR,&readVal);
m_progressOffset.SetPos(j);
}
theCamera.WriteQuadlet(ISG_INIT_MEM_OFFSET,0);
this->OnSetActive();
EndWaitCursor();
}