From 9d8aa5fe91e3457c46d732387231736d0422f318 Mon Sep 17 00:00:00 2001 From: Anna Bergamaschi Date: Thu, 6 Dec 2018 17:26:54 +0100 Subject: [PATCH] Works with CTB5 (and should be backward compatible with the rest) --- .../jctbDetectorServer/firmware_funcs.c | 65 ++++++++++++++++--- 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c b/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c index 3104a8a22..1e3297502 100755 --- a/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c +++ b/slsDetectorSoftware/jctbDetectorServer/firmware_funcs.c @@ -75,7 +75,8 @@ typedef struct ip_header_struct { struct timeval tss,tse,tsss; //for timing - +#define MAXDAC 32 +u_int32_t dac[MAXDAC]; FILE *debugfp, *datafp; @@ -1671,22 +1672,28 @@ int initHighVoltage(int val, int imod){ codata=((dacvalue)&0xff); - valw=bus_r(offw)&0x7fff; //switch off HV + valw=(bus_r(offw) & 0x7fff) | 0x00ff; + bus_w(offw,(valw)); // start point valw=((valw&(~(0x1<>(7-i))&0x1)<>(7-i))&0x1)<=0) { - valw=bus_r(offw)|0xff00;; //switch on HV + if (val>=0) { + valw=bus_r(offw) | 0x8000;; //switch on HV + printf("switch on HV in CTB4 %x\n"); } else { - valw=bus_r(offw)&0x7fff;//switch off HV + valw=bus_r(offw) & 0x7fff;//switch off HV + printf("switch off HV in CTB4\n"); } @@ -1695,6 +1702,22 @@ int initHighVoltage(int val, int imod){ bus_w(HV_REG,val); + + //added for CTB5! + + // valw=bus_r(POWER_ON_REG); + if (val>=0) { + i=bus_r(POWER_ON_REG) | 0x80000000;; //switch on HV + printf("switch on HV in CTB5 %08x\n", i); + } else { + i=bus_r(POWER_ON_REG) & 0x7fffffff;//switch off HV + printf("switch off HV in CTB5 %08x\n", i); + } + + bus_w(POWER_ON_REG,i); + + + // } } @@ -3212,12 +3235,22 @@ int setDacRegister(int dacnum,int dacvalue) { /* printf("Dac register %x wrote %08x\n",(DAC_REG_OFF+dacnum/2)<<11,val); */ /* bus_w((DAC_REG_OFF+dacnum/2)<<11, val); */ - +#ifdef CTB4 bus_w(DAC_NUM_REG, dacnum); bus_w(DAC_VAL_REG, dacvalue); bus_w(DAC_NUM_REG, dacnum | (1<<16)); bus_w(DAC_NUM_REG, dacnum); printf("Wrote dac register value %d address %d\n",bus_r(DAC_VAL_REG),bus_r(DAC_NUM_REG)) ; +#endif + +#ifndef CTB4 + + if (dacnum=0) { if (arg) bus_w(POWER_ON_REG,preg|0xffff0000);