JLab fADC125 Library  1.2.1
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups
fa125Lib.c File Reference

Macros

#define LSWAP(x)
 
#define FA125LOCK   if(pthread_mutex_lock(&fa125Mutex)<0) perror("pthread_mutex_lock");
 
#define FA125UNLOCK   if(pthread_mutex_unlock(&fa125Mutex)<0) perror("pthread_mutex_unlock");
 
#define SHOWBERR
 
#define MCS_MAX_SIZE   (FA125_FIRMWARE_MAX_PAGES*FA125_FIRMWARE_MAX_BYTE_PER_PAGE)
 

Enumerations

enum  ifpgatype { MAIN, FE, PROC, NFPGATYPE }
 

Functions

int fa125Init (UINT32 addr, UINT32 addr_inc, int nadc, int iFlag)
 Initialize the fa125 Library. More...
 
void fa125CheckAddresses (int id)
 
int fa125Slot (unsigned int i)
 Convert an index into a slot number, where the index is the element of an array of fA125s in the order in which they were initialized. More...
 
int fa125Status (int id, int pflag)
 Print Status of fADC125 to standard out. More...
 
void fa125GStatus (int pflag)
 Print a summary of all initialized fADC1250s. More...
 
int fa125SetProcMode (int id, int pmode, unsigned int PL, unsigned int PTW, unsigned int NSB, unsigned int NSA, unsigned int NP)
 Configure the processing type/mode. More...
 
int fa125SetByteSwap (int id, int enable)
 Enable/Disable onboard byteswapping. More...
 
int fa125PowerOff (int id)
 Power Off the fADC125. More...
 
int fa125PowerOn (int id)
 Power On the fADC125. More...
 
int fa125SetOffset (int id, int chan, int dacData)
 Set the DAC offset for a specific fADC125 Channel. More...
 
int fa125SetOffsetFromFile (int id, char *filename)
 Set the DAC offset for a specific fADC125 Channel from a specified file. More...
 
unsigned short fa125ReadOffset (int id, int chan)
 Readback the DAC offset set for a specific fADC125 Channel. More...
 
int fa125ReadOffsetToFile (int id, char *filename)
 Readback the DAC offset set for a specific fADC125 Channel into a specified file. More...
 
int fa125SetThreshold (int id, unsigned short tvalue, unsigned short chan)
 Set the readout threshold for a specific fADC125 Channel. More...
 
int fa125SetChannelDisable (int id, int channel)
 Disable a specific fADC125 Channel. More...
 
int fa125SetChannelDisableMask (int id, unsigned int cmask0, unsigned int cmask1, unsigned int cmask2)
 Disable specific fADC125 Channels using three separate channel masks. More...
 
int fa125SetChannelEnable (int id, int channel)
 Enable a specific fADC125 Channel. More...
 
int fa125SetChannelEnableMask (int id, unsigned int cmask0, unsigned int cmask1, unsigned int cmask2)
 Enable specific fADC125 Channels using three separate channel masks. More...
 
int fa125SetCommonThreshold (int id, unsigned short tvalue)
 Set a common readout threshold for all fADC125 Channels. More...
 
void fa125GSetCommonThreshold (unsigned short tvalue)
 Set a common readout threshold for all fADC125 Channels for all initialized modules. More...
 
int fa125PrintThreshold (int id)
 Print to standarad out the set readout threshold for all fADC125 Channels in the specified module. More...
 
int fa125SetPulserAmplitude (int id, int chan, int dacData)
 Set the output Pulser Amplitude for the specified connector. More...
 
int fa125SetMulThreshold (int id, int dacData)
 Set the multiplicity sum for an internal trigger. More...
 
int fa125PrintTemps (int id)
 Print the temperature of the main board and mezzanine to standard out. More...
 
int fa125SetClockSource (int id, int clksrc)
 Set the clock source for the specified fADC125. More...
 
int fa125SetTriggerSource (int id, int trigsrc)
 Set the trigger source for the specified fADC125. More...
 
