kopia lustrzana https://github.com/lora-aprs/LoRa_APRS_iGate
Closing comm devices
When checking for the board, close the communication devices. If we do not do that, successive calls to begin will not configure the pins properly and thus the board check might fail...pull/231/head
rodzic
7fadeb303c
commit
da77afcbe5
|
@ -21,6 +21,7 @@ BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) {
|
||||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
||||||
powerManagement.begin(Wire);
|
powerManagement.begin(Wire);
|
||||||
powerManagement.activateOLED();
|
powerManagement.activateOLED();
|
||||||
|
Wire.end();
|
||||||
} else if (boardconf->needCheckPowerChip) {
|
} else if (boardconf->needCheckPowerChip) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +39,7 @@ BoardConfig const *BoardFinder::searchBoardConfig(logging::Logger &logger) {
|
||||||
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
Wire.begin(boardconf->OledSda, boardconf->OledScl);
|
||||||
powerManagement.begin(Wire);
|
powerManagement.begin(Wire);
|
||||||
powerManagement.activateLoRa();
|
powerManagement.activateLoRa();
|
||||||
|
Wire.end();
|
||||||
}
|
}
|
||||||
if (checkModemConfig(boardconf)) {
|
if (checkModemConfig(boardconf)) {
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "found a board config: %s", boardconf->Name.c_str());
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "found a board config: %s", boardconf->Name.c_str());
|
||||||
|
@ -75,8 +77,10 @@ bool BoardFinder::checkOledConfig(BoardConfig const *boardConfig, logging::Logge
|
||||||
}
|
}
|
||||||
Wire.beginTransmission(boardConfig->OledAddr);
|
Wire.beginTransmission(boardConfig->OledAddr);
|
||||||
if (!Wire.endTransmission()) {
|
if (!Wire.endTransmission()) {
|
||||||
|
Wire.end();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Wire.end();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,9 +102,8 @@ bool BoardFinder::checkModemConfig(BoardConfig const *boardConfig) {
|
||||||
SPI.transfer(0x42);
|
SPI.transfer(0x42);
|
||||||
uint8_t response = SPI.transfer(0x00);
|
uint8_t response = SPI.transfer(0x00);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
|
|
||||||
digitalWrite(boardConfig->LoraCS, HIGH);
|
digitalWrite(boardConfig->LoraCS, HIGH);
|
||||||
|
SPI.end();
|
||||||
if (response == 0x12) {
|
if (response == 0x12) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -120,6 +123,8 @@ bool BoardFinder::checkPowerConfig(BoardConfig const *boardConfig, logging::Logg
|
||||||
int response = Wire.read();
|
int response = Wire.read();
|
||||||
Wire.endTransmission();
|
Wire.endTransmission();
|
||||||
|
|
||||||
|
Wire.end();
|
||||||
|
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "wire response: %d", response);
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "wire response: %d", response);
|
||||||
if (response == 0x03) {
|
if (response == 0x03) {
|
||||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "power chip found!");
|
logger.log(logging::LoggerLevel::LOGGER_LEVEL_DEBUG, MODULE_NAME, "power chip found!");
|
||||||
|
|
Ładowanie…
Reference in New Issue