CCCUSB

Name

CCCUSB -- Provide access to a CC-USB device.

Synopsis


        

            class CCCUSB {
            
  static std::vector<struct usb_device*> enumerate();
            
              static std::string serialNo(struct usb_device* dev);
            
           
  CCCUSB(struct usb_device* vmUsbDevice);
              void writeActionRegister(uint16_t value);
              CCCUSBReadoutList* createReadoutList();
              int simpleWrite16(int n, int a, int f, uint16_t data, uint16_t& qx);
              int simpleWrite24(int n, int a, int f, uint32_t data, uint16_t& qx);
              int simpleRead16(int n, int a, int f, uint16_t& data, uint16_t& qx);
              int simpleRead24(int n, int a, int f, uint32_t& data, uint16_t& qx);
              int simpleControl(int n, int a, int f, uint16_t& qx);
              int readFirmware(uint32_t& value);
              int readGlobalMode(uint16_t& value);
              int writeGlobalMode(uint16_t value);
              int readDelays(uint16_t& value);
              int writeDelays(uint16_t value);
              int readScalerControl(uint32_t& value);
              int writeScalerControl(uint32_t value);
              int readLedSelector(uint32_t& value);
              int writeLedSelector(uint32_t value);
              int readOutputSelector(uint32_t& value);
              int writeOutputSelector(uint32_t value);
              int readDeviceSourceSelectors(uint32_t& value);
              int writeDeviceSourceSelectors(uint32_t value);
              int readDGGA(uint32_t& value);
              int readDGGB(uint32_t& value);
              int readDGGExt(uint32_t& value);
              int writeDGGA(uint32_t value);
              int writeDGGB(uint32_t value);
              int writeDGGExt(uint32_t value);
              int readScalerA(uint32_t& value);
              int readScalerB(uint32_t& value);
              int readLamTriggers(uint32_t& value);
              int writeLamTriggers(uint32_t value);
              int readUSBBulkTransferSetup(uint32_t& value);
              int writeUSBBulkTransferSetup(uint32_t value);
              int c();
              int z();
              int inhibit();
              int uninhibit();
              int executeList(CCCUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);
              int loadList(uint8_t listNumber, CCCUSBReadoutList& list);
              int usbRead(void* data, size_t bufferSize, size_t*  transferCount, int timeout =  2000);
              void setDefaultTimeout(int ms);
              static const uint16_t CCCUSB::ActionRegister::startDAQ = 1;
              static const uint16_t CCCUSB::ActionRegister::usbTrigger = 2;
              static const uint16_t CCCUSB::ActionRegister::clear = 4;
              static const uint16_t CCCUSB::ActionRegister::scalerDump = 0x10;
              static const uint32_t CCCUSB::FirmwareRegister::revisionMask = 0xff;
              static const uint32_t CCCUSB::FirmwareRegister::revisionShift = 0;
              static const uint32_t CCCUSB::FirmwareRegister::yearMask = 0xf00;
              static const uint32_t CCCUSB::FirmwareRegister::yearShift = 8;
              static const uint32_t CCCUSB::FirmwareRegister::monthMask = 0xf000;
              static const uint32_t CCCUSB::FirmwareRegister::monthShift =  12;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLenMask = 0xf;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLenShift = 0;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLen4K = 0;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLen2K = 1;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLen1K = 2;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLen512 = 3;
              static const uint16_t  CCCUSB::GlobalModeRegister::bufferLen256 = 4;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLen128 = 5;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLen64 = 6;
              static const uint16_t CCCUSB::GlobalModeRegister::bufferLenSingle = 7;
              static const uint16_t CCCUSB::GlobalModeRegister::mixedBuffers = 0x20;
              static const uint16_t CCCUSB::GlobalModeRegister::doubleHeader = 0x100;
              static const uint16_t CCCUSB::GlobalModeRegister::enableSecondary = 0x1000;
              static const uint16_t CCCUSB::DelayRegister::triggerDelayMask = 0xff;
              static const uint16_t CCCUSB::DelayRegister::triggerDelayShift = 0;
              static const uint16_t CCCUSB::DelayRegister::lamTimeoutMask = 0xff00;
              static const uint16_t CCCUSB::DelayRegister::lamTimeoutShift = 8;
              static const uint32_t CCCUSB::ScalerControlRegister::eventsCountMask = 0xffff;
              static const uint32_t CCCUSB::ScalerControlRegister::eventsCountShift = 0;
              static const  uint32_t CCCUSB::ScalerControlRegister::timeIntervalMask = 0xff0000;
              static const uint32_t CCCUSB::ScalerControlRegister::timeIntervalShift = 16;
            
            
              static const uint32_t CCCUSB::LedSourceRegister::redEventTrigger = 0;
              static const uint32_t CCCUSB::LedSourceRegister::redBusy = 1;
              static const uint32_t CCCUSB::LedSourceRegister::redUSBOutFifoNotEmpty = 2;
              static const  uint32_t CCCUSB::LedSourceRegister::redUSBInFifoNotEmpty = 3;
              static const uint32_t CCCUSB::LedSourceRegister::redInvert = 0x10;
              static const  uint32_t CCCUSB::LedSourceRegister::redLatch = 0x20;
              static const uint32_t CCCUSB::LedSourceRegister::redShift = 0;
            
              static const uint32_t CCCUSB::LedSourceRegister::greenShift = 8;
              static const uint32_t CCCUSB::LedSourceRegister::greenAcquire = (0 << greenShift);
              static const uint32_t CCCUSB::LedSourceRegister::greenNimI1 = (1 << greenShift);
              static const  uint32_t CCCUSB::LedSourceRegister::greenUSBInFifoNotEmpty = (2 << greenShift;
              static const  uint32_t CCCUSB::LedSourceRegister::greenUSBTrigger = (3 << greenShift);
              static const uint32_t CCCUSB::LedSourceRegister::greenInvert = (0x10 << greenShift);
              static const  uint32_t CCCUSB::LedSourceRegister::greenLatch = (0x20 << greenShift);
            
        
              static const uint32_t CCCUSB::LedSourceRegister::yellowShift = = 16;
              static const uint32_t CCCUSB::LedSourceRegister::yellowNimI2 = (0 << yellowShift);
              static const  uint32_t CCCUSB::LedSourceRegister::yellowNimI3 = (1 << yellowShift);
              static const  uint32_t CCCUSB::LedSourceRegister::yellowBusy = (2 << yellowShift);
              static const  uint32_t CCCUSB::LedSourceRegister::yellowUsbInFifoNotEmpty = (3 << yellowShift);
              static const  uint32_t CCCUSB::LedSourceRegister::yellowInvert = (0x10 << yellowShift);
              static const uint32_t CCCUSB::LedSourceRegister::yellowLatch = (0x20 << yellowShift);
    
            
            



              static const  uint32_t CCCUSB::OutputSourceRegister::nimO1Shift = 0;
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO1Busy = (0 << nimO1Shift);
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO1Event = (1 << nimO1Shift;
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO1DGGA = (2 << nimO1Shift);
              static const uint32_t CCCUSB::OutputSourceRegister::nimO1DGGB = (3 << nimO1Shift);
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO1Invert = (0x10 << nimO1Shift);
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO1Latch = (0x20 << nimO1Shift);

 
 
              static const uint32_t CCCUSB::OutputSourceRegister::nimO2Shift = 8;
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO2Acquire = (0 <<nimO2Shift);
              static const uint32_t CCCUSB::OutputSourceRegister::nimO2Event = (1 << nimO2Shift);
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO2DGGA = (2 << nimO2Shift);
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO2DGGB = 3 << nimO2Shift;
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO2Invert = (0x10 << nimO2Shift);
              static const uint32_t CCCUSB::OutputSourceRegister::nimO2Latch = (0x20 << nimO2Shift);



              static const uint32_t CCCUSB::OutputSourceRegister::nimO3Shift = 16;
              static const  uint32_t nimO3BusyEnd = (0 << nimO3Shift);
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO3Busy = (1 << nimO3Shift;
              static const uint32_t CCCUSB::OutputSourceRegister::nimO3DGGA = (2 << nimO3Shift);
              static const uint32_t CCCUSB::OutputSourceRegister::nimO3DGGB = (3 << nimO3Shift;
              static const uint32_t CCCUSB::OutputSourceRegister::nimO3Invert = (0x10 << nimO3Shift);
              static const  uint32_t CCCUSB::OutputSourceRegister::nimO3Latch = (0x20 << nimO3Shift);
         
    
    
   
   
              static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAShift = 0;
              static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerADisabled = (0 << scalerAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerANimI1 = (1 << scalerAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerANimI2 = (2 << scalerAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerANimI3 = (3 << scalerAShift);
              static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAEvent = (4 << scalerAShift);
              static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAScalerBCarry = (5 << scalerAShift);
              static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerADGGA = (6 << scalerAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerADGGB = (7 << scalerAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAEnable = (0x10 << scalerAShift);
              static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAReset = (0x20 < scalerAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAFreeze = (0x40 << scalerAShift);
            
            
            
              static const  uint32_t scalerBShift =  8;
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBDisabled = (0 << scalerBShift);
              static const  uint32_t  CCCUSB::DeviceSourceSelectorsRegister::scalerBNimI1 = (1 << scalerBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBNimI2 = (2 << scalerBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBNimI3 = (3 << scalerBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBEvent = (4 << scalerBShift);
              static const int32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBScalerACarry = (5 << scalerBShift);
              static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBDGGA = (6 << scalerBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBDGGB  = (7 << scalerBShift);
              static const uint32_t  CCCUSB::DeviceSourceSelectorsRegister::scalerBEnable = (0x10 << scalerBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBReset = (0x20 << scalerBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBFreeze = (0x40 << scalerBShift);
            
            
            
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGAShift = 16;
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGADisabled = (0 << DGGAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGANimI1 = (1 << DGGAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGANimI2 = (2 << DGGAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGANimI3 = (3 << DGGAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGAEvent = (4 << DGGAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGABusyEnd = (5 << DGGAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGAUSBTrigger = (6 << DGGAShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGAPulser = (7 << DGGAShift);

            
            
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBShift = 24;
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBDisabled  = (0 << DGGBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBNimI1 = (1 << DGGBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBNimI2 = (2 << DGGBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBNimI3 = (3 << DGGBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBEvent = (4 << DGGBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBBusyEnd = (5 << DGGBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBUSBTrigger = (6 << DGGBShift);
              static const  uint32_t CCCUSB::DeviceSourceSelectorsRegister::DGGBPulser = (7 << DGGBShift);
    



              static const uint32_t CCCUSB::DGGAndPulserRegister::dggFineDelayMask = 0xffff;
              static const uint32_t CCCUSB::DGGAndPulserRegister::dggFineDelayShift = 0;
              static const uint32_t CCCUSB::DGGAndPulserRegister::dggGateWidthMask = 0xffff0000;
              static const uint32_t CCCUSB::DGGAndPulserRegister::dggGateWidthShift = 16;
              static const uint32_t CCCUSB::DGGCoarseRegister::ACoarseMask = xffff;;
              static const uint32_t CCCUSB::DGGCoarseRegister::ACoarseShift = 0;
              static const uint32_t CCCUSB::DGGCoarseRegister::BCoarseMask = 0xffff0000;
              static const uint32_t CCCUSB::DGGCoarseRegister::BCoarseShift = 16;
              static const uint32_t CCCCUSB::TransferSetupRegister::multiBufferCountMask = 0xff;
              static const  uint32_t  CCCCUSB::TransferSetupRegister::multiBufferCountShift = 0;
              static const  uint32_t CCCCUSB::TransferSetupRegister::timeoutMask = 0xf00;
              static const uint32_t CCCCUSB::TransferSetupRegister::timeoutShift = 8;
              static const uint16_t CCCUSB::Q = 1;
              static const uint16_t CCCUSB::X = 2;
            };
       

DESCRIPTION

The CCCUSB class represents a connection to a CC-USB controller. The static members enumerate and serialNo allow programs to become aware of the set of interfaces that are currently plugged in and powered up, and to associated them with serial number strings.

Constructing an object around a specific usb_device* allows you to interact with the device represented by that struct. The class exports a rich set of methods which are described in the METHODS section below. Bits and bit fields are defined as class constants described in PUBLIC VARIABLES, TYPES and CONSTANTS below.

METHODS

In the functions listed below, any function that returns an int returns 0 on success, -1 if the write operation to the device failed or -2 if the read operation failed. Negative values result in the errno variable set to the actual reason for the failure.

static std::vector<struct usb_device*> enumerate();

Enumerates the set of CC-USB devices that are attached and powered up on the host. The return value is a vector of usb_device* pointers each of which represents one of those devices.

You can use a usb_device* pointer to construct a CCCUSB object or to query the serial number of that device.

static std::string serialNo(struct usb_device* dev);

Returns the serial number string for the CC-USB represented by the dev parameter. dev should have been gotten from a call to CCCUSB::enumerate.

CCCUSB(struct usb_device* vmUsbDevice);

Constructs a CCCUSB object. The resulting object can be used to communicate with the CC-USB represented by the vmUsbDevice object.

void writeActionRegister(uint16_t value);

Writes the CCUSB's action register. The class also supplies symoblic definitions for bits in the action register. See the Action register section of PUBLIC VARIABLES, TYPES and CONSTANTS below.

CCCUSBReadoutList* createReadoutList();

Creates an empty readout list.

int simpleWrite16(int n, int a, int f, uint16_t data, uint16_t& qx);

Performs a CAMAC write operations with a 16 bit wide data transfer. The parameters n,a,f specify the slot, subaddress and function code respectively while the data parameter provides the data to write. The qx parameter receives a bit encoding of the Q and X responses of the operation. See PUBLIC VARIABLES, TYPES and CONSTANTS for the CCCUSB::Q and CCCUSB::X bit field definitions.

int simpleWrite24(int n, int a, int f, uint32_t data, uint16_t& qx);

Same as simpleWrite16 above, however the least significant 24 bits of data are written.

int simpleRead16(int n, int a, int f, uint16_t& data, uint16_t& qx);

Performs a 16 bit read from a CAMAC module. n,a,f define the slot, subaddress and function code respectively while data will receive the data from the operation. qx will contain a bit encoding of the dataway Q and X responses.

int simpleRead24(int n, int a, int f, uint32_t& data, uint16_t& qx);

Same as simpleRead16, however the data transfer is 24 bits. These are placed in the least significant 24 bits of data. The top 8 bits are zeroed.

int simpleControl(int n, int a, int f, uint16_t& qx);

Performs the non-data transfer operation (control function) specified by n,a,f. As usuall the dataway Q and X responses are stored in the qx parameter.

int readFirmware(uint32_t& value);

Reads the firmware id register storing it in the value parameter. This field is bit encoded. See the Firmware Register subsection of PUBLIC VARIABLES, TYPES and CONSTANTS below for symbols that allow you to extract the firmware register fields.

int readGlobalMode(uint16_t& value);

Reads the global mode register of the CC-USB. The value of that register is stored in the value parameter. The global mode register consists of several bits and bit fields. See the Global Mode subsection of PUBLIC VARIABLES, TYPES and CONSTANTS below for symbolic definitions of those bits and bit fields.

int writeGlobalMode(uint16_t value);

Writes the global mode register so that it contains value

int readDelays(uint16_t& value);

Reads the delays register into value. The delays register contains bit fields that control the trigger delay and lam timeout of lam waits. See the Delays Register section of PUBLIC VARIABLES, TYPES and CONSTANTS below for symbolic definitions of this register's contents.

int writeDelays(uint16_t value);

Writes value into the CC-USB's delays register.

int readScalerControl(uint32_t& value);

Reads the CC-USB scaler control register into value. This regtister contains bit fields that are defined in the Scaler Control Register subsection of PUBLIC VARIABLES, TYPES and CONSTANTS below.

int writeScalerControl(uint32_t value);

Writes value into the scaler control register of the CC-USB.

int readLedSelector(uint32_t& value);

Reads the value of the LED selector register into value. The LED selector register defines the meaning of the lights on the CC-USB front panel. The bit field definitions and values are described in LED Selector Register below in PUBLIC VARIABLES, TYPES and CONSTANTS

int writeLedSelector(uint32_t value);

Writes value into the LED selector register.

int readOutputSelector(uint32_t& value);

Read the value of the Output Selector register into value. The Output selector register determines the functions of the NIM output connectors on the front panel of the CC-USB. The bit field and code definitions of this register have symbolic definitions that are described in Output Selector Register in PUBLIC VARIABLES, TYPES and CONSTANTS below.

int writeOutputSelector(uint32_t value);

Write value into the output selector register.

int readDeviceSourceSelectors(uint32_t& value);

Read the device source selectors register into value. This register determines the input sources for various CC-USB onboard resources, specifically the two scalers and two gate generators. The bit fields in this register are described in Device Source Selector register in PUBLIC VARIABLES, TYPES and CONSTANTS below.

int writeDeviceSourceSelectors(uint32_t value);

Writes value into the device source selector register.

int readDGGA(uint32_t& value); int readDGGB(uint32_t& value); int readDGGExt(uint32_t& value);

These functions read registers that set up the parameters that control the two gate and delay generators in the CC-USB into the value parameter. The bit fields definitions for these registers are described in Gate and Delay Generators below in PUBLIC VARIABLES, TYPES and CONSTANTS

int writeDGGA(uint32_t value); int writeDGGB(uint32_t value); int writeDGGExt(uint32_t value);

Writes value into the registers that control the two gate and delay generators in the CC-USB.

int readScalerA(uint32_t& value); int readScalerB(uint32_t& value);

Reads the current value of scaler A or B internal to the CC-USB into the value parameter.

int readLamTriggers(uint32_t& value);

Reads the contents of the lam trigger register into value. The LAM trigger register is a mask of LAMs which if matched by the dataway LAM pattern will trigger the event list. If zero, readout is triggered by front panel inputs.

int writeLamTriggers(uint32_t value);

Write value to the LAM trigger register.

int readUSBBulkTransferSetup(uint32_t& value);

Reads the value of the USB Bulk transfer register into value. The bulk transfer register contains two bit fields which are defined in the USB Bulk Transfer Register under the PUBLIC VARIABLES, TYPES and CONSTANTS section below.

int writeUSBBulkTransferSetup(uint32_t value);

Writes value into the USB Bulk transfer register.

int c();

Performs a dataway C cycle.

int z();

Performs a data way Z cycle.

int inhibit();

Sets the dataway Inhibit line.

int uninhibit();

Unsets the dataway Inhibit line.

int executeList(CCCUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);

Performs a CAMAC list operation in immediate mode. In order to do this data taking mode must not be on. The list is built up by constructing a CCCUSBReadoutList (see CCCUSBReadoutList(3ccusb)) object and using its methods to add the appropriate set of instructions to the list.

pReadBuffer is a pointer to a buffer you have prepared to receive the results of the read operations in the list. This buffer has readBufferSize bytes of data. On successful return, bytesRead will contain the actual number of bytes transferred into your buffer. On failure (return value other than 0), the value of bytesRead is not well defined.

int loadList(uint8_t listNumber, CCCUSBReadoutList& list);

Loads a list into the CC-USB. The listNumber must be 0 for the event list and 1 for the scaler list. If it is any value other than this, the function will return -4. list is the CCCUSBReadoutList to load. See CCCUSBReadoutList(3ccusb) for information about this parameter and how to build it.

int usbRead(void* data, size_t bufferSize, size_t* transferCount, int timeout = 2000);

Pefroms a bulk read on the data transfer endpoint of the CC-USB. Normally this only needs to be called by the CCUSBReadout framework when in data taking mode. data is a buffer into which data read should be transferred. bufferSize is the number of bytes that can be stored in buffer transferCount points to a buffer that will contain the number of bytes actually transferred to the buffer. timeout is the number of milliseconds to wait for the transfer to complete before ending with a timeout condition.

void setDefaultTimeout(int ms);

Most of the immediate operations require a write to the CC-USB followed by a read to get status and/or data. This function allows you to override the default timeout for the read. ms is the number of milliseconds in the new timeout. Normally you will not need to call this.

PUBLIC VARIABLES, TYPES and CONSTANTS

The CCCUSB class exports several public constants that provide symbolic constants that help you to build up the contents of CC-USB registers. The subsections in this section describe these values for each register.

Action Register

The Action register is a write-only register. Setting bit patterns in the Action register cause the CC-USB to take specific actions.

static const uint16_t CCCUSB::ActionRegister::startDAQ = 1;

When this bit is set, the CC-USB enters data taking mode. In data taking mode the CC-USB responds to triggers for the Event and Scaler stacks by executing them and buffering their data for read via usbRead. Prior to executing immediate actions you must clear this bit and drain any buffered event data from the module.

static const uint16_t CCCUSB::ActionRegister::usbTrigger = 2;

Setting this bit performs a one-time trigger of the event readout list.

static const uint16_t CCCUSB::ActionRegister::clear = 4;

This bit is "intended primarily for use during firmware debugging" it should not be set by ordinary users like us.

static const uint16_t CCCUSB::ActionRegister::scalerDump = 0x10;

Setting this bit triggers execution of the scaler list.

Note that all bits except the startDAQ are one-shots that automatically reset after 150ns.

Firmware Register

This register contains the current revision of the device firmware. This is a set of bit fields in a 32 bit word:

static const uint32_t CCCUSB::FirmwareRegister::revisionMask = 0xff; static const uint32_t CCCUSB::FirmwareRegister::revisionShift = 0;

These two value define the revision field. If d contains the firmware revision register, you can extract the revisionfield by performing:


uint32_t revision = (d & CCCUSB::FirmwareRegister::revisionMask)
                    >> CCCUSB::FirmwareRegister::revisionShift;
                                

The remaining fields are defined in this way, by a mask and a shift count. Analagous operations can be used to extract the value of the field given the full firmware revision register value.

static const uint32_t CCCUSB::FirmwareRegister::yearMask = 0xf00; static const uint32_t CCCUSB::FirmwareRegister::yearShift = 8;

Defines the field that gives the year in which the firmware version was finalized. The manual does not define what a 0 in this field means.

static const uint32_t CCCUSB::FirmwareRegister::monthMask = 0xf000; static const uint32_t CCCUSB::FirmwareRegister::monthShift = 12;

Defines the month field. This field contains the month in which the firmware was finalized. Presumably this is a value between [1..12].

Global Mode Register

The global mode register is described in section 3.3.2 of the CC-USB manual. This register can be built up by bitwise or-ing together the values described in this section.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLenMask = 0xf; , static const uint16_t CCCUSB::GlobalModeRegister::bufferLenShift = 0;

These values define the field in the global mode register that sets the lengt of the data buffer produced by the CC-USB.

For actual values you can or into the register see the fields bufferLenxx below.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLen4K = 0;

Selects buffers that are 4096 uint16_t units long.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLen2K = 1;

Use an output buffer length of 2048 uint16_t units long.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLen1K = 2;

Use an output buffer length of 1024 uint16_t units long.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLen512 = 3;

Use an output buffer length of 512 uint16_t units long.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLen256 = 4;

Use an output buffer length of 256 uint16_t units long.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLen128 = 5;

Use a 128 uint16_t unit large output buffer.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLen64 = 6;

Use a 64 uint16_t unit large output buffer.

static const uint16_t CCCUSB::GlobalModeRegister::bufferLenSingle = 7;

Use a buffer that holds only a single event.

static const uint16_t CCCUSB::GlobalModeRegister::mixedBuffers = 0x20;

Mix scaler and event data together in the same scaler buffer. If zero, buffers are homogenous with respect to the stack that contributes data to them.

static const uint16_t CCCUSB::GlobalModeRegister::doubleHeader = 0x100;

If set the buffer header will include a second word that contains the number of words in the buffer.

static const uint16_t CCCUSB::GlobalModeRegister::enableSecondary = 0x1000;

If set, CAMAC bus arbitration is enabled, allowing the use of an Auxiliary crate controller. In this case you must cable the Aux controller to request mastership via RQ, GIN, and GOUT signals on the front of the controller.

Delay Register

This register has fields for controlling the delay between the trigger and stack execution as well as the LAM timeout interval. Both fields are in units of microseconds.

static const uint16_t CCCUSB::DelayRegister::triggerDelayMask = 0xff; static const uint16_t CCCUSB::DelayRegister::triggerDelayShift = 0;

Mask and shift counts for the trigger delay field. This field controls the amount of time between the receipt of a trigger and execution of the event stack.

static const uint16_t CCCUSB::DelayRegister::lamTimeoutMask = 0xff00; static const uint16_t CCCUSB::DelayRegister::lamTimeoutShift = 8;

Mask and shift counts for the lam timeout field. This field controls the number of microseconds stack lines with the LM (lam wait mode) bit set will wait for a LM from the station specified.

Scaler Control register

The manual (3.3.4) refers to this as tyhe ACS control register, its function, however is to determine when the scaler (Auxilliary stack) is triggered. There are two fields. Both can be non-zero allowing for two trigger conditions. One trigger condition allows scalers to be triggered after a fixed number of events have been read. The second condition allows readout of scalers at fixed time intervals.

If a field is zero, that trigger condition is disabled.

static const uint32_t CCCUSB::ScalerControlRegister::eventsCountMask = 0xffff; static const uint32_t CCCUSB::ScalerControlRegister::eventsCountShift = 0;

Define the field that controls scaler triggers every fixed number of events. If this field is non zero, it specifies the number of events between scaler reads.

static const uint32_t CCCUSB::ScalerControlRegister::timeIntervalMask = 0xff0000; static const uint32_t CCCUSB::ScalerControlRegister::timeIntervalShift = 16;

Defines the field that sets up the time periodic trigger. If this is nonzero, it represents the scaler readout period in 0.5second units.

LED Source Register

This register contains a set of bit fields that describe the signal source that lights each of the LEDs on the front panel. Normally this register will be written with a logical or of values of one item from each bit field. The fields are named after the colors of the LED each field controls.

NoteFirmware changes
 

It appears that these definitions are for firmware revisions < 1.01. These definitions will be updated in the future to reflect the updated definitions.

static const uint32_t CCCUSB::LedSourceRegister::redEventTrigger = 0;

The red LED will light on an event trigger.

static const uint32_t CCCUSB::LedSourceRegister::redBusy = 1;

The red led will light when the CC-USB is busy. Busy means that the CC-USB is processing the event or scaler stack.

static const uint32_t CCCUSB::LedSourceRegister::redUSBTrigger = 2;

Lights the red LED when the software requests a USB trigger of the event stack by writing the CCCUSB::ActionRegister::usbTrigger bit to the action register.

static const uint32_t CCCUSB::LedSourceRegister::redUSBOutFifoNotEmpty = 3;

Lights the red LED whenever the USB output fifo is not empty.

static const uint32_t CCCUSB::LedSourceRegister::redUSBInFifoNotFull = 4;

Lights the red led whenever the USB input fifo is not ful.

static const uint32_t CCCUSB::LedSourceRegister::redAcquire = 6;;

Lights the red LED when acquisition mode is turned on (that is the last write to the action register set the CCCUSB::ActionRegister::startDAQ bit).

static const uint32_t CCCUSB::LedSourceRegister::redCAMACF2 = 7;

Lights the red LED whenever the 2's bit is set in the current CAAMC function being performed.

static const uint32_t CCCUSB::LedSourceRegister::redInvert = 0x10;

Inverts the state of the read LED.

static const uint32_t CCCUSB::LedSourceRegister::redLatch = 0x20;

When the trigger condition for the led exists, latches the led on until this bit is toggled off then on.

static const uint32_t CCCUSB::LedSourceRegister::greenAcquire = 0x000;

Sets the green LED when data acquisition is enabled.

static const uint32_t CCCUSB::LedSourceRegister::greenCAMACF1 = 0x100;

Sets the green LED whe the F1 line is set on the last CAMAC operation.

static const uint32_t CCCUSB::LedSourceRegister::greenEventTrigger = 0x300;

Turns on the green LED whenever the event trigger is being processed.

static const uint32_t CCCUSB::LedSourceRegister::greenCAMACN = 0x400;

Lights the green LED whhen a CAMAC operation has occured.

static const uint32_t CCCUSB::LedSourceRegister::greenI1 = 0x600;

Lights the green LED if the I1 input has a NIM true presented on it.

static const uint32_t CCCUSB::LedSourceRegister::greenUSBInFifoNotEmpty = 0x700;

Lights the green LED if the input FIFO is not empty.

static const uint32_t CCCUSB::LedSourceRegister::greenInvert = 0x1000;

Invert the sense of the green led.

static const uint32_t CCCUSB::LedSourceRegister::greenLatch = 0x2000;

Latch the green led. When the condition to light the LED occurs, the led stays on until this bit is toggled off (and then back on if the latch condition should be re-established).

static const uint32_t CCCUSB::LedSourceRegister::yellowI3 = 0x00000;

Light the yellow LED if the I3 input is active.

static const uint32_t CCCUSB::LedSourceRegister::yellowBusy = 0x10000;

Ligths the yellow LED when the CC-USB is busy executing one of the command stacks.

static const uint32_t CCCUSB::LedSourceRegister::yellowI2 = 0x20000;

Light the Yellow LED when the I2 input is active.

static const uint32_t CCCUSB::LedSourceRegister::yellowCAMACS1 = 0x30000;

Lights the yellow LED when the S1 signal on the CAMAC dataway is active.

static const uint32_t CCCUSB::LedSourceRegister::yellowCAMACS2 = 0x40000;

Lights the yellow LED when the CAMAC S2 dataway line is active.

static const uint32_t CCCUSB::LedSourceRegister::yellowUSBInFifoNotEmpty = 0x50000;

Lights the Yellow LED when the USB input FIFO is not empty.

static const uint32_t CCCUSB::LedSourceRegister::yellowScalerReadout = 0x60000;

Lights the Yellow led when the scaler stack is being executed.

static const uint32_t CCCUSB::LedSourceRegister::yellowUSBTrigger = 0x70000;

Lights the yellow LED when event stack execution has been requested by a USB write to the Action register.

static const uint32_t CCCUSB::LedSourceRegister::yellowInvert = 0x100000;

Inverts the sense of the Yellow LED.

static const uint32_t CCCUSB::LedSourceRegister::yellowLatch = 0x200000;

Enables latch mode for the yellow LED.

Output source selection register.

This register has several coded bit fields that select which signals are presented at the module nim outputs O1, O2, and O3.

NoteFirmware < 1.01
 

Thie definitions shwon here are only valid for firmware revisions < 1.01. This section and the header files themselves must be updated to reflect the current reduced set of output functionality.

static const uint32_t CCCUSB::OutputSourceRegisternimO1Busy = 0x000000;

O1 is asserted when the CC-USB is executing a stack.

static const uint32_t CCCUSB::OutputSourceRegisternimO1EventTrigger = 0x000001;

Ouptut 1 reflects that an event trigger has been recently received.

static const uint32_t CCCUSB::OutputSourceRegisternimO1DGGA = 0x000002;

O1 reflets the output gate and delay generator A.

static const uint32_t CCCUSB::OutputSourceRegisternimO1DGGB = 0x000003;

O1 reflects the output of gate and delay generator B.

static const uint32_t CCCUSB::OutputSourceRegisternimO1Latch = 0x000010M;

O1 is latched when set until this bit is toggled.

static const uint32_t CCCUSB::OutputSourceRegisternimO1Invert = 0x000020;

O1 is inverted relative to the code that selets its output.

static const uint32_t CCCUSB::OutputSourceRegisternimO2Acquire = 0x000000;

Asserts O1 when acquisition mode is turned on via the action register.

static const uint32_t CCCUSB::OutputSourceRegisternimO2Event = 0x000200;

Turns O2 on when an event trigger has been recently received.

static const uint32_t CCCUSB::OutputSourceRegisternimO2DGGA = 0x000400;

Reflects the output of gate and delay generator A in the O2 output.

static const uint32_t CCCUSB::OutputSourceRegisternimO2DGGB = 0x000600;

Reflects the output of gate and delay generator B to the O2 output.

static const uint32_t CCCUSB::OutputSourceRegisternimO2Latch = 0x001000;

Sets the O2 register in latching mode.

static const uint32_t CCCUSB::OutputSourceRegisternimO2Invert = 0x002000;

Inverts the sense of O2.

static const uint32_t CCCUSB::OutputSourceRegisternimO3EndOfBusy = 0x000000;

Asserts O3 when busy ends.

static const uint32_t CCCUSB::OutputSourceRegisternimO3Busy = 0x020000;

Asserts O3 when the CC-USB is executing a stack.

static const uint32_t CCCUSB::OutputSourceRegisternimO3DGGA = 0x040000;

O3 reflects the output of gate and delay generator A

static const uint32_t CCCUSB::OutputSourceRegisternim03DGGB = 0x060000;

O3 reflects the state of gate and delay generator B.

static const uint32_t CCCUSB::OutputSourceRegisternimO3Latch = 0x100000;

Latches the state of O3.

static const uint32_t CCCUSB::OutputSourceRegisternimO3Invert = 0x200000;

Inverts the sense of the O3 output.

Device source register

This register contains several fields that control the input sources to the scalers and gate and delay generators implemented in the CC-USB. The register contains four fields which are called scalerA, scalerB dggA and dggB. Typically you will bitwise or a code from each of the fields. In the case of the scaler fields there are three bits, Enable, Reset, and FreezeReg that can also be ored into the codes.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerADisabled = 0x00000000;

Scale A has no input, effectively disabling it. Note that if code is not use you will need to set the enable bit as well to enable the scaler to count.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAI1 = 0x00000001;

Selects I1 as the input to Scaler A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAI2 = 0x00000002;

Selects I2 as the input to scaler A.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAI3 = 0x00000003;

Selects I3 to be the input to scalerA.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAEvent = 0x00000004;

Selects the event trigger to be the source for Scaler A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerACarryB = 0x00000005;

Selects the carry out of scalerB to increment ScalerA this allows you to gang ScalerB (LSBs) and Scaler A (MSBs) into a single 48 bit scaler.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerADGGA = 0x00000006;

Scaler A will count when DGGA snds an output pulse.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerADGGB = 0x00000007;

Counts scaler A when when DGGB sends an output pulse.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAEnable = 0x00000010;

Enables Scaler A to count.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAScalerAReset = 0x00000020;

Resets scaler A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerAFreezReg = 0x00000040;

Any operation that writes this register with this bit set will not modify the effective code for selecting the inputs for scaler A. This allows you to enable/disable/clear scaler A without needing to know the actual scaler source. Note that since there is no corresponding freeze bit for the dggA/B sources this capability is of limited utility.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBDisabled = 0x00000000;

Directs to inputs to Scaler B. Note that if another input is used it's still necessary to also set the CCCUSB::DeviceSourceSelectorsRegister::scalerBEnable bit to enable the scaler to count.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBI1 = 0x00000100;

I1 is the input to ScalerB.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBI2 = 0x00000200;

Selects I2 as the input for Scaler B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBI3 = 0x00000300;

Selecst I3 as the input for Scaler B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBEvent = 0x00000400;

Selects the event trigger as the input for scaler B. Presumably using this allows the scaler to count the number of events acquired.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBCarryA = 0x00000500;

Selects the carry from Scaler A as the input to scalerB this enables the use of ScalerA/B as a 48 bit scaler with the LSBs in ScalerA and MSBs in ScalerB.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBDGGA = 0x00000600;

Enables the output of gate and delay generator A to be the input to scaler B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBDGGB = 0x00000700;

Enables the output of gate and delay generator B to be the input of scaler B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBEnable = 0x00001000;

This bit can be ored in with the selected Scaler B code values. It enables scaler B to count.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBReset = 0x00002000;

Resets scaler B

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::scalerBFreezeReg;

Freezes the scaler B input selector field. This allows one to write Reset and Enable bits without disturbing the event source. Note that you still must regenerate the DGGA and DGGB source selectors.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggADisabled = 0x00000000;

Provides no input signal to Gate and delay generator A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggAI1 = 0x00010000;

Routes the I1 front panel input to the input of gate and delay generator A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggAI2 = 0x00020000;

Routes the I2 front panel input to the input of gate and delay generator A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggAI3 = 0x00030000;

Routes the I3 front panel input to the input of gate and delay generator A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggAEvent = 0x00040000;

Routes the event trigger to the input of gate and delay generator A

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggAEndOfEvent = 0x00050000;

Pulses the inpt of gate and delay generator A when event readout has completed.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggAUSBTrigger = 0x00060000;

Pulses the input of gate and delay generator A when a USB stack trigger is written to the action register.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggAPulser = 0x00070000;

Pulses the input of gate and delay generator A from the output of the pulser.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBDisabled = 0x00000000;

Provides no input to gate and delay generator B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBI1 = 0x01000000;

Routes the I1 input signal to the input of Gate and delay generator B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBI2 = 0x02000000;

Routes the I2 input signal to the input of Gate and delay generator B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBI3 = 0x03000000;

Routes the I3 input signal to the input of Gate and delay generator B.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBEvent = 0x04000000;

Puses the input of gate and delay generator B when an event trigger is processed.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBEndOfTrigger = 0x05000000;

Pulses the input of DGGB at the end of processing an event trigger.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBUSBTrigger = 0x06000000;

Pulses the input of gate and delay generator B when a USB trigger is written to the Actino regsiter.

static const uint32_t CCCUSB::DeviceSourceSelectorsRegister::dggBPulser = 0x07000000;

Connects the pulser output to the input of gate and delay generator B

Gate and delay generator and pulser set up registers.

Several registers are used to set the timing of gate and delay registers. The timing parameters for gate and delay generator A also determine the timing for the pulser as showin in section 3.3.7 of the CC-USB manual.

This section describes the bit fields in these registers. Each field is descdribed as a mask and shift count. The mask removes all extraneous bits from the register except the desired field and the shift count, when used to shift the result right right justifies the field data.

static const uint32_t CCCUSB::DGGAndPulserRegister::dggFineDelayMask = 0xffff; static const uint32_t CCCUSB::DGGAndPulserRegister::dggFineDelayShift = 0;

Defines the fine delay field. See the course delays below.

static const uint32_t CCCUSB::DGGAndPulserRegister::dggGateWidthMask = 0xffff0000; static const uint32_t CCCUSB::DGGAndPulserRegister::dggGateWidthShift = 16;

Defines the gate width field.

static const uint32_t CCCUSB::DGGCoarseRegister::ACoarseMask = xffff;; static const uint32_t CCCUSB::DGGCoarseRegister::ACoarseShift = 0;

Defines the course delay fields for the a pulser.

static const uint32_t CCCUSB::DGGCoarseRegister::BCoarseMask = 0xffff0000; static const uint32_t CCCUSB::DGGCoarseRegister::BCoarseShift = 16;

Defines the B course delay field.

Transfer setup register

This regiseter allows you to read several buffers from the CC-USB in a single read, as well as setting a time bound on how long before the CC-USB terminates a multibuffer read.

static const uint32_t CCCCUSB::TransferSetupRegister::multiBufferCountMask = 0xff; static const uint32_t CCCCUSB::TransferSetupRegister::multiBufferCountShift = 0;

Defines the number of buffers that can be batched into a single usb_bulk_read request.

static const uint32_t CCCCUSB::TransferSetupRegister::timeoutMask = 0xf00; static const uint32_t CCCCUSB::TransferSetupRegister::timeoutShift = 8;

Determines the number of seconds after which the CC-USB will terminate a bulk transfer if not all of the buffers determined by themultiBuffer count have been transferred.

X and Q

The qx parameter on the simple CAMAC operations allow you access to the dataway Q and X lines. The bit encoding of that parameter is:

static const uint16_t CCCUSB::Q = 1;

If this bit was set in the qx parameter, the module asserted a Q on the dataway.

static const uint16_t CCCUSB::X = 2;

If this bit is set in the qx parameter, the module asserted an X on the dataway.

SEE ALSO

CCCUSBReadoutList(3ccusb)