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

Go to the source code of this file.

Data Structures

struct  SDStruct
 

Macros

#define SD_SUPPORTED_FIRMWARE   0xA5
 
#define TEST
 
#define SD_INIT_IGNORE_VERSION   (1<<0)
 
#define SD_SYSTEM_CLKA_BYPASS_MODE   (1<<0)
 
#define SD_SYSTEM_CLKA_FREQUENCY_MASK   0x000C
 
#define SD_SYSTEM_CLKB_BYPASS_MODE   (1<<4)
 
#define SD_SYSTEM_CLKB_FREQUENCY_MASK   0x00C0
 
#define SD_SYSTEM_TI_LINK_ENABLE   (1<<9)
 
#define SD_SYSTEM_TEST_RESET   (1<<15)
 
#define SD_STATUS_CLKB_LOSS_OF_SIGNAL   (1<<0)
 
#define SD_STATUS_CLKB_LOSS_OF_LOCK   (1<<1)
 
#define SD_STATUS_CLKA_LOSS_OF_SIGNAL   (1<<2)
 
#define SD_STATUS_CLKA_LOSS_OF_LOCK   (1<<3)
 
#define SD_STATUS_POWER_FAULT   (1<<4)
 
#define SD_STATUS_TRIGOUT   (1<<5)
 
#define SD_STATUS_BUSYOUT   (1<<6)
 
#define SD_STATUS_CLKA_DETECTED_MASK   0x300
 
#define SD_STATUS_CLKA_DETECTED_UNKNOWN   (0<<8)
 
#define SD_STATUS_CLKA_DETECTED_31_25   (1<<8)
 
#define SD_STATUS_CLKA_DETECTED_125   (2<<8)
 
#define SD_STATUS_CLKA_DETECTED_250   (3<<8)
 
#define SD_STATUS_CLKB_DETECTED_MASK   0xC00
 
#define SD_STATUS_CLKB_DETECTED_UNKNOWN   (0<<10)
 
#define SD_STATUS_CLKB_DETECTED_31_25   (1<<10)
 
#define SD_STATUS_CLKB_DETECTED_125   (2<<10)
 
#define SD_STATUS_CLKB_DETECTED_250   (3<<10)
 
#define SD_CSRTEST_CLKA_PLL_BYPASS   (1<<0)
 
#define SD_CSRTEST_CLKA_TEST_STATUS   (1<<1)
 
#define SD_CSRTEST_CLKA_FREQ   ((1<<2)|(1<<3))
 
#define SD_CSRTEST_CLKB_PLL_BYPASS   (1<<4)
 
#define SD_CSRTEST_CLKB_TEST_STATUS   (1<<5)
 
#define SD_CSRTEST_CLKB_FREQ   ((1<<6)|(1<<7))
 
#define SD_CSRTEST_TI_BUSYOUT   (1<<8)
 
#define SD_CSRTEST_TI_TOKENIN   (1<<9)
 
#define SD_CSRTEST_TI_GTPLINK   (1<<10)
 
#define SD_CSRTEST_SWA_LOOPBACK0   (1<<11)
 
#define SD_CSRTEST_SWA_LOOPBACK1   (1<<12)
 
#define SD_CSRTEST_SWA_LOOPBACK2   (1<<13)
 
#define SD_CSRTEST_SWA_LOOPBACK_MASK   (SD_CSRTEST_SWA_LOOPBACK0|SD_CSRTEST_SWA_LOOPBACK1|SD_CSRTEST_SWA_LOOPBACK2)
 
#define SD_CSRTEST_TEST_RESET   (1<<15)
 
#define SD_MEMADDR_LSB_MASK   0xFFFF
 
#define SD_MEMADDR_MSB_MASK   0x00FF
 
#define SD_MEMWRITECTRL_DATA_MASK   0x00FF
 
#define SD_MEMWRITECTRL_WRITE   (1<<8)
 
#define SD_MEMWRITECTRL_WREN   (1<<9)
 
#define SD_MEMWRITECTRL_SHIFT_BYTES   (1<<10)
 
#define SD_MEMWRITECTRL_SECTOR_ERASE   (1<<12)
 
#define SD_MEMWRITECTRL_SECTOR_PROTECT   (1<<13)
 
#define SD_MEMREADCTRL_DATA_MASK   0x00FF
 
#define SD_MEMREADCTRL_READ   (1<<8)
 
#define SD_MEMREADCTRL_RDEN   (1<<9)
 
#define SD_MEMREADCTRL_READ_STATUS   (1<<10)
 
#define SD_MEMREADCTRL_NEGATE_BUSY   (1<<11)
 

Functions

int sdInit (int flag)
 Initialize the Signal Distribution Module. More...
 
int sdStatus ()
 
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 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 sdGetBusyoutStatus (int pflag)
 Return the mask value of payload ports that are currently BUSY. 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...
 
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...
 

Macro Definition Documentation

#define SD_CSRTEST_CLKA_FREQ   ((1<<2)|(1<<3))
#define SD_CSRTEST_CLKA_PLL_BYPASS   (1<<0)
#define SD_CSRTEST_CLKA_TEST_STATUS   (1<<1)

Referenced by sdTestGetClockAStatus().

#define SD_CSRTEST_CLKB_FREQ   ((1<<6)|(1<<7))
#define SD_CSRTEST_CLKB_PLL_BYPASS   (1<<4)
#define SD_CSRTEST_CLKB_TEST_STATUS   (1<<5)

Referenced by sdTestGetClockBStatus().

