mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 23:37:14 +02:00
gotthard, cmakefiles language line removed
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(slsDetectorPackage LANGUAGES CXX)
|
||||
#project(slsDetectorPackage LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
|
||||
set (CALIBRATE OFF)
|
||||
|
@ -481,7 +481,7 @@ void setupDetector() {
|
||||
// set spi defines
|
||||
AD7689_SetDefines(ADC_SPI_REG, ADC_SPI_SLOW_VAL_REG, ADC_SPI_SLOW_SRL_CNV_MSK, ADC_SPI_SLOW_SRL_CLK_MSK, ADC_SPI_SLOW_SRL_DT_MSK, ADC_SPI_SLOW_SRL_DT_OFST);
|
||||
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK, ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_OFST);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, MAX_DAC_VOLTAGE_VALUE);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, DAC_MAX_VOLTAGE_MV);
|
||||
MAX1932_SetDefines(SPI_REG, SPI_HV_SRL_CS_OTPT_MSK, SPI_HV_SRL_CLK_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_OFST);
|
||||
|
||||
// disable spi
|
||||
@ -1031,7 +1031,14 @@ int validateTimer(enum timerIndex ind, int64_t val, int64_t retval) {
|
||||
|
||||
/* parameters - dac, adc, hv */
|
||||
|
||||
int getMaxDacSteps() {
|
||||
|
||||
}
|
||||
|
||||
void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0)
|
||||
return;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
int dacval = val;
|
||||
#ifdef VIRTUAL
|
||||
@ -1054,7 +1061,7 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
int getMAXDACUnits() {
|
||||
int getMaxDacSteps() {
|
||||
return LTC2620_MAX_STEPS;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,6 @@ enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9,
|
||||
#define WAIT_TIME_US_STP_ACQ (100)
|
||||
#define WAIT_TIME_CONFIGURE_MAC (500 * 1000)
|
||||
|
||||
#define MAX_DAC_VOLTAGE_VALUE (2500)
|
||||
#define DAC_MAX_VOLTAGE_MV (2500)
|
||||
#define VCHIP_MAX_MV (2700)
|
||||
#define VCHIP_MIN_MV (1700)
|
||||
|
@ -415,9 +415,9 @@ void setupDetector() {
|
||||
int retval[2]={-1,-1};
|
||||
const int defaultvals[NDAC] = DEFAULT_DAC_VALS;
|
||||
for(i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i,defaultvals[i],0,retval);
|
||||
if (retval[0] != defaultvals[i]) {
|
||||
FILE_LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], retval[0]));
|
||||
setDAC((enum DACINDEX)i,defaultvals[i],0);
|
||||
if ((detectorModules)->dacs[i] != defaultvals[i]) {
|
||||
FILE_LOG(logERROR, ("Setting dac %d failed, wrote %d, read %d\n",i ,defaultvals[i], (detectorModules)->dacs[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -847,10 +847,9 @@ int setModule(sls_detector_module myMod, char* mess) {
|
||||
// dacs
|
||||
{
|
||||
int i = 0;
|
||||
int retval[2] = {0, 0};
|
||||
for(i = 0; i < myMod.ndac; ++i) {
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i] , 0, retval);
|
||||
if (myMod.dacs[i] != retval[0]) {
|
||||
for(i = 0; i < NDAC; ++i) {
|
||||
setDAC((enum DACINDEX)i, myMod.dacs[i] , 0);
|
||||
if (myMod.dacs[i] != (detectorModules)->dacs[i]) {
|
||||
sprintf(mess, "Could not set module. Could not set dac %d\n", i);
|
||||
FILE_LOG(logERROR, (mess));
|
||||
setSettings(UNDEFINED);
|
||||
@ -929,12 +928,6 @@ int getModule(sls_detector_module *myMod) {
|
||||
int i;
|
||||
int retval[2];
|
||||
|
||||
//dacs
|
||||
for(i=0;i<NDAC;i++) {
|
||||
setDAC((enum DACINDEX)i,-1,0,retval);
|
||||
//FILE_LOG(logINFO,"dac%d:%d\n",i, *((detectorModules->dacs)+i));
|
||||
}
|
||||
|
||||
//trimbits
|
||||
unsigned int* tt;
|
||||
tt = Feb_Control_GetTrimbits();
|
||||
@ -1027,7 +1020,7 @@ void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
}
|
||||
|
||||
#ifdef VIRTUAL
|
||||
if (mV && Common_VoltageToDac(val, &dacval, 0, MAX_DAC_VOLTAGE_VALUE, MAX_DAC_UNIT_VALUE) == OK)
|
||||
if (mV && Common_VoltageToDac(val, &dacval, 0, DAC_MAX_VOLTAGE_MV, MAX_DAC_UNIT_VALUE) == OK)
|
||||
(detectorModules)->dacs[ind] = val;
|
||||
#else
|
||||
char iname[10];
|
||||
@ -1063,16 +1056,16 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
|
||||
if (!mV) {
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac\n",ind, (detectorModules)->dacs[ind]));
|
||||
return dacValues[ind];
|
||||
return (detectorModules)->dacs[ind];
|
||||
}
|
||||
int voltage = -1;
|
||||
Common_DacToVoltage((detectorModules)->dacs[ind], &voltage, 0, MAX_DAC_VOLTAGE_VALUE, MAX_DAC_UNIT_VALUE);
|
||||
Common_DacToVoltage((detectorModules)->dacs[ind], &voltage, 0, DAC_MAX_VOLTAGE_MV, MAX_DAC_UNIT_VALUE);
|
||||
FILE_LOG(logDEBUG1, ("Getting DAC %d : %d dac (%d mV)\n",ind, (detectorModules)->dacs[ind], voltage));
|
||||
return voltage;
|
||||
}
|
||||
|
||||
int getMAXDACUnits() {
|
||||
return MAX_DAC_UNIT_VALUE;
|
||||
int getMaxDacSteps() {
|
||||
return DAC_MAX_STEPS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,9 +74,8 @@ enum {E_PARALLEL, E_NON_PARALLEL, E_SAFE};
|
||||
#define DEFAULT_TEST_MODE (0)
|
||||
#define DEFAULT_HIGH_VOLTAGE (0)
|
||||
|
||||
#define MAX_DAC_VOLTAGE_VALUE (2048)
|
||||
#define MAX_DAC_UNIT_VALUE (4096)
|
||||
|
||||
#define DAC_MAX_VOLTAGE_MV (2048)
|
||||
#define DAC_MAX_STEPS (4096)
|
||||
|
||||
#define MAX_SUBFRAME_EXPOSURE_VAL_IN_10NS (0x1FFFFFFF) /** 29 bit register for max subframe exposure value */
|
||||
|
||||
|
@ -131,7 +131,7 @@
|
||||
#define TEMP_SPI_IN_T2_CLK_MSK (0x00000001 << TEMP_SPI_IN_T2_CLK_OFST)
|
||||
#define TEMP_SPI_IN_T2_CS_OFST (3)
|
||||
#define TEMP_SPI_IN_T2_CS_MSK (0x00000001 << TEMP_SPI_IN_T2_CS_OFST)
|
||||
#define TEMP_SPI_IDLE_MSK (TEMP_SPI_IN_T1_CS_MSK | TEMP_SPI_IN_T2_CS_MSK)
|
||||
#define TEMP_SPI_IN_IDLE_MSK (TEMP_SPI_IN_T1_CS_MSK | TEMP_SPI_IN_T2_CS_MSK | TEMP_SPI_IN_T1_CLK_MSK | TEMP_SPI_IN_T2_CLK_MSK)
|
||||
|
||||
/** Temperatre SPI Out register */
|
||||
#define TEMP_SPI_OUT_REG (0x1c << MEM_MAP_SHIFT)
|
||||
|
1
slsDetectorServers/gotthardDetectorServer/common.h
Symbolic link
1
slsDetectorServers/gotthardDetectorServer/common.h
Symbolic link
@ -0,0 +1 @@
|
||||
../slsDetectorServer/common.h
|
@ -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: 87f75630357249e5082b435a9ba852335881331f
|
||||
Revision: 13
|
||||
Repsitory UUID: bfda07d262dd4eb8c8298df6809d0172d10076e5
|
||||
Revision: 14
|
||||
Branch: refactor
|
||||
Last Changed Author: Dhanya_Thattil
|
||||
Last Changed Rev: 4181
|
||||
Last Changed Date: 2018-12-06 15:21:07.000000002 +0100 ./RegisterDefs.h
|
||||
Last Changed Rev: 4199
|
||||
Last Changed Date: 2019-01-04 12:28:36.000000002 +0100 ./.target-makefrag
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "87f75630357249e5082b435a9ba852335881331f"
|
||||
#define GITREPUUID "bfda07d262dd4eb8c8298df6809d0172d10076e5"
|
||||
#define GITAUTH "Dhanya_Thattil"
|
||||
#define GITREV 0x4181
|
||||
#define GITDATE 0x20181206
|
||||
#define GITREV 0x4199
|
||||
#define GITDATE 0x20190104
|
||||
#define GITBRANCH "refactor"
|
||||
|
@ -113,13 +113,13 @@ void basictests() {
|
||||
|
||||
"Firmware Version : 0x%llx\n"
|
||||
"Software Version : 0x%llx\n"
|
||||
"F/w-S/w API Version : 0x%llx\n"
|
||||
"Required F/w Version : 0x%x\n"
|
||||
"Client-S/w API Version : 0x%llx\n"
|
||||
"********************************************************\n",
|
||||
boardrev,
|
||||
|
||||
ipadd,
|
||||
(long long unsigned int)macadd,
|
||||
|
||||
(long long int)fwversion,
|
||||
(long long int)swversion,
|
||||
(long long int)client_sw_apiversion
|
||||
@ -379,7 +379,7 @@ void setupDetector() {
|
||||
AD9252_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK, ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_OFST);
|
||||
else
|
||||
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK, ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_OFST);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, MAX_DAC_VOLTAGE_VALUE);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, DAC_MAX_VOLTAGE_MV);
|
||||
|
||||
// disable spi
|
||||
if (getBoardRevision() == 1)
|
||||
@ -388,9 +388,8 @@ void setupDetector() {
|
||||
AD9257_Disable();
|
||||
LTC2620_Disable();
|
||||
|
||||
bus_w(DAC_CNTRL_REG, DAC_CNTRL_SPI_IDLE_MSK);
|
||||
bus_w(ADC_SPI_REG, ADC_SERIAL_CS_OUT_MSK);
|
||||
bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IDLE_MSK);
|
||||
bus_w(TEMP_SPI_IN_REG, TEMP_SPI_IN_IDLE_MSK);
|
||||
bus_w(TEMP_SPI_OUT_REG, 0x0);
|
||||
|
||||
#ifndef VIRTUAL
|
||||
if (getBoardRevision() == 1)
|
||||
@ -1144,6 +1143,9 @@ enum detectorSettings getSettings(){
|
||||
/* parameters - dac, adc, hv */
|
||||
|
||||
void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0)
|
||||
return;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
int dacval = val;
|
||||
#ifdef VIRTUAL
|
||||
@ -1166,7 +1168,7 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
int getMAXDACUnits() {
|
||||
int getMaxDacSteps() {
|
||||
return LTC2620_MAX_STEPS;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ enum DACINDEX {VREF_DS, VCASCN_PB, VCASCP_PB, VOUT_CM, VCASC_OUT, VIN
|
||||
#define DEFAULT_PHASE_SHIFT (120)
|
||||
#define DEFAULT_TX_UDP_PORT (0xE185)
|
||||
|
||||
#define MAX_DAC_VOLTAGE_VALUE (2500)
|
||||
#define DAC_MAX_VOLTAGE_MV (2500)
|
||||
|
||||
/** ENEt conf structs */
|
||||
typedef struct mac_header_struct{
|
||||
|
@ -399,7 +399,7 @@ void setupDetector() {
|
||||
|
||||
// set spi defines
|
||||
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK, ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_OFST);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, MAX_DAC_VOLTAGE_VALUE);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, DAC_MAX_VOLTAGE_MV);
|
||||
MAX1932_SetDefines(SPI_REG, SPI_HV_SRL_CS_OTPT_MSK, SPI_HV_SRL_CLK_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_OFST);
|
||||
|
||||
// disable spi
|
||||
@ -838,6 +838,9 @@ enum detectorSettings getSettings(){
|
||||
|
||||
/* parameters - dac, adc, hv */
|
||||
void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0)
|
||||
return;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
int dacval = val;
|
||||
#ifdef VIRTUAL
|
||||
@ -865,7 +868,7 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
int getMAXDACUnits() {
|
||||
int getMaxDacSteps() {
|
||||
return LTC2620_MAX_STEPS;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ enum NETWORKINDEX { TXN_FRAME };
|
||||
#define DEFAULT_NUM_STRG_CLLS (0)
|
||||
#define DEFAULT_STRG_CLL_STRT (0xf)
|
||||
|
||||
#define MAX_DAC_VOLTAGE_VALUE (2500)
|
||||
#define DAC_MAX_VOLTAGE_MV (2500)
|
||||
|
||||
/* Defines in the Firmware */
|
||||
#define FIX_PATT_VAL (0xACDC2014)
|
||||
|
@ -478,7 +478,7 @@ void setupDetector() {
|
||||
|
||||
// set spi defines
|
||||
AD9257_SetDefines(ADC_SPI_REG, ADC_SPI_SRL_CS_OTPT_MSK, ADC_SPI_SRL_CLK_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_MSK, ADC_SPI_SRL_DT_OTPT_OFST);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, MAX_DAC_VOLTAGE_VALUE);
|
||||
LTC2620_SetDefines(SPI_REG, SPI_DAC_SRL_CS_OTPT_MSK, SPI_DAC_SRL_CLK_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_MSK, SPI_DAC_SRL_DGTL_OTPT_OFST, NDAC, DAC_MAX_VOLTAGE_MV);
|
||||
MAX1932_SetDefines(SPI_REG, SPI_HV_SRL_CS_OTPT_MSK, SPI_HV_SRL_CLK_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_MSK, SPI_HV_SRL_DGTL_OTPT_OFST);
|
||||
|
||||
// disable spi
|
||||
@ -1019,6 +1019,9 @@ int validateTimer(enum timerIndex ind, int64_t val, int64_t retval) {
|
||||
/* parameters - dac, adc, hv */
|
||||
|
||||
void setDAC(enum DACINDEX ind, int val, int mV) {
|
||||
if (val < 0)
|
||||
return;
|
||||
|
||||
FILE_LOG(logDEBUG1, ("Setting dac[%d]: %d %s \n", (int)ind, val, (mV ? "mV" : "dac units")));
|
||||
int dacval = val;
|
||||
#ifdef VIRTUAL
|
||||
@ -1041,7 +1044,7 @@ int getDAC(enum DACINDEX ind, int mV) {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
int getMAXDACUnits() {
|
||||
int getMaxDacSteps() {
|
||||
return LTC2620_MAX_STEPS;
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,6 @@ enum DACINDEX {D0, D1, D2, D3, D4, D5, D6, D7, D8, D9,
|
||||
#define WAIT_TIME_US_STP_ACQ (100)
|
||||
#define WAIT_TIME_CONFIGURE_MAC (500 * 1000)
|
||||
|
||||
#define MAX_DAC_VOLTAGE_VALUE (2500)
|
||||
#define DAC_MAX_VOLTAGE_MV (2500)
|
||||
#define VCHIP_MAX_MV (2700)
|
||||
#define VCHIP_MIN_MV (1700)
|
||||
|
@ -96,9 +96,9 @@ void AD7689_SetDefines(uint32_t reg, uint32_t roreg, uint32_t cmsk, uint32_t clk
|
||||
* Disable SPI
|
||||
*/
|
||||
void AD7689_Disable() {
|
||||
bus_w(AD7689_Reg, bus_r(AD7689_Reg)
|
||||
bus_w(AD7689_Reg, (bus_r(AD7689_Reg)
|
||||
| AD7689_CnvMask
|
||||
| AD7689_ClkMask
|
||||
| AD7689_ClkMask)
|
||||
&~(AD7689_DigMask));
|
||||
}
|
||||
|
||||
|
@ -126,10 +126,10 @@ void AD9252_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t dm
|
||||
* Disable SPI
|
||||
*/
|
||||
void AD9252_Disable() {
|
||||
bus_w(AD9252_REG, bus_r(AD9252_REG)
|
||||
| AD9252_CS_MSK
|
||||
| AD9252_CLK_MSK
|
||||
&~(AD9252_DT_MSK));
|
||||
bus_w(AD9252_Reg, (bus_r(AD9252_Reg)
|
||||
| AD9252_CsMask
|
||||
| AD9252_ClkMask)
|
||||
&~(AD9252_DigMask));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,8 +141,8 @@ void AD9252_Set(int addr, int val) {
|
||||
u_int32_t codata;
|
||||
codata = val + (addr << 8);
|
||||
FILE_LOG(logINFO, ("\tSetting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr));
|
||||
serializeToSPI(AD9252_REG, codata, AD9252_CS_MSK, AD9252_ADC_NUMBITS,
|
||||
AD9252_CLK_MSK, AD9252_DT_MSK, AD9252_DT_OFST);
|
||||
serializeToSPI(AD9252_Reg, codata, AD9252_CsMask, AD9252_ADC_NUMBITS,
|
||||
AD9252_ClkMask, AD9252_DigMask, AD9252_DigOffset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,10 +151,10 @@ void AD9257_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t dm
|
||||
* Disable SPI
|
||||
*/
|
||||
void AD9257_Disable() {
|
||||
bus_w(AD9257_Reg, bus_r(AD9257_Reg)
|
||||
bus_w(AD9257_Reg, (bus_r(AD9257_Reg)
|
||||
| AD9257_CsMask
|
||||
| AD9257_ClkMask
|
||||
&~(AD9257_DigMask));
|
||||
| AD9257_ClkMask)
|
||||
& ~(AD9257_DigMask));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "commonServerFunctions.h" // blackfin.h, ansi.h
|
||||
#include "common.h"
|
||||
|
||||
#include "math.h"
|
||||
|
||||
/* LTC2620 DAC DEFINES */
|
||||
// first 4 bits are 0 as this is a 12 bit dac
|
||||
#define LTC2620_DAC_DATA_OFST (4)
|
||||
@ -23,7 +25,7 @@
|
||||
#define LTC2620_DAISY_CHAIN_NUMBITS (32) // due to shift register FIXME: was 33 earlier
|
||||
#define LTC2620_NUMCHANNELS (8)
|
||||
#define LTC2620_MIN_MV (0)
|
||||
#define LTC2620_MAX_STEPS (2^12) // 4096
|
||||
#define LTC2620_MAX_STEPS (pow(2,12)) // 4096
|
||||
#define LTC2620_PWR_DOWN_VAL (-100)
|
||||
|
||||
uint32_t LTC2620_Reg = 0x0;
|
||||
@ -54,57 +56,17 @@ void LTC2620_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t d
|
||||
LTC2620_MaxMV = mv;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable SPI
|
||||
*/
|
||||
void LTC2620_Disable() {
|
||||
bus_w(LTC2620_Reg, bus_r(LTC2620_Reg)
|
||||
bus_w(LTC2620_Reg, (bus_r(LTC2620_Reg)
|
||||
| LTC2620_CsMask
|
||||
| LTC2620_ClkMask
|
||||
&~(LTC2620_DigMask));
|
||||
| LTC2620_ClkMask)
|
||||
& ~(LTC2620_DigMask));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set dac in dac units or mV
|
||||
* @param dacnum dac index
|
||||
* @param val value in dac units or mV
|
||||
* @param mV 0 for dac units and 1 for mV unit
|
||||
* @param dacval pointer to value in dac units
|
||||
* @returns OK or FAIL for success of operation
|
||||
*/
|
||||
int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) {
|
||||
// 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));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// get
|
||||
if (val < 0 && val != LTC2620_PWR_DOWN_VAL)
|
||||
return FAIL;
|
||||
|
||||
// convert to dac or get mV value
|
||||
*dacval = val;
|
||||
int dacmV = val;
|
||||
if (mV) {
|
||||
ret = LTC2620_VoltageToDac(val, dacval);
|
||||
} else if (val >= 0) { // do not convert power down dac val
|
||||
ret = LTC2620_DacToVoltage(val, &dacmV);
|
||||
}
|
||||
|
||||
// conversion out of bounds
|
||||
if (ret == FAIL) {
|
||||
FILE_LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, (mV ? "mV" : "dac units")));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// set
|
||||
if ( (dacval >= 0) || (dacval == LTC2620_PWR_DOWN_VAL)) {
|
||||
FILE_LOG(logINFO, ("Setting DAC %d: %d dac (%d mV)\n",ind, dacval, dacmV));
|
||||
LTC2620_SetDAC(ind, dacval);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert voltage to dac units
|
||||
@ -116,6 +78,7 @@ int LTC2620_VoltageToDac(int voltage, int* dacval) {
|
||||
return Common_VoltageToDac(voltage, dacval, LTC2620_MIN_MV, LTC2620_MaxMV, LTC2620_MAX_STEPS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert dac units to voltage
|
||||
* @param dacval dac units
|
||||
@ -126,71 +89,6 @@ int LTC2620_DacToVoltage(int dacval, int* voltage) {
|
||||
return Common_DacToVoltage(dacval, voltage, LTC2620_MIN_MV, LTC2620_MaxMV, LTC2620_MAX_STEPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure (obtains dacaddr, command and ichip and calls LTC2620_Set)
|
||||
*/
|
||||
void LTC2620_Configure(){
|
||||
FILE_LOG(logINFOBLUE, ("Configuring LTC2620\n"));
|
||||
|
||||
// dac channel - all channels
|
||||
int addr = LTC2620_DAC_ADDR_MSK;
|
||||
|
||||
// data (any random low value, just writing to power up)
|
||||
int data = 0x6;
|
||||
|
||||
// command
|
||||
int cmd = LTC2620_DAC_CMD_WR_IN_VAL; //FIXME: should be command update and not write(does not power up)
|
||||
// also why do we need to power up (for jctb, we power down next)
|
||||
|
||||
LTC2620_Set(data, addr, cmd, -1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Dac (obtains dacaddr, command and ichip and calls LTC2620_Set)
|
||||
* @param dacnum dac number
|
||||
* @param data dac value to set
|
||||
*/
|
||||
void LTC2620_SetDAC (int dacnum, int data) {
|
||||
FILE_LOG(logDEBUG1, ("\tSetting dac %d to %d\n", dacnum, data));
|
||||
// LTC2620 index
|
||||
int ichip = dacnum / LTC2620_NUMCHANNELS;
|
||||
|
||||
// dac channel
|
||||
int addr = dacnum % LTC2620_NUMCHANNELS;
|
||||
|
||||
// command
|
||||
int cmd = LTC2620_DAC_CMD_WR_UPDTE_DAC_VAL;
|
||||
|
||||
// power down mode, value is ignored
|
||||
if (val == -100) {
|
||||
cmd = LTC2620_DAC_CMD_PWR_DWN_VAL;
|
||||
FILE_LOG(logDEBUG1, ("\tPOWER DOWN\n"));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1,("\tWrite to Input Register and Update\n"));
|
||||
}
|
||||
|
||||
LTC2620_Set(data, addr, cmd, ichip);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets a single chip (LTC2620_SetSingle) or multiple chip (LTC2620_SetDaisy)
|
||||
* multiple chip is only for ctb where the multiple chips are connected in daisy fashion
|
||||
* @param cmd command to send
|
||||
* @param data dac value to be set
|
||||
* @param dacaddr dac channel number for the chip
|
||||
* @param chipIndex the chip to be set
|
||||
*/
|
||||
void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
// ctb
|
||||
if (LTC2620_Ndac > LTC2620_NUMCHANNELS)
|
||||
LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex);
|
||||
// others
|
||||
else
|
||||
LTC2620_SetSingle(cmd, data, dacaddr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a single chip (all non ctb detectors use this)
|
||||
@ -211,6 +109,17 @@ void LTC2620_SetSingle(int cmd, int data, int dacaddr) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* bit bang the data into all the chips daisy fashion
|
||||
* @param valw current value of register while bit banging
|
||||
* @param val data to be sent (data, dac addr and command)
|
||||
*/
|
||||
void LTC2620_SendDaisyData(uint32_t* valw, uint32_t val) {
|
||||
sendDataToSPI(valw, LTC2620_Reg, val, LTC2620_DAISY_CHAIN_NUMBITS,
|
||||
LTC2620_ClkMask, LTC2620_DigMask, LTC2620_DigOffset);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a single chip (all non ctb detectors use this)
|
||||
* when max dac is 8
|
||||
@ -273,16 +182,112 @@ void LTC2620_SetDaisy(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
|
||||
|
||||
/**
|
||||
* bit bang the data into all the chips daisy fashion
|
||||
* @param valw current value of register while bit banging
|
||||
* @param val data to be sent (data, dac addr and command)
|
||||
* Sets a single chip (LTC2620_SetSingle) or multiple chip (LTC2620_SetDaisy)
|
||||
* multiple chip is only for ctb where the multiple chips are connected in daisy fashion
|
||||
* @param cmd command to send
|
||||
* @param data dac value to be set
|
||||
* @param dacaddr dac channel number for the chip
|
||||
* @param chipIndex the chip to be set
|
||||
*/
|
||||
void LTC2620_SendDaisyData(uint32_t* valw, uint32_t val) {
|
||||
sendDataToSPI(valw, LTC2620_Reg, val, LTC2620_DAISY_CHAIN_NUMBITS,
|
||||
LTC2620_ClkMask, LTC2620_DigMask, LTC2620_DigOffset);
|
||||
void LTC2620_Set(int cmd, int data, int dacaddr, int chipIndex) {
|
||||
// ctb
|
||||
if (LTC2620_Ndac > LTC2620_NUMCHANNELS)
|
||||
LTC2620_SetDaisy(cmd, data, dacaddr, chipIndex);
|
||||
// others
|
||||
else
|
||||
LTC2620_SetSingle(cmd, data, dacaddr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Configure (obtains dacaddr, command and ichip and calls LTC2620_Set)
|
||||
*/
|
||||
void LTC2620_Configure(){
|
||||
FILE_LOG(logINFOBLUE, ("Configuring LTC2620\n"));
|
||||
|
||||
// dac channel - all channels
|
||||
int addr = LTC2620_DAC_ADDR_MSK;
|
||||
|
||||
// data (any random low value, just writing to power up)
|
||||
int data = 0x6;
|
||||
|
||||
// command
|
||||
int cmd = LTC2620_DAC_CMD_WR_IN_VAL; //FIXME: should be command update and not write(does not power up)
|
||||
// also why do we need to power up (for jctb, we power down next)
|
||||
|
||||
LTC2620_Set(data, addr, cmd, -1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set Dac (obtains dacaddr, command and ichip and calls LTC2620_Set)
|
||||
* @param dacnum dac number
|
||||
* @param data dac value to set
|
||||
*/
|
||||
void LTC2620_SetDAC (int dacnum, int data) {
|
||||
FILE_LOG(logDEBUG1, ("\tSetting dac %d to %d\n", dacnum, data));
|
||||
// LTC2620 index
|
||||
int ichip = dacnum / LTC2620_NUMCHANNELS;
|
||||
|
||||
// dac channel
|
||||
int addr = dacnum % LTC2620_NUMCHANNELS;
|
||||
|
||||
// command
|
||||
int cmd = LTC2620_DAC_CMD_WR_UPDTE_DAC_VAL;
|
||||
|
||||
// power down mode, value is ignored
|
||||
if (data == LTC2620_PWR_DOWN_VAL) {
|
||||
cmd = LTC2620_DAC_CMD_PWR_DWN_VAL;
|
||||
FILE_LOG(logDEBUG1, ("\tPOWER DOWN\n"));
|
||||
} else {
|
||||
FILE_LOG(logDEBUG1,("\tWrite to Input Register and Update\n"));
|
||||
}
|
||||
|
||||
LTC2620_Set(data, addr, cmd, ichip);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set dac in dac units or mV
|
||||
* @param dacnum dac index
|
||||
* @param val value in dac units or mV
|
||||
* @param mV 0 for dac units and 1 for mV unit
|
||||
* @param dacval pointer to value in dac units
|
||||
* @returns OK or FAIL for success of operation
|
||||
*/
|
||||
int LTC2620_SetDACValue (int dacnum, int val, int mV, int* dacval) {
|
||||
// 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));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// get
|
||||
if (val < 0 && val != LTC2620_PWR_DOWN_VAL)
|
||||
return FAIL;
|
||||
|
||||
// convert to dac or get mV value
|
||||
*dacval = val;
|
||||
int dacmV = val;
|
||||
int ret = OK;
|
||||
if (mV) {
|
||||
ret = LTC2620_VoltageToDac(val, dacval);
|
||||
} else if (val >= 0) { // do not convert power down dac val
|
||||
ret = LTC2620_DacToVoltage(val, &dacmV);
|
||||
}
|
||||
|
||||
// conversion out of bounds
|
||||
if (ret == FAIL) {
|
||||
FILE_LOG(logERROR, ("Setting Dac %d %s is out of bounds\n", dacnum, (mV ? "mV" : "dac units")));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
// set
|
||||
if ( (*dacval >= 0) || (*dacval == LTC2620_PWR_DOWN_VAL)) {
|
||||
FILE_LOG(logINFO, ("Setting DAC %d: %d dac (%d mV)\n",dacnum, *dacval, dacmV));
|
||||
LTC2620_SetDAC(dacnum, *dacval);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,10 +36,10 @@ void MAX1932_SetDefines(uint32_t reg, uint32_t cmsk, uint32_t clkmsk, uint32_t d
|
||||
* Disable SPI
|
||||
*/
|
||||
void MAX1932_Disable() {
|
||||
bus_w(MAX1932_Reg, bus_r(MAX1932_Reg)
|
||||
bus_w(MAX1932_Reg, (bus_r(MAX1932_Reg)
|
||||
| MAX1932_CsMask
|
||||
| MAX1932_ClkMask
|
||||
&~(MAX1932_DigMask));
|
||||
| MAX1932_ClkMask)
|
||||
& ~(MAX1932_DigMask));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@
|
||||
void SPIChipSelect (uint32_t* valw, uint32_t addr, uint32_t csmask, uint32_t clkmask, uint32_t digoutmask) {
|
||||
|
||||
// start point
|
||||
(*valw) = (bus_r(addr) | csmask | clkmask &~(digoutmask));
|
||||
(*valw) = ((bus_r(addr) | csmask | clkmask) &(~digoutmask));
|
||||
bus_w (addr, (*valw));
|
||||
|
||||
// chip sel bar down
|
||||
@ -74,7 +74,7 @@ void serializeToSPI(uint32_t addr, uint32_t val, uint32_t csmask, int numbitstos
|
||||
}
|
||||
uint32_t valw;
|
||||
|
||||
SPIChipSelect (&valw, addr, csmask);
|
||||
SPIChipSelect (&valw, addr, csmask, clkmask, digoutmask);
|
||||
|
||||
sendDataToSPI(&valw, addr, val, numbitstosend, clkmask, digoutmask, digofset);
|
||||
|
||||
|
@ -157,7 +157,7 @@ extern void AD9257_SetVrefVoltage(int val) // AD9257.h
|
||||
|
||||
void setDAC(enum DACINDEX ind, int val, int mV);
|
||||
int getDAC(enum DACINDEX ind, int mV);
|
||||
int getMAXDACUnits();
|
||||
int getMaxDacSteps();
|
||||
#ifdef CHIPTESTBOARDD
|
||||
int checkVLimitCompliant(int mV);
|
||||
int checkVLimitDacCompliant(int dac);
|
||||
|
@ -835,13 +835,13 @@ int set_dac(int file_des) {
|
||||
|
||||
// dacs
|
||||
default:
|
||||
if (mV && val > MAX_DAC_VOLTAGE_VALUE) {
|
||||
if (mV && val > DAC_MAX_VOLTAGE_MV) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not set dac %d to value %d. Allowed limits (0 - %d mV).\n", ind, val, MAX_DAC_VOLTAGE_VALUE);
|
||||
sprintf(mess,"Could not set dac %d to value %d. Allowed limits (0 - %d mV).\n", ind, val, DAC_MAX_VOLTAGE_MV);
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else if (!mV && val > LTC2620_MAX_STEPS ) {
|
||||
} else if (!mV && val > getMaxDacSteps() ) {
|
||||
ret = FAIL;
|
||||
sprintf(mess,"Could not set dac %d to value %d. Allowed limits (0 - %d dac units).\n", ind, val, LTC2620_MAX_STEPS);
|
||||
sprintf(mess,"Could not set dac %d to value %d. Allowed limits (0 - %d dac units).\n", ind, val, getMaxDacSteps());
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else {
|
||||
#ifdef CHIPTESTBOARDD
|
||||
@ -854,7 +854,8 @@ int set_dac(int file_des) {
|
||||
FILE_LOG(logERROR,(mess));
|
||||
} else
|
||||
#endif
|
||||
setDAC(serverDacIndex, val, mV, retval);
|
||||
setDAC(serverDacIndex, val, mV);
|
||||
retval = getDAC(serverDacIndex, mV);
|
||||
}
|
||||
#ifdef EIGERD
|
||||
if (val != -1) {
|
||||
@ -885,7 +886,7 @@ int set_dac(int file_des) {
|
||||
FILE_LOG(logERROR,(mess));
|
||||
}
|
||||
}
|
||||
FILE_LOG(logDEBUG1, ("Dac (%d): %d %s\n", serverDacIndex, retval, (mv ? "mV" : "dac units")));
|
||||
FILE_LOG(logDEBUG1, ("Dac (%d): %d %s\n", serverDacIndex, retval, (mV ? "mV" : "dac units")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user