From f873087849c21d0e3b203d7ced2dbf621af778a0 Mon Sep 17 00:00:00 2001 From: Harsh Sharma Date: Mon, 21 Mar 2022 14:20:05 -0500 Subject: mtcap fpga loader bug fix --- include/General.h | 1 + src/AccessoryCards/Mtac15Fpga.cpp | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/General.h b/include/General.h index 861ec62..5e32f0b 100644 --- a/include/General.h +++ b/include/General.h @@ -59,6 +59,7 @@ typedef unsigned int uint; // 32 bit - even on 64 bit machines #define CRESET "/creset" #define LORA_1_5_MTCAP_SPI "/dev/spidev0.0" +#define LORA_1_5_MTCAP_SPI_FPGA "/dev/spidev0.1" #define LORA_1_5_MTCDT_SPI_AP_1 "/dev/spidev0.2" #define LORA_1_5_MTCDT_SPI_AP_2 "/dev/spidev1.2" diff --git a/src/AccessoryCards/Mtac15Fpga.cpp b/src/AccessoryCards/Mtac15Fpga.cpp index fda3737..ed30fe3 100644 --- a/src/AccessoryCards/Mtac15Fpga.cpp +++ b/src/AccessoryCards/Mtac15Fpga.cpp @@ -684,7 +684,18 @@ Mtac15Fpga::Mtac15Fpga(std::string inputFile, std::string forcedPath) { } std::string hwVersion = deviceInfo["hardwareVersion"].GetString(); - if (deviceInfo.HasMember("accessoryCards") && + if (hwVersion.find("MTCAP") != std::string::npos) { + hardwareType = HARDWARE_MTCAP; + port = "lora"; + if (inputFile.empty()) { + input_file = MTCAP_DEFAULT_FILE; + } else { + input_file = inputFile; + } + spiPath = LORA_1_5_MTCAP_SPI; + getFpgaVersion(); + spiPath = LORA_1_5_MTCAP_SPI_FPGA; + } else if (deviceInfo.HasMember("accessoryCards") && deviceInfo["accessoryCards"].IsArray() && deviceInfo["accessoryCards"].Size() > 0) { rapidjson::SizeType acCardCount = deviceInfo["accessoryCards"].Size(); @@ -692,8 +703,6 @@ Mtac15Fpga::Mtac15Fpga(std::string inputFile, std::string forcedPath) { hardwareType = HARDWARE_MTCDT3; } else if (hwVersion.find("MTCDT") != std::string::npos) { hardwareType = HARDWARE_MTCDT; - } else if (hwVersion.find("MTCAP") != std::string::npos) { - hardwareType = HARDWARE_MTCAP; } else { return; } @@ -748,15 +757,6 @@ Mtac15Fpga::Mtac15Fpga(std::string inputFile, std::string forcedPath) { exitHandler(99); } - getFpgaVersion(); - } else if (hwVersion.find("MTCAP") != std::string::npos) { - hardwareType = HARDWARE_MTCAP; - if (inputFile.empty()) { - input_file = MTCAP_DEFAULT_FILE; - } else { - input_file = inputFile; - } - spiPath = "/dev/spidev0.0"; getFpgaVersion(); } else { printError("No accessory cards installed/invalid hardware"); @@ -845,6 +845,9 @@ int Mtac15Fpga::upgradeFpga() { } sleep(5); printInfo("Reading New FPGA configuration"); + if (hardwareType == HARDWARE_MTCAP) { + spiPath = LORA_1_5_MTCAP_SPI; + } ret = getFpgaVersion(); if (ret != 0) { return ret; -- cgit v1.2.3