From 1df06c66d58c07c65923c813a1993a4baad293b6 Mon Sep 17 00:00:00 2001 From: Morgan Diepart Date: Tue, 20 Dec 2022 22:19:34 +0100 Subject: [PATCH] Revert "Closing comm devices" This reverts commit da77afcbe5aa3aa20e338984741d8982364c9f49. --- lib/BoardFinder/BoardFinder.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/BoardFinder/BoardFinder.cpp b/lib/BoardFinder/BoardFinder.cpp index cc87d6f..37dd058 100644 --- a/lib/BoardFinder/BoardFinder.cpp +++ b/lib/BoardFinder/BoardFinder.cpp @@ -21,7 +21,6 @@ BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) { Wire.begin(boardconf->OledSda, boardconf->OledScl); powerManagement.begin(Wire); powerManagement.activateOLED(); - Wire.end(); } else if (boardconf->needCheckPowerChip) { continue; } @@ -39,7 +38,6 @@ BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) { Wire.begin(boardconf->OledSda, boardconf->OledScl); powerManagement.begin(Wire); powerManagement.activateLoRa(); - Wire.end(); } if (checkModemConfig(boardconf)) { logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "found a board config: %s", boardconf->Name.c_str()); @@ -77,10 +75,8 @@ bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig, logging::Logge } Wire.beginTransmission(boardConfig->OledAddr); if (!Wire.endTransmission()) { - Wire.end(); return true; } - Wire.end(); return false; } @@ -102,8 +98,9 @@ bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) { SPI.transfer(0x42); uint8_t response = SPI.transfer(0x00); SPI.endTransaction(); + digitalWrite(boardConfig->LoraCS, HIGH); - SPI.end(); + if (response == 0x12) { return true; } @@ -123,8 +120,6 @@ bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logg int response = Wire.read(); Wire.endTransmission(); - Wire.end(); - logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "wire response: %d", response); if (response == 0x03) { logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "power chip found!");