JLab Signal Distribution Switch Slot module  A5
 All Data Structures Files Functions Variables Macros Groups
sdLib.c File Reference

Macros

#define DEVEL
 
#define SDLOCK   if(pthread_mutex_lock(&sdMutex)<0) perror("pthread_mutex_lock");
 
#define SDUNLOCK   if(pthread_mutex_unlock(&sdMutex)<0) perror("pthread_mutex_unlock");
 
#define SDBASE   0x40000
 
#define SD_MAX_FIRMWARE_SIZE   1024*1024
 

Functions

int sdInit (int flag)
 Initialize the Signal Distribution Module. More...
 
int sdStatus (int rflag)
 Display status of SD registers. More...
 
int sdGetFirmwareVersion (int pflag)
 Return and optionally display the SD firmware version. More...
 
int sdSetTiFastLink (int enable)
 Enable or Disable the Fast link to the TI. More...
 
int sdGetTiFastLink ()
 Return the state of the fast link to the TI. More...
 
int sdSetPLLClockFrequency (int iclk, int ifreq)
 Set the PLL Clock Frequency of A/B/Both. More...
 
int sdGetPLLClockFrequency (int iclk)
 Return the PLL clock frequency for the selected iclk. More...
 
int sdGetClockFrequency (int iclk, int pflag)
 Return the detected clock frequency for the selected iclk. More...
 
int sdSetClockMode (int iclk, int imode)
 Select whether the Clock fanned out will be jitter attenuated (PLL on) or as received from the TI. More...
 
int sdGetClockMode (int iclk)
 Return whether the Clock fanned out will be jitter attenuated (PLL) or as received from the TI(D) More...
 
int sdReset ()
 Reset the SD. More...
 
int sdSetActivePayloadPorts (unsigned int imask)
 Routine for user to define the Payload Ports that participate in Trigger Out, Busy Out, Token, and Status communication. More...
 
int sdSetActiveVmeSlots (unsigned int vmemask)
 Routine for user to define the Vme Slots that participate in Trigger Out, Busy Out, Token, and Status communication. More...
 
int sdGetActivePayloadPorts ()
 Routine to return the currently defined Payload Ports that participate in Trigger Out, Busy Out, Token, and Status communication. More...
 
int sdGetBusyoutCounter (int ipayload)
 Return the value of the Busyout Counter for a specified payload board Value of the counter is reset after read. More...
 
int sdPrintBusyoutCounters ()
 Display (to standard out) values of the busy counters for all VME Slots. More...
 
int sdGetBusyoutStatus (int pflag)
 Return the mask value of payload ports that are currently BUSY. More...
 
int sdGetTrigoutCounter (int ipayload)
 Return the value of the Trigout Counter for a specified payload board Value of the counter is reset after read. More...
 
int sdPrintTrigoutCounters ()
 Display (to standard out) values of the trigout counters for all VME Slots. More...
 
int sdFirmwareFlushFifo ()
 Flush the FIFO used in write data to the ROM. More...
 
int sdFirmwareLoadFile (char *filename)
 Load the specified file containing the firmware, into local memory. More...
 
void sdFirmwareFreeMemory ()
 Free the memory allocated to store the firmware. More...
 
int sdFirmwareVerifyPage (unsigned int mem_addr)
 Verify the page of data starting a specified memory address. More...
 
int sdFirmwareVerifyPageZero (unsigned int mem_addr)
 Verify the page of data starting a specified memory address, is zero. More...
 
void sdFirmwareWritePage (unsigned int mem_addr)
 Write a page of data starting a specified memory address. More...
 
int sdFirmwareWriteToMemory ()
 Write entire firmware to SD's ROM. More...
 
int sdFirmwareVerifyMemory ()
 Verify that SD's ROM contains exactly the contents of the firmware. More...
 
int sdFirmwareReadStatus ()
 Check the read status of the FIFO. More...
 
int sdFirmwareReadAddr (unsigned int addr)
 Read a specific address from the ROM. More...
 
void sdFirmwarePrintSpecs ()
 Read protected information from the ROM. More...
 
unsigned int sdGetSerialNumber (char *rSN)
 Return the serial number of the SD. More...
 
int sdTestGetBusyout ()
 Return the mask of busy's asserted from the payload ports. More...
 
int sdTestGetSdLink ()
 Return the asserted level from the TI over the SDlink. More...
 
int sdTestGetTokenIn ()
 Return payload port mask of those payload modules asserting TokenIN. More...
 
int sdTestGetTrigOut ()
 Return payload port mask of those payload modules asserting TrigOUT. More...
 
void sdTestSetTokenOutMask (int mask)
 Set TokenOUT levels HI to those payload ports specified in mask. More...
 
void sdTestSetStatBitBMask (int mask)
 Set StatBitB levels HI to those payload ports specified in mask. More...
 
void sdTestSetClkAPLL (int mode)
 Set the PLL mode for Clock A (LHS of crate). More...
 
int sdTestGetClockAStatus ()
 Return the amount of clocks ticks that occurred for a two second period after the Clock A Mode was set. More...
 
int sdTestGetClockAFreq ()
 Return the Clock A Frequency. This test was bypassed during acceptance testing. More...
 
void sdTestSetClkBPLL (int mode)
 Set the PLL mode for Clock B (LHS of crate). More...
 
int sdTestGetClockBStatus ()
 Return the amount of clocks ticks that occurred for a two second period after the Clock A Mode was set. More...
 
int sdTestGetClockBFreq ()
 Return the Clock B Frequency. This test was bypassed during acceptance testing. More...
 
void sdTestSetTIBusyOut (int level)
 Set the Busy OUT level to the TI. More...
 
int sdTestGetTITokenIn ()
 Get the input level from the TI TokenIN. More...
 
void sdTestSetTIGTPLink (int level)
 Set the GTP Link output to the TI. More...
 
unsigned int sdTestGetClkACounter ()
 Get the counter associated with the Clock A Frequency during period of 0.1ms. More...
 
unsigned int sdTestGetClkBCounter ()
 Get the counter associated with the Clock B Frequency during period of 0.1ms. More...
 
unsigned int sdTestGetSWALoopback ()
 Return the bit mask of levels sent from the SWA Module. This test was bypassed during acceptance testing. More...
 

Variables

pthread_mutex_t sdMutex = PTHREAD_MUTEX_INITIALIZER
 
volatile struct SDStructSDp =NULL
 
volatile struct TI_A24RegStruct * TIp
 
volatile struct TS_A24RegStruct * TSp
 

Macro Definition Documentation

#define DEVEL
#define SD_MAX_FIRMWARE_SIZE   1024*1024

Referenced by sdFirmwareLoadFile().

#define SDBASE   0x40000

Referenced by sdInit().

Variable Documentation

pthread_mutex_t sdMutex = PTHREAD_MUTEX_INITIALIZER
volatile struct SDStruct* SDp =NULL
volatile struct TI_A24RegStruct* TIp

Referenced by sdInit(), and sdStatus().

volatile struct TS_A24RegStruct* TSp

Referenced by sdInit(), and sdStatus().