Mini PCIe ADC
Users Guide
Document: CTIM-00149
Revision: 0.02
Page 19 of 22
Connect Tech Inc. 800-426-8979 | 519-836-1291
Date: 2018-10-25
Application Examples
Example A – writing/reading from scratch pad
/**************************************************************/
printf(
"reading scratch pad registers\n"
);
/***************************************************************/
wrreg=0xABCDEF01;
ret = CTIFPGAWrDword(pbrd, BAR_MAIN, COMMSCRATCHPAD_REG_1, wrreg);
if
(ret != CTI_STATUS_OK)
{
printf(
"Error write to SCRATCHPAD_REG_1\n"
); result = FALSE;
}
ret = CTIFPGARdDword(pbrd, BAR_MAIN, COMMSCRATCHPAD_REG_1, &rdreg);
if
(ret != CTI_STATUS_OK)
{
printf(
"Error read from FPGA mem"
); result = FALSE;
}
else
{
printf (
"rd reg = 0x%08x \n"
, rdreg);
}
if
(wrreg !=rdreg)
{
printf(
"Expected %x, read %x\n"
, wrreg, rdreg);
}
Example B – reading ID registers
/**************************************************************/
printf(
"reading ID registers\n"
);
/***************************************************************/
time_t rawtime;
struct
tm* timeinfo;
ret = CTIFPGARdDword(pbrd, BAR_MAIN, 0x0, &idreg);
if
(ret != CTI_STATUS_OK)
{
printf(
"Error read from FPGA mem"
); result = FALSE;
}
else
{
printf (
"ID reg = 0x%08x \n"
, idreg);
}
ret = CTIFPGARdDword(pbrd, BAR_MAIN, 0x4, &tsreg);
if
(ret != CTI_STATUS_OK)
{
printf(
"Error read from FPGA mem"
); result = FALSE;
}
else
{
rawtime = tsreg;
timeinfo = localtime(&rawtime);
printf (
"Timestamp reg = 0x%08x , %s\n"
, idreg, asctime(timeinfo));
}