control/fem_api_extension/api/src/ExcaliburFemClientMpx3.cpp
void ExcaliburFemClient::mpx3CtprWrite(unsigned int aChipId)
{

  // If chip ID = 0, loop over all chips and call this function recursively
  if (aChipId == 0)
  {
    for (unsigned int iChip = 1; iChip <= kNumAsicsPerFem; iChip++)
    {
      this->mpx3CtprWrite(iChip);
    }
  }
  else
  {
    // Internal chip index runs from 0 to 7
    unsigned int chipIdx = aChipId - 1;

    // Store CTPR values into u32 vector for upload to FEM
    std::vector<u32> ctprValues(kNumAsicDpmWords, 0);

    // Pack CTPR values into the words of the vector, starting with the rightmost column (255)
    // as the bits are loaded MSB first
    unsigned int wordIdx = 0;
    unsigned int bitIdx = 31;

    for (int iCol = (kNumColsPerAsic - 1); iCol >= 0; iCol--)
    {
      ctprValues[wordIdx] |= (mMpx3ColumnTestPulseEnable[chipIdx][iCol] & 1) << bitIdx;
      if (bitIdx == 0)
      {
        bitIdx = 31;
        wordIdx++;
      }
      else
      {
        bitIdx--;
      }
    }

    {
        std::ostringstream os;
        for (unsigned int iWord = 0; iWord < 8; iWord++)
        {
          os  << "0x" << std::hex << std::setw(8) << std::setfill('0') << ctprValues[iWord]
              << std::dec << " ";
        }
        FEMLOG(mFemId, logDEBUG) << "CTPR Chip: " << chipIdx << " " << os.str();
    }

    // Write DAC values into FEM (into DPM area accessed via RDMA)
    this->rdmaWrite(kExcaliburAsicDpmRdmaAddress, ctprValues);

    // Set ASIC MUX register
    this->asicControlMuxChipSelect(chipIdx);

    // Set OMR registers
    mpx3Omr theOmr = this->mpx3OMRBuild(chipIdx, setCtpr);
    this->asicControlOmrSet(theOmr);

    // Trigger OMR command write
    this->asicControlCommandExecute(asicCommandWrite);

  }
}
/** mpx3CtprWrite - write the column test pulse enable registers to an ASIC
 *
 * This function uploads the current column test pulse enable settings to the FEM and
 * then loads them into the specified ASIC. The settings are derived from the
 * locally-cached values, which in turn are set up by the pixel configuration calls.
 *
 * @param aChipId chip ID  to write (1-8, 0=all)
 */
write the column test pulse enable registers to an ASIC
This function uploads the current column test pulse enable settings to the FEM and
then loads them into the specified ASIC. The settings are derived from the
locally-cached values, which in turn are set up by the pixel configuration calls.

@param aChipId chip ID  to write (1-8, 0=all)
write the column test pulse enable registers to an ASIC This function uploads the current column test pulse enable settings to the FEM and then loads them into the specified ASIC . The settings are derived from the locally - cached values which in turn are set up by the pixel configuration calls . @param aChipId chip ID to write ( 1 - 8 0 = all )
void ExcaliburFemClient::mpx3CtprWrite(unsigned int aChipId)
{
  if (aChipId == 0)
  {
    for (unsigned int iChip = 1; iChip <= kNumAsicsPerFem; iChip++)
    {
      this->mpx3CtprWrite(iChip);
    }
  }
  else
  {
    unsigned int chipIdx = aChipId - 1;
    std::vector<u32> ctprValues(kNumAsicDpmWords, 0);
    unsigned int wordIdx = 0;
    unsigned int bitIdx = 31;
    for (int iCol = (kNumColsPerAsic - 1); iCol >= 0; iCol--)
    {
      ctprValues[wordIdx] |= (mMpx3ColumnTestPulseEnable[chipIdx][iCol] & 1) << bitIdx;
      if (bitIdx == 0)
      {
        bitIdx = 31;
        wordIdx++;
      }
      else
      {
        bitIdx--;
      }
    }
    {
        std::ostringstream os;
        for (unsigned int iWord = 0; iWord < 8; iWord++)
        {
          os  << "0x" << std::hex << std::setw(8) << std::setfill('0') << ctprValues[iWord]
              << std::dec << " ";
        }
        FEMLOG(mFemId, logDEBUG) << "CTPR Chip: " << chipIdx << " " << os.str();
    }
    this->rdmaWrite(kExcaliburAsicDpmRdmaAddress, ctprValues);
    this->asicControlMuxChipSelect(chipIdx);
    mpx3Omr theOmr = this->mpx3OMRBuild(chipIdx, setCtpr);
    this->asicControlOmrSet(theOmr);
    this->asicControlCommandExecute(asicCommandWrite);
  }
}
void ExcaliburFemClient :: mpx3CtprWrite ( unsigned int aChipId ) { if ( aChipId == 0 ) { for ( unsigned int iChip = 1 ; iChip <= kNumAsicsPerFem ; iChip ++ ) { this -> mpx3CtprWrite ( iChip ) ; } } else { unsigned int chipIdx = aChipId - 1 ; std :: vector < u32 > ctprValues ( kNumAsicDpmWords , 0 ) ; unsigned int wordIdx = 0 ; unsigned int bitIdx = 31 ; for ( int iCol = ( kNumColsPerAsic - 1 ) ; iCol >= 0 ; iCol -- ) { ctprValues [ wordIdx ] |= ( mMpx3ColumnTestPulseEnable [ chipIdx ] [ iCol ] & 1 ) << bitIdx ; if ( bitIdx == 0 ) { bitIdx = 31 ; wordIdx ++ ; } else { bitIdx -- ; } } { std :: ostringstream os ; for ( unsigned int iWord = 0 ; iWord < 8 ; iWord ++ ) { os << " " << std :: hex << std :: setw ( 8 ) << std :: setfill ( ' ' ) << ctprValues [ iWord ] << std :: dec << " " ; } FEMLOG ( mFemId , logDEBUG ) << " " << chipIdx << " " << os . str ( ) ; } this -> rdmaWrite ( kExcaliburAsicDpmRdmaAddress , ctprValues ) ; this -> asicControlMuxChipSelect ( chipIdx ) ; mpx3Omr theOmr = this -> mpx3OMRBuild ( chipIdx , setCtpr ) ; this -> asicControlOmrSet ( theOmr ) ; this -> asicControlCommandExecute ( asicCommandWrite ) ; } }
mpx3CtprWrite - write the column test pulse enable registers to an ASIC
 This function uploads the current column test pulse enable settings to the FEM and
 then loads them into the specified ASIC.
mpx3CtprWrite - write the column test pulse enable registers to an ASIC This function uploads the current column test pulse enable settings to the FEM and then loads them into the specified ASIC .
// If chip ID = 0, loop over all chips and call this function recursively // Internal chip index runs from 0 to 7 // Store CTPR values into u32 vector for upload to FEM // Pack CTPR values into the words of the vector, starting with the rightmost column (255) // as the bits are loaded MSB first // Write DAC values into FEM (into DPM area accessed via RDMA) // Set ASIC MUX register // Set OMR registers // Trigger OMR command write