[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 # CS: 7
# IRQ: 25 # IRQ: 25
# Module: sx1280 # SX1280
# CS: 21
# IRQ: 16
# Busy: 20
# Reset: 18
### Set gpio chip to use in /dev/. Defaults to 0. ### Set gpio chip to use in /dev/. Defaults to 0.
### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4 ### Notably the Raspberry Pi 5 puts the GPIO header on gpiochip4
# gpiochip: 4 # gpiochip: 4

View File

@ -742,6 +742,20 @@ void setup()
LOG_INFO("RF95 Radio init succeeded, using RF95 radio\n"); 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) #elif defined(HW_SPI1_DEVICE)
@ -965,4 +979,4 @@ void loop()
mainDelay.delay(delayMsec); mainDelay.delay(delayMsec);
} }
// if (didWake) LOG_DEBUG("wake!\n"); // if (didWake) LOG_DEBUG("wake!\n");
} }

View File

@ -131,11 +131,14 @@ void portduinoSetup()
if (yamlConfig["Lora"]) { if (yamlConfig["Lora"]) {
settingsMap[use_sx1262] = false; settingsMap[use_sx1262] = false;
settingsMap[use_rf95] = false; settingsMap[use_rf95] = false;
settingsMap[use_sx1280] = false;
if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "sx1262") { if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "sx1262") {
settingsMap[use_sx1262] = true; settingsMap[use_sx1262] = true;
} else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "RF95") { } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "RF95") {
settingsMap[use_rf95] = true; 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[dio2_as_rf_switch] = yamlConfig["Lora"]["DIO2_AS_RF_SWITCH"].as<bool>(false);
settingsMap[cs] = yamlConfig["Lora"]["CS"].as<int>(RADIOLIB_NC); settingsMap[cs] = yamlConfig["Lora"]["CS"].as<int>(RADIOLIB_NC);
@ -296,4 +299,4 @@ int initGPIOPin(int pinNum, std::string gpioChipName)
return ERRNO_DISABLED; return ERRNO_DISABLED;
} }
} }
#endif #endif

View File

@ -10,6 +10,7 @@ enum configNames {
reset, reset,
dio2_as_rf_switch, dio2_as_rf_switch,
use_rf95, use_rf95,
use_sx1280,
user, user,
gpiochip, gpiochip,
has_gps, has_gps,
@ -33,4 +34,4 @@ extern std::map<configNames, int> settingsMap;
extern std::map<configNames, std::string> settingsStrings; extern std::map<configNames, std::string> settingsStrings;
int initGPIOPin(int pinNum, std::string gpioChipname); int initGPIOPin(int pinNum, std::string gpioChipname);
#endif #endif