mirror of
https://github.com/alexhopeoconnor/firmware.git
synced 2026-10-17 17:11:30 +10:00
Add GPIO_DETECT_PA portduino config, and support 13302 detection with it.
This commit is contained in:
@@ -537,6 +537,27 @@ void portduinoSetup()
|
||||
}
|
||||
}
|
||||
|
||||
// In one test, this dance seemed necessary to trigger the pin to detect properly.
|
||||
if (portduino_config.has_gpio_detect_pa) {
|
||||
pinMode(portduino_config.lora_pa_detect_pin.pin, INPUT_PULLDOWN);
|
||||
sleep(1);
|
||||
if (digitalRead(portduino_config.lora_pa_detect_pin.pin) == LOW) {
|
||||
std::cout << "Pin " << portduino_config.lora_pa_detect_pin.pin << " PULLDOWN is LOW" << std::endl;
|
||||
}
|
||||
pinMode(portduino_config.lora_pa_detect_pin.pin, INPUT_PULLUP);
|
||||
sleep(1);
|
||||
if (digitalRead(portduino_config.lora_pa_detect_pin.pin) == HIGH) {
|
||||
std::cout << "Pin " << portduino_config.lora_pa_detect_pin.pin << " PULLUP is HIGH, dropping PA curve" << std::endl;
|
||||
portduino_config.num_pa_points = 1;
|
||||
portduino_config.tx_gain_lora[0] = 0;
|
||||
} else {
|
||||
std::cout << "Pin " << portduino_config.lora_pa_detect_pin.pin << " PULLUP is LOW, using PA curve" << std::endl;
|
||||
}
|
||||
|
||||
// disable bias once finished
|
||||
pinMode(portduino_config.lora_pa_detect_pin.pin, INPUT);
|
||||
}
|
||||
|
||||
// Only initialize the radio pins when dealing with real, kernel controlled SPI hardware
|
||||
if (portduino_config.lora_spi_dev != "" && portduino_config.lora_spi_dev != "ch341") {
|
||||
SPI.begin(portduino_config.lora_spi_dev.c_str());
|
||||
@@ -660,6 +681,11 @@ bool loadConfig(const char *configPath)
|
||||
portduino_config.lr1120_max_power = yamlConfig["Lora"]["LR1120_MAX_POWER"].as<int>(13);
|
||||
if (yamlConfig["Lora"]["RF95_MAX_POWER"])
|
||||
portduino_config.rf95_max_power = yamlConfig["Lora"]["RF95_MAX_POWER"].as<int>(20);
|
||||
if (yamlConfig["Lora"]["GPIO_DETECT_PA"]) {
|
||||
portduino_config.has_gpio_detect_pa = true;
|
||||
portduino_config.gpio_detect_pa = yamlConfig["Lora"]["GPIO_DETECT_PA"].as<int>(0);
|
||||
portduino_config.lora_pa_detect_pin.pin = portduino_config.gpio_detect_pa;
|
||||
}
|
||||
|
||||
if (yamlConfig["Lora"]["TX_GAIN_LORA"]) {
|
||||
YAML::Node tx_gain_node = yamlConfig["Lora"]["TX_GAIN_LORA"];
|
||||
|
||||
Reference in New Issue
Block a user