int fa125GetTriggerSource (int id)
 Returns the trigger source for the specified fADC125. More...
 
int fa125SetSyncResetSource (int id, int srsrc)
 Set the Sync Reset source for the specified fADC125. More...
 
int fa125Poll (int id)
 Poll the specified fADC125's busy status. More...
 
unsigned int fa125GetBerrCount ()
 Return the Bus Error count that occurred while checking the busy status. More...
 
int fa125Clear (int id)
 Clear used with serial acquisition buffers. Deprecated as this is no longer the way to readout data from the module. More...
 
int fa125Enable (int id)
 Enable buffers and FIFOs for data acquisition. More...
 
int fa125Disable (int id)
 Disable buffers and FIFOs for data acquisition. More...
 
int fa125Reset (int id, int reset)
 Perform the selected Reset to a specific fADC125. More...
 
int fa125ResetCounters (int id)
 Reset all counters (trigger count, clock count, sync reset count, trig2 count) More...
 
int fa125ResetToken (int id)
 Returns the token to the first module This routine only has an effect on the first module of the Multiblock setup. More...
 
int fa125GetTokenMask ()
 Return the slot mask of modules with the token. More...
 
int fa125SetBlocklevel (int id, int blocklevel)
 Set the number of events in the block. More...
 
int fa125SoftTrigger (int id)
 Initiate a software trigger for a specific fADC125 module. More...
 
int fa125SetPulserTriggerDelay (int id, int delay)
 Set the delay between the output pulse and f1TDC trigger. More...
 
int fa125SetPulserWidth (int id, int width)
 Set the width of the output pulse. More...
 
int fa125SoftPulser (int id, int output)
 Trigger the pulser. More...
 
int fa125SetPPG (int id, int fe_chip, unsigned short *sdata, int nsamples)
 Setup fADC125 Progammable Pulse Generator. More...
 
int fa125PPGEnable (int id)
 Enable the programmable pulse generator. More...
 
int fa125PPGDisable (int id)
 Disable the programmable pulse generator. More...
 
int fa125ReadEvent (int id, volatile UINT32 *data, int nwrds, unsigned int rflag)
 General Data readout routine. Deprecated. Replaced with fa125ReadBlock. More...
 
int fa125Bready (int id)
 Return a Block Ready status. More...
 
unsigned int fa125GBready ()
 Return a Block Ready status mask for all initialized fADC125s. More...
 
unsigned int fa125ScanMask ()
 Return the vme slot mask of all initialized fADC125s. More...
 
int fa125ReadBlockStatus (int pflag)
 Return the block error flag and optionally print out the description to standard out. More...
 
int fa125ReadBlock (int id, volatile UINT32 *data, int nwrds, int rflag)
 General Data readout routine. More...
 
void fa125DecodeData (unsigned int data)
 Decode a data word from an fADC125 and print to standard out. More...
 
void fa125FirmwareSetDebug (unsigned int debug)
 Set the debugging flags for diagnosing firmware updating problems. More...
 
int fa125FirmwareGVerifyFull ()
 Verify that the firmware has been written correctly to all initialized fADC125s. More...
 
int fa125FirmwareReadMcsFile (char *filename)
 Read in the firmware from selected MCS file. More...
 
void fa125FirmwarePrintFPGAStats ()
 Prints to standard out, the memory size and location of each FPGA firmware. More...
 
void fa125FirmwarePrintPage (int page)
 Prints the selected firmware page to standard out. More...
 
int fa125FirmwareEraseFull (int id)
 Erase the entire contents of the configuration ROM of the selected fADC125. More...
 
int fa125FirmwareGEraseFull ()
 Erase the entire contents of the configuration ROM for all initialized fADC125s. More...
 
int fa125FirmwareWriteFull (int id)
 Write the contents of the read in MCS file to the selected fADC125 Configuration ROM. More...
 
