mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-03-01 22:48:44 +01:00
@@ -0,0 +1,5 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
|
||||
int XILINX_FMC_enable_all(char *error_message, int message_size);
|
||||
int XILINX_FMC_disable_all(char *error_message, int message_size);
|
||||
83
slsDetectorServers/slsDetectorServer/src/XILINX_FMC.c
Normal file
83
slsDetectorServers/slsDetectorServer/src/XILINX_FMC.c
Normal file
@@ -0,0 +1,83 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-other
|
||||
// Copyright (C) 2021 Contributors to the SLS Detector Package
|
||||
#include "XILINX_FMC.h"
|
||||
#include "arm64.h"
|
||||
#include "clogger.h"
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// clang-format off
|
||||
#define FMC_BASE_PATH "/root/fmc/"
|
||||
#define FMC_VADJ_EN "FMC_VADJ_EN"
|
||||
#define FMCP_VADJ_EN "FMCP_VADJ_EN"
|
||||
#define FMCP_3V3_EN "FMCP_3V3_EN"
|
||||
#define FMC_3V3_EN "FMC_3V3_EN"
|
||||
#define FMC_12V_EN "FMC_12V_EN"
|
||||
#define FMCP_12V_EN "FMCP_12V_EN"
|
||||
|
||||
static const char *fmc_files[] = {
|
||||
FMC_VADJ_EN,
|
||||
FMCP_VADJ_EN,
|
||||
FMCP_3V3_EN,
|
||||
FMC_3V3_EN,
|
||||
FMC_12V_EN,
|
||||
FMCP_12V_EN
|
||||
};
|
||||
#define FMC_NUM_FILES (sizeof(fmc_files) / sizeof(fmc_files[0]))
|
||||
// clang-format on
|
||||
|
||||
int XILINX_FMC_enable_all(char *error_message, int message_size) {
|
||||
LOG(logINFOBLUE, ("enable FMC power\n"));
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
char full_path[64];
|
||||
for (size_t i = 0; i < FMC_NUM_FILES; ++i) {
|
||||
const char *file = fmc_files[i];
|
||||
snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, file);
|
||||
FILE *fp = fopen(full_path, "w");
|
||||
if (fp == NULL) {
|
||||
snprintf(error_message, message_size,
|
||||
"XILINX_FMC: Couuld not enable.\n");
|
||||
LOG(logERROR, (error_message));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fprintf(fp, "1\n") != 2) {
|
||||
snprintf(error_message, message_size,
|
||||
"XILINX_FMC: Could not write enable.\n");
|
||||
LOG(logERROR, (error_message));
|
||||
return 1;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int XILINX_FMC_disable_all(char *error_message, int message_size) {
|
||||
LOG(logINFOBLUE, ("disable FMC power\n"));
|
||||
#ifdef VIRTUAL
|
||||
return;
|
||||
#endif
|
||||
char full_path[64];
|
||||
for (size_t i = 0; i < FMC_NUM_FILES; ++i) {
|
||||
const char *file = fmc_files[i];
|
||||
snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, file);
|
||||
FILE *fp = fopen(full_path, "w");
|
||||
if (fp == NULL) {
|
||||
snprintf(error_message, message_size,
|
||||
"XILINX_FMC: Could not disable\n");
|
||||
LOG(logERROR, (error_message));
|
||||
return 1;
|
||||
}
|
||||
if (fprintf(fp, "0\n") != 2) {
|
||||
snprintf(error_message, message_size,
|
||||
"XILINX_FMC: Could not write disable.\n");
|
||||
LOG(logERROR, (error_message));
|
||||
return 1;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ add_executable(xilinx_ctbDetectorServer_virtual
|
||||
../slsDetectorServer/src/communication_funcs.c
|
||||
../slsDetectorServer/src/arm64.c
|
||||
../slsDetectorServer/src/XILINX_PLL.c
|
||||
../slsDetectorServer/src/XILINX_FMC.c
|
||||
../slsDetectorServer/src/common.c
|
||||
../slsDetectorServer/src/sharedMemory.c
|
||||
../slsDetectorServer/src/loadPattern.c
|
||||
|
||||
@@ -23,7 +23,7 @@ DESTDIR ?= bin
|
||||
INSTMODE = 0777
|
||||
|
||||
SRCS = slsDetectorFunctionList.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)arm64.c $(main_src)XILINX_PLL.c $(main_src)common.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c $(md5_dir)md5.c $(main_src)programViaArm.c $(main_src)LTC2620_Driver.c
|
||||
SRCS += $(main_src)slsDetectorServer.c $(main_src)slsDetectorServer_funcs.c $(main_src)communication_funcs.c $(main_src)arm64.c $(main_src)XILINX_PLL.c $(main_src)XILINX_FMC.c $(main_src)common.c $(main_src)/sharedMemory.c $(main_src)/loadPattern.c $(md5_dir)md5.c $(main_src)programViaArm.c $(main_src)LTC2620_Driver.c
|
||||
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -9,8 +9,8 @@
|
||||
#include "sls/versionAPI.h"
|
||||
|
||||
#include "LTC2620_Driver.h"
|
||||
#include "XILINX_FMC.h"
|
||||
#include "XILINX_PLL.h"
|
||||
|
||||
#include "loadPattern.h"
|
||||
#ifdef VIRTUAL
|
||||
#include "communication_funcs_UDP.h"
|
||||
@@ -257,17 +257,17 @@ int testFixedFPGAPattern() {
|
||||
LOG(logINFO, ("Testing FPGA Fixed Pattern:\n"));
|
||||
#ifndef VIRTUAL
|
||||
uint32_t val = bus_r(FIXEDPATTERNREG);
|
||||
if (val == FIXEDPATTERNVAL) {
|
||||
if (val == FIXEDPATTERNREG_PRESET) {
|
||||
LOG(logINFO, ("\tFixed pattern: successful match (0x%08x)\n", val));
|
||||
} else {
|
||||
LOG(logERROR,
|
||||
("Fixed pattern does not match! Read 0x%08x, expected 0x%08x\n",
|
||||
val, FIXEDPATTERNVAL));
|
||||
val, FIXEDPATTERNREG_PRESET));
|
||||
return FAIL;
|
||||
}
|
||||
#endif
|
||||
LOG(logINFO,
|
||||
("\tSuccessfully read FPGA Fixed Pattern (0x%x)\n", FIXEDPATTERNVAL));
|
||||
LOG(logINFO, ("\tSuccessfully read FPGA Fixed Pattern (0x%x)\n",
|
||||
FIXEDPATTERNREG_PRESET));
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -405,6 +405,13 @@ void setupDetector() {
|
||||
|
||||
LTC2620_D_SetDefines(DAC_MIN_MV, DAC_MAX_MV, DAC_DRIVER_FILE_NAME, NDAC,
|
||||
NPWR, DAC_POWERDOWN_DRIVER_FILE_NAME);
|
||||
|
||||
// power LTC2620 before talking to it:
|
||||
initError = XILINX_FMC_enable_all(initErrorMessage, MAX_STR_LENGTH);
|
||||
if (initError == FAIL) {
|
||||
return;
|
||||
}
|
||||
|
||||
LOG(logINFOBLUE, ("Powering down all dacs\n"));
|
||||
for (int idac = 0; idac < NDAC; ++idac) {
|
||||
setDAC(idac, LTC2620_D_GetPowerDownValue(), 0);
|
||||
@@ -579,9 +586,10 @@ int powerChip(int on, char *mess) {
|
||||
} else {
|
||||
LOG(logINFOBLUE, ("Powering chip: off\n"));
|
||||
bus_w(addr, bus_r(addr) & ~mask);
|
||||
|
||||
chipConfigured = 0;
|
||||
|
||||
if (FAIL == XILINX_FMC_disable_all(mess, MAX_STR_LENGTH)) {
|
||||
return FAIL;
|
||||
}
|
||||
#ifdef VIRTUAL
|
||||
setTransceiverAlignment(0);
|
||||
#endif
|
||||
|
||||
@@ -804,7 +804,7 @@ typedef struct {
|
||||
}
|
||||
|
||||
sls_detector_module &operator=(const sls_detector_module &other) {
|
||||
if(this == &other)
|
||||
if (this == &other)
|
||||
return *this;
|
||||
delete[] dacs;
|
||||
delete[] chanregs;
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
#define APIGOTTHARD2 "0.0.0 0x250909"
|
||||
#define APIMOENCH "0.0.0 0x250909"
|
||||
#define APIEIGER "0.0.0 0x250909"
|
||||
#define APIXILINXCTB "0.0.0 0x251015"
|
||||
#define APIXILINXCTB "0.0.0 0x260106"
|
||||
#define APIJUNGFRAU "0.0.0 0x250909"
|
||||
#define APIMYTHEN3 "0.0.0 0x250922"
|
||||
|
||||
Reference in New Issue
Block a user