Compare commits

...

2 Commits

Author SHA1 Message Date
8063560e3a added FMC control
All checks were successful
Build on RHEL9 / build (push) Successful in 4m33s
Build on RHEL8 / build (push) Successful in 5m48s
2025-11-26 12:16:30 +01:00
178851fcf2 Merge branch 'developer' into MH02_debug
All checks were successful
Build on RHEL9 / build (push) Successful in 3m52s
Build on RHEL8 / build (push) Successful in 5m26s
2025-11-20 14:44:43 +01:00
6 changed files with 77 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
void XILINX_FMC_enable_all();
void XILINX_FMC_disable_all();

View File

@@ -0,0 +1,64 @@
// 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
};
// clang-format on
void XILINX_FMC_enable_all() {
LOG(logINFOBLUE, ("enable FMC power\n"));
#ifdef VIRTUAL
return;
#endif
char full_path[64];
for (size_t i = 0; i < sizeof(fmc_files) / sizeof(fmc_files[0]); ++i) {
snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, fmc_files[i]);
FILE *fp = fopen(full_path, "w");
if (fp == NULL) {
LOG(logERROR,("XILINX_FMC: enable Error\n"));
continue;
}
fprintf(fp, "1\n");
fclose(fp);
}
}
void XILINX_FMC_disable_all() {
LOG(logINFOBLUE, ("disable FMC power\n"));
#ifdef VIRTUAL
return;
#endif
char full_path[64];
for (size_t i = 0; i < sizeof(fmc_files) / sizeof(fmc_files[0]); ++i) {
snprintf(full_path, sizeof(full_path), "%s%s", FMC_BASE_PATH, fmc_files[i]);
FILE *fp = fopen(full_path, "w");
if (fp == NULL) {
LOG(logERROR,("XILINX_FMC: disable Error\n"));
continue;
}
fprintf(fp, "0\n");
fclose(fp);
}
}

View File

@@ -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

View File

@@ -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)

View File

@@ -10,6 +10,7 @@
#include "LTC2620_Driver.h"
#include "XILINX_PLL.h"
#include "XILINX_FMC.h"
#include "loadPattern.h"
#ifdef VIRTUAL
@@ -405,6 +406,10 @@ 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:
XILINX_FMC_enable_all();
LOG(logINFOBLUE, ("Powering down all dacs\n"));
for (int idac = 0; idac < NDAC; ++idac) {
setDAC(idac, LTC2620_D_GetPowerDownValue(), 0);
@@ -579,6 +584,7 @@ int powerChip(int on, char *mess) {
} else {
LOG(logINFOBLUE, ("Powering chip: off\n"));
bus_w(addr, bus_r(addr) & ~mask);
XILINX_FMC_disable_all();
chipConfigured = 0;