diff --git a/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_refactor b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_refactor new file mode 100755 index 000000000..7745ef80d Binary files /dev/null and b/slsDetectorServers/gotthardDetectorServer/bin/gotthardDetectorServer_refactor differ diff --git a/slsDetectorServers/gotthardDetectorServer/gitInfo.txt b/slsDetectorServers/gotthardDetectorServer/gitInfo.txt index 08b691b85..9e4f965f2 100644 --- a/slsDetectorServers/gotthardDetectorServer/gitInfo.txt +++ b/slsDetectorServers/gotthardDetectorServer/gitInfo.txt @@ -1,9 +1,9 @@ Path: slsDetectorPackage/slsDetectorServers/gotthardDetectorServer URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git -Repsitory UUID: bfda07d262dd4eb8c8298df6809d0172d10076e5 -Revision: 14 +Repsitory UUID: 06a6d53a3f1c5aeeced47475057f956b72d9a74f +Revision: 15 Branch: refactor Last Changed Author: Dhanya_Thattil -Last Changed Rev: 4199 -Last Changed Date: 2019-01-04 12:28:36.000000002 +0100 ./.target-makefrag +Last Changed Rev: 4200 +Last Changed Date: 2019-01-07 12:06:28.000000002 +0100 ./.target-makefrag diff --git a/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h b/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h index 264a99d0d..8e66ba82a 100644 --- a/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h +++ b/slsDetectorServers/gotthardDetectorServer/gitInfoGotthard.h @@ -1,6 +1,6 @@ #define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git" -#define GITREPUUID "bfda07d262dd4eb8c8298df6809d0172d10076e5" +#define GITREPUUID "06a6d53a3f1c5aeeced47475057f956b72d9a74f" #define GITAUTH "Dhanya_Thattil" -#define GITREV 0x4199 -#define GITDATE 0x20190104 +#define GITREV 0x4200 +#define GITDATE 0x20190107 #define GITBRANCH "refactor" diff --git a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c index 61e2eae01..173f5e95f 100644 --- a/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/gotthardDetectorServer/slsDetectorFunctionList.c @@ -391,13 +391,14 @@ void setupDetector() { bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IN_IDLE_MSK); bus_w(TEMP_SPI_OUT_REG, 0x0); + #ifndef VIRTUAL if (getBoardRevision() == 1) AD9252_Configure(); else AD9257_Configure(); #endif - //configureADC(); + setROIADC(-1); // set adcsyncreg, daqreg, chipofinterestreg, cleanfifos, setGbitReadout(); LTC2620_Configure(); /*FIXME: if it doesnt work, switch to the old dac*/ @@ -487,65 +488,6 @@ void setPhaseShift(int numphaseshift) { FILE_LOG(logDEBUG1, ("Multipurpose reg: 0x%x\n", val)); } -void configureADC() { - printf("Preparing ADC\n"); - u_int32_t valw,codata,csmask; - int i,j,cdx,ddx; - cdx=0; ddx=1; - csmask=0x7c; // 1111100 - - for(j=0;j<3;j++){ - //command and value; - codata = 0; - if(j==0) - codata=(0x08<<8)+(0x3);//Power modes(global) //reset - else if(j==1) - codata=(0x08<<8)+(0x0);//Power modes(global) //chip run - else - codata = (0x14<<8)+(0x0);//Output mode //offset binary - - - // start point - valw=0xffffffff; - bus_w(ADC_SPI_REG,(valw)); - - //chip sel bar down - valw=((0xffffffff&(~csmask))); - bus_w(ADC_SPI_REG,valw); - - for (i=0;i<24;i++) { - //cldwn - valw=valw&(~(0x1<>(23-i))&0x1)< 0) { - if (mV) - val = voltageToDac(val); //gives -1 on error - else - dacmV = dacToVoltage(val); //gives -1 on error - } - - if (val >= 0) { - FILE_LOG(logINFO, ("Setting DAC %d: %d dac (%d mV)\n",ind, val, dacmV)); -#ifndef VIRTUAL - initDAC(ind,val); - clearDACSregister(); -#else - dacValues[ind] = val; -#endif - } - - retval[0] = dacValues[ind]; - retval[1] = dacToVoltage(retval[0]); - FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, retval[0], retval[1])); -} - -void initDAC(int dac_addr, int value) { - FILE_LOG(logDEBUG1, ("Programming dac %d with value %d\n", dac_addr, value)); - clearDACSregister(); - if (value >= 0) - program_one_dac(dac_addr,value); - nextDAC(); -} - -void clearDACSregister() { - putout("1111111111111111");//reset - putout("1111111111111110");//cs down -} - -void nextDAC() { - putout("1111111111111011");//cs up - putout("1111111111111001");//clk down - putout("1111111111111111");//reset -} - -void program_one_dac(int addr, int value) { - FILE_LOG(logDEBUG1, ("Programming dac %d with value %d\n", addr, value)); - int origValue = value; - int control = 32 + addr; - value = (value << 4) | (control << 16); - - { - int i = 0; - for (i = 0; i < 24; ++i) { - int bit = value & (1 << (23 - i)); - if (bit) { - putout("1111111111111100");//clk down - putout("1111111111111100");//write data - putout("1111111111111110");//clk up - } - else - { - putout("1111111111111000");//clk down - putout("1111111111111000");//write data - putout("1111111111111010");//clk up - } - } - } - dacValues[addr] = origValue; - FILE_LOG(logDEBUG1, ("\tDac %d set to %dn", addr, origValue)); -} - -// direct pattern output -u_int32_t putout(char *s) { - if (strlen(s)<16) { - FILE_LOG(logERROR, ("putout: incorrect pattern length\n")); - return FAIL; - } - - u_int32_t pat=0; - {int i = 0; - for (i = 0; i < 16; ++i) { - if (s[i]=='1') - pat = pat + (1 << (15 - i)); - } - } - bus_w(DAC_CNTRL_REG, pat); - return OK; -} -*/ int getADC(enum ADCINDEX ind){ #ifdef VIRTUAL @@ -1354,8 +1205,11 @@ int setHighVoltage(int val){ } FILE_LOG(logDEBUG1, ("\tHigh voltage value to be sent: 0x%x\n", sel)); - // switch off high voltage and set value - bus_w(addr, (bus_r(addr) & ~HV_ENBL_MSK) | sel); + // switch off high voltage + bus_w(addr, (bus_r(addr) & ~HV_ENBL_MSK)); + + // unset mask and set value + bus_w(addr, (bus_r(addr) & ~HV_SEL_MSK) | sel); // switch on high voltage if (val > 0) diff --git a/slsDetectorServers/slsDetectorServer/AD9257.h b/slsDetectorServers/slsDetectorServer/AD9257.h index 4d357a8e8..52e363f5e 100755 --- a/slsDetectorServers/slsDetectorServer/AD9257.h +++ b/slsDetectorServers/slsDetectorServer/AD9257.h @@ -204,9 +204,13 @@ void AD9257_Configure(){ FILE_LOG(logINFO, ("\tBinary offset\n")); AD9257_Set(AD9257_OUT_MODE_REG, AD9257_OUT_BINARY_OFST_VAL); - //output clock phase - FILE_LOG(logINFO, ("\tOutput clock phase\n")); //FIXME:?? + //output clock phase +#ifdef GOTTHARDD + FILE_LOG(logINFO, ("\tOutput clock phase is at default: 180\n")); +#else + FILE_LOG(logINFO, ("\tOutput clock phase: 60\n")); AD9257_Set(AD9257_OUT_PHASE_REG, AD9257_OUT_CLK_60_VAL); +#endif // lvds-iee reduced , binary offset FILE_LOG(logINFO, ("\tLvds-iee reduced, binary offset\n")); @@ -216,18 +220,18 @@ void AD9257_Configure(){ FILE_LOG(logINFO, ("\tAll devices on chip to receive next command\n")); AD9257_Set(AD9257_DEV_IND_2_REG, AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK); -#ifdef GOTTHARDD - AD9257_Set(AD9257_DEV_IND_1_REG, - AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK );// FIXME: gotthard setting dco and ifco to off?? -#else + AD9257_Set(AD9257_DEV_IND_1_REG, AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK | AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK); -#endif - // vref 1.33 - FILE_LOG(logINFO, ("\tVref 1.33\n"));// FIXME: needed for Gottthard? earlier not set (default 3.0 v) + // vref +#ifdef GOTTHARDD + FILE_LOG(logINFO, ("\tVref default at 2.0\n")); +#else + FILE_LOG(logINFO, ("\tVref 1.33\n")); AD9257_Set(AD9257_VREF_REG, AD9257_VREF_1_33_VAL); +#endif // no test mode FILE_LOG(logINFO, ("\tNo test mode\n")); diff --git a/slsDetectorServers/slsDetectorServer/LTC2620.h b/slsDetectorServers/slsDetectorServer/LTC2620.h index ec484081c..0d9d741a4 100755 --- a/slsDetectorServers/slsDetectorServer/LTC2620.h +++ b/slsDetectorServers/slsDetectorServer/LTC2620.h @@ -4,6 +4,7 @@ #include "common.h" #include "math.h" +#include /* LTC2620 DAC DEFINES */ // first 4 bits are 0 as this is a 12 bit dac @@ -190,6 +191,7 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) { * @param chipIndex the chip to be set */ void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) { + FILE_LOG(logDEBUG1, ("\tcmd:%d data:%d dacaddr:%d chipIndex:%d\n", cmd, data, dacaddr, chipIndex)); // ctb if (LTC2620_Ndac > LTC2620_NUMCHANNELS) LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex); @@ -243,10 +245,9 @@ void LTC2620_SetDAC (int dacnum, int data) { FILE_LOG(logDEBUG1,("\tWrite to Input Register and Update\n")); } - LTC2620_Set(data, addr, cmd, ichip); + LTC2620_Set(cmd, data, addr, ichip); } - /** * Set dac in dac units or mV * @param dacnum dac index @@ -256,6 +257,7 @@ void LTC2620_SetDAC (int dacnum, int data) { * @returns OK or FAIL for success of operation */ int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) { + FILE_LOG(logDEBUG1, ("\tdacnum:%d, val:%d, mV:%d\n", dacnum, val, mV)); // validate index if (dacnum < 0 || dacnum >= LTC2620_Ndac) { FILE_LOG(logERROR, ("Dac index %d is out of bounds (0 to %d)\n", dacnum, LTC2620_Ndac - 1)); @@ -289,5 +291,3 @@ int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) { } return OK; } - - diff --git a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h index 89dba5dd9..ea097ee33 100644 --- a/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/slsDetectorFunctionList.h @@ -89,7 +89,6 @@ void resetPeripheral(); #elif GOTTHARDD void setPhaseShiftOnce(); void setPhaseShift(int numphaseshift); -void configureADC(); void cleanFifos(); void setADCSyncRegister(); void setDAQRegister();