Changeset 11519


Ignore:
Timestamp:
07/21/11 17:36:51 (13 years ago)
Author:
tbretz
Message:
Added new command to configure a single FTU and use this in SetThreshold and in EnablePixel.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/HeadersFTM.h

    r11469 r11519  
    5252        kCmdCrateReset     = 0x0020, ///< Reboot (no power cycle) all FTUs and FADs of one crate
    5353        kCmdDisableReports = 0x0040, ///< Disable transmission of rate-reports (dynamic data)
     54        kCmdConfigFTU      = 0x0080, ///< Configure single FTU board
    5455        kCmdToggleLed      = 0xc000,
    5556
     
    260261        bool IsEnabled(GeneralSettings type) const { return fGeneralSettings&uint16_t(type); }
    261262
    262         void EnablePixel(int idx, bool enable)
     263        uint16_t *EnablePixel(int idx, bool enable)
    263264        {
    264265            const int pixel = idx%9;
     
    272273            else
    273274                pix &= ~(1<<pixel);
     275
     276            return &pix;
    274277        }
    275278
  • trunk/FACT++/src/ftmctrl.cc

    r11483 r11519  
    554554        PostCmd(data, FTM::kCmdWrite, FTM::kCmdRegister);
    555555
    556         fBufStaticData.clear();
     556        reinterpret_cast<uint16_t*>(&fBufStaticData)[addr] = val;
    557557
    558558        // Request the changed configuration to ensure the
     
    600600    }
    601601
     602
    602603    void SetVerbose(bool b)
    603604    {
     
    670671            return false;
    671672
    672         FTM::StaticData data(fStaticData);
    673 
    674673        if (patch<0)
    675674        {
     675            FTM::StaticData data(fStaticData);
     676
    676677            bool ident = true;
    677678            for (int i=0; i<160; i++)
     
    687688            for (int i=0; i<160; i++)
    688689                data[i/4].fDAC[i%4] = value;
    689         }
    690         else
    691         {
    692             if (data[patch/4].fDAC[patch%4] == value)
    693                 return true;
    694 
    695             data[patch/4].fDAC[patch%4] = value;
    696         }
    697 
    698         // Maybe move to a "COMMIT" command?
    699         CmdSendStatDat(data);
     690
     691            // Maybe move to a "COMMIT" command?
     692            CmdSendStatDat(data);
     693
     694            return true;
     695        }
     696
     697        /*
     698         if (data[patch/4].fDAC[patch%4] == value)
     699            return true;
     700
     701         data[patch/4].fDAC[patch%4] = value;
     702
     703         CmdSendStatDat(data);
     704         return true;
     705         */
     706
     707        // Calculate offset in static data block
     708        const uint16_t addr = (uintptr_t(&fStaticData[patch/4].fDAC[patch%4])-uintptr_t(&fStaticData))/2;
     709
     710        // From CmdSetRegister
     711        const array<uint16_t, 2> data = {{ addr, uint16_t(value) }};
     712        PostCmd(data, FTM::kCmdWrite, FTM::kCmdRegister);
     713
     714        reinterpret_cast<uint16_t*>(&fBufStaticData)[addr] = value;
     715
     716        // Now execute change before the static data is requested back
     717        PostCmd(FTM::kCmdConfigFTU, (patch/40) | (((patch/4)%10)<<8));
     718
     719        CmdGetRegister(addr);
     720        //CmdReqStatDat();
    700721
    701722        return true;
     
    939960            return false;
    940961
    941         FTM::StaticData data(fStaticData);
    942 
    943962        if (idx==-1)
     963        {
     964            FTM::StaticData data(fStaticData);
     965
    944966            for (int i=0; i<=FTM::StaticData::kMaxPixelIdx; i++)
    945967                data.EnablePixel(i, enable);
    946         else
    947             data.EnablePixel(idx, enable);
    948 
    949         CmdSendStatDat(data);
     968
     969            CmdSendStatDat(data);
     970
     971            return true;
     972        }
     973
     974        /*
     975         data.EnablePixel(idx, enable);
     976         CmdSendStatDat(data);
     977         return true;
     978         */
     979
     980        FTM::StaticData data(fStaticData);
     981
     982        const uintptr_t base = uintptr_t(&data);
     983        const uint16_t *mem  = data.EnablePixel(idx, enable);
     984
     985        // Calculate offset in static data block
     986        const uint16_t addr = (uintptr_t(mem)-base)/2;
     987
     988        // From CmdSetRegister
     989        const array<uint16_t, 2> cmd = {{ addr, *mem }};
     990        PostCmd(cmd, FTM::kCmdWrite, FTM::kCmdRegister);
     991
     992        reinterpret_cast<uint16_t*>(&fBufStaticData)[addr] = *mem;
     993
     994        // Now execute change before the static data is requested back
     995        PostCmd(FTM::kCmdConfigFTU, (idx/360) | (((idx/36)%10)<<8));
     996
     997        // Now request the register back to ensure consistency
     998        CmdGetRegister(addr);
     999        //CmdReqStatDat();
    9501000
    9511001        return true;
     
    17761826             "|status[bool]:disable or enable that the FTM sends rate reports (yes/no)");
    17771827
    1778         T::AddEvent("SET_THRESHOLD", "I:2", FTM::kIdle)
     1828       T::AddEvent("SET_THRESHOLD", "I:2", FTM::kIdle, FTM::kTakingData)
    17791829            (bind(&StateMachineFTM::SetThreshold, this, placeholders::_1))
    17801830            ("Set the comparator threshold"
     
    17931843             "|Enable[bool]:Whether FTU should be enabled or disabled (yes/no)");
    17941844
    1795         T::AddEvent("DISABLE_PIXEL", "S:1", FTM::kIdle)
     1845        T::AddEvent("DISABLE_PIXEL", "S:1", FTM::kIdle, FTM::kTakingData)
    17961846            (bind(&StateMachineFTM::EnablePixel, this, placeholders::_1, false))
    17971847            ("(-1 or all)");
    17981848
    1799         T::AddEvent("ENABLE_PIXEL", "S:1", FTM::kIdle)
     1849        T::AddEvent("ENABLE_PIXEL", "S:1", FTM::kIdle, FTM::kTakingData)
    18001850            (bind(&StateMachineFTM::EnablePixel, this, placeholders::_1, true))
    18011851            ("(-1 or all)");
Note: See TracChangeset for help on using the changeset viewer.