From a048b7ba4f1da520a05a9a50c62295850bc37c31 Mon Sep 17 00:00:00 2001 From: Douglas Araujo <douglas.araujo@ess.eu> Date: Tue, 26 Mar 2024 10:18:55 +0100 Subject: [PATCH] Fix channel SPI loop --- vmmTblApp/src/vmm_config.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/vmmTblApp/src/vmm_config.cpp b/vmmTblApp/src/vmm_config.cpp index 316de95..3b1df25 100644 --- a/vmmTblApp/src/vmm_config.cpp +++ b/vmmTblApp/src/vmm_config.cpp @@ -22,7 +22,11 @@ void FENConfigModule::sendAll(bool useConfigCheck) { configFEN(); for(int hybrid = 0; hybrid <= HYBRIDS_PER_FEN; hybrid++) { if (isHybridEnabled(hybrid)) { + configHybrid(hybrid); + for(int vmm = 0; vmm < VMMS_PER_HYBRID; vmm++) { + configVMM(hybrid, vmm, useConfigCheck); + } } } } @@ -142,8 +146,6 @@ bool FENConfigModule::configVMM(int hybrid_index, int vmm_index, bool enableConf unsigned int firstGlobalRegSPI_2 = 0; unsigned int lastGlobalRegSPI_2 = 2; - unsigned int firstChRegSPI = 3; - unsigned int lastChRegSPI = 66; unsigned int firstGlobalRegSPI_1 = 67; unsigned int lastGlobalRegSPI_1 = 69; @@ -155,11 +157,12 @@ bool FENConfigModule::configVMM(int hybrid_index, int vmm_index, bool enableConf } //channel SPI - for(unsigned int i = firstChRegSPI; i <= lastChRegSPI; i++) { - std::string param = "vmm_ch" + std::to_string(i - firstChRegSPI); - param += sVmmIndex; - param += std::string(2 - std::to_string(i - firstChRegSPI).length(), '0'); // Right justify with '0' - uint32_t value = std::stoul(channelRegisters[i - firstChRegSPI], nullptr, 2); + for(unsigned int i = 0; i < CHANNELS_PER_VMM; i++) { + std::string position_str = std::to_string(i); + if (position_str.size() == 1) position_str = "0" + position_str; + std::string param = "vmm_ch" + position_str + sVmmIndex; + uint32_t value = std::stoul(channelRegisters[i], nullptr, 2); + std::cout << "param: " << param << std::endl; pFEN->user_reg_write(param, value); } -- GitLab