#define SD_CSRTEST_SWA_LOOPBACK0   (1<<11)
#define SD_CSRTEST_SWA_LOOPBACK1   (1<<12)
#define SD_CSRTEST_SWA_LOOPBACK2   (1<<13)
#define SD_CSRTEST_SWA_LOOPBACK_MASK   (SD_CSRTEST_SWA_LOOPBACK0|SD_CSRTEST_SWA_LOOPBACK1|SD_CSRTEST_SWA_LOOPBACK2)

Referenced by sdTestGetSWALoopback().

#define SD_CSRTEST_TEST_RESET   (1<<15)
#define SD_CSRTEST_TI_BUSYOUT   (1<<8)

Referenced by sdTestSetTIBusyOut().

#define SD_CSRTEST_TI_GTPLINK   (1<<10)

Referenced by sdTestSetTIGTPLink().

#define SD_CSRTEST_TI_TOKENIN   (1<<9)

Referenced by sdTestGetTITokenIn().

#define SD_INIT_IGNORE_VERSION   (1<<0)

Referenced by sdInit().

#define SD_MEMADDR_LSB_MASK   0xFFFF
#define SD_MEMADDR_MSB_MASK   0x00FF
#define SD_MEMREADCTRL_DATA_MASK   0x00FF
#define SD_MEMREADCTRL_NEGATE_BUSY   (1<<11)
#define SD_MEMREADCTRL_RDEN   (1<<9)
#define SD_MEMREADCTRL_READ   (1<<8)
#define SD_MEMREADCTRL_READ_STATUS   (1<<10)
#define SD_MEMWRITECTRL_DATA_MASK   0x00FF
#define SD_MEMWRITECTRL_SECTOR_ERASE   (1<<12)
#define SD_MEMWRITECTRL_SECTOR_PROTECT   (1<<13)
#define SD_MEMWRITECTRL_SHIFT_BYTES   (1<<10)
#define SD_MEMWRITECTRL_WREN   (1<<9)
#define SD_MEMWRITECTRL_WRITE   (1<<8)
#define SD_STATUS_BUSYOUT   (1<<6)

Referenced by sdStatus().

#define SD_STATUS_CLKA_DETECTED_125   (2<<8)

Referenced by sdStatus().

#define SD_STATUS_CLKA_DETECTED_250   (3<<8)

Referenced by sdStatus().

#define SD_STATUS_CLKA_DETECTED_31_25   (1<<8)

Referenced by sdStatus().

#define SD_STATUS_CLKA_DETECTED_MASK   0x300

Referenced by sdGetClockFrequency(), and sdStatus().

#define SD_STATUS_CLKA_DETECTED_UNKNOWN   (0<<8)

Referenced by sdStatus().

#define SD_STATUS_CLKA_LOSS_OF_LOCK   (1<<3)

Referenced by sdStatus().

#define SD_STATUS_CLKA_LOSS_OF_SIGNAL   (1<<2)

Referenced by sdStatus().

#define SD_STATUS_CLKB_DETECTED_125   (2<<10)

Referenced by sdStatus().

#define SD_STATUS_CLKB_DETECTED_250   (3<<10)

Referenced by sdStatus().

#define SD_STATUS_CLKB_DETECTED_31_25   (1<<10)

Referenced by sdStatus().

#define SD_STATUS_CLKB_DETECTED_MASK   0xC00

Referenced by sdGetClockFrequency(), and sdStatus().

#define SD_STATUS_CLKB_DETECTED_UNKNOWN   (0<<10)

Referenced by sdStatus().

#define SD_STATUS_CLKB_LOSS_OF_LOCK   (1<<1)

Referenced by sdStatus().

#define SD_STATUS_CLKB_LOSS_OF_SIGNAL   (1<<0)

Referenced by sdStatus().

#define SD_STATUS_POWER_FAULT   (1<<4)

Referenced by sdStatus().

#define SD_STATUS_TRIGOUT   (1<<5)

Referenced by sdStatus().

#define SD_SUPPORTED_FIRMWARE   0xA5
-------------------------------------------------------------------------—*
  Copyright (c) 2010        Southeastern Universities Research Association, *
                            Thomas Jefferson National Accelerator Facility  *
                                                                            *
    This software was developed under a United States Government license    *
    described in the NOTICE file included as part of this distribution.     *
                                                                            *
    Authors: Bryan Moffit                                                   *
             moffi.nosp@m.t@jl.nosp@m.ab.or.nosp@m.g                   Jefferson Lab, MS-12B3       *
             Phone: (757) 269-5660             12000 Jefferson Ave.         *
             Fax:   (757) 269-5800             Newport News, VA 23606       *
                                                                            *
-------------------------------------------------------------------------—*
 Description:
     Status and Control library for the JLAB Signal Distribution
     (SD) module using an i2c interface from the JLAB Trigger
     Interface/Supervisor (TI/TS) module.


  

Referenced by sdInit().

#define SD_SYSTEM_CLKA_BYPASS_MODE   (1<<0)
#define SD_SYSTEM_CLKA_FREQUENCY_MASK   0x000C
#define SD_SYSTEM_CLKB_BYPASS_MODE   (1<<4)
#define SD_SYSTEM_CLKB_FREQUENCY_MASK   0x00C0
#define SD_SYSTEM_TEST_RESET   (1<<15)

Referenced by sdReset().

#define SD_SYSTEM_TI_LINK_ENABLE   (1<<9)
#define TEST

Function Documentation

int sdStatus ( )