[Add] SX1280 to linux native Portduino (#3023)

* Update PortduinoGlue.cpp

* Update PortduinoGlue.h

* Update main.cpp

* Update config-dist.yaml

* Update config-dist.yaml

* Fix whitespace in main.cpp

---------

Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
This commit is contained in:
Mark Trevor Birss 2023-12-18 02:05:04 +02:00 committed by GitHub
parent a138e9cb6b
commit 16a3a32f2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 3 deletions

View File

@ -25,6 +25,12 @@ Lora:
# CS: 7
# IRQ: 25
# Module: sx1280 # SX1280
# CS: 21
# IRQ: 16
# Busy: 20
# Reset: 18
### Set gpio chip to use in /dev/. Defaults to 0.
### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4
# gpiochip: 4

View File

@ -742,6 +742,20 @@ void setup()
LOG_INFO("RF95 Radio init succeeded, using RF95 radio\n");
}
}
} else if (settingsMap[use_sx1280]) {
if (!rIf) {
LockingArduinoHal *RadioLibHAL = new LockingArduinoHal(SPI, spiSettings);
rIf = new SX1280Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[busy]);
if (!rIf->init()) {
LOG_ERROR("Failed to find SX1280 radio\n");
delete rIf;
rIf = NULL;
exit(EXIT_FAILURE);
} else {
LOG_INFO("SX1280 Radio init succeeded, using SX1280 radio\n");
}
}
}
#elif defined(HW_SPI1_DEVICE)

View File

@ -131,11 +131,14 @@ void portduinoSetup()
if (yamlConfig["Lora"]) {
settingsMap[use_sx1262] = false;
settingsMap[use_rf95] = false;
settingsMap[use_sx1280] = false;
if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "sx1262") {
settingsMap[use_sx1262] = true;
} else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "RF95") {
settingsMap[use_rf95] = true;
} else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "sx1280") {
settingsMap[use_sx1280] = true;
}
settingsMap[dio2_as_rf_switch] = yamlConfig["Lora"]["DIO2_AS_RF_SWITCH"].as<bool>(false);
settingsMap[cs] = yamlConfig["Lora"]["CS"].as<int>(RADIOLIB_NC);

View File

@ -10,6 +10,7 @@ enum configNames {
reset,
dio2_as_rf_switch,
use_rf95,
use_sx1280,
user,
gpiochip,
has_gps,