Pick up support for more than 64 GPIO lines under Portduino

This commit is contained in:
Jonathan Bennett
2024-05-01 13:06:42 -05:00
parent ec92f7a5a3
commit 5095efc55f
2 changed files with 23 additions and 2 deletions

View File

@@ -76,7 +76,21 @@ void portduinoCustomInit()
void portduinoSetup()
{
printf("Setting up Meshtastic on Portduino...\n");
gpioInit();
int max_GPIO = 0;
int GPIO_lines[] = {cs,
irq,
busy,
reset,
txen,
rxen,
displayDC,
displayCS,
displayBacklight,
displayBacklightPWMChannel,
displayReset,
touchscreenCS,
touchscreenIRQ,
user};
std::string gpioChipName = "gpiochip";
settingsStrings[i2cdev] = "";
@@ -245,6 +259,13 @@ void portduinoSetup()
exit(EXIT_FAILURE);
}
for (int i : GPIO_lines) {
if (i > max_GPIO)
max_GPIO = i;
}
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
if (settingsMap.count(cs) > 0 && settingsMap[cs] != RADIOLIB_NC) {
if (initGPIOPin(settingsMap[cs], gpioChipName) != ERRNO_OK) {