From a17b7b177833c9e314188ad4fa905aee66bf30db Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Wed, 15 Sep 2021 11:06:39 +0200 Subject: [PATCH] m3:connected module id --- .../mythen3DetectorServer/RegisterDefs.h | 6 ++++++ .../slsDetectorFunctionList.c | 14 ++++++++++---- .../mythen3DetectorServer/slsDetectorServer_defs.h | 2 +- .../include/slsDetectorFunctionList.h | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h index 0a04b7916..ffa134e38 100644 --- a/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h +++ b/slsDetectorServers/mythen3DetectorServer/RegisterDefs.h @@ -113,6 +113,12 @@ #define SYSTEM_STATUS_SLV_BRD_DTCT_MSK (0x00000001 << SYSTEM_STATUS_SLV_BRD_DTCT_OFST) +#define MOD_ID_REG (0x0B * REG_OFFSET + BASE_CONTROL) + +#define MOD_ID_OFST (0) +#define MOD_ID_MSK (0x0000FFFF << MOD_ID_OFST) + + /* Config RW regiseter */ #define CONFIG_REG (0x20 * REG_OFFSET + BASE_CONTROL) diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c index 3d8c99b13..71b62a216 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorFunctionList.c @@ -283,7 +283,14 @@ u_int32_t getDetectorNumber() { int getModuleId(int *ret, char *mess) { - return getModuleIdInFile(ret, mess, ID_FILE); + return ((bus_r(MOD_ID_REG) & ~MOD_ID_MSK) >> MOD_ID_OFST); +} + +void setModuleId(int modid) { + LOG(logINFOBLUE, ("Setting module id in fpga: %d\n", modid)) + bus_w(MOD_ID_REG, bus_r(MOD_ID_REG) & ~MOD_ID_MSK); + bus_w(MOD_ID_REG, + bus_r(MOD_ID_REG) | ((modid << MOD_ID_OFST) & MOD_ID_MSK)); } u_int64_t getDetectorMAC() { @@ -445,12 +452,11 @@ void setupDetector() { setADIFDefaults(); // set module id in register - getModuleIdInFile(&initError, initErrorMessage, ID_FILE); + int modid = getModuleIdInFile(&initError, initErrorMessage, ID_FILE); if (initError == FAIL) { return; } - // until firmware is done - // setModuleId(modid); + setModuleId(modid); // set trigger flow for m3 (for all timing modes) bus_w(FLOW_TRIGGER_REG, bus_r(FLOW_TRIGGER_REG) | FLOW_TRIGGER_MSK); diff --git a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h index 8efa6ead6..f39da11b8 100644 --- a/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h +++ b/slsDetectorServers/mythen3DetectorServer/slsDetectorServer_defs.h @@ -1,7 +1,7 @@ #pragma once #include "sls/sls_detector_defs.h" -#define REQRD_FRMWRE_VRSN (0x210201) +#define REQRD_FRMWRE_VRSN (0x210910) #define KERNEL_DATE_VRSN "Wed May 20 13:58:38 CEST 2020" #define ID_FILE "detid_mythen3.txt" diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index 8614e7672..28725264a 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -96,7 +96,7 @@ u_int32_t getDetectorNumber(); #if defined(GOTTHARD2D) || defined(EIGERD) || defined(MYTHEN3D) int getModuleId(int *ret, char *mess); #endif -#ifdef GOTTHARD2D +#if defined(GOTTHARD2D) || defined(MYTHEN3D) void setModuleId(int modid); #endif u_int64_t getDetectorMAC();