mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-23 18:27:27 +00:00
Maybe add working extra GPIO pins to portduino
This commit is contained in:
@@ -487,6 +487,11 @@ void portduinoSetup()
|
|||||||
max_GPIO = i->pin;
|
max_GPIO = i->pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto i : portduino_config.extra_pins) {
|
||||||
|
if (i.enabled && i.gpiochip > max_GPIO)
|
||||||
|
max_GPIO = i.pin;
|
||||||
|
}
|
||||||
|
|
||||||
gpioInit(max_GPIO + 1); // Done here so we can inform Portduino how many GPIOs we need.
|
gpioInit(max_GPIO + 1); // Done here so we can inform Portduino how many GPIOs we need.
|
||||||
|
|
||||||
// Need to bind all the configured GPIO pins so they're not simulated
|
// Need to bind all the configured GPIO pins so they're not simulated
|
||||||
@@ -504,6 +509,19 @@ void portduinoSetup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto i : portduino_config.extra_pins) {
|
||||||
|
// In the case of a ch341 Lora device, we don't want to touch the system GPIO lines for Lora
|
||||||
|
// Those GPIO are handled in our usermode driver instead.
|
||||||
|
if (i.config_section == "Lora" && portduino_config.lora_spi_dev == "ch341") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i.enabled) {
|
||||||
|
if (initGPIOPin(i.pin, gpioChipName + std::to_string(i.gpiochip), i.line) != ERRNO_OK) {
|
||||||
|
printf("Error setting pin number %d. It may not exist, or may already be in use.\n", i.line);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only initialize the radio pins when dealing with real, kernel controlled SPI hardware
|
// 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") {
|
if (portduino_config.lora_spi_dev != "" && portduino_config.lora_spi_dev != "ch341") {
|
||||||
@@ -717,6 +735,16 @@ bool loadConfig(const char *configPath)
|
|||||||
portduino_config.has_gps = 1;
|
portduino_config.has_gps = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (yamlConfig["GPIO"]["ExtraPins"]) {
|
||||||
|
for (auto extra_pin : yamlConfig["GPIO"]["ExtraPins"]) {
|
||||||
|
portduino_config.extra_pins.push_back(pinMapping());
|
||||||
|
portduino_config.extra_pins.back().config_section = "GPIO";
|
||||||
|
portduino_config.extra_pins.back().config_name = "ExtraPins";
|
||||||
|
portduino_config.extra_pins.back().enabled = true;
|
||||||
|
readGPIOFromYaml(extra_pin, portduino_config.extra_pins.back());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (yamlConfig["I2C"]) {
|
if (yamlConfig["I2C"]) {
|
||||||
portduino_config.i2cdev = yamlConfig["I2C"]["I2CDevice"].as<std::string>("");
|
portduino_config.i2cdev = yamlConfig["I2C"]["I2CDevice"].as<std::string>("");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "LR11x0Interface.h"
|
#include "LR11x0Interface.h"
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
@@ -97,6 +98,7 @@ extern struct portduino_config_struct {
|
|||||||
pinMapping lora_txen_pin = {"Lora", "TXen"};
|
pinMapping lora_txen_pin = {"Lora", "TXen"};
|
||||||
pinMapping lora_rxen_pin = {"Lora", "RXen"};
|
pinMapping lora_rxen_pin = {"Lora", "RXen"};
|
||||||
pinMapping lora_sx126x_ant_sw_pin = {"Lora", "SX126X_ANT_SW"};
|
pinMapping lora_sx126x_ant_sw_pin = {"Lora", "SX126X_ANT_SW"};
|
||||||
|
std::vector<pinMapping> extra_pins = {};
|
||||||
|
|
||||||
// GPS
|
// GPS
|
||||||
bool has_gps = false;
|
bool has_gps = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user