int fa125FirmwareGWriteFull ()
 Write the contents of the read in MCS file to the Configuration ROM of all initialized fADC125s. More...
 
void fa125FirmwarePrintTimes ()
 Print the time it took for each firmware update step to standard out. debug = FA125_FIRMWARE_DEBUG_MEASURE_TIMES Must be selected prior to update. More...
 
int fa125FirmwareGCheckErrors ()
 Print to standard out the results of the firmware update for each initialized fADC125. More...
 

Variables

pthread_mutex_t fa125Mutex = PTHREAD_MUTEX_INITIALIZER
 
int nfa125 =0
 
volatile struct fa125_a24fa125p [(FA125_MAX_BOARDS+1)]
 
volatile struct fa125_a32fa125pd [(FA125_MAX_BOARDS+1)]
 
volatile unsigned int * FA125pmb
 
int fa125ID [FA125_MAX_BOARDS]
 
int fa125A32Base = 0x09000000
 
int fa125A32Offset = 0x08000000
 
int fa125A24Offset =0
 
unsigned int fa125AddrList [FA125_MAX_BOARDS]
 
int fa125MaxSlot =0
 
int fa125MinSlot =0
 
int fa125TriggerSource =0
 
int berr_count =0
 
int fa125BlockError =FA125_BLOCKERROR_NO_ERROR
 
const char * fa125_blockerror_names [FA125_BLOCKERROR_NTYPES]
 
volatile struct data_struct fadc_data
 
struct firmware_stats fa125FWstats
 
struct fpga_fw_info sfpga [NFPGATYPE]
 
const char * fa125_mode_names [FA125_SUPPORTED_NMODES]
 

Macro Definition Documentation

#define LSWAP (   x)
Value:
((((x) & 0x000000ff) << 24) | \
(((x) & 0x0000ff00) << 8) | \
(((x) & 0x00ff0000) >> 8) | \
(((x) & 0xff000000) >> 24))

Referenced by fa125Poll(), and fa125ReadBlock().

#define SHOWBERR

Enumeration Type Documentation

enum ifpgatype
Enumerator
MAIN 
FE 
PROC 
NFPGATYPE 

Function Documentation

void fa125CheckAddresses ( int  id)

References fa125ID, and fa125p.

Variable Documentation

int berr_count =0

Referenced by fa125GetBerrCount(), and fa125Poll().

const char* fa125_blockerror_names[FA125_BLOCKERROR_NTYPES]
Initial value:
=
{
"No Error",
"Termination on word count",
"Unknown Bus Error",
"Zero Word Count",
"DmaDone(..) Error"
}
const char* fa125_mode_names[FA125_SUPPORTED_NMODES]
Initial value:
=
{
"Raw Window Mode"
}

Referenced by fa125Status().

int fa125A24Offset =0
int fa125A32Base = 0x09000000

Referenced by fa125Init().

int fa125A32Offset = 0x08000000

Referenced by fa125Init(), and fa125ReadBlock().

unsigned int fa125AddrList[FA125_MAX_BOARDS]

Referenced by fa125Init().

int fa125BlockError =FA125_BLOCKERROR_NO_ERROR
int fa125MaxSlot =0

Referenced by fa125Init(), and fa125ReadBlock().

int fa125MinSlot =0

Referenced by fa125Init().

pthread_mutex_t fa125Mutex = PTHREAD_MUTEX_INITIALIZER
volatile struct fa125_a32* fa125pd[(FA125_MAX_BOARDS+1)]
volatile unsigned int* FA125pmb

Referenced by fa125Init(), and fa125ReadBlock().

int fa125TriggerSource =0

Referenced by fa125Init().

volatile struct data_struct fadc_data

Referenced by fa125DecodeData().

struct fpga_fw_info sfpga[NFPGATYPE]
Initial value:
=
{
{"MAIN", 0x45480, 0x0, 0, 0},
{"FE" , 0xC435A, 0x754E0, 0, 0},
{"PROC", 0x1659FA, 0x1E1B90, 0, 0